-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DatePicker] Display week number #6144
Conversation
These are the results for the performance tests:
|
9957445
to
cc90090
Compare
Maybe @gerdadesign review would be interesting on this one I feel like the week number is to close from the 1st column of days |
@flaviendelangle I agree. I just wanted to see before with you and @LukasTy if we agree on the DX. For now, there is no way to get the week number from date-io. So I propose a two steps strategy:
This should avoid breaking changes |
If we were to add a method in the adapter and release it under a minor version, it would not be breaking right ? |
Yes. For developpers using It's like introducing the customization callback before the default behavior 😅 |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I do not understand those typescript errors
Yes |
Which causes your problem: the utils of type This kind of issue often comes from similar problem, the one prop TS uses to infer the generic is nullable when it should not. |
Thanks for the explanation. I fixed most of them. The remaining ones are about localization with Sounds to be an interesting PR for detecting typing errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the week number is to close from the 1st column of days
I agree. It can be solved in UserLand, but a bit more spacing by default can help visually group the more important information on the calendar.
Another customization I tried on the sandbox above was to change the calendarWeekText, but I couldn't get it working.
localeText={{ calendarWeekNumberText: "KW" }}
Am I missing something?
p.s.: KW stands for Kalenderwoche, the used acronym in Germany.
@joserodolfofreitas this translation key is a callback. |
Thanks! It'll probably be covered by any community translation, but should it work like this?
https://codesandbox.io/s/custom-week-numbers-es327n?file=/demo.tsx |
Oh indeed we have a big bug with the nested The following work: https://codesandbox.io/s/custom-week-numbers-forked-2d033y?file=/demo.tsx EDIT: Fixed by #6895 |
To shows all days of displayed weeks, included those outside of the current month, use `showDaysOutsideCurrentMonth`. | ||
|
||
By default, only weeks of the current month are displayed, but you can provide a total number of week to display with `fixedWeekNumber` prop. | ||
This value is usually set to `6` for Gregorian calendars, because months display can vary between 4 and 6 weeks. | ||
|
||
{{"demo": "CustomMonthLayout.js"}} | ||
|
||
### Add week number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Add week number | |
### Display week number |
@@ -98,13 +98,22 @@ You can take advantage of the [PickersDay](/x/api/date-pickers/pickers-day/) com | |||
|
|||
You can customize the month layout with some props. | |||
|
|||
### Show additional days | |||
|
|||
To shows all days of displayed weeks, included those outside of the current month, use `showDaysOutsideCurrentMonth`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can review the props names to be more consistent between each other (in another PR).
For instance, would it make sense to rename this property to displayDaysOutsideCurrentMonth
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not. Can you create an issue for it?
### Add week number | ||
|
||
To display week number, use the `displayWeekNumber`. | ||
You can customize the string displayed, by using the localization key`localeText.calendarWeekNumberText`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if there are use cases where users need to render something different for the week numbers, I'd think there's more chance that they want to update the header.
You can customize the string displayed, by using the localization key`localeText.calendarWeekNumberText`. | |
You can customize the calendar week header by using the localization key `localeText.calendarWeekNumberHeaderText`. | |
As well you can also customize what's rendered as a calendar week number, using a callback for the localization key `localeText.calendarWeekNumberText` |
Should we also add an example for the callback usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not super inspired by what could be a customized week number, so I simply added a point at the end of week numbers, and I override the header to set the default "#"
. It does not change any thing but it highlight the localization key.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work !
Sorry for the delay reviewing that one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch !
packages/x-date-pickers-pro/src/StaticNextDateRangePicker/StaticNextDateRangePicker.tsx
Outdated
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
why we can not click weekNumber. |
@Eshakheni123 Could you open an issue such that we can have a distinct discussion about your feature request Would be nice in your issue to add some context, about what would be the use-case solved by being able to click on week-numbers: For which kind of application will it be used, and what would be the behavior when clicking on it? |
Thanks for your Response. I have created a new issue. |
Fix #4606
doc preview
After agreeing on the main pipeline: