-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Document and exposes colorManipulator helpers #10789
Comments
theme.palette.primary[n]
@rocketraman There are no official alternatives to the Right now, the You can find some shared pain points with #10499. |
@rocketraman The palette is primarily about giving control over the colors that Material-UI components use, but don't forget that you can also add custom keys to the theme, so you can easily provide additional colors to use in your own components: import { createMuiTheme } from 'material-ui/styles';
import red from 'material-ui/colors/red';
import green from 'material-ui/colors/green';
import blue from 'material-ui/colors/blue';
const theme = createMuiTheme({
palette: {
red,
green,
blue,
},
}); Or, as @oliviertassinari mentioned, just import them directly in your component.
No, because the Material Design colors don't follow any standard gradient, and hue and saturation are also tweaked variously across colors. There is no way to apply a standard function to a 500 color to arrive at some other color matching the spec. |
@oliviertassinari @mbrookes Both of those are useful comments, thanks. If some of the functions in
|
If you only add However unless That said, I have no objection to |
Yes, this was just an example, of course. Good to know 0.2 is the default for
Yes, that is the case for me. The docs point people to the material IO color tool, and often times people will use the
Are you thinking about something like https://github.com/bgrins/TinyColor? I'm wondering if |
@rocketraman I was referring to your users, and giving them the ability to change the color of your app, bet even then you'd probably want to provide a predefined set of options. Since your
I don't know that that's possible (or at least that simple) given that, as mentioned, for any particular hue, the shades don't follow a standard pattern. Try working out how much to lighten red[500] by to get say, red[200], then apply the same to other hues and see how well they match up with the spec. |
Yeah, that makes sense. Well, no reason other than the self-documenting program that results from a calculated value rather than a static value. Same reason people define constants like:
But yeah, I can always add a comment instead...
Fair enough. I didn't realize the predefined color shades were customized by Google to such an extent. The existing |
I'm closing for #13039. |
In recent beta's it looks like a lot of nice simplifications have been made to the theme palette approach. However, there is one thing which is unclear to me. In my old code, I was able to have logic like this:
The closest thing I seem to have now is to use
colorManipulator.lighten
anddarken
, passing in a relative value as the "coefficient" e.g.Is this the "right" approach to use now? If so, the docs should probably describe the best way to use these methods, and typical values of the coefficient value to achieve various shades in the source palette. For example, is it true to say that, assuming
primary.main
is the equivalent ofprimary[500]
before, thenprimary[200]
would now be achieved via a coefficient of 0.4, since200/500=0.4
?The text was updated successfully, but these errors were encountered: