Skip to content
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

Remove palette input from the theme #31

Open
wants to merge 1 commit into
base: feat/css-vars-provider-mui-material
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/mui-material/src/styles/CssVarsProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { unstable_createCssVarsProvider as createCssVarsProvider } from '@mui/system';
import createTheme, { ThemeOptions, Theme } from './createTheme';
import createTheme, { ThemeOptions } from './createTheme';
import { PaletteOptions } from './createPalette';

interface ThemeInput extends ThemeOptions {
interface ThemeInput extends Omit<ThemeOptions, 'palette'> {
colorSchemes?: Partial<
Record<
'light' | 'dark',
Expand All @@ -11,19 +11,20 @@ interface ThemeInput extends ThemeOptions {
>;
}

const defaultTheme = createTheme();
const darkTheme = createTheme({ palette: { mode: 'dark' } });
const { palette: lightPalette, ...lightTheme } = createTheme();
const { palette: darkPalette } = createTheme({ palette: { mode: 'dark' } });

const { CssVarsProvider, useColorScheme, getInitColorSchemeScript } = createCssVarsProvider<
'light' | 'dark',
ThemeInput
>({
prefix: 'mui',
theme: {
...defaultTheme,
Copy link
Author

@siriwatknp siriwatknp Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default theme includes palette, that's why it is generated twice.

...lightTheme,
colorSchemes: {
// TODO: Shuold we remove the non color scheme values from here, like getContrastText, contrastThreshold etc.
light: { palette: defaultTheme.palette },
dark: { palette: darkTheme.palette },
light: { palette: lightPalette },
dark: { palette: darkPalette },
},
},
defaultColorScheme: {
Expand Down