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

[docs] Improve settings toggle button styling #23754

Merged
merged 5 commits into from
Nov 30, 2020

Conversation

mbrookes
Copy link
Member

Higher contrast, and use primary color for selected state:

image

@mbrookes mbrookes added the docs Improvements or additions to the documentation label Nov 28, 2020
@mui-pr-bot
Copy link

mui-pr-bot commented Nov 28, 2020

No bundle size changes

Generated by 🚫 dangerJS against 626bbc7

Copy link
Member

@oliviertassinari oliviertassinari 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 better. What if we added the support for a color prop on the component itself?

@mbrookes
Copy link
Member Author

What if we added the support for a color prop on the component itself?

I wondered about that. I'll open an issue for it.

@mbrookes mbrookes force-pushed the docs-settings-styling branch from dfd553d to c8d9a42 Compare November 28, 2020 18:13
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

I would also change the hover+selected style to match the convention:

Capture d’écran 2020-11-28 à 19 43 19

@mbrookes
Copy link
Member Author

mbrookes commented Nov 28, 2020

I would also change the hover+selected style to match the convention

Oops, yes. When I was forcing it with !important it looked ok.

@@ -37,6 +37,9 @@ const styles = (theme) => ({
'&$toggleButtonSelected': {
color: `${theme.palette.primary.main}`,
backgroundColor: `${alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity)}`,
'&:hover': {
backgroundColor: `${alpha(theme.palette.primary.main, 0.12)}`,
Copy link
Member

Choose a reason for hiding this comment

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

See https://github.com/mui-org/material-ui/blob/6f56be2a07185be06984476aed9f518cbbd6b87d/packages/material-ui-lab/src/TreeItem/TreeItem.js#L50-L58 for a good approach, I think that we miss the hover none and the design tokens for the alpha value.

Copy link
Member Author

@mbrookes mbrookes Nov 29, 2020

Choose a reason for hiding this comment

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

theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity

Ah, I didn't think of summing them. 👍

By comparison, an active list item doesn't change shade when hovered.

Perhaps there should be a distinction between a toggle button that can be deselected (changes shade when hovered), and one that can't (doesn't change shade when hovered)?

Copy link
Member

@oliviertassinari oliviertassinari Nov 29, 2020

Choose a reason for hiding this comment

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

By comparison, an active list item doesn't change shade when hovered.

It seems to do in my case: https://next.material-ui.com/components/lists/#selected-listitem. We marked it as handled in #10870.

Perhaps there should be a distinction between a toggle button that can be deselected (changes shade when hovered), and one that can't (doesn't change shade when hovered)?

Why not. This new design makes me think about https://ant.design/components/radio/#Radio/Radio.Button

@mbrookes
Copy link
Member Author

mbrookes commented Nov 29, 2020

We marked it as handled in #10870.

I'd forgotten about that. I think I checked on https://material-ui.com

In this example the active item doesn't change color on hover (i.e. doesn't lighten when the mouse moves off after selection):
https://kstatic.googleusercontent.com/files/f8f8274b12c59c47666497f405cc79236262b8d412733526508ab7844809a9b7a92d6412a348aa4c4cc40d92ebcf93c1023b13245591d4cccde45115f2941ed6

(Taken from https://material.io/design/interaction/states.html#activated, Behavior)

Perhaps there should be a distinction between a toggle button that can be deselected (changes shade when hovered), and one that can't (doesn't change shade when hovered)?

Why not. This new design makes me think about https://ant.design/components/radio/#Radio/Radio.Button

Except that, in the case of Ant, the active item does change on hover.


BTW it seems the toggle button spec has ben updated to be higher contrast the Toggle Button spec: https://material.io/components/buttons#toggle-button, so we can move some of these changes into ToggleButton.

I'm going to commit them here first though to fix the Settings panel in the short term. I'll update them when ToggleButton is updated.

There's also some precedence in the spec for a colored active state, see update in: #23755

@oliviertassinari
Copy link
Member

Material Design mentions "can", so it might be up to the designer.

Capture d’écran 2020-11-30 à 18 31 22

https://material.io/design/interaction/states.html#hover

@mbrookes mbrookes merged commit f5361ec into mui:next Nov 30, 2020
@mbrookes mbrookes deleted the docs-settings-styling branch November 30, 2020 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants