From dac280549975cb0592cf7d6c3e96dc7843ab7204 Mon Sep 17 00:00:00 2001 From: Dan <35927536+dan-mba@users.noreply.github.com> Date: Tue, 3 May 2022 09:20:17 -0400 Subject: [PATCH] add CSS variable support --- .../material-ui/list-item-icon.tsx | 78 +++++++++++++++++++ .../src/ListItemIcon/ListItemIcon.js | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 docs/pages/experiments/material-ui/list-item-icon.tsx diff --git a/docs/pages/experiments/material-ui/list-item-icon.tsx b/docs/pages/experiments/material-ui/list-item-icon.tsx new file mode 100644 index 00000000000000..ceba697c421e61 --- /dev/null +++ b/docs/pages/experiments/material-ui/list-item-icon.tsx @@ -0,0 +1,78 @@ +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 List from '@mui/material/List'; +import ListItem from '@mui/material/ListItem'; +import ListItemButton from '@mui/material/ListItemButton'; +import ListItemIcon from '@mui/material/ListItemIcon'; +import CommentIcon from '@mui/icons-material/Comment'; +import ListItemText from '@mui/material/ListItemText'; + +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', + }, + }} + > + + + + + + + + + + + + + + ); +} diff --git a/packages/mui-material/src/ListItemIcon/ListItemIcon.js b/packages/mui-material/src/ListItemIcon/ListItemIcon.js index d2c3329301cd2a..7372fd18af0d35 100644 --- a/packages/mui-material/src/ListItemIcon/ListItemIcon.js +++ b/packages/mui-material/src/ListItemIcon/ListItemIcon.js @@ -27,7 +27,7 @@ const ListItemIconRoot = styled('div', { }, })(({ theme, ownerState }) => ({ minWidth: 56, - color: theme.palette.action.active, + color: (theme.vars || theme).palette.action.active, flexShrink: 0, display: 'inline-flex', ...(ownerState.alignItems === 'flex-start' && {