-
-
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] Export CssVarsProvider with default theme #29150
Conversation
@@ -0,0 +1,268 @@ | |||
const colors = { |
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.
Copied from tailwindcss to get started with some default colors.
? { theme?: PartialDeep<Theme> } | ||
? { theme?: Theme } | ||
: { | ||
theme: PartialDeep<Omit<Theme, 'colorSchemes'>> & { | ||
colorSchemes: PartialDeep< |
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.
Remove PartialDeep
here because it breaks function type. It is better to let DesignSystem handle the Theme type.
RequiredDeep< | ||
Record<ApplicationColorScheme, Theme['colorSchemes'][ApplicationColorScheme]> | ||
>; |
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.
use RequiredDeep
to make sure that all of the key:value for ApplicationColorScheme
must be specified.
DesignSystemThemeInput extends { | ||
colorSchemes: Record<DesignSystemColorScheme | ApplicationColorScheme, any>; | ||
}, | ||
DesignSystemColorScheme extends string, | ||
ApplicationColorScheme extends string = never, | ||
ApplicationThemeInput extends { | ||
colorSchemes: Record<DesignSystemColorScheme | ApplicationColorScheme, any>; | ||
} = DesignSystemThemeInput, |
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.
Split into DesignSystemThemeInput
and ApplicationThemeInput
to handle types separately.
| number | ||
>, | ||
string | ||
expectedStyle: Partial< |
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.
In testfile.test.tsx
, without Partial
, the matcher expect all of CSSStyleDeclaration
8c94779
to
ef574b4
Compare
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 didn't really understand the need for the useTheme
option in createStyled
. Could you elaborate more on it. Especially as with it we are adding wrappers around each styled component. This means that we are diverging from how it is implemented in both emotion/styled-components.
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.
🤩
Co-authored-by: Benny Joo <sldisek783@gmail.com>
expect(screen.getByTestId('palette').textContent).to.equal( | ||
JSON.stringify({ | ||
brand: { | ||
50: 'var(--joy-palette-brand-50)', |
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.
Does it mean that the Material Design CSS variable will be?
50: 'var(--joy-palette-brand-50)', | |
50: 'var(--md-palette-brand-50)', |
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, developer will be able to custom the prefix.
@@ -38,15 +38,28 @@ | |||
"typescript:module-augmentation": "node scripts/testModuleAugmentation.js" | |||
}, | |||
"peerDependencies": { | |||
"@emotion/react": "^11.4.1", |
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 might be safer to use the same version as Material Design:
"@emotion/react": "^11.4.1", | |
"@emotion/react": "^11.5.0", |
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.
Noted.
@@ -0,0 +1,141 @@ | |||
import * as React from 'react'; | |||
import colors from '../colors'; | |||
|
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.
Should we leave a TODO?
// TODO extend import { createTheme, ThemeOptions, Theme } from '@mui/system'; | |
This is the first PR for defining Joy's theme structure. It is necessary before building components.
The theme structure is based on the github discussion #29024.
Necessary APIs for building components are exported from
mui-joy/src/styles
similar to material. All the types of the theme structure is defined inmui-joy/src/styles/defaultTheme.ts
CssVarsProvider
ThemeProvider
styled
Some properties are not included yet (will add in other PR when it is needed).