diff --git a/docs/pages/experiments/material-ui/accordion.tsx b/docs/pages/experiments/material-ui/accordion.tsx new file mode 100644 index 00000000000000..e8718e2784ae07 --- /dev/null +++ b/docs/pages/experiments/material-ui/accordion.tsx @@ -0,0 +1,108 @@ +import * as React from 'react'; +import { + Experimental_CssVarsProvider as CssVarsProvider, + useColorScheme, +} from '@mui/material/styles'; +import CssBaseline from '@mui/material/CssBaseline'; +import Box from '@mui/material/Box'; +import Button from '@mui/material/Button'; +import Container from '@mui/material/Container'; +import Moon from '@mui/icons-material/DarkMode'; +import Sun from '@mui/icons-material/LightMode'; +import Accordion from '@mui/material/Accordion'; +import AccordionSummary from '@mui/material/AccordionSummary'; +import AccordionDetails from '@mui/material/AccordionDetails'; +import Typography from '@mui/material/Typography'; +import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; + +const ColorSchemePicker = () => { + const { mode, setMode } = useColorScheme(); + const [mounted, setMounted] = React.useState(false); + React.useEffect(() => { + setMounted(true); + }, []); + if (!mounted) { + return null; + } + + return ( + + ); +}; + +export default function CssVarsTemplate() { + return ( + + + + + + + div': { + placeSelf: 'center', + }, + }} + > + + + } + aria-controls="panel1a-content" + id="panel1a-header" + > + Accordion 1 + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada + lacus ex, sit amet blandit leo lobortis eget. + + + + + } + aria-controls="panel2a-content" + id="panel2a-header" + > + Accordion 2 + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada + lacus ex, sit amet blandit leo lobortis eget. + + + + + } + aria-controls="panel3a-content" + id="panel3a-header" + > + Disabled Accordion + + + + + + + ); +} diff --git a/packages/mui-material/src/Accordion/Accordion.js b/packages/mui-material/src/Accordion/Accordion.js index 79196b501d2611..50edbe4ff75a08 100644 --- a/packages/mui-material/src/Accordion/Accordion.js +++ b/packages/mui-material/src/Accordion/Accordion.js @@ -60,7 +60,7 @@ const AccordionRoot = styled(Paper, { height: 1, content: '""', opacity: 1, - backgroundColor: theme.palette.divider, + backgroundColor: (theme.vars || theme).palette.divider, transition: theme.transitions.create(['opacity', 'background-color'], transition), }, '&:first-of-type': { @@ -85,7 +85,7 @@ const AccordionRoot = styled(Paper, { }, }, [`&.${accordionClasses.disabled}`]: { - backgroundColor: theme.palette.action.disabledBackground, + backgroundColor: (theme.vars || theme).palette.action.disabledBackground, }, }; }, @@ -93,12 +93,12 @@ const AccordionRoot = styled(Paper, { ...(!ownerState.square && { borderRadius: 0, '&:first-of-type': { - borderTopLeftRadius: theme.shape.borderRadius, - borderTopRightRadius: theme.shape.borderRadius, + borderTopLeftRadius: (theme.vars || theme).shape.borderRadius, + borderTopRightRadius: (theme.vars || theme).shape.borderRadius, }, '&:last-of-type': { - borderBottomLeftRadius: theme.shape.borderRadius, - borderBottomRightRadius: theme.shape.borderRadius, + borderBottomLeftRadius: (theme.vars || theme).shape.borderRadius, + borderBottomRightRadius: (theme.vars || theme).shape.borderRadius, // Fix a rendering issue on Edge '@supports (-ms-ime-align: auto)': { borderBottomLeftRadius: 0, diff --git a/packages/mui-material/src/AccordionSummary/AccordionSummary.js b/packages/mui-material/src/AccordionSummary/AccordionSummary.js index 0a292f31f0448e..5510841e172be0 100644 --- a/packages/mui-material/src/AccordionSummary/AccordionSummary.js +++ b/packages/mui-material/src/AccordionSummary/AccordionSummary.js @@ -38,10 +38,10 @@ const AccordionSummaryRoot = styled(ButtonBase, { padding: theme.spacing(0, 2), transition: theme.transitions.create(['min-height', 'background-color'], transition), [`&.${accordionSummaryClasses.focusVisible}`]: { - backgroundColor: theme.palette.action.focus, + backgroundColor: (theme.vars || theme).palette.action.focus, }, [`&.${accordionSummaryClasses.disabled}`]: { - opacity: theme.palette.action.disabledOpacity, + opacity: (theme.vars || theme).palette.action.disabledOpacity, }, [`&:hover:not(.${accordionSummaryClasses.disabled})`]: { cursor: 'pointer', @@ -78,7 +78,7 @@ const AccordionSummaryExpandIconWrapper = styled('div', { overridesResolver: (props, styles) => styles.expandIconWrapper, })(({ theme }) => ({ display: 'flex', - color: theme.palette.action.active, + color: (theme.vars || theme).palette.action.active, transform: 'rotate(0deg)', transition: theme.transitions.create('transform', { duration: theme.transitions.duration.shortest,