Skip to content

Commit

Permalink
fix no colorSchemeSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Aug 28, 2024
1 parent 01c1748 commit 32aeb9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/mui-material/src/styles/createTheme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ describe('createTheme', () => {
});

describe('CSS variables', () => {
it('should have default light with media selector if no `palette` and colorSchemes.dark is provided ', () => {
const theme = createTheme({
cssVariables: true,
colorSchemes: { dark: true },
});
expect(theme.defaultColorScheme).to.equal('light');
expect(theme.colorSchemeSelector).to.equal('media');
expect(theme.colorSchemes.light).not.to.equal(undefined);
expect(theme.colorSchemes.dark).not.to.equal(undefined);
});

it('should have a light as a default colorScheme if only `palette` is provided', () => {
const theme = createTheme({
cssVariables: true,
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-material/src/styles/createTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export default function createTheme(
return theme;
}

if (!palette && !('light' in colorSchemesInput) && defaultColorSchemeInput === 'light') {
colorSchemesInput.light = true;
}

return createThemeWithVars(
{
...rest,
Expand Down

0 comments on commit 32aeb9b

Please sign in to comment.