Skip to content
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] should have css class for weekend days and header to style them separate #4765

Closed
FalkNisius opened this issue Jul 21, 2016 · 2 comments
Labels
component: date picker This is the name of the generic UI component, not the React module! new feature New feature or request

Comments

@FalkNisius
Copy link

If you wan't highlight saturdays and sundays (weekends) or some special days then is there no way for doing that in the usage of the component.

I would prefer to add a css class to the buttons represent the days and the spans represent weekday headers.

For more flexibility and including holiday etc. the highlighted days should be also added with a function like shouldDisableDay.

@henrymoews
Copy link

henrymoews commented Jul 26, 2016

I just wanted to find a solution for the same problem. I did not find a solution elsewhere so I decided to implement a patch that you find a attached.

After applying the patch from the root folder (that contains the node_modules folder) with patch -s -p0 < patches/datePicker_highlightedDays.diff the component offers two more props.

There already was a prop to disable any date so I decided to add a prop to highlight any date the same way:

isWeekendDay(date) {
   return date.getDay() === 0 || date.getDay() === 6;
}

render(){
   return (
      <DatePicker shouldHighlightDate={this.isWeekendDay} />
   )
}

To highlight the weekdays title ('M', 'T', 'W', 'T', 'F', 'S', 'S') as well you can use the highlightedWeekTitleDays property that accepts an array with weekday indices from Sunday = 0 to Saturday = 6. This highlights only Saturday and Sunday:

<DatePicker highlightedWeekTitleDays={[0, 6]} />

Here is the patch. It was made for material-ui@0.15.0:

datePicker_highlightedDays.diff.zip

@mpontikes mpontikes mentioned this issue Aug 5, 2016
13 tasks
@oliviertassinari oliviertassinari changed the title DatePicker should have css class for weekend days and header to style them separate (feature request) [DatePicker] should have css class for weekend days and header to style them separate Sep 18, 2016
@oliviertassinari oliviertassinari added the new feature New feature or request label Sep 18, 2016
@oliviertassinari oliviertassinari added the component: date picker This is the name of the generic UI component, not the React module! label Oct 19, 2016
@oliviertassinari
Copy link
Member

Closing for #4787

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: date picker This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants