-
-
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
[Input] Support CSS variables #32128
[Input] Support CSS variables #32128
Conversation
@material-ui/core: parsed: +0.15% , gzip: +0.16% |
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.
Thanks for looking into this :) I've left two comments. As this is still very early in the development there will be occurrences like this where we will need to make a decision, so sorry if this takes a bit longer :)
const light = (theme.vars || theme).palette.mode === 'light'; | ||
const bottomLineColor = light ? 'rgba(0, 0, 0, 0.42)' : 'rgba(255, 255, 255, 0.7)'; |
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 goes against the purpose of using the new CSS variables structure, as we would still be depending on JS transformations. My proposal would be creating new theme token in the palette something like inputBorderColor
that will have the correct values in the light and dark mode. We would add this only in the experimental_extendTheme
default theme, to avoid changes in the current theme structure.
@mnajdova I have to add a few more variables to make it works.
|
Exactlly what I had in mind 👍 |
@@ -1,7 +1,6 @@ | |||
import { deepmerge } from '@mui/utils'; | |||
import { colorChannel } from '@mui/system'; | |||
import createThemeWithoutVars from './createTheme'; | |||
import createPalette from './createPalette'; | |||
|
|||
export const defaultOpacity = { |
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.
@siriwatknp I think we need to have different default opacity values for light and dark theme to simplify the implementaiton. Now we have different values for inputTouchBottomLine
and placeholder
, but in MD even the hover opacity should have different value in light vs dark mode.
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 difference is the reason why in the Button.js
I am using the opacity from the action.hoverOpacity
.
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.
@mnajdova I think we should not add the active
, disabled
... to the theme.vars.opacity
at this point because we already have theme.vars.palette.action.xxxOpacity
which are already configurable on both light and dark color schemes.
Adding theme to theme.vars.opacity
could create confusion and we are not using them in the migration at all. What do you think?
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.
Sure, let's skip them for now. Long term I think we should have all opacities under one object, that was my intention with the comment.
@@ -33,6 +33,7 @@ export interface TypeAction { | |||
export interface TypeBackground { | |||
default: string; | |||
paper: string; | |||
invertChannel: string; |
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.
I don't think it's safe to add this type here. The createTheme
is not adding this value. I think we can just cast to this in the extendTheme
util if necessary.
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.
Okay, sounds good to me.
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.
The changes look good to me. @siriwatknp please see one last comment related to the types updates in createPalette.d.ts
Previews:
Part of #32049