-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy paththeme.ts
More file actions
55 lines (50 loc) · 1.59 KB
/
Copy paththeme.ts
File metadata and controls
55 lines (50 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* eslint-disable no-console */
import { DefaultTheme } from 'styled-components';
import { mergeDeepRight } from 'ramda';
import { colors as themeColors } from './colors';
import { createTypography } from './typography';
import { createForms } from './forms';
import { createLayout } from './layout';
import { createDepths } from './depths';
import { createSpace } from './space';
import { createRadii } from './radii';
import { createTokens } from './tokens';
import { Subset } from '../types/utils.types';
export const createTheme = (
overrides: Subset<DefaultTheme> = {},
): DefaultTheme => {
const {
colors: colorsOverride = {},
typography: typographyOverride = {},
forms: formsOverride = {},
layout: layoutOverride = {},
depths: depthsOverride = {},
space: spaceOverride = {},
radii: radiiOverride = {},
tokens: tokensOverride = {},
...rest
} = overrides;
const colors = mergeDeepRight(themeColors, colorsOverride);
const typography = mergeDeepRight(createTypography(), typographyOverride);
const forms = mergeDeepRight(createForms(), formsOverride);
const layout = mergeDeepRight(createLayout(), layoutOverride);
const depths = mergeDeepRight(createDepths(), depthsOverride);
const space = mergeDeepRight(createSpace(), spaceOverride);
const radii = mergeDeepRight(createRadii(), radiiOverride);
const tokens = mergeDeepRight(
createTokens(colors, typography),
tokensOverride,
);
return {
colors,
typography,
forms,
layout,
depths,
space,
radii,
tokens,
...rest,
};
};
export const theme = createTheme();