-
-
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
[Joy] Add Button
- 1st iteration
#29464
Conversation
Please see my feedback in Notion |
FYI, this PR is not about design, I will fix it once we have decided about the naming but it should not block this PR. |
That's why I left the feedback in Notion not here. 😄 (Not that anyone has responded to it...) |
skip: ['propsSpread', 'componentsProp', 'classesRoot'], | ||
})); | ||
|
||
it('by default, should render with the root, variantText, sizeMedium and colorBrand classes', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the tests if the button is rendered with all classes all test would pass :) Shouldw e maybe test that by default the other classes are not added? Or update the other test to test that the class is not there by default, but it is if the props is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldw e maybe test that by default the other classes are not added
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
]; | ||
}, | ||
})<{ ownerState: ButtonProps }>(({ theme, ownerState }) => { | ||
const colorPalette = theme.vars.palette[ownerState.color || 'brand']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a DX perspective, I wonder if we shouldn't reverse the tradeoff. It seems that the right path (using the CSS variable) is more painful (more to type/read) than accessing the raw value.
const colorPalette = theme.vars.palette[ownerState.color || 'brand']; | |
const colorPalette = theme.palette[ownerState.color || 'brand']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I propose in #27651 under "Decision on the API".
2 things about using vars
- I consider CSS variables as a feature on top of ThemeProvider, so adding
vars
instead of replace the theme makes more sense. - When we have to update
mui-material
to support CSS variables, we can incrementally change the code in each component and it should not break other components.
Anyway, I will try your method and share the finding again. If it is better, we can change Joy to use it.
classes, | ||
testStateOverrides, | ||
render, | ||
ThemeProvider = MDThemeProvider, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we settle on the naming conversions? How are we abbreviating Material Design as "MUI" or "MD"? It seems to be MD and MUI for Material to build UIs. Alright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MD is better because the option we want to move forward on the docs says "MUI Core as a product line — System, Joy, MD, and Base as products"
https://deploy-preview-29464--material-ui.netlify.app/joy/
This PR
please review the implementation & coding pattern, so that we can make this as a standard for other Joy components.
variant: text | outlined | contained
(same as material)size: small | medium | large
(same as material)color: brand
(related to theme.palette)fullWidth
classes
as propNext iteration