Skip to content

Commit faadfef

Browse files
authored
[DateRangePicker] Migrate DateRangePickerDay to emotion (#26368)
1 parent 0efe477 commit faadfef

File tree

4 files changed

+274
-161
lines changed

4 files changed

+274
-161
lines changed
+10-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"props": {
3-
"classes": { "type": { "name": "object" }, "required": true },
43
"day": { "type": { "name": "any" }, "required": true },
54
"isEndOfHighlighting": { "type": { "name": "bool" }, "required": true },
65
"isEndOfPreviewing": { "type": { "name": "bool" }, "required": true },
@@ -10,38 +9,34 @@
109
"isStartOfPreviewing": { "type": { "name": "bool" }, "required": true },
1110
"outsideCurrentMonth": { "type": { "name": "bool" }, "required": true },
1211
"children": { "type": { "name": "node" } },
13-
"selected": { "type": { "name": "bool" } }
12+
"classes": { "type": { "name": "object" } },
13+
"selected": { "type": { "name": "bool" } },
14+
"sx": { "type": { "name": "object" } }
1415
},
1516
"name": "DateRangePickerDay",
1617
"styles": {
1718
"classes": [
1819
"root",
19-
"dayWithMargin",
20-
"dayOutsideMonth",
21-
"hiddenDaySpacingFiller",
22-
"today",
23-
"selected",
24-
"disabled",
25-
"day",
2620
"rangeIntervalDayHighlight",
2721
"rangeIntervalDayHighlightStart",
2822
"rangeIntervalDayHighlightEnd",
29-
"dayOutsideRangeInterval",
30-
"dayInsideRangeInterval",
31-
"notSelectedDate",
3223
"rangeIntervalPreview",
3324
"rangeIntervalDayPreview",
3425
"rangeIntervalDayPreviewStart",
35-
"rangeIntervalDayPreviewEnd"
26+
"rangeIntervalDayPreviewEnd",
27+
"day",
28+
"dayOutsideRangeInterval",
29+
"dayInsideRangeInterval",
30+
"notSelectedDate"
3631
],
37-
"globalClasses": { "selected": "Mui-selected", "disabled": "Mui-disabled" },
32+
"globalClasses": {},
3833
"name": "MuiDateRangePickerDay"
3934
},
4035
"spread": false,
4136
"forwardsRefTo": "HTMLButtonElement",
4237
"filename": "/packages/material-ui-lab/src/DateRangePickerDay/DateRangePickerDay.tsx",
4338
"inheritance": null,
4439
"demos": "<ul><li><a href=\"/components/date-range-picker/\">Date Range Picker</a></li></ul>",
45-
"styledComponent": false,
40+
"styledComponent": true,
4641
"cssComponent": false
4742
}

docs/translations/api-docs/date-range-picker-day/date-range-picker-day.json

+36-15
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,60 @@
1111
"isStartOfHighlighting": "Set to <code>true</code> if the <code>day</code> is the start of a highlighted date range.",
1212
"isStartOfPreviewing": "Set to <code>true</code> if the <code>day</code> is the end of a highlighted date range.",
1313
"outsideCurrentMonth": "If <code>true</code>, day is outside of month and will be hidden.",
14-
"selected": "If <code>true</code>, renders as selected."
14+
"selected": "If <code>true</code>, renders as selected.",
15+
"sx": "The system prop that allows defining system overrides as well as additional CSS styles. See the <a href=\"/system/basics/#the-sx-prop\">`sx` page</a> for more details."
1516
},
1617
"classDescriptions": {
1718
"root": { "description": "Styles applied to the root element." },
18-
"dayWithMargin": {
19+
"rangeIntervalDayHighlight": {
1920
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
2021
"nodeName": "the root element",
21-
"conditions": "<code>disableMargin=false</code>"
22+
"conditions": "<code>isHighlighting=true</code> and <code>outsideCurrentMonth=false</code>"
2223
},
23-
"dayOutsideMonth": {
24+
"rangeIntervalDayHighlightStart": {
2425
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
2526
"nodeName": "the root element",
26-
"conditions": "<code>outsideCurrentMonth=true</code> and <code>showDaysOutsideCurrentMonth=true</code>"
27+
"conditions": "<code>isStartOfHighlighting=true</code> or <code>day</code> is the start of the month"
2728
},
28-
"hiddenDaySpacingFiller": {
29+
"rangeIntervalDayHighlightEnd": {
2930
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
3031
"nodeName": "the root element",
31-
"conditions": "<code>outsideCurrentMonth=true</code> and <code>showDaysOutsideCurrentMonth=false</code>"
32+
"conditions": "<code>isEndOfHighlighting=true</code> or <code>day</code> is the end of the month"
3233
},
33-
"today": {
34+
"rangeIntervalPreview": {
35+
"description": "Styles applied to {{nodeName}}.",
36+
"nodeName": "the preview element"
37+
},
38+
"rangeIntervalDayPreview": {
3439
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
3540
"nodeName": "the root element",
36-
"conditions": "<code>disableHighlightToday=false</code> and <code>today=true</code>"
41+
"conditions": "<code>isPreviewing=true</code> and <code>outsideCurrentMonth=false</code>"
3742
},
38-
"selected": {
39-
"description": "Pseudo-class applied to {{nodeName}} if {{conditions}}.",
43+
"rangeIntervalDayPreviewStart": {
44+
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
4045
"nodeName": "the root element",
41-
"conditions": "<code>selected=true</code>"
46+
"conditions": "<code>isStartOfPreviewing=true</code> or <code>day</code> is the start of the month"
4247
},
43-
"disabled": {
44-
"description": "Pseudo-class applied to {{nodeName}} if {{conditions}}.",
48+
"rangeIntervalDayPreviewEnd": {
49+
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
4550
"nodeName": "the root element",
46-
"conditions": "<code>disabled=true</code>"
51+
"conditions": "<code>isEndOfPreviewing=true</code> or <code>day</code> is the end of the month"
52+
},
53+
"day": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the day element" },
54+
"dayOutsideRangeInterval": {
55+
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
56+
"nodeName": "the day element",
57+
"conditions": "<code>isHighlighting=false</code>"
58+
},
59+
"dayInsideRangeInterval": {
60+
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
61+
"nodeName": "the day element",
62+
"conditions": "<code>selected=false</code> and <code>isHighlighting=true</code>"
63+
},
64+
"notSelectedDate": {
65+
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
66+
"nodeName": "the day element",
67+
"conditions": "<code>selected=false</code>"
4768
}
4869
}
4970
}
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,22 @@
11
import * as React from 'react';
2-
import { getClasses, createMount, createClientRender, describeConformance } from 'test/utils';
2+
import { createMount, createClientRender, describeConformanceV5 } from 'test/utils';
33
import LocalizationProvider from '@material-ui/lab/LocalizationProvider';
4-
import DateRangePickerDay from '@material-ui/lab/DateRangePickerDay';
4+
import DateRangePickerDay, {
5+
dateRangePickerDayClasses as classes,
6+
} from '@material-ui/lab/DateRangePickerDay';
57
import { adapterToUse, AdapterClassToUse } from '../internal/pickers/test-utils';
68

79
describe('<DateRangePickerDay />', () => {
810
const mount = createMount();
911
const render = createClientRender();
10-
let classes: Record<string, string>;
1112

1213
const localizedMount = (node: React.ReactNode) => {
1314
return mount(
1415
<LocalizationProvider dateAdapter={AdapterClassToUse}>{node}</LocalizationProvider>,
1516
);
1617
};
1718

18-
before(() => {
19-
classes = getClasses(
20-
<DateRangePickerDay
21-
day={adapterToUse.date()}
22-
outsideCurrentMonth={false}
23-
selected
24-
onDaySelect={() => {}}
25-
isHighlighting
26-
isPreviewing
27-
isStartOfPreviewing
28-
isEndOfPreviewing
29-
isStartOfHighlighting
30-
isEndOfHighlighting
31-
/>,
32-
);
33-
});
34-
35-
describeConformance(
19+
describeConformanceV5(
3620
<DateRangePickerDay
3721
day={adapterToUse.date()}
3822
outsideCurrentMonth={false}
@@ -48,12 +32,22 @@ describe('<DateRangePickerDay />', () => {
4832
() => ({
4933
classes,
5034
inheritComponent: 'button',
35+
muiName: 'MuiDateRangePickerDay',
5136
render: (node: React.ReactNode) =>
5237
render(<LocalizationProvider dateAdapter={AdapterClassToUse}>{node}</LocalizationProvider>),
5338
mount: localizedMount,
5439
refInstanceof: window.HTMLButtonElement,
5540
// cannot test reactTestRenderer because of required context
56-
skip: ['componentProp', 'reactTestRenderer', 'propsSpread', 'refForwarding'],
41+
skip: [
42+
'componentProp',
43+
'componentsProp',
44+
'reactTestRenderer',
45+
'propsSpread',
46+
'refForwarding',
47+
// TODO: Fix DateRangePickerDays is not spreading props on root
48+
'themeDefaultProps',
49+
'themeVariants',
50+
],
5751
}),
5852
);
5953
});

0 commit comments

Comments
 (0)