diff --git a/packages/material-ui-lab/src/DateTimePicker/DateTimePickerTabs.tsx b/packages/material-ui-lab/src/DateTimePicker/DateTimePickerTabs.tsx index b5f5b9a8f0b764..89b7f5772248a7 100644 --- a/packages/material-ui-lab/src/DateTimePicker/DateTimePickerTabs.tsx +++ b/packages/material-ui-lab/src/DateTimePicker/DateTimePickerTabs.tsx @@ -1,9 +1,8 @@ import * as React from 'react'; -import clsx from 'clsx'; import Tab from '@material-ui/core/Tab'; import Tabs from '@material-ui/core/Tabs'; import Paper from '@material-ui/core/Paper'; -import { MuiStyles, WithStyles, withStyles, useTheme, StyleRules } from '@material-ui/core/styles'; +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'; @@ -35,55 +34,51 @@ export interface DateTimePickerTabsProps { view: DateTimePickerView; } -export type DateTimePickerTabsClassKey = 'root' | 'modeDesktop' | 'tabs'; +const DateTimePickerTabsRoot = styled( + Paper, + {}, + { skipSx: true }, +)(({ styleProps = {} }) => ({ + ...(styleProps.wrapperVariant === 'desktop' && { + order: 1, + }), +})); -export const styles: MuiStyles = ( - theme, -): StyleRules => { +const DateTimePickerTabsTabs = styled( + Tabs, + {}, + { skipSx: true }, +)(({ theme }) => { const tabsBackground = theme.palette.mode === 'light' ? theme.palette.primary.main : theme.palette.background.default; - return { - root: {}, - modeDesktop: { - order: 1, - }, - tabs: { - color: theme.palette.getContrastText(tabsBackground), - backgroundColor: tabsBackground, - }, + color: theme.palette.getContrastText(tabsBackground), + backgroundColor: tabsBackground, }; -}; +}); /** * @ignore - internal component. */ -const DateTimePickerTabs: React.FC> = ( - props, -) => { - const { - classes, - dateRangeIcon = , - onChange, - timeIcon = , - view, - } = props; +const DateTimePickerTabs = (props: DateTimePickerTabsProps) => { + const { dateRangeIcon = , onChange, timeIcon = , view } = props; const theme = useTheme(); const wrapperVariant = React.useContext(WrapperVariantContext); const indicatorColor = theme.palette.mode === 'light' ? 'secondary' : 'primary'; + const styleProps = { ...props, wrapperVariant }; + const handleChange = (event: React.SyntheticEvent, value: TabValue) => { onChange(tabToView(value)); }; return ( - - + {timeIcon}} /> - - + + ); }; -export default withStyles(styles, { name: 'MuiInternalDateTimePickerTabs' })(DateTimePickerTabs); +export default DateTimePickerTabs; diff --git a/packages/material-ui-lab/src/DateTimePicker/DateTimePickerToolbar.tsx b/packages/material-ui-lab/src/DateTimePicker/DateTimePickerToolbar.tsx index 498ea9d7ece0e6..a2123fded0e319 100644 --- a/packages/material-ui-lab/src/DateTimePicker/DateTimePickerToolbar.tsx +++ b/packages/material-ui-lab/src/DateTimePicker/DateTimePickerToolbar.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; -import { MuiStyles, WithStyles, withStyles } from '@material-ui/core/styles'; +import { experimentalStyled as styled } from '@material-ui/core/styles'; +import { generateUtilityClasses } from '@material-ui/unstyled'; import PickersToolbarText from '../internal/pickers/PickersToolbarText'; import PickersToolbar from '../internal/pickers/PickersToolbar'; import PickersToolbarButton from '../internal/pickers/PickersToolbarButton'; @@ -9,47 +10,58 @@ import { WrapperVariantContext } from '../internal/pickers/wrappers/WrapperVaria import { ToolbarComponentProps } from '../internal/pickers/typings/BasePicker'; import { DateTimePickerView } from './shared'; -export const styles: MuiStyles< - 'root' | 'separator' | 'timeContainer' | 'dateContainer' | 'timeTypography' | 'penIcon' -> = { - root: { - paddingLeft: 16, - paddingRight: 16, - justifyContent: 'space-around', - }, - separator: { - margin: '0 4px 0 2px', - cursor: 'default', - }, - timeContainer: { - display: 'flex', - }, - dateContainer: { - display: 'flex', - flexDirection: 'column', - alignItems: 'flex-start', - }, - timeTypography: {}, - penIcon: { +const classes = generateUtilityClasses('PrivateDateTimePickerToolbar', ['penIcon']); + +const DateTimePickerToolbarRoot = styled( + PickersToolbar, + {}, + { skipSx: true }, +)({ + paddingLeft: 16, + paddingRight: 16, + justifyContent: 'space-around', + [`& .${classes.penIcon}`]: { position: 'absolute', top: 8, right: 8, }, -}; +}); + +const DateTimePickerToolbarDateContainer = styled( + 'div', + {}, + { skipSx: true }, +)({ + display: 'flex', + flexDirection: 'column', + alignItems: 'flex-start', +}); + +const DateTimePickerToolbarTimeContainer = styled( + 'div', + {}, + { skipSx: true }, +)({ + display: 'flex', +}); -export type DateTimePickerToolbarClassKey = keyof WithStyles['classes']; +const DateTimePickerToolbarSeparator = styled( + PickersToolbarText, + {}, + { skipSx: true }, +)({ + margin: '0 4px 0 2px', + cursor: 'default', +}); /** * @ignore - internal component. */ -const DateTimePickerToolbar: React.FC> = ( - props, -) => { +const DateTimePickerToolbar = (props: ToolbarComponentProps) => { const { ampm, date, dateRangeIcon, - classes, hideTabs, isMobileKeyboardViewOpen, onChange, @@ -87,16 +99,15 @@ const DateTimePickerToolbar: React.FC {wrapperVariant !== 'desktop' && ( - -
+ -
-
+ + setOpenView('hours')} selected={openView === 'hours'} value={date ? formatHours(date) : '--'} - typographyClassName={classes.timeTypography} /> - + setOpenView('minutes')} selected={openView === 'minutes'} value={date ? utils.format(date, 'minutes') : '--'} - typographyClassName={classes.timeTypography} /> -
-
+ + )} {showTabs && (