/
themeSchema.ts
127 lines (116 loc) · 2.71 KB
/
themeSchema.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { Theme } from '@precursor/theme';
import { color, space, fontFamily, elevation } from '@precursor/tokens';
interface Text extends Nested {
type: 'text';
}
interface Option extends Nested {
type: 'option';
options: any[];
}
interface Color extends Nested {
type: 'color';
options: any[];
}
interface Numeral extends Nested {
type: 'number';
}
interface Range extends Nested {
type: 'range';
min: number;
max: number;
step?: number;
}
interface Nested {
nested?: Record<string, OptionType>;
}
export type OptionType = Text | Color | Option | Numeral | Range;
export type ThemeSchema = Record<keyof Theme, OptionType>;
const allColors = [
...Object.values(color.neutral),
...Object.values(color.warning),
...Object.values(color.error),
...Object.values(color.success),
];
const themeSchema: Record<keyof Theme, OptionType> = {
color: {
type: 'color',
options: allColors,
nested: {
typography: {
type: 'color',
options: Object.values(color.neutral),
},
background: {
type: 'color',
options: Object.values(color.neutral),
},
info: {
type: 'color',
options: Object.values(color.info),
},
warning: {
type: 'color',
options: Object.values(color.warning),
},
error: {
type: 'color',
options: Object.values(color.error),
},
success: {
type: 'color',
options: Object.values(color.success),
},
},
},
space: {
type: 'text',
},
spacePreset: {
type: 'option',
options: Object.values(space),
},
font: {
type: 'option',
options: [
...Object.values(fontFamily),
'Arial',
'Helvetica',
'Comic Sans MS',
'Verdana',
'Courier New',
'Monaco',
'monospace',
],
},
fontSize: {
type: 'text',
},
lineHeight: {
type: 'text',
},
fontWeight: {
type: 'option',
options: [100, 200, 300, 400, 500, 600, 700],
},
radius: {
type: 'text',
},
border: {
type: 'text',
nested: {
color: {
type: 'color',
options: allColors,
},
},
},
breakpoint: { type: 'text' },
mediaQuery: {
type: 'text',
},
elevation: {
type: 'option',
options: Object.values(elevation),
},
};
export default themeSchema;