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

[styled] Convert implicit styleProps to explicit #26461

Merged
merged 4 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 24 additions & 20 deletions docs/src/pages/components/steppers/CustomizedSteppers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,28 @@ const QontoConnector = styled(StepConnector)(({ theme }) => ({
},
}));

const QontoStepIconRoot = styled('div')(({ theme, styleProps = {} }) => ({
color: theme.palette.mode === 'dark' ? theme.palette.grey[700] : '#eaeaf0',
display: 'flex',
height: 22,
alignItems: 'center',
...(!!styleProps.active && {
color: '#784af4',
const QontoStepIconRoot = styled('div')<{ styleProps: { active?: boolean } }>(
({ theme, styleProps }) => ({
color: theme.palette.mode === 'dark' ? theme.palette.grey[700] : '#eaeaf0',
display: 'flex',
height: 22,
alignItems: 'center',
...(!!styleProps.active && {
color: '#784af4',
}),
'& .QontoStepIcon-completedIcon': {
color: '#784af4',
zIndex: 1,
fontSize: 18,
},
'& .QontoStepIcon-circle': {
width: 8,
height: 8,
borderRadius: '50%',
backgroundColor: 'currentColor',
},
}),
'& .QontoStepIcon-completedIcon': {
color: '#784af4',
zIndex: 1,
fontSize: 18,
},
'& .QontoStepIcon-circle': {
width: 8,
height: 8,
borderRadius: '50%',
backgroundColor: 'currentColor',
},
}));
);

function QontoStepIcon(props: StepIconProps) {
const { active, completed, className } = props;
Expand Down Expand Up @@ -96,7 +98,9 @@ const ColorlibConnector = styled(StepConnector)(({ theme }) => ({
},
}));

const ColorlibStepIconRoot = styled('div')(({ theme, styleProps = {} }) => ({
const ColorlibStepIconRoot = styled('div')<{
styleProps: { completed?: boolean; active?: boolean };
oliviertassinari marked this conversation as resolved.
Show resolved Hide resolved
}>(({ theme, styleProps }) => ({
backgroundColor: theme.palette.mode === 'dark' ? theme.palette.grey[700] : '#ccc',
zIndex: 1,
color: '#fff',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const CalendarPickerRoot = styled(PickerView, {
name: 'MuiCalendarPicker',
slot: 'Root',
overridesResolver: (props, styles) => styles.root,
})({
})<{ styleProps: CalendarPickerProps<any> }>({
display: 'flex',
flexDirection: 'column',
});
Expand All @@ -153,7 +153,7 @@ const CalendarPickerViewTransitionContainer = styled(FadeTransitionGroup, {
name: 'MuiCalendarPicker',
slot: 'ViewTransitionContainer',
overridesResolver: (props, styles) => styles.viewTransitionContainer,
})({
})<{ styleProps: CalendarPickerProps<any> }>({
overflowY: 'auto',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export interface PickersCalendarHeaderProps<TDate>
onViewChange?: (view: CalendarPickerView) => void;
}

const PickersCalendarHeaderRoot = styled('div', { skipSx: true })({
const PickersCalendarHeaderRoot = styled('div', { skipSx: true })<{
styleProps: PickersCalendarHeaderProps<any>;
}>({
display: 'flex',
alignItems: 'center',
marginTop: 16,
Expand All @@ -69,7 +71,9 @@ const PickersCalendarHeaderRoot = styled('div', { skipSx: true })({
minHeight: 30,
});

const PickersCalendarHeaderLabel = styled('div', { skipSx: true })(({ theme }) => ({
const PickersCalendarHeaderLabel = styled('div', { skipSx: true })<{
styleProps: PickersCalendarHeaderProps<any>;
}>(({ theme }) => ({
display: 'flex',
maxHeight: 30,
overflow: 'hidden',
Expand All @@ -80,24 +84,26 @@ const PickersCalendarHeaderLabel = styled('div', { skipSx: true })(({ theme }) =
fontWeight: theme.typography.fontWeightMedium,
}));

const PickersCalendarHeaderLabelItem = styled('div', { skipSx: true })({
const PickersCalendarHeaderLabelItem = styled('div', { skipSx: true })<{
styleProps: PickersCalendarHeaderProps<any>;
}>({
marginRight: 6,
});

const PickersCalendarHeaderSwitchViewButton = styled(IconButton, { skipSx: true })({
marginRight: 'auto',
});

const PickersCalendarHeaderSwitchView = styled(ArrowDropDownIcon, { skipSx: true })(
({ theme, styleProps = {} }) => ({
willChange: 'transform',
transition: theme.transitions.create('transform'),
transform: 'rotate(0deg)',
...(styleProps.openView === 'year' && {
transform: 'rotate(180deg)',
}),
const PickersCalendarHeaderSwitchView = styled(ArrowDropDownIcon, { skipSx: true })<{
styleProps: PickersCalendarHeaderProps<any>;
}>(({ theme, styleProps }) => ({
willChange: 'transform',
transition: theme.transitions.create('transform'),
transform: 'rotate(0deg)',
...(styleProps.openView === 'year' && {
transform: 'rotate(180deg)',
}),
);
}));

function getSwitchingViewAriaText(view: CalendarPickerView) {
return view === 'year'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const CalendarPickerSkeletonDay = styled(Skeleton, {
name: 'MuiCalendarPickerSkeleton',
slot: 'Day',
overridesResolver: (props, styles) => styles.daySkeleton,
})(({ styleProps = {} }) => ({
})<{ styleProps: { day: number } }>(({ styleProps }) => ({
margin: `0 ${DAY_MARGIN}px`,
...(styleProps.day === 0 && {
visibility: 'hidden',
Expand Down
52 changes: 28 additions & 24 deletions packages/material-ui-lab/src/ClockPicker/Clock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,37 @@ const ClockPin = styled('div', { skipSx: true })(({ theme }) => ({
transform: 'translate(-50%, -50%)',
}));

const ClockAmButton = styled(IconButton, { skipSx: true })(({ theme, styleProps = {} }) => ({
zIndex: 1,
position: 'absolute',
bottom: 8,
left: 8,
...(styleProps.meridiemMode === 'am' && {
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
'&:hover': {
backgroundColor: theme.palette.primary.light,
},
const ClockAmButton = styled(IconButton, { skipSx: true })<{ styleProps: ClockProps<any> }>(
({ theme, styleProps }) => ({
zIndex: 1,
position: 'absolute',
bottom: 8,
left: 8,
...(styleProps.meridiemMode === 'am' && {
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
'&:hover': {
backgroundColor: theme.palette.primary.light,
},
}),
}),
}));
);

const ClockPmButton = styled(IconButton, { skipSx: true })(({ theme, styleProps = {} }) => ({
zIndex: 1,
position: 'absolute',
bottom: 8,
right: 8,
...(styleProps.meridiemMode === 'pm' && {
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
'&:hover': {
backgroundColor: theme.palette.primary.light,
},
const ClockPmButton = styled(IconButton, { skipSx: true })<{ styleProps: ClockProps<any> }>(
({ theme, styleProps }) => ({
zIndex: 1,
position: 'absolute',
bottom: 8,
right: 8,
...(styleProps.meridiemMode === 'pm' && {
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
'&:hover': {
backgroundColor: theme.palette.primary.light,
},
}),
}),
}));
);

/**
* @ignore - internal component.
Expand Down
50 changes: 26 additions & 24 deletions packages/material-ui-lab/src/ClockPicker/ClockNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,33 @@ export interface ClockNumberProps extends React.HTMLAttributes<HTMLSpanElement>

export const classes = generateUtilityClasses('PrivateClockNumber', ['selected', 'disabled']);

const ClockNumberRoot = styled('span', { skipSx: true })(({ theme, styleProps = {} }) => ({
height: CLOCK_HOUR_WIDTH,
width: CLOCK_HOUR_WIDTH,
position: 'absolute',
left: `calc((100% - ${CLOCK_HOUR_WIDTH}px) / 2)`,
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
borderRadius: '50%',
color: theme.palette.text.primary,
'&:focused': {
backgroundColor: theme.palette.background.paper,
},
[`&.${classes.selected}`]: {
color: theme.palette.primary.contrastText,
},
[`&.${classes.disabled}`]: {
pointerEvents: 'none',
color: theme.palette.text.disabled,
},
...(!!styleProps.inner && {
...theme.typography.body2,
color: theme.palette.text.secondary,
const ClockNumberRoot = styled('span', { skipSx: true })<{ styleProps: ClockNumberProps }>(
({ theme, styleProps }) => ({
height: CLOCK_HOUR_WIDTH,
width: CLOCK_HOUR_WIDTH,
position: 'absolute',
left: `calc((100% - ${CLOCK_HOUR_WIDTH}px) / 2)`,
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
borderRadius: '50%',
color: theme.palette.text.primary,
'&:focused': {
backgroundColor: theme.palette.background.paper,
},
[`&.${classes.selected}`]: {
color: theme.palette.primary.contrastText,
},
[`&.${classes.disabled}`]: {
pointerEvents: 'none',
color: theme.palette.text.disabled,
},
...(!!styleProps.inner && {
...theme.typography.body2,
color: theme.palette.text.secondary,
}),
}),
}));
);

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/ClockPicker/ClockPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const ClockPickerArrowSwitcher = styled(PickersArrowSwitcher, {
name: 'MuiClockPicker',
slot: 'ArrowSwticher',
overridesResolver: (props, styles) => styles.arrowSwitcher,
})({
})<{ styleProps: ClockPickerProps<any> }>({
position: 'absolute',
right: 12,
top: 15,
Expand Down
54 changes: 27 additions & 27 deletions packages/material-ui-lab/src/ClockPicker/ClockPointer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,36 @@ export interface ClockPointerProps extends React.HTMLAttributes<HTMLDivElement>
value: number;
}

const ClockPointerRoot = experimentalStyled('div', { skipSx: true })(
({ theme, styleProps = {} }) => ({
width: 2,
backgroundColor: theme.palette.primary.main,
position: 'absolute',
left: 'calc(50% - 1px)',
bottom: '50%',
transformOrigin: 'center bottom 0px',
...(!!styleProps.toAnimateTransform && {
transition: theme.transitions.create(['transform', 'height']),
}),
const ClockPointerRoot = experimentalStyled('div', { skipSx: true })<{
styleProps: ClockPointerProps & ClockPointer['state'];
}>(({ theme, styleProps }) => ({
width: 2,
backgroundColor: theme.palette.primary.main,
position: 'absolute',
left: 'calc(50% - 1px)',
bottom: '50%',
transformOrigin: 'center bottom 0px',
...(!!styleProps.toAnimateTransform && {
transition: theme.transitions.create(['transform', 'height']),
}),
);
}));

const ClockPointerThumb = experimentalStyled('div', { skipSx: true })(
({ theme, styleProps = {} }) => ({
width: 4,
height: 4,
backgroundColor: theme.palette.primary.contrastText,
borderRadius: '50%',
position: 'absolute',
top: -21,
left: `calc(50% - ${CLOCK_HOUR_WIDTH / 2}px)`,
border: `${(CLOCK_HOUR_WIDTH - 4) / 2}px solid ${theme.palette.primary.main}`,
boxSizing: 'content-box',
...(!!styleProps.hasSelected && {
backgroundColor: theme.palette.primary.main,
}),
const ClockPointerThumb = experimentalStyled('div', { skipSx: true })<{
styleProps: ClockPointerProps & ClockPointer['state'];
}>(({ theme, styleProps }) => ({
width: 4,
height: 4,
backgroundColor: theme.palette.primary.contrastText,
borderRadius: '50%',
position: 'absolute',
top: -21,
left: `calc(50% - ${CLOCK_HOUR_WIDTH / 2}px)`,
border: `${(CLOCK_HOUR_WIDTH - 4) / 2}px solid ${theme.palette.primary.main}`,
boxSizing: 'content-box',
...(!!styleProps.hasSelected && {
backgroundColor: theme.palette.primary.main,
}),
);
}));

/**
* @ignore - internal component.
Expand Down
12 changes: 7 additions & 5 deletions packages/material-ui-lab/src/DatePicker/DatePickerToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ import { CalendarPickerView } from '../CalendarPicker';

const classes = generateUtilityClasses('PrivateDatePickerToolbar', ['penIcon']);

const DatePickerToolbarRoot = styled(PickersToolbar, { skipSx: true })({
const DatePickerToolbarRoot = styled(PickersToolbar, { skipSx: true })<{ styleProps: any }>({
[`& .${classes.penIcon}`]: {
position: 'relative',
top: 4,
},
});

const DatePickerToolbarTitle = styled(Typography, { skipSx: true })(({ styleProps = {} }) => ({
...(!!styleProps.isLandscape && {
margin: 'auto 16px auto auto',
const DatePickerToolbarTitle = styled(Typography, { skipSx: true })<{ styleProps: any }>(
({ styleProps }) => ({
...(!!styleProps.isLandscape && {
margin: 'auto 16px auto auto',
}),
}),
}));
);

/**
* @ignore - internal component.
Expand Down
17 changes: 12 additions & 5 deletions packages/material-ui-lab/src/DateTimePicker/DateTimePickerTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import Paper from '@material-ui/core/Paper';
import { useTheme, experimentalStyled as styled } from '@material-ui/core/styles';
import TimeIcon from '../internal/svg-icons/Time';
import DateRangeIcon from '../internal/svg-icons/DateRange';
import { WrapperVariantContext } from '../internal/pickers/wrappers/WrapperVariantContext';
import {
WrapperVariantContext,
WrapperVariant,
} from '../internal/pickers/wrappers/WrapperVariantContext';
import { DateTimePickerView } from './shared';

type TabValue = 'date' | 'time';
Expand Down Expand Up @@ -34,11 +37,15 @@ export interface DateTimePickerTabsProps {
view: DateTimePickerView;
}

const DateTimePickerTabsRoot = styled(Paper, { skipSx: true })(({ styleProps = {} }) => ({
...(styleProps.wrapperVariant === 'desktop' && {
order: 1,
type StyleProps = DateTimePickerTabsProps & { wrapperVariant: WrapperVariant };

const DateTimePickerTabsRoot = styled(Paper, { skipSx: true })<{ styleProps: StyleProps }>(
({ styleProps = {} }) => ({
...(styleProps.wrapperVariant === 'desktop' && {
order: 1,
}),
}),
}));
);

const DateTimePickerTabsTabs = styled(Tabs, { skipSx: true })(({ theme }) => {
const tabsBackground =
Expand Down