Skip to content
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

Merged

Conversation

jesrodri
Copy link
Contributor

co-authored: @EduardoSCosta

This PR resolve #29749

image
image

@mui-bot
Copy link

mui-bot commented Sep 28, 2022

Netlify deploy preview

https://deploy-preview-34508--material-ui.netlify.app/

@material-ui/core: parsed: +0.08% , gzip: +0.05%

Bundle size report

Details of bundle changes

Generated by 🚫 dangerJS against 5abef5a

@michaldudak michaldudak added design: material This is about Material Design, please involve a visual or UX designer in the process component: button This is the name of the generic UI component, not the React module! labels Oct 12, 2022
@michaldudak michaldudak removed their request for review October 28, 2022 09:08
@jesrodri
Copy link
Contributor Author

jesrodri commented Nov 7, 2022

@danilo-leal @mnajdova could you guys take a look at this please?

@siriwatknp siriwatknp self-requested a review November 9, 2022 10:15
@siriwatknp
Copy link
Member

I will take a look at this tomorrow! thanks for the fix.

@mnajdova
Copy link
Member

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

Copy link
Member

@siriwatknp siriwatknp left a 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

Copy link
Contributor

@danilo-leal danilo-leal left a 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.

@mnajdova
Copy link
Member

Looks like these changes affect both light and dark modes, should this be improved in v6? @mnajdova

Good point, maybe we should focus on changing only dark mode in this PR.

@feliperli feliperli force-pushed the fix/29749/contained-inherit-button-dark-mode branch from f79e94f to fcea75f Compare December 6, 2022 21:12
@feliperli feliperli force-pushed the fix/29749/contained-inherit-button-dark-mode branch from 37c5b9d to a035ca1 Compare December 7, 2022 19:48
@feliperli
Copy link

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 MultilineButton and the demo you guys pointed above, hope I get it right. I've also changed the dark mode color to darker and the light mode to lighter

image

image

Mention me for futher feedback :) Thanks!

Copy link
Contributor

@danilo-leal danilo-leal left a 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 👍

@mnajdova mnajdova requested review from siriwatknp and removed request for mnajdova December 13, 2022 14:42
@@ -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'
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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

@ZeeshanTamboli ZeeshanTamboli changed the title fix: adapt button colors when contained+inherit [Button]: Fix contained with inherit prop not adapting on dark mode Apr 14, 2023
@ZeeshanTamboli ZeeshanTamboli changed the title [Button]: Fix contained with inherit prop not adapting on dark mode [Button] Fix contained with inherit prop not adapting on dark mode Apr 14, 2023
@ZeeshanTamboli ZeeshanTamboli added the bug 🐛 Something doesn't work label Apr 14, 2023
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a 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.

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.

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Great job everyone!

@ZeeshanTamboli ZeeshanTamboli merged commit 1bedbbc into mui:master Apr 17, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! design: material This is about Material Design, please involve a visual or UX designer in the process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Button] Contained with inherit prop not adapting on dark mode
8 participants