-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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] Able to remove default tokens from theme types #36006
[Joy] Able to remove default tokens from theme types #36006
Conversation
Netlify deploy previewhttps://deploy-preview-36006--material-ui.netlify.app/ Bundle size report |
…fix-global-variant-types
…fix-global-variant-types
100: false; | ||
120: true; |
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.
It's still not clear to me if this can really work, for example:
plainHoverBg: getCssVarColor(`palette-${color}-100`),
This variable will no longer point to a valid value. Should we expect developers to map all variables to point to this value to something new?
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.
You will also need to specify undefined
as a value to the token (100: undefined
).
That's the expected behavior. The goal is to let developers be able to customize the color range to match their design system needs (the tokens should not be limited to 50-900 range)
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.
Those lines only add/remove the theme typings.
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.
Coming a bit late to the party, but this was my comment: https://codesandbox.io/s/joy-cra-typescript-forked-2dfxd5?file=/src/App.tsx I know you can make it technically correct, but components will break. We need to make sure we give detailed instructions of what needs to be done after some specific palette value is removed, for e.g. some tokens will need to be redefined.
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.
but components will break
In my point of view, this break is expected because you are changing the token structure. I agree with you that docs should address this clearly and I plan to add a page to the advanced section of Joy UI customization.
…fix-global-variant-types
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.
Yes much more solid typings. Looks good.
Context
While working on #35741, I noticed some types augmentation are wrong and missing.
Before
A lot of theme augmentation does not work correctly:
undefined
in theextendTheme()
.After
sandbox: https://codesandbox.io/s/joy-cra-typescript-forked-g7u3b5?file=/src/App.tsx
undefined
toextendTheme()
(before this, you have to use// @ts-ignore
)theme.vars
are sync with the module augmentation