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

[core] Revise the theme.palette.primary & secondary approach #9794

Merged
merged 10 commits into from
Jan 13, 2018
Merged

[core] Revise the theme.palette.primary & secondary approach #9794

merged 10 commits into from
Jan 13, 2018

Conversation

mbrookes
Copy link
Member

@mbrookes mbrookes commented Jan 8, 2018

Closes #8075
Closes #8183

Still outstanding:

  • Two uses of primary accent colors (currently converted to primary.dark / light)
    (ok as is)
  • Enhanced dark / light method?
    (Not needed)
  • Revert the docs secondary color change, it's just for testing with.
    (Although personally I like orange better with our current blue primary!)
  • FIx flow errors & reinstate flow.

Breaking change

It's an important simplification of the palette system. You can now directly use the “official” Color Tool.

  • Instead of using a rich color object of 14 different keys, we rely on an object of 4 different keys: light, main, dark and contrastText.
  • Providing the full-color object used to be required. Now, we will provide a nice default to the different values using the main value.
import { createMuiTheme } from 'material-ui/styles';
import blue from 'material-ui/colors/blue';
import pink from 'material-ui/colors/pink';

const theme = createMuiTheme({
  palette: {
-   primary: blue,
-   secondary: pink,
+   primary: {
+     light: blue[300],
+     main: blue[500],
+     dark: blue[700],
+   },
+   secondary: {
+     light: pink[300],
+     main: pink[500],
+     dark: pink[700],
+   }
    type: theme.paletteType,
  },
});

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.

Awesome start :)

@@ -4,14 +4,14 @@ import { create, SheetsRegistry } from 'jss';
import rtl from 'jss-rtl';
import { createMuiTheme, createGenerateClassName, jssPreset } from 'material-ui/styles';
import blue from 'material-ui/colors/blue';
import pink from 'material-ui/colors/pink';
import orange from 'material-ui/colors/orange';
Copy link
Member

@oliviertassinari oliviertassinari Jan 9, 2018

Choose a reason for hiding this comment

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

Why not.
capture d ecran 2018-01-09 a 08 41 10

Copy link
Member

@oliviertassinari oliviertassinari Jan 9, 2018

Choose a reason for hiding this comment

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

Wait no, please revert, the contrast was 4.01 and it's 2.16 now.

Copy link
Member

Choose a reason for hiding this comment

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

capture d ecran 2018-01-09 a 08 42 36
capture d ecran 2018-01-09 a 08 42 24

Copy link
Member Author

@mbrookes mbrookes Jan 9, 2018

Choose a reason for hiding this comment

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

Dude, please read: #9794 (comment) It's temporary. 😄 (But if we were going to change this, darkOrange might be a nice compromise.)

package.json Outdated
"test:unit": "cross-env NODE_ENV=test mocha test/**/*.spec.js src/{,**/}*.spec.js",
"test:watch": "yarn test:unit -w",
"test:coverage": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc mocha test/**/*.spec.js src/{,**/}*.spec.js && nyc report -r lcovonly",
"test:coverage:html": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc mocha test/**/*.spec.js src/{,**/}*.spec.js && nyc report --reporter=html",
"test:karma": "cross-env NODE_ENV=test karma start test/karma.conf.js --single-run",
"test:regressions": "webpack --config test/regressions/webpack.config.js && rimraf test/regressions/screenshots/chrome/* && vrtest run --config test/vrtest.config.js --record",
"typescript": "tsc -p tsconfig.json",
"flow": "flow --show-all-errors",
"flow": "echo \"No flow.\"",
Copy link
Member

Choose a reason for hiding this comment

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

Wait. We still use internally for some of our files. Please put it back.

Copy link
Member Author

@mbrookes mbrookes Jan 9, 2018

Choose a reason for hiding this comment

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

Relax ☺️, it's just to get through CI to check everything else. Flow was giving me the runaround over something trivial. I ran out of patience with it at 1:00am.

@@ -4,7 +4,8 @@ import classNames from 'classnames';
import withStyles from '../styles/withStyles';

export const styles = theme => {
const focusColor = theme.palette.primary[theme.palette.type === 'light' ? 'A700' : 'A200'];
// FIXME: 'dark' & 'light' were accent colors before the theme change
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think that we are good, you can remove the comment:
capture d ecran 2018-01-09 a 08 18 14

@@ -74,7 +74,8 @@ export const styles = theme => {
},
inkbar: {
'&:after': {
backgroundColor: theme.palette.primary[theme.palette.type === 'light' ? 'A700' : 'A200'],
// FIXME: 'dark' & 'light' were accent colors before the theme change
Copy link
Member

Choose a reason for hiding this comment

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

It's reducing entropy 👍 .

@@ -13,27 +13,27 @@ export const styles = theme => ({
height: 5,
},
primaryColor: {
backgroundColor: theme.palette.primary[100],
backgroundColor: theme.palette.primary.light,
Copy link
Member

Choose a reason for hiding this comment

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

The color is too close to theme.palette.primary.main. We can't see the difference:
capture d ecran 2018-01-09 a 08 24 07
I think that we need a lighten() call.

Copy link
Member Author

@mbrookes mbrookes Jan 9, 2018

Choose a reason for hiding this comment

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

@oliviertassinari:
We can use A200 for A100

Yeah, I had my doubts about that. lighten() it is.

secondary = pink,
error = red,
primary = {
light: indigo[300],
Copy link
Member

Choose a reason for hiding this comment

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

Question, why using 300 and not a lighter version of indigo[500]?
(we could just remove this line so the default logic quicks in)

Copy link
Member Author

@mbrookes mbrookes Jan 9, 2018

Choose a reason for hiding this comment

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

Bacuase it's the "correct" color according to the MD spec. But we can approximate if you're happy with that.

Copy link
Member

@oliviertassinari oliviertassinari Jan 9, 2018

Choose a reason for hiding this comment

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

Sounds good :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, which?

Copy link
Member

@oliviertassinari oliviertassinari Jan 9, 2018

Choose a reason for hiding this comment

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

@mbrookes Your argument sounds good. I thought MCW was doing the opposite.

type = 'light',
// Same value used by material-components-web
// https://github.com/material-components/material-components-web/blob/ac46b8863c4dab9fc22c4c662dc6bd1b65dd652f/packages/mdc-theme/_functions.scss#L49
contrastThreshold = 3.1,
contrastThreshold = 3,
Copy link
Member

@oliviertassinari oliviertassinari Jan 9, 2018

Choose a reason for hiding this comment

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

Copy link
Member Author

@mbrookes mbrookes Jan 12, 2018

Choose a reason for hiding this comment

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

"It's déjà vu all over again". 😄

#8183 (comment)

  1. That isn't the spec for contrast color it's the spec for the color pallette. The text is simply labels, so it doesn't matter that they're different.
  1. our current color tables' labels don't match the spec in places if you compare them.

This is the best default for end users IMHO. If you really want the docs color table labels closer to the labels in the spec (contrastThreshold = 3.1 doesn't exactly match either), we can override it in the docs.

Copy link
Member

@oliviertassinari oliviertassinari Jan 12, 2018

Choose a reason for hiding this comment

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

I won't argue for 0.1. Fine.

@mbrookes
Copy link
Member Author

@oliviertassinari I think we're nearly there. The only thing I'm wondering is if we should add error.accent: red.A400, and make error.main: red[500].

If so, we could do the same for primary / secondary, and keep the Input underline etc. consistent with the current implementation.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 12, 2018

@mbrookes Why do we use two different error colors in the first place 😮 ? Something is wrong here, nothing is justifying us using two different values here 🙈 :

  1. https://github.com/mui-org/material-ui/blob/33d0954b8626528fda6eeaa8cc39216ccc3117dd/src/SvgIcon/SvgIcon.js#L31-L33
  2. https://github.com/mui-org/material-ui/blob/33d0954b8626528fda6eeaa8cc39216ccc3117dd/src/Typography/Typography.js#L58-L60

I could only find one occurrence of the error color on material-components-web side, they are using red.A700.
The specification is encouraging using A400. Bootstrap has only one alert color.

@mbrookes
Copy link
Member Author

I don't know why for sure, but it does seem red.A400 is a bit "harsh" for <Icon color="error" />, while red[500] is perhaps a bit dull for error text. If you're happy to standardize, lets pick one and go with it.

@mbrookes mbrookes merged commit eb36957 into mui:v1-beta Jan 13, 2018
@mbrookes mbrookes mentioned this pull request Jan 13, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 13, 2018

@mbrookes Yeah 🎉 ! Good job 👯‍♂️

@yuchi
Copy link
Contributor

yuchi commented Jan 13, 2018

I love you guys ❤️

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 13, 2018

@yuchi Half the value comes from you raising the issue and convincing us to do the change 💯 .

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.

3 participants