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

[classes] Normalize the classes names #10457

Merged
merged 1 commit into from
Mar 1, 2018

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Feb 26, 2018

Breaking change

This is an effort in order to harmonize the classes API. The best way to recover from this breaking change is to check the warnings in the console and to check the added documentation around the design rules around this API.

I'm quite happy with the current "classes" state, the main thing missing is documented in the roadmap:

Change the CSS specificity rule to solve #10010 and #9742 at scale. It's inspired by the Bootstrap approach to writing CSS.


CSS Classes

All the components accept a classes property to customize the styles.
The classes design answers two constraints.
We try to make the classes structure as simple as possible while keeping it complex enough for implementing the Material specification.

  • The class applied on the root element is always called root.
  • The classes applied on non-root element are prefixed with the name of the element, e.g. dashedXX.
  • All the default styles are grouped in a single class.
  • The boolean variants applied aren't prefixed e.g. rounded.
  • The enum variants applied are prefixed e.g. colorXX.
  • A variant has one level of specificity.
    For instance, the color and variant properties are considered a variant.
    The lower the style specificity is, the simpler you can override it.
  • We increase the specificity for a variant modifier. We already have to do it for the pseudo-classes (:hover, :focus, etc.). It allows much more control at the cost of extra complexity. Hopefully, it's more intuitive.
const styles = {
  root: {
    color: green[600],
    '&$checked': {
      color: green[500],
    },
  },
  checked: {},
};

@@ -168,12 +168,12 @@ const styles = theme => ({
fontFamily: 'Consolas, "Liberation Mono", Menlo, monospace',
},
'& .required': {
color: theme.palette.type === 'light' ? '#008900' : '#65a665',
color: theme.palette.type === 'light' ? '#006500' : '#9bc89b',
Copy link
Member Author

@oliviertassinari oliviertassinari Feb 27, 2018

Choose a reason for hiding this comment

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

AAA contrast

@oliviertassinari oliviertassinari self-assigned this Feb 28, 2018
@oliviertassinari oliviertassinari force-pushed the table-flat-classes branch 2 times, most recently from 14a067f to 95db90f Compare March 1, 2018 08:50
@oliviertassinari oliviertassinari merged commit dbd338f into mui:v1-beta Mar 1, 2018
@oliviertassinari oliviertassinari deleted the table-flat-classes branch March 1, 2018 19:37
@xaviergonz
Copy link
Contributor

xaviergonz commented Mar 8, 2018

I'm trying to understand this change but don't quite get it without an example.
How would I create a red raised button with this new idea compared to how it was in #10010 ?

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Mar 8, 2018

@xaviergonz Nothing has changed on this end yet. This pull-request was only about normalizing and documenting the logic behind the classes wordings. I will ping you once I have a prototype of the change we can apply to solve the issue. Does that sounds good?

@xaviergonz
Copy link
Contributor

@oliviertassinari sounds great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants