From 9ad82056b7488440aefceafb5717996019f296cd Mon Sep 17 00:00:00 2001 From: Timo Wilhelm Date: Mon, 4 Jul 2022 04:06:13 +0200 Subject: [PATCH] [SnackbarContent] fix message text color with css var provider (#33285) --- .../src/SnackbarContent/SnackbarContent.js | 2 +- .../src/styles/experimental_extendTheme.js | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/mui-material/src/SnackbarContent/SnackbarContent.js b/packages/mui-material/src/SnackbarContent/SnackbarContent.js index d2526323b8120c..69ba78c1363642 100644 --- a/packages/mui-material/src/SnackbarContent/SnackbarContent.js +++ b/packages/mui-material/src/SnackbarContent/SnackbarContent.js @@ -31,7 +31,7 @@ const SnackbarContentRoot = styled(Paper, { return { ...theme.typography.body2, color: theme.vars - ? theme.vars.palette.text.primary + ? theme.vars.palette.SnackbarContent.color : theme.palette.getContrastText(backgroundColor), backgroundColor: theme.vars ? theme.vars.palette.SnackbarContent.bg : backgroundColor, display: 'flex', diff --git a/packages/mui-material/src/styles/experimental_extendTheme.js b/packages/mui-material/src/styles/experimental_extendTheme.js index e40a43d83cc979..2628a52a6f450a 100644 --- a/packages/mui-material/src/styles/experimental_extendTheme.js +++ b/packages/mui-material/src/styles/experimental_extendTheme.js @@ -157,7 +157,13 @@ export default function extendTheme(options = {}, ...args) { setColor(palette.Slider, 'infoTrack', lighten(palette.info.main, 0.62)); setColor(palette.Slider, 'successTrack', lighten(palette.success.main, 0.62)); setColor(palette.Slider, 'warningTrack', lighten(palette.warning.main, 0.62)); - setColor(palette.SnackbarContent, 'bg', emphasize(palette.background.default, 0.8)); + const snackbarContentBackground = emphasize(palette.background.default, 0.8); + setColor(palette.SnackbarContent, 'bg', snackbarContentBackground); + setColor( + palette.SnackbarContent, + 'color', + lightPalette.getContrastText(snackbarContentBackground), + ); setColor(palette.SpeedDialAction, 'fabHoverBg', emphasize(palette.background.paper, 0.15)); setColor(palette.StepConnector, 'border', getCssVar('palette-grey-400')); setColor(palette.StepContent, 'border', getCssVar('palette-grey-400')); @@ -223,7 +229,13 @@ export default function extendTheme(options = {}, ...args) { setColor(palette.Slider, 'infoTrack', darken(palette.info.main, 0.5)); setColor(palette.Slider, 'successTrack', darken(palette.success.main, 0.5)); setColor(palette.Slider, 'warningTrack', darken(palette.warning.main, 0.5)); - setColor(palette.SnackbarContent, 'bg', emphasize(palette.background.default, 0.98)); + const snackbarContentBackground = emphasize(palette.background.default, 0.98); + setColor(palette.SnackbarContent, 'bg', snackbarContentBackground); + setColor( + palette.SnackbarContent, + 'color', + darkPalette.getContrastText(snackbarContentBackground), + ); setColor(palette.SpeedDialAction, 'fabHoverBg', emphasize(palette.background.paper, 0.15)); setColor(palette.StepConnector, 'border', getCssVar('palette-grey-600')); setColor(palette.StepContent, 'border', getCssVar('palette-grey-600'));