@mui/codemod
Version:
Codemod scripts for Material UI.
34 lines (33 loc) • 1.04 kB
JavaScript
;
const IconRoot = styled('span')(({
theme,
ownerState
}) => ({
userSelect: 'none',
width: '1em',
height: '1em',
overflow: 'hidden',
display: 'inline-block',
// allow overflow hidden to take action
textAlign: 'center',
// support non-square icon
flexShrink: 0,
fontSize: {
inherit: 'inherit',
small: theme.typography.pxToRem(20),
medium: theme.typography.pxToRem(24),
large: theme.typography.pxToRem(36)
}[ownerState.fontSize],
// TODO v5 deprecate, v6 remove for sx
color: {
primary: (theme.vars || theme).palette.primary.main,
secondary: (theme.vars || theme).palette.secondary.main,
info: (theme.vars || theme).palette.info.main,
success: (theme.vars || theme).palette.success.main,
warning: (theme.vars || theme).palette.warning.main,
action: (theme.vars || theme).palette.action.active,
error: (theme.vars || theme).palette.error.main,
disabled: (theme.vars || theme).palette.action.disabled,
inherit: undefined
}[ownerState.color]
}));