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