Skip to content
Permalink
Newer
Older
100644 60 lines (54 sloc) 1.64 KB
1
import deepmerge from 'deepmerge'; // < 1kb payload overhead when lodash/merge is > 3kb.
2
import isPlainObject from 'is-plain-object';
3
import warning from 'warning';
4
import createBreakpoints from './createBreakpoints';
5
import createMixins from './createMixins';
6
import createPalette from './createPalette';
7
import createTypography from './createTypography';
8
import shadows from './shadows';
9
import shape from './shape';
10
import defaultSpacing from './spacing';
11
import transitions from './transitions';
12
import zIndex from './zIndex';
13
14
function createMuiTheme(options = {}) {
15
const {
16
breakpoints: breakpointsInput = {},
17
mixins: mixinsInput = {},
18
palette: paletteInput = {},
19
shadows: shadowsInput,
20
spacing: spacingInput = {},
21
typography: typographyInput = {},
22
...other
23
} = options;
24
25
const palette = createPalette(paletteInput);
26
const breakpoints = createBreakpoints(breakpointsInput);
27
const spacing = { ...defaultSpacing, ...spacingInput };
29
const muiTheme = {
30
breakpoints,
31
direction: 'ltr',
32
mixins: createMixins(breakpoints, spacing, mixinsInput),
33
overrides: {}, // Inject custom styles
34
palette,
35
props: {}, // Inject custom properties
36
shadows: shadowsInput || shadows,
37
typography: createTypography(palette, typographyInput),
38
...deepmerge(
39
{
43
zIndex,
44
},
45
other,
46
{
47
isMergeableObject: isPlainObject,
48
},
51
52
warning(
53
muiTheme.shadows.length === 25,
54
'Material-UI: the shadows array provided to createMuiTheme should support 25 elevations.',
55
);
56
57
return muiTheme;
58
}
59
60
export default createMuiTheme;