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

[material-next][ButtonGroup] Apply MD3 style to ButtonGroup #40124

Merged
merged 16 commits into from
Jan 10, 2024

Conversation

lhilgert9
Copy link
Contributor

@lhilgert9 lhilgert9 commented Dec 6, 2023

ButtonGroup issue: #39686
Material You umbrella issue: #29345
Preview: https://deploy-preview-40124--material-ui.netlify.app/material-ui/react-button-group/#material-3-version

Changes

  • Change color props
  • Change variant props
  • Apply MD3 style
  • Add playground to docs
  • Remove combined classes and styleOverrides-keys

@mui-bot
Copy link

mui-bot commented Dec 6, 2023

@lhilgert9 lhilgert9 changed the title [material-next][ButtonGroup] Apply MD3 style toButtonGroup [material-next][ButtonGroup] Apply MD3 style to ButtonGroup Dec 6, 2023
@lhilgert9 lhilgert9 marked this pull request as ready for review December 7, 2023 12:29
@zannager zannager added the component: ButtonGroup The React component. label Dec 7, 2023
@zannager zannager requested a review from mj12albert December 7, 2023 17:19
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 12, 2023
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 12, 2023
@DiegoAndai DiegoAndai self-requested a review December 29, 2023 18:17
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @lhilgert9, and sorry for the late review.

I left a couple of questions.

Besides that, I will assign @zanivan for a design review. Victor, could you help us here with filling the Material 3 specs gaps? The specs only specify styles for the outlined variant:

Screenshot 2024-01-03 at 10 30 10

But we need to adapt it to other variants. I think what Lucas did with the other variants is looking good:

Screenshot 2024-01-03 at 10 31 00

But I think we could use some borders in between. I'm curious to see if you come up with anything else we might want to add to these. You can test out the different variants in the playground.

packages/mui-material-next/migration.md Show resolved Hide resolved
@@ -24,7 +24,7 @@ export interface ButtonGroupOwnProps {
* @default 'primary'
*/
color?: OverridableStringUnion<
'inherit' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning',
'primary' | 'secondary' | 'tertiary',
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't remove the inherit and other color options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DiegoAndai I had removed these because the other colors were also removed in the button. https://github.com/mui/material-ui/blob/master/packages/mui-material-next/src/Button/Button.types.ts#L40

Copy link
Member

@DiegoAndai DiegoAndai Jan 4, 2024

Choose a reason for hiding this comment

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

True. May I ask you to bring those back? We can do it in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DiegoAndai 'error' | 'info' | 'success' | 'warning' are no problem to implement, but 'inherit' is very expensive to implement, because at every point where the property color is called, a check must first be made to ensure that it is not inherit and then the special forms for inherit must be implemented. So the question is whether you really want to keep inherit and whether it is worth the effort?

Copy link
Member

Choose a reason for hiding this comment

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

That's a good point; it does seem like a specific use case that bloats the styles—tagging @mui/core to get more opinions.

Copy link
Member

Choose a reason for hiding this comment

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

I discussed with some Core members and realized that the inherit color is pretty useful when dealing with composed components like navigation bars, modals, and alerts.

Is there a way we can improve the implementation so it's not so "expensive"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, that sounds logical.
However, due to the complexity, I would suggest implementing the whole thing in a new PR, in which the missing colors are then returned for both the button and the button group. Here you could possibly also solve the problems with the color change of the button, which occurs when you use filledTonal or elevated as a variant and is only used primary as a color.

packages/mui-material-next/src/ButtonGroup/ButtonGroup.tsx Outdated Show resolved Hide resolved
@DiegoAndai DiegoAndai requested a review from zanivan January 3, 2024 13:32
@zanivan
Copy link
Contributor

zanivan commented Jan 8, 2024

Hey there! Joining late to the party, but I'll leave my review from the design aspect of it:

This is how I believe the variants should look like—I tried to use the button and the divider as a base for it:

image

moreover, I believe the states (hovered, disabled, etc) should follow the same as buttons!

Thanks for tackling this, @lhilgert9! 🚀

@lhilgert9
Copy link
Contributor Author

lhilgert9 commented Jan 9, 2024

@zanivan Everything should be implemented. Please have a look and give me some feedback. Regarding the hovered state, I'm not sure whether we should implement this in the same way as the button, as this looks strange in my eyes. However, you don't see a big change in the state as I have currently implemented it. Any ideas on this?

Original Button implementation:

  • filled
Bildschirmfoto 2024-01-09 um 10 54 26
  • filledTonal
Bildschirmfoto 2024-01-09 um 10 54 09

My Button implementation:

  • filled (I think this is okay)
Bildschirmfoto 2024-01-09 um 11 00 44
  • filledTonal (this is not okay, because you see no change)
Bildschirmfoto 2024-01-09 um 11 00 31

Copy link
Contributor

@zanivan zanivan left a comment

Choose a reason for hiding this comment

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

It looks good!

Please, correct me if I'm wrong, but I suspect that the current implementation of the hover is not how it is supposed to be (judging by the design resources). If I understood i it correctly, currently we're only using the opacity layer, so that's why it seems unchanged on the demo.

Since we're using the opacity (0.8, I believe) the background will influence directly on the contrast. See when we change it to black, for instance:

White background Black background
Screenshot 2024-01-09 at 13 38 31 Screenshot 2024-01-09 at 13 38 53
Screenshot 2024-01-09 at 13 39 10 Screenshot 2024-01-09 at 13 39 02

The right approach, as I see, would be to implement it as it's on the design guidelines—at least on Figma kit—where we have a layer using a solid background color, and while :hover we add an opacity layer over. For example:

image

@DiegoAndai This seems to be happening on the current Material You button too. Maybe we should solve there first?

@DiegoAndai
Copy link
Member

I suspect that the current implementation of the hover is not how it is supposed to be (judging by the design resources).

You're correct. We noticed it during the Chip implementation. On that component, it's implemented properly using color-mix: https://github.com/mui/material-ui/blob/master/packages/mui-material-next/src/Chip/Chip.tsx#L253

We need to port this to other components that are already implemented, I created an issue for it (but it is on hold for now): #40517

I would merge this in its current state and resume it when we start working on v7. How does that sound, @lhilgert9 @zanivan?

@lhilgert9
Copy link
Contributor Author

@DiegoAndai That's okay with me, since it's only an experimental package, so bugs can still occur and it doesn't look bad per se.

@zanivan
Copy link
Contributor

zanivan commented Jan 10, 2024

I would merge this in its current state and resume it when we start working on v7

Sure, I think we can wait since more components are affected the same way.

@DiegoAndai DiegoAndai merged commit 87af0d0 into mui:master Jan 10, 2024
22 checks passed
@lhilgert9 lhilgert9 deleted the apply-md3-style-to-button-group branch January 10, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ButtonGroup The React component.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants