-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Button] Fix contained with inherit prop not adapting on dark mode #34508
[Button] Fix contained with inherit prop not adapting on dark mode #34508
Conversation
Netlify deploy previewhttps://deploy-preview-34508--material-ui.netlify.app/ @material-ui/core: parsed: +0.08% , gzip: +0.05% Bundle size report |
@danilo-leal @mnajdova could you guys take a look at this please? |
I will take a look at this tomorrow! thanks for the fix. |
Thanks for looking into this. I would probably make the background a bit lighter in light mode. Also, could you please add a regression test for this? Using the codsandbox linked in the issue can be a great start: https://codesandbox.io/s/togglecolormode-material-demo-forked-1j544?file=/demo.js You can add the fixture here: https://github.com/mui/material-ui/tree/master/test/regressions/fixtures/Button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these changes affect both light and dark modes, should this be improved in v6? @mnajdova
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Echoing @mnajdova's comment, I'd probably make the light background color lighter and the dark mode bg darker as well.
Good point, maybe we should focus on changing only dark mode in this PR. |
f79e94f
to
fcea75f
Compare
37c5b9d
to
a035ca1
Compare
Hey @siriwatknp @mnajdova @danilo-leal , I'm Jessica's friend and will be dealing with this PR for now on :) I've added the regression test based on Mention me for futher feedback :) Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least visually, this looks good to me 👍
@@ -121,7 +121,10 @@ const ButtonRoot = styled(ButtonBase, { | |||
}, | |||
}), | |||
...(ownerState.variant === 'contained' && { | |||
backgroundColor: (theme.vars || theme).palette.grey.A100, | |||
backgroundColor: | |||
(theme.vars || theme).palette.mode === 'dark' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using CSS variables, ideally we would use the same variable for both dark and light mode, and we would only switch the value of the variable. cc @siriwatknp should we add a variable for the inherit background of the button?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnajdova @siriwatknp should we use this approach here? or is it good to go as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would tend to use CSS variables, for e.g. as it is done for other components: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/styles/experimental_extendTheme.js#L137. cc @siriwatknp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I continued on this PR and made the remaining changes.
I added the CSS vars for Button in extend theme as pointed out by @mnajdova in #34508 (comment).
I tested and it works well both with and without CssVarsProvider.
- Without CssVarsProvider - https://codesandbox.io/s/togglecolormode-material-demo-forked-1dlsye?file=/demo.js
- With CssVarsProvider - https://codesandbox.io/s/togglecolormode-material-demo-forked-99h1p7?file=/demo.js
Also, as @siriwatknp pointed out that it is a breaking change in light mode in #34508 (review), I kept the light mode values same and added new ones for dark mode. The related issue is also specifically only for dark mode.
I also improved the visual regression test to test it in both light and dark palette modes.
It looks good to me to merge. However, it needs one other final review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Great job everyone!
co-authored: @EduardoSCosta
This PR resolve #29749