Skip to content

Commit

Permalink
[core] Simplify createPalette (#44075)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Oct 12, 2024
1 parent a25a365 commit a49333c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/mui-material/src/styles/createPalette.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,15 @@ export default function createPalette(palette) {
return color;
};

const modes = { dark: getDark(), light: getLight() };
let modeHydrated;
if (mode === 'light') {
modeHydrated = getLight();
} else if (mode === 'dark') {
modeHydrated = getDark();
}

if (process.env.NODE_ENV !== 'production') {
if (!modes[mode]) {
if (!modeHydrated) {
console.error(`MUI: The palette mode \`${mode}\` is not supported.`);
}
}
Expand Down Expand Up @@ -310,7 +315,7 @@ export default function createPalette(palette) {
// E.g., shift from Red 500 to Red 300 or Red 700.
tonalOffset,
// The light and dark mode object.
...modes[mode],
...modeHydrated,
},
other,
);
Expand Down

0 comments on commit a49333c

Please sign in to comment.