-
-
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
[RFC] color prop API #13028
Comments
The default color should be whatever is consistent with the spec if no alternative Removing it would be a breaking change though, so deprecation warnings required. |
This will only affect the Badges are currently in a weird sport because The versioning would look like this:
|
default variantThe default variant is the value that matches the specification. It's the color value you would expect by default. It's not consistent by design. What do we win by removing it? How do you solve the problem instead? Regarding the Badge, agree, it seems wrong, I don't think that a default variant makes sense. I think that we could rename
Is it how you are suggesting to solve the problem? Would inherit variant
Yes, it's expected, we rely on the default browser value. Isn't that correct? To sum up, I think that we can fix the Badge implementation and we should be good. |
Oh, the AppBar is an interesting case. The specification changed, having a |
@oliviertassinari
It doesn't matter what I expect. The runtime already falls back to whatever is defined as a default value if you pass undefined as an argument to a function. If I'm used to that behavior when using javascript I'm used to that behavior in whatever is written in javascript. TL;DR: Remove I have never seen a component API that used a string literal to instruct that the component should use its default behavior. My main issue is with facebook's understanding of what an optional type is. Using What I don't understand is why the current API is easier to understand than Or would you design the signature of a function so that users can write function multiply(a, b = "default") {
const c = b === "default" ? 1 : b;
return a * c;
} I think this is really confusing if we set the default value of most components to the literal It's also bad because Edit: |
It does mean the same thing: As a user, you can set a color on the parent and see it being applied to the children. Same output, no matter the implementation. What changed, is that in some cases, we have to add some extra CSS, in some other cases we don't need it. It's an implementation detail.
It's about having the default behavior documented in the AP. Sometimes, the color inherit: |
Fair enough.
That is the current behavior though.
That is not the case currently. I don't know what color is applied when I use For example https://material-ui.com/api/icon-button/ has separate classes for each color category except
|
@eps1lon In this case, what about using an explicit value by renaming the |
Let's take https://material.io/design/color/the-color-system.html#color-theme-creation as the baseline. We have
Each category + variant combination has a contrast color which is named as I believe that the API is simply I would hope that there is no need for helpers like This is at least how I interpret the current spec. |
@eps1lon I gave this issue a second read. I have changed my mind. I do no longer have a strong opinion in any direction. I agree, it would help to replace the
Now, with the introduction of the system package. I think that we should work in the direction of integrating the package with the core components. Meaning having all the scope of the colors available, like |
@oliviertassinari This is something I'd like to revisit once I'd like to have a look at the color palette first since the concept is not very close to the material color system anyway. There is no such thing as I'd really like for designers that are familiar with material design to "just" pick up our theming and build new ones without having to study our API docs to see what color corresponds to what in the components. If we state that we implement material design then we should make every effort to make the transition as smooth as possible and wherever we deviate we should have a strong argument for it and at least an adapter for it. |
The |
Please don't remove the |
@skirunman inherit is a must-have, there is no plan in losing this capability. I think that the concern is about how we harmonize the implementation. |
Currently our type declarations contain the following definition for color props:
indicating that there is a library wide understanding what these color represent and that every component that has a color prop should implement each variant.
However only
primary
andsecondary
are implemented for every component with a color prop.inherit
anddefault
are not implemented in every component.default
doesn't even have a consistent style.Implementation overview
default
variantImplementation
theme.palette.getContrastText(backgroundColorDefault)
theme.palette.type === 'light' ? theme.palette.grey[100 ] : theme.palette.grey[900 ]
theme.palette.textColor
(which isundefined
)theme.palette.color
(alsoundefined
)theme.typography.button
theme.palette.getContrastText(backgroundColor)
theme.palette.type === 'light' ? theme.palette.grey[300 ] : theme.palette.grey[700 ]
theme.palette.action.active
fade(theme.palette.action.active, theme.palette.action.hoverOpacity)
if:hover
Proposal
Remove it because:
Badge
with no report (I was not able to determine when this actually broke but I guess this happened a few months ago; Edit: passed undefined even in 1.0.0-alpha.2)People can always set the
color
prop toundefined
which will result in no applied css rules concerning color which is a proper default in my opinion.inherit
variantImplementation
inherit
inherit
inherit
Funny enough in
Icon
fontSize="inherit" color="inherit"
causesfont-size: inherit;
but no definedcolor
in css.Also the default for
fontSize
in those components isdefault
and applies always no css rules but the default forcolor
isinherit
which applies sometimes no css rules. This might as well be removed. There is no value in a named default value in my opinion but this is should be discussed separately.Proposal
No strong opinion about that one. Either repurpose this as a
default
replacement which means color and background-color are not set or actually setinherit
which is the most obvious. AppBar for example does not do anything withinherit
which might be confusing./cc @mui-org/core-contributors
The text was updated successfully, but these errors were encountered: