mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[pickers] Add `PickerDay2` and `DateRangePickerDay2` components

Open noraleonte opened this issue 1 year ago • 5 comments

closes https://github.com/mui/mui-x/issues/14753 closes https://github.com/mui/mui-x/issues/13361

This is an exploration

I'm exploring the option of creating only one day component used by both simple and range pickers & writing the styles in a way that they are truly separated from each other. i.e. The selected state should not care whether isStartOfPreviewing is true or not. It just applies the styles related to selection. I reduced the DOM structure to a single element (ButtonBase) and the previewing and highlighting (now renamed to selectedRange) is handled with pseudo elements.

The advantage of this is that we reduce the complexity of customizing this component a lot and we can avoid specificity issues. See new demo vs custom theme from the overview page

A downside is that the padding of the pseudo elements is calculated based on the margins of the root => so any customizations of the spacing of the root element need to be reflected in the calculation of the positioning of the pseudo elements. We can try abstracting some of that and introducing css variables, but I think documenting this should be enough. Plus, it might even make it easier to achieve custom designs where the highlighting and previewing don't connect. (Like the picture) image

TO DO

  • [x] Create new component
  • [x] add slot to enable it
  • [ ] add docs

noraleonte avatar Dec 17 '24 15:12 noraleonte

Deploy preview: https://deploy-preview-15921--material-ui-x.netlify.app/

Updated pages:

Bundle size report

Total Size Change: 🔺+40.7KB(+0.32%) - Total Gzip Change: 🔺+12.3KB(+0.32%) Files: 122 total (2 added, 0 removed, 10 changed)

Show details for 100 more bundles (22 more not shown)

@mui/x-date-pickers-proparsed: 🔺+11.5KB(+3.70%) gzip: 🔺+2.63KB(+3.27%) @mui/x-date-pickersparsed: 🔺+3.65KB(+1.59%) gzip: 🔺+663B(+1.09%) @mui/x-date-pickers-pro/DateRangeCalendarparsed: 🔺+292B(+0.38%) gzip: 🔺+81B(+0.34%) @mui/x-date-pickers-pro/DateRangePickerparsed: 🔺+292B(+0.17%) gzip: 🔺+82B(+0.16%) @mui/x-date-pickers-pro/DateTimeRangePickerparsed: 🔺+292B(+0.14%) gzip: 🔺+84B(+0.14%) @mui/x-date-pickers-pro/DesktopDateRangePickerparsed: 🔺+292B(+0.17%) gzip: 🔺+77B(+0.15%) @mui/x-date-pickers-pro/DesktopDateTimeRangePickerparsed: 🔺+292B(+0.14%) gzip: 🔺+77B(+0.13%) @mui/x-date-pickers-pro/MobileDateRangePickerparsed: 🔺+292B(+0.17%) gzip: 🔺+76B(+0.15%) @mui/x-date-pickers-pro/MobileDateTimeRangePickerparsed: 🔺+292B(+0.15%) gzip: 🔺+80B(+0.14%) @mui/x-date-pickers-pro/StaticDateRangePickerparsed: 🔺+291B(+0.29%) gzip: 🔺+75B(+0.24%) @mui/x-date-pickers-pro/DateRangePickerDay2parsed: 🔺+13.7KB(new) gzip: 🔺+4.64KB(new) @mui/x-date-pickers/PickerDay2parsed: 🔺+9.47KB(new) gzip: 🔺+3.74KB(new) @mui/x-chartsparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-proparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/BarChartProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/ChartContainerProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/ChartDataProviderProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/ChartsToolbarProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/ChartZoomSliderparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/FunnelChartparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/Heatmapparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/LineChartProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/PieChartProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/RadarChartProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts-pro/ScatterChartProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/BarChartparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartContainerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartDataProviderparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsAxisparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsAxisHighlightparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsClipPathparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsGridparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsLabelparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsLegendparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsLocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsOverlayparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsReferenceLineparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsSurfaceparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsTextparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsTooltipparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsXAxisparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ChartsYAxisparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/Gaugeparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/LineChartparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/PieChartparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/RadarChartparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/ScatterChartparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/SparkLineChartparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-charts/Toolbarparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-data-gridparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-data-grid-premiumparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-data-grid-premium/DataGridPremiumparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-data-grid-proparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-data-grid-pro/DataGridProparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-data-grid/DataGridparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/AdapterDateFnsparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/AdapterDateFnsJalaliparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/AdapterDayjsparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/AdapterLuxonparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/AdapterMomentparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/AdapterMomentHijriparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/AdapterMomentJalaaliparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/DateRangePickerDayparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/DesktopTimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/LocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/MobileTimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/MultiInputDateRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/MultiInputDateTimeRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/MultiInputTimeRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/PickersRangeCalendarHeaderparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/SingleInputDateRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/SingleInputDateTimeRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/SingleInputTimeRangeFieldparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers-pro/TimeRangePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/AdapterDateFnsparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/AdapterDateFnsBaseparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/AdapterDateFnsJalaliparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/AdapterDayjsparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/AdapterLuxonparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/AdapterMomentparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/AdapterMomentHijriparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/AdapterMomentJalaaliparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DateCalendarparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DateFieldparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DatePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DateTimeFieldparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DateTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DayCalendarSkeletonparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DesktopDatePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DesktopDateTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DesktopTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/DigitalClockparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/LocalizationProviderparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/MobileDatePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/MobileDateTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/MobileTimePickerparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/MonthCalendarparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/MultiSectionDigitalClockparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/PickersActionBarparsed: 0B(0.00%) gzip: 0B(0.00%) @mui/x-date-pickers/PickersCalendarHeaderparsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Generated by :no_entry_sign: dangerJS against 2afcbc0725f36554dd38e303638ccd973dfadc3b

mui-bot avatar Dec 17 '24 15:12 mui-bot

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Jan 03 '25 13:01 github-actions[bot]

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Feb 03 '25 09:02 github-actions[bot]

Comparison of your owner state with my Base UI Calendar set of data attributes. Most of them slightly diverge and we need to settle on a shared name.

  • isDayHidden => :red_circle: (I think it make sense to keep it on the MUI version with the showDaysOutsideCurrentMonth prop. But I would unify the logic with isHighlightTodayDisabled. One isDayHidden we have the UI state in the owner state, in isHighlightTodayDisabled we have the prop in the owner state and the CSS decides the UI. It should be the same for both. Maybe more setting the prop in the owner state imo)
  • isLastDayOfWeek => data-end-of-week :yellow_circle: (lighter than data-last-day-of-week, tbd)
  • isFirstDayOfWeek => data-start-of-week :yellow_circle: (lighter than data-first-day-of-week, tbd)
  • isSelected => data-selected :heavy_check_mark:
  • isHighlightTodayDisabled => :red_circle: (I think it make sense to keep it on the MUI version with the disableHighlightToday prop)
  • isToday => data-current :yellow_circle: (to be able to do the same on the month and year views)
  • isDisabled => data-disabled :heavy_check_mark:
  • isOutsideCurrentMonth => data-outside-month :yellow_circle: (lighter than data-outside-current-month, it's React Aria's naming)
  • isStartOfPreviewing => data-preview-start :yellow_circle: (lighter than data-start-of-previewing, tbd)
  • isEndOfPreviewing => data-preview-end :yellow_circle: (lighter than `data-end-of-previewing, tbd)
  • isPreviewing => data-previewed :yellow_circle: (coherent with data-selected)
  • isStartOfSelectedRange => data-selection-start :yellow_circle: (lighter than data-start-of-selected-range, tbd)
  • isEndOfSelectedRange => data-selection-end :yellow_circle: (lighter than data-end-of-selected-range, tbd)
  • isWithinSelectedRange => data-inside-selection :yellow_circle: (lighter than data-within-selected-range, tbd)
  • isDragSelected => :red_circle: (what is it needed for?)

flaviendelangle avatar Feb 18 '25 09:02 flaviendelangle

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Apr 30 '25 14:04 github-actions[bot]

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Jun 06 '25 08:06 github-actions[bot]