Skip to content

Commit

Permalink
[palette] Better defensive logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Aug 3, 2018
1 parent 1d6ba9a commit ea12a36
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/material-ui/src/styles/createPalette.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ export default function createPalette(palette: Object) {
if (!color.main && color[mainShade]) {
color.main = color[mainShade];
}

if (process.env.NODE_ENV !== 'production' && !color.main) {
throw new Error(
[
'Material-UI: the color provided to augmentColor(color) is invalid.',
`The color object needs to have a \`main\` property or a \`${mainShade}\` property.`,
].join('\n'),
);
}

addLightOrDark(color, 'light', lightShade, tonalOffset);
addLightOrDark(color, 'dark', darkShade, tonalOffset);
if (!color.contrastText) {
Expand Down

0 comments on commit ea12a36

Please sign in to comment.