Skip to content

Commit

Permalink
even simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Oct 12, 2024
1 parent 505d35e commit 7859020
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/mui-material/src/styles/createPalette.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ function getDefaultWarning(mode = 'light') {
};
}

const getModeBasePalette = { dark: getDark, light: getLight };

export default function createPalette(palette) {
const { mode = 'light', contrastThreshold = 3, tonalOffset = 0.2, ...other } = palette;

Expand Down Expand Up @@ -264,15 +266,8 @@ export default function createPalette(palette) {
return color;
};

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

if (process.env.NODE_ENV !== 'production') {
if (!modeHydrated) {
if (!getModeBasePalette[mode]) {
console.error(`MUI: The palette mode \`${mode}\` is not supported.`);
}
}
Expand Down Expand Up @@ -315,7 +310,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.
...modeHydrated,
...getModeBasePalette[mode](),
},
other,
);
Expand Down

0 comments on commit 7859020

Please sign in to comment.