-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Restructure the keys inside the theme by component name #21923
Comments
One element I wonder about, the |
The difference that I see is that, the first ones are overrides for the component's styles, and second ones are styles for the variant specified. So maybe |
Does |
Styles is used for defining additional styles for variants and combination of props that did not exists previosly. You can take a look on #21749 for more details |
I guess my question was more to find out if there was a difference in behavior and it seems there is. |
That's why we are proposing |
I think the overall structure change is nice, but I think it is important to add a function to ease migration such as |
Makes sense. I am suggesting that your original proposal is good because cssOverrides deals in class names and styles does not. |
If we were to unify the terminology, I think I prefer |
Thanks that you're making MaterialUI better, trying new approaches and improvements. My thoughts about proposal (after reading comments):
const theme = createMuiTheme({
components: {
MuiButton: {
css: { // <-- In this property I would write CSS
root: {
fontSize: 20,
'&:hover, &:focus': { // <-- :hover, :focus, :active, :before, :after etc...
borderColor: 'green',
},
'& span': { // <-- What if I want use span as block inside the button? Depends design requirement
display: 'block',
},
'@media (min-width: 1024px)': { // <-- I can want use media queries
fontSize: 18
},
},
fullWidth: {
boxSizing: 'border-box',
width: '100%',
},
},
props: { // <-- We know that it's default props when make the theme (because all of theme object are default values). So we can use props instead defaultProps
disableFocusRipple: true,
},
},
},
}); |
I fear that we'll not be able to codemod a lot of existing patterns. We should be extremely careful with handwaving breaking changes as "might as well do it while we're at it". This was a criticism in the most recent survey and change would double down on criticism (again after introducing a new API for customization). I don't understand why we do these surveys if we not only ignore them but directly go against the points made in the answers. |
A couple more comments on the RFC on the replies of https://twitter.com/olivtassinari/status/1286950696298872832.
@eps1lon How did you conclude that this "thinking approach" is one as the motivation for the change?
How did you identify this feedback from our users as frequent (or if we extrapolate, important) from the survey answers? |
Reading
Reading
Under "5. How can we improve Material-UI for you?" -- https://medium.com/material-ui/2020-material-ui-developer-survey-results-7565085580a8 |
@eps1lon A couple of thoughts:
|
@eps1lon the main purpose of the RFC is restructuring the keys inside the theme, that's what the name indicates as well. The renaming is added only as consideration.
I did not get it whether you disagree with the proposal for moving the keys, or only the renaming part. If we wanted to rename this in the past, and now we are going to introduce some changes in the object structure anyway, probably now it is the best time to batch this breaking changes together, to avoid in the future two times solving breaking changes in one place. That is the only reason why I proposed this change in the RFC too. |
At what percentage do we ignore the feedback? Ignoring it after reading the survey makes the data useless.
This statements says nothing. It reads like an advertisement. |
@eps1lon I don't know. I think that we should focus on the biggest pain points. If feedback X is in opposition to feedback Y, probably we should weight them per frequency? In our case, if easier customization is x27 more frequently asked for than fewer breaking changes, maybe it's a weight we can take into account?
Agree, to clarify it, I think that we should be long term focused (a couple of years). Breaking changes has a lot of short-term considerations that we should ignore. With two limits. 1. If we make too many of them, people might avoid us for long term considerations of their product development flow (the BCs are not worth it). 2. Any breaking change might motivate a team to consider the alternatives, we take the risk of churn. My cynical view would be, it's a great feedback loop. If people are moving away, it's because we didn't deliver what they truly want. A great way to course-correct, it accelerates learning. |
An interesting approach to customizability that goes in this direction: https://www.vue-tailwind.com/ |
Another interesting approach to customizability that goes in this direction: const theme = {
components: {
Badge: {
baseStyle: {
fontSize: "12px",
fontWeight: "bold",
textTransform: "uppercase",
color: "white",
px: "2",
py: "1",
borderRadius: "4px",
},
variants: {
"in-progress": {
bg: "blue.600",
},
new: {
bg: "purple.600",
},
removed: {
bg: "red.600",
},
default: {
bg: "gray.600",
},
},
defaultProps: {
variant: "default",
},
},
},
}; https://next.chakra-ui.com/docs/theming/overview#where-to-put-the-style-config |
@oliviertassinari I'm missing what value that adds over the proposed API. |
The only thing missing from these APIs is combination of props, otherwise they look really similar (and I like the components key as first 👍 ) On the second proposal I am not sure if they are changing the actual styles or they have some component level tokens, which may be an interesting thing to explore. |
Summary
This RFC proposes slightly different structure to the theme, by moving the components as first key, and nesting the existing keys (
overrides
,props
andvariants
- will be added with #21648) inside. As we are doing this breaking change, we may even consider renaming the existing keys based on this #21012 (comment) tocssOverrides
anddefaultProps
.Changes
Current:
Proposed:
Motivation
Think component first.
With the proposed definition all theme definitions related to one component can be easily discovered and defined together. It's also interesting if later on, developers have a concern about tree-shaking and want to move the configuration from the theme singleton to wrapper components they import.
Drawbacks
Other than the change being breaking, I don't see any other drawback with the proposed restructuring.
Prio-arts
Same approach in
The text was updated successfully, but these errors were encountered: