From e2403fb4d1d15b97f378b83aa658528ef7df2672 Mon Sep 17 00:00:00 2001 From: Victor Casas Date: Mon, 2 May 2022 08:07:55 -0400 Subject: [PATCH] Add support CSS variables --- .../material-ui/card-action-area.tsx | 86 +++++++++++++++++++ .../src/CardActionArea/CardActionArea.js | 4 +- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 docs/pages/experiments/material-ui/card-action-area.tsx diff --git a/docs/pages/experiments/material-ui/card-action-area.tsx b/docs/pages/experiments/material-ui/card-action-area.tsx new file mode 100644 index 00000000000000..a91177d3f6a7c5 --- /dev/null +++ b/docs/pages/experiments/material-ui/card-action-area.tsx @@ -0,0 +1,86 @@ +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 Card from '@mui/material/Card'; +import CardActionArea from '@mui/material/CardActionArea'; +import CardContent from '@mui/material/CardContent'; +import CardMedia from '@mui/material/CardMedia'; +import Container from '@mui/material/Container'; +import Typography from '@mui/material/Typography'; +import Moon from '@mui/icons-material/DarkMode'; +import Sun from '@mui/icons-material/LightMode'; + +const ColorSchemePicker = () => { + const { mode, setMode } = useColorScheme(); + const [mounted, setMounted] = React.useState(false); + React.useEffect(() => { + setMounted(true); + }, []); + if (!mounted) { + return null; + } + + return ( + + ); +}; + +export default function CardActionAreaCssVars() { + return ( + + + + + + + div': { + placeSelf: 'center', + }, + }} + > + + + + + + Lizard + + + Lizards are a widespread group of squamate reptiles, with over 6,000 species, + ranging across all continents except Antarctica + + + + + + + + ); +} diff --git a/packages/mui-material/src/CardActionArea/CardActionArea.js b/packages/mui-material/src/CardActionArea/CardActionArea.js index cfe59d7fb66e7c..93d24c5fae27c3 100644 --- a/packages/mui-material/src/CardActionArea/CardActionArea.js +++ b/packages/mui-material/src/CardActionArea/CardActionArea.js @@ -27,13 +27,13 @@ const CardActionAreaRoot = styled(ButtonBase, { textAlign: 'inherit', width: '100%', [`&:hover .${cardActionAreaClasses.focusHighlight}`]: { - opacity: theme.palette.action.hoverOpacity, + opacity: (theme.vars || theme).palette.action.hoverOpacity, '@media (hover: none)': { opacity: 0, }, }, [`&.${cardActionAreaClasses.focusVisible} .${cardActionAreaClasses.focusHighlight}`]: { - opacity: theme.palette.action.focusOpacity, + opacity: (theme.vars || theme).palette.action.focusOpacity, }, }));