53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
// @flow
|
|
|
|
import deepmerge from 'deepmerge'; // < 1kb payload overhead when lodash/merge is > 3kb.
|
|
import warning from 'warning';
|
|
import createTypography from './createTypography';
|
|
import createBreakpoints from './createBreakpoints';
|
|
import createPalette from './createPalette';
|
|
import createMixins from './createMixins';
|
|
import shadows from './shadows';
|
|
import transitions from './transitions';
|
|
import zIndex from './zIndex';
|
|
import spacing from './spacing';
|
|
|
|
function createMuiTheme(options: Object = {}) {
|
|
const {
|
|
palette: paletteInput = {},
|
|
breakpoints: breakpointsInput = {},
|
|
mixins: mixinsInput = {},
|
|
typography: typographyInput = {},
|
|
shadows: shadowsInput,
|
|
...other
|
|
} = options;
|
|
|
|
const palette = createPalette(paletteInput);
|
|
const breakpoints = createBreakpoints(breakpointsInput);
|
|
|
|
const muiTheme = {
|
|
direction: 'ltr',
|
|
palette,
|
|
typography: createTypography(palette, typographyInput),
|
|
mixins: createMixins(breakpoints, spacing, mixinsInput),
|
|
breakpoints,
|
|
shadows: shadowsInput || shadows,
|
|
...deepmerge(
|
|
{
|
|
transitions,
|
|
spacing,
|
|
zIndex,
|
|
},
|
|
other,
|
|
),
|
|
};
|
|
|
|
warning(
|
|
muiTheme.shadows.length === 25,
|
|
'Material-UI: the shadows array provided to createMuiTheme should support 25 elevations.',
|
|
);
|
|
|
|
return muiTheme;
|
|
}
|
|
|
|
export default createMuiTheme;
|