From e29ffb2ffeaa4d0f4159f9ae829c4edd101b161f Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 15 Aug 2021 19:10:43 +0200 Subject: [PATCH] [styled-engine] Drop withComponent support --- .../modules/components/AppNavDrawerItem.js | 65 +++++++++---------- .../material-ui-system/src/createStyled.d.ts | 12 +--- 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/docs/src/modules/components/AppNavDrawerItem.js b/docs/src/modules/components/AppNavDrawerItem.js index 59d2ca85eb0359..943cd5e573b429 100644 --- a/docs/src/modules/components/AppNavDrawerItem.js +++ b/docs/src/modules/components/AppNavDrawerItem.js @@ -6,39 +6,36 @@ import ButtonBase from '@material-ui/core/ButtonBase'; import ArrowRightIcon from '@material-ui/icons/ArrowRight'; import Link from 'docs/src/modules/components/Link'; -const Item = styled('div', { - shouldForwardProp: - // disable `as` prop - () => true, -})(({ theme }) => { - return { - ...theme.typography.body2, - display: 'flex', - borderRadius: theme.shape.borderRadius, - outline: 0, - width: '100%', - paddingTop: 8, - paddingBottom: 8, - justifyContent: 'flex-start', - fontWeight: theme.typography.fontWeightMedium, - transition: theme.transitions.create(['color', 'background-color'], { - duration: theme.transitions.duration.shortest, - }), - '&:hover': { - color: theme.palette.text.primary, - backgroundColor: alpha(theme.palette.text.primary, theme.palette.action.hoverOpacity), - }, - '&.Mui-focusVisible': { - backgroundColor: theme.palette.action.focus, - }, - [theme.breakpoints.up('md')]: { - paddingTop: 6, - paddingBottom: 6, - }, - }; -}); +const Item = styled(({ component: Component = 'div', ...props }) => , { + // disable `as` prop + shouldForwardProp: () => true, +})(({ theme }) => ({ + ...theme.typography.body2, + display: 'flex', + borderRadius: theme.shape.borderRadius, + outline: 0, + width: '100%', + paddingTop: 8, + paddingBottom: 8, + justifyContent: 'flex-start', + fontWeight: theme.typography.fontWeightMedium, + transition: theme.transitions.create(['color', 'background-color'], { + duration: theme.transitions.duration.shortest, + }), + '&:hover': { + color: theme.palette.text.primary, + backgroundColor: alpha(theme.palette.text.primary, theme.palette.action.hoverOpacity), + }, + '&.Mui-focusVisible': { + backgroundColor: theme.palette.action.focus, + }, + [theme.breakpoints.up('md')]: { + paddingTop: 6, + paddingBottom: 6, + }, +})); -const ItemLink = styled(Item.withComponent(Link), { +const ItemLink = styled(Item, { shouldForwardProp: (prop) => prop !== 'depth', })(({ depth, theme }) => { return { @@ -78,7 +75,7 @@ const ItemButtonIcon = styled(ArrowRightIcon, { }; }); -const ItemButton = styled(Item.withComponent(ButtonBase), { +const ItemButton = styled(Item, { shouldForwardProp: (prop) => prop !== 'depth', })(({ depth, theme }) => { return { @@ -120,6 +117,7 @@ export default function AppNavDrawerItem(props) { return ( = Pick>; export interface StyledComponent extends React.FunctionComponent, - ComponentSelector { - /** - * @desc this method is type-unsafe - */ - withComponent( - tag: NewTag, - ): StyledComponent; - withComponent>( - tag: Tag, - ): StyledComponent, StyleProps, Theme>; -} + ComponentSelector {} export interface StyledOptions { label?: string;