@kaizen/design-tokens 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +773 -0
- package/LICENSE +21 -0
- package/README.md +66 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/react/ThemeProvider.d.ts +13 -0
- package/dist/react/ThemeProvider.d.ts.map +1 -0
- package/dist/react/ThemeProvider.js +42 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +13 -0
- package/dist/src/ThemeManager.d.ts +23 -0
- package/dist/src/ThemeManager.d.ts.map +1 -0
- package/dist/src/ThemeManager.js +70 -0
- package/dist/src/lib/addExtraThemeEntries.d.ts +25 -0
- package/dist/src/lib/addExtraThemeEntries.d.ts.map +1 -0
- package/dist/src/lib/addExtraThemeEntries.js +56 -0
- package/dist/src/lib/cssVariables.d.ts +23 -0
- package/dist/src/lib/cssVariables.d.ts.map +1 -0
- package/dist/src/lib/cssVariables.js +33 -0
- package/dist/src/lib/makeCssVariableDefinitionsMap.d.ts +30 -0
- package/dist/src/lib/makeCssVariableDefinitionsMap.d.ts.map +1 -0
- package/dist/src/lib/makeCssVariableDefinitionsMap.js +57 -0
- package/dist/src/lib/makeCssVariableTheme.d.ts +35 -0
- package/dist/src/lib/makeCssVariableTheme.d.ts.map +1 -0
- package/dist/src/lib/makeCssVariableTheme.js +54 -0
- package/dist/src/lib/mapLeafsOfObject.d.ts +23 -0
- package/dist/src/lib/mapLeafsOfObject.d.ts.map +1 -0
- package/dist/src/lib/mapLeafsOfObject.js +59 -0
- package/dist/src/themes/heart.d.ts +3 -0
- package/dist/src/themes/heart.d.ts.map +1 -0
- package/dist/src/themes/heart.js +286 -0
- package/dist/src/themes/index.d.ts +4 -0
- package/dist/src/themes/index.d.ts.map +1 -0
- package/dist/src/themes/index.js +9 -0
- package/dist/src/themes/zen.d.ts +3 -0
- package/dist/src/themes/zen.d.ts.map +1 -0
- package/dist/src/themes/zen.js +293 -0
- package/dist/src/types.d.ts +205 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/elm/Kaizen/Theme.elm +29 -0
- package/index.ts +9 -0
- package/less/animation.less +49 -0
- package/less/border.less +47 -0
- package/less/color.less +210 -0
- package/less/layout.less +8 -0
- package/less/shadow.less +12 -0
- package/less/spacing.less +20 -0
- package/less/typography.less +526 -0
- package/package.json +63 -0
- package/react/ThemeProvider.d.ts +12 -0
- package/react/ThemeProvider.js +43 -0
- package/react/ThemeProvider.js.map +1 -0
- package/react/ThemeProvider.tsx +39 -0
- package/react/index.d.ts +1 -0
- package/react/index.js +14 -0
- package/react/index.js.map +1 -0
- package/react/index.tsx +1 -0
- package/sass/animation.scss +49 -0
- package/sass/border.scss +47 -0
- package/sass/color.scss +210 -0
- package/sass/layout.scss +8 -0
- package/sass/shadow.scss +12 -0
- package/sass/spacing.scss +20 -0
- package/sass/typography.scss +526 -0
- package/src/ThemeManager.d.ts +22 -0
- package/src/ThemeManager.js +71 -0
- package/src/ThemeManager.js.map +1 -0
- package/src/ThemeManager.ts +70 -0
- package/src/lib/__tests__/themeForTesting.d.ts +38 -0
- package/src/lib/__tests__/themeForTesting.js +21 -0
- package/src/lib/__tests__/themeForTesting.js.map +1 -0
- package/src/lib/__tests__/themeForTesting.ts +17 -0
- package/src/lib/addExtraThemeEntries.d.ts +24 -0
- package/src/lib/addExtraThemeEntries.js +57 -0
- package/src/lib/addExtraThemeEntries.js.map +1 -0
- package/src/lib/addExtraThemeEntries.ts +56 -0
- package/src/lib/cssVariables.d.ts +22 -0
- package/src/lib/cssVariables.js +34 -0
- package/src/lib/cssVariables.js.map +1 -0
- package/src/lib/cssVariables.ts +27 -0
- package/src/lib/makeCssVariableDefinitionsMap.d.ts +29 -0
- package/src/lib/makeCssVariableDefinitionsMap.js +58 -0
- package/src/lib/makeCssVariableDefinitionsMap.js.map +1 -0
- package/src/lib/makeCssVariableDefinitionsMap.ts +55 -0
- package/src/lib/makeCssVariableTheme.d.ts +34 -0
- package/src/lib/makeCssVariableTheme.js +55 -0
- package/src/lib/makeCssVariableTheme.js.map +1 -0
- package/src/lib/makeCssVariableTheme.ts +63 -0
- package/src/lib/mapLeafsOfObject.d.ts +22 -0
- package/src/lib/mapLeafsOfObject.js +60 -0
- package/src/lib/mapLeafsOfObject.js.map +1 -0
- package/src/lib/mapLeafsOfObject.ts +50 -0
- package/src/lib/patterns.d.ts +2 -0
- package/src/lib/patterns.js +6 -0
- package/src/lib/patterns.js.map +1 -0
- package/src/lib/patterns.ts +2 -0
- package/src/themes/heart.d.ts +2 -0
- package/src/themes/heart.js +287 -0
- package/src/themes/heart.js.map +1 -0
- package/src/themes/heart.ts +285 -0
- package/src/themes/index.d.ts +3 -0
- package/src/themes/index.js +17 -0
- package/src/themes/index.js.map +1 -0
- package/src/themes/index.ts +4 -0
- package/src/themes/zen.d.ts +2 -0
- package/src/themes/zen.js +294 -0
- package/src/themes/zen.js.map +1 -0
- package/src/themes/zen.ts +292 -0
- package/src/types.d.ts +204 -0
- package/src/types.js +3 -0
- package/src/types.js.map +1 -0
- package/src/types.ts +225 -0
- package/tokens/animation.json +34 -0
- package/tokens/animation.json.d.ts +12 -0
- package/tokens/border.json +44 -0
- package/tokens/border.json.d.ts +12 -0
- package/tokens/color.json +228 -0
- package/tokens/color.json.d.ts +12 -0
- package/tokens/layout.json +9 -0
- package/tokens/layout.json.d.ts +12 -0
- package/tokens/shadow.json +12 -0
- package/tokens/shadow.json.d.ts +12 -0
- package/tokens/spacing.json +22 -0
- package/tokens/spacing.json.d.ts +12 -0
- package/tokens/typography.json +236 -0
- package/tokens/typography.json.d.ts +12 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
/** THIS IS AN AUTOGENERATED FILE **/
|
|
2
|
+
|
|
3
|
+
$typography-data-large-font-family: var(
|
|
4
|
+
--typography-data-large-font-family,
|
|
5
|
+
"Inter",
|
|
6
|
+
"Noto Sans",
|
|
7
|
+
Helvetica,
|
|
8
|
+
Arial,
|
|
9
|
+
sans-serif
|
|
10
|
+
);
|
|
11
|
+
$typography-data-large-font-family-id: --typography-data-large-font-family;
|
|
12
|
+
$typography-data-large-font-weight: var(
|
|
13
|
+
--typography-data-large-font-weight,
|
|
14
|
+
700
|
|
15
|
+
);
|
|
16
|
+
$typography-data-large-font-weight-id: --typography-data-large-font-weight;
|
|
17
|
+
$typography-data-large-font-size: var(
|
|
18
|
+
--typography-data-large-font-size,
|
|
19
|
+
5.25rem
|
|
20
|
+
);
|
|
21
|
+
$typography-data-large-font-size-id: --typography-data-large-font-size;
|
|
22
|
+
$typography-data-large-line-height: var(
|
|
23
|
+
--typography-data-large-line-height,
|
|
24
|
+
5.25rem
|
|
25
|
+
);
|
|
26
|
+
$typography-data-large-line-height-id: --typography-data-large-line-height;
|
|
27
|
+
$typography-data-large-letter-spacing: var(
|
|
28
|
+
--typography-data-large-letter-spacing,
|
|
29
|
+
normal
|
|
30
|
+
);
|
|
31
|
+
$typography-data-large-letter-spacing-id: --typography-data-large-letter-spacing;
|
|
32
|
+
$typography-data-large-units-font-family: var(
|
|
33
|
+
--typography-data-large-units-font-family,
|
|
34
|
+
"Inter",
|
|
35
|
+
"Noto Sans",
|
|
36
|
+
Helvetica,
|
|
37
|
+
Arial,
|
|
38
|
+
sans-serif
|
|
39
|
+
);
|
|
40
|
+
$typography-data-large-units-font-family-id: --typography-data-large-units-font-family;
|
|
41
|
+
$typography-data-large-units-font-weight: var(
|
|
42
|
+
--typography-data-large-units-font-weight,
|
|
43
|
+
700
|
|
44
|
+
);
|
|
45
|
+
$typography-data-large-units-font-weight-id: --typography-data-large-units-font-weight;
|
|
46
|
+
$typography-data-large-units-font-size: var(
|
|
47
|
+
--typography-data-large-units-font-size,
|
|
48
|
+
2.625rem
|
|
49
|
+
);
|
|
50
|
+
$typography-data-large-units-font-size-id: --typography-data-large-units-font-size;
|
|
51
|
+
$typography-data-large-units-line-height: var(
|
|
52
|
+
--typography-data-large-units-line-height,
|
|
53
|
+
5.25rem
|
|
54
|
+
);
|
|
55
|
+
$typography-data-large-units-line-height-id: --typography-data-large-units-line-height;
|
|
56
|
+
$typography-data-large-units-letter-spacing: var(
|
|
57
|
+
--typography-data-large-units-letter-spacing,
|
|
58
|
+
normal
|
|
59
|
+
);
|
|
60
|
+
$typography-data-large-units-letter-spacing-id: --typography-data-large-units-letter-spacing;
|
|
61
|
+
$typography-data-medium-font-family: var(
|
|
62
|
+
--typography-data-medium-font-family,
|
|
63
|
+
"Inter",
|
|
64
|
+
"Noto Sans",
|
|
65
|
+
Helvetica,
|
|
66
|
+
Arial,
|
|
67
|
+
sans-serif
|
|
68
|
+
);
|
|
69
|
+
$typography-data-medium-font-family-id: --typography-data-medium-font-family;
|
|
70
|
+
$typography-data-medium-font-weight: var(
|
|
71
|
+
--typography-data-medium-font-weight,
|
|
72
|
+
700
|
|
73
|
+
);
|
|
74
|
+
$typography-data-medium-font-weight-id: --typography-data-medium-font-weight;
|
|
75
|
+
$typography-data-medium-font-size: var(
|
|
76
|
+
--typography-data-medium-font-size,
|
|
77
|
+
3rem
|
|
78
|
+
);
|
|
79
|
+
$typography-data-medium-font-size-id: --typography-data-medium-font-size;
|
|
80
|
+
$typography-data-medium-line-height: var(
|
|
81
|
+
--typography-data-medium-line-height,
|
|
82
|
+
5rem
|
|
83
|
+
);
|
|
84
|
+
$typography-data-medium-line-height-id: --typography-data-medium-line-height;
|
|
85
|
+
$typography-data-medium-letter-spacing: var(
|
|
86
|
+
--typography-data-medium-letter-spacing,
|
|
87
|
+
normal
|
|
88
|
+
);
|
|
89
|
+
$typography-data-medium-letter-spacing-id: --typography-data-medium-letter-spacing;
|
|
90
|
+
$typography-data-medium-units-font-family: var(
|
|
91
|
+
--typography-data-medium-units-font-family,
|
|
92
|
+
"Inter",
|
|
93
|
+
"Noto Sans",
|
|
94
|
+
Helvetica,
|
|
95
|
+
Arial,
|
|
96
|
+
sans-serif
|
|
97
|
+
);
|
|
98
|
+
$typography-data-medium-units-font-family-id: --typography-data-medium-units-font-family;
|
|
99
|
+
$typography-data-medium-units-font-weight: var(
|
|
100
|
+
--typography-data-medium-units-font-weight,
|
|
101
|
+
700
|
|
102
|
+
);
|
|
103
|
+
$typography-data-medium-units-font-weight-id: --typography-data-medium-units-font-weight;
|
|
104
|
+
$typography-data-medium-units-font-size: var(
|
|
105
|
+
--typography-data-medium-units-font-size,
|
|
106
|
+
1.5rem
|
|
107
|
+
);
|
|
108
|
+
$typography-data-medium-units-font-size-id: --typography-data-medium-units-font-size;
|
|
109
|
+
$typography-data-medium-units-line-height: var(
|
|
110
|
+
--typography-data-medium-units-line-height,
|
|
111
|
+
5rem
|
|
112
|
+
);
|
|
113
|
+
$typography-data-medium-units-line-height-id: --typography-data-medium-units-line-height;
|
|
114
|
+
$typography-data-medium-units-letter-spacing: var(
|
|
115
|
+
--typography-data-medium-units-letter-spacing,
|
|
116
|
+
normal
|
|
117
|
+
);
|
|
118
|
+
$typography-data-medium-units-letter-spacing-id: --typography-data-medium-units-letter-spacing;
|
|
119
|
+
$typography-data-small-font-family: var(
|
|
120
|
+
--typography-data-small-font-family,
|
|
121
|
+
"Greycliff CF",
|
|
122
|
+
"Noto Sans",
|
|
123
|
+
Helvetica,
|
|
124
|
+
Arial,
|
|
125
|
+
sans-serif
|
|
126
|
+
);
|
|
127
|
+
$typography-data-small-font-family-id: --typography-data-small-font-family;
|
|
128
|
+
$typography-data-small-font-weight: var(
|
|
129
|
+
--typography-data-small-font-weight,
|
|
130
|
+
700
|
|
131
|
+
);
|
|
132
|
+
$typography-data-small-font-weight-id: --typography-data-small-font-weight;
|
|
133
|
+
$typography-data-small-font-size: var(
|
|
134
|
+
--typography-data-small-font-size,
|
|
135
|
+
1.5rem
|
|
136
|
+
);
|
|
137
|
+
$typography-data-small-font-size-id: --typography-data-small-font-size;
|
|
138
|
+
$typography-data-small-line-height: var(
|
|
139
|
+
--typography-data-small-line-height,
|
|
140
|
+
1.5rem
|
|
141
|
+
);
|
|
142
|
+
$typography-data-small-line-height-id: --typography-data-small-line-height;
|
|
143
|
+
$typography-data-small-letter-spacing: var(
|
|
144
|
+
--typography-data-small-letter-spacing,
|
|
145
|
+
normal
|
|
146
|
+
);
|
|
147
|
+
$typography-data-small-letter-spacing-id: --typography-data-small-letter-spacing;
|
|
148
|
+
$typography-data-small-units-font-family: var(
|
|
149
|
+
--typography-data-small-units-font-family,
|
|
150
|
+
"Greycliff CF",
|
|
151
|
+
"Noto Sans",
|
|
152
|
+
Helvetica,
|
|
153
|
+
Arial,
|
|
154
|
+
sans-serif
|
|
155
|
+
);
|
|
156
|
+
$typography-data-small-units-font-family-id: --typography-data-small-units-font-family;
|
|
157
|
+
$typography-data-small-units-font-weight: var(
|
|
158
|
+
--typography-data-small-units-font-weight,
|
|
159
|
+
700
|
|
160
|
+
);
|
|
161
|
+
$typography-data-small-units-font-weight-id: --typography-data-small-units-font-weight;
|
|
162
|
+
$typography-data-small-units-font-size: var(
|
|
163
|
+
--typography-data-small-units-font-size,
|
|
164
|
+
1.125rem
|
|
165
|
+
);
|
|
166
|
+
$typography-data-small-units-font-size-id: --typography-data-small-units-font-size;
|
|
167
|
+
$typography-data-small-units-line-height: var(
|
|
168
|
+
--typography-data-small-units-line-height,
|
|
169
|
+
1.5rem
|
|
170
|
+
);
|
|
171
|
+
$typography-data-small-units-line-height-id: --typography-data-small-units-line-height;
|
|
172
|
+
$typography-data-small-units-letter-spacing: var(
|
|
173
|
+
--typography-data-small-units-letter-spacing,
|
|
174
|
+
normal
|
|
175
|
+
);
|
|
176
|
+
$typography-data-small-units-letter-spacing-id: --typography-data-small-units-letter-spacing;
|
|
177
|
+
$typography-display-0-font-family: var(
|
|
178
|
+
--typography-display-0-font-family,
|
|
179
|
+
"Tiempos Headline",
|
|
180
|
+
Georgia,
|
|
181
|
+
serif
|
|
182
|
+
);
|
|
183
|
+
$typography-display-0-font-family-id: --typography-display-0-font-family;
|
|
184
|
+
$typography-display-0-font-weight: var(--typography-display-0-font-weight, 800);
|
|
185
|
+
$typography-display-0-font-weight-id: --typography-display-0-font-weight;
|
|
186
|
+
$typography-display-0-font-size: var(--typography-display-0-font-size, 4.5rem);
|
|
187
|
+
$typography-display-0-font-size-id: --typography-display-0-font-size;
|
|
188
|
+
$typography-display-0-line-height: var(
|
|
189
|
+
--typography-display-0-line-height,
|
|
190
|
+
5.25rem
|
|
191
|
+
);
|
|
192
|
+
$typography-display-0-line-height-id: --typography-display-0-line-height;
|
|
193
|
+
$typography-display-0-letter-spacing: var(
|
|
194
|
+
--typography-display-0-letter-spacing,
|
|
195
|
+
0em
|
|
196
|
+
);
|
|
197
|
+
$typography-display-0-letter-spacing-id: --typography-display-0-letter-spacing;
|
|
198
|
+
$typography-heading-1-font-family: var(
|
|
199
|
+
--typography-heading-1-font-family,
|
|
200
|
+
"Inter",
|
|
201
|
+
"Noto Sans",
|
|
202
|
+
Helvetica,
|
|
203
|
+
Arial,
|
|
204
|
+
sans-serif
|
|
205
|
+
);
|
|
206
|
+
$typography-heading-1-font-family-id: --typography-heading-1-font-family;
|
|
207
|
+
$typography-heading-1-font-weight: var(--typography-heading-1-font-weight, 700);
|
|
208
|
+
$typography-heading-1-font-weight-id: --typography-heading-1-font-weight;
|
|
209
|
+
$typography-heading-1-font-size: var(
|
|
210
|
+
--typography-heading-1-font-size,
|
|
211
|
+
2.125rem
|
|
212
|
+
);
|
|
213
|
+
$typography-heading-1-font-size-id: --typography-heading-1-font-size;
|
|
214
|
+
$typography-heading-1-line-height: var(
|
|
215
|
+
--typography-heading-1-line-height,
|
|
216
|
+
2.625rem
|
|
217
|
+
);
|
|
218
|
+
$typography-heading-1-line-height-id: --typography-heading-1-line-height;
|
|
219
|
+
$typography-heading-1-letter-spacing: var(
|
|
220
|
+
--typography-heading-1-letter-spacing,
|
|
221
|
+
normal
|
|
222
|
+
);
|
|
223
|
+
$typography-heading-1-letter-spacing-id: --typography-heading-1-letter-spacing;
|
|
224
|
+
$typography-heading-2-font-family: var(
|
|
225
|
+
--typography-heading-2-font-family,
|
|
226
|
+
"Inter",
|
|
227
|
+
"Noto Sans",
|
|
228
|
+
Helvetica,
|
|
229
|
+
Arial,
|
|
230
|
+
sans-serif
|
|
231
|
+
);
|
|
232
|
+
$typography-heading-2-font-family-id: --typography-heading-2-font-family;
|
|
233
|
+
$typography-heading-2-font-weight: var(--typography-heading-2-font-weight, 700);
|
|
234
|
+
$typography-heading-2-font-weight-id: --typography-heading-2-font-weight;
|
|
235
|
+
$typography-heading-2-font-size: var(--typography-heading-2-font-size, 1.75rem);
|
|
236
|
+
$typography-heading-2-font-size-id: --typography-heading-2-font-size;
|
|
237
|
+
$typography-heading-2-line-height: var(
|
|
238
|
+
--typography-heading-2-line-height,
|
|
239
|
+
2.25rem
|
|
240
|
+
);
|
|
241
|
+
$typography-heading-2-line-height-id: --typography-heading-2-line-height;
|
|
242
|
+
$typography-heading-2-letter-spacing: var(
|
|
243
|
+
--typography-heading-2-letter-spacing,
|
|
244
|
+
normal
|
|
245
|
+
);
|
|
246
|
+
$typography-heading-2-letter-spacing-id: --typography-heading-2-letter-spacing;
|
|
247
|
+
$typography-heading-3-font-family: var(
|
|
248
|
+
--typography-heading-3-font-family,
|
|
249
|
+
"Inter",
|
|
250
|
+
"Noto Sans",
|
|
251
|
+
Helvetica,
|
|
252
|
+
Arial,
|
|
253
|
+
sans-serif
|
|
254
|
+
);
|
|
255
|
+
$typography-heading-3-font-family-id: --typography-heading-3-font-family;
|
|
256
|
+
$typography-heading-3-font-weight: var(--typography-heading-3-font-weight, 700);
|
|
257
|
+
$typography-heading-3-font-weight-id: --typography-heading-3-font-weight;
|
|
258
|
+
$typography-heading-3-font-size: var(
|
|
259
|
+
--typography-heading-3-font-size,
|
|
260
|
+
1.375rem
|
|
261
|
+
);
|
|
262
|
+
$typography-heading-3-font-size-id: --typography-heading-3-font-size;
|
|
263
|
+
$typography-heading-3-line-height: var(
|
|
264
|
+
--typography-heading-3-line-height,
|
|
265
|
+
1.5rem
|
|
266
|
+
);
|
|
267
|
+
$typography-heading-3-line-height-id: --typography-heading-3-line-height;
|
|
268
|
+
$typography-heading-3-letter-spacing: var(
|
|
269
|
+
--typography-heading-3-letter-spacing,
|
|
270
|
+
normal
|
|
271
|
+
);
|
|
272
|
+
$typography-heading-3-letter-spacing-id: --typography-heading-3-letter-spacing;
|
|
273
|
+
$typography-heading-4-font-family: var(
|
|
274
|
+
--typography-heading-4-font-family,
|
|
275
|
+
"Inter",
|
|
276
|
+
"Noto Sans",
|
|
277
|
+
Helvetica,
|
|
278
|
+
Arial,
|
|
279
|
+
sans-serif
|
|
280
|
+
);
|
|
281
|
+
$typography-heading-4-font-family-id: --typography-heading-4-font-family;
|
|
282
|
+
$typography-heading-4-font-weight: var(--typography-heading-4-font-weight, 600);
|
|
283
|
+
$typography-heading-4-font-weight-id: --typography-heading-4-font-weight;
|
|
284
|
+
$typography-heading-4-font-size: var(
|
|
285
|
+
--typography-heading-4-font-size,
|
|
286
|
+
1.125rem
|
|
287
|
+
);
|
|
288
|
+
$typography-heading-4-font-size-id: --typography-heading-4-font-size;
|
|
289
|
+
$typography-heading-4-line-height: var(
|
|
290
|
+
--typography-heading-4-line-height,
|
|
291
|
+
1.5rem
|
|
292
|
+
);
|
|
293
|
+
$typography-heading-4-line-height-id: --typography-heading-4-line-height;
|
|
294
|
+
$typography-heading-4-letter-spacing: var(
|
|
295
|
+
--typography-heading-4-letter-spacing,
|
|
296
|
+
normal
|
|
297
|
+
);
|
|
298
|
+
$typography-heading-4-letter-spacing-id: --typography-heading-4-letter-spacing;
|
|
299
|
+
$typography-heading-5-font-family: var(
|
|
300
|
+
--typography-heading-5-font-family,
|
|
301
|
+
"Inter",
|
|
302
|
+
"Noto Sans",
|
|
303
|
+
Helvetica,
|
|
304
|
+
Arial,
|
|
305
|
+
sans-serif
|
|
306
|
+
);
|
|
307
|
+
$typography-heading-5-font-family-id: --typography-heading-5-font-family;
|
|
308
|
+
$typography-heading-5-font-weight: var(--typography-heading-5-font-weight, 600);
|
|
309
|
+
$typography-heading-5-font-weight-id: --typography-heading-5-font-weight;
|
|
310
|
+
$typography-heading-5-font-size: var(--typography-heading-5-font-size, 1rem);
|
|
311
|
+
$typography-heading-5-font-size-id: --typography-heading-5-font-size;
|
|
312
|
+
$typography-heading-5-line-height: var(
|
|
313
|
+
--typography-heading-5-line-height,
|
|
314
|
+
1.5rem
|
|
315
|
+
);
|
|
316
|
+
$typography-heading-5-line-height-id: --typography-heading-5-line-height;
|
|
317
|
+
$typography-heading-5-letter-spacing: var(
|
|
318
|
+
--typography-heading-5-letter-spacing,
|
|
319
|
+
normal
|
|
320
|
+
);
|
|
321
|
+
$typography-heading-5-letter-spacing-id: --typography-heading-5-letter-spacing;
|
|
322
|
+
$typography-heading-6-font-family: var(
|
|
323
|
+
--typography-heading-6-font-family,
|
|
324
|
+
"Inter",
|
|
325
|
+
"Noto Sans",
|
|
326
|
+
Helvetica,
|
|
327
|
+
Arial,
|
|
328
|
+
sans-serif
|
|
329
|
+
);
|
|
330
|
+
$typography-heading-6-font-family-id: --typography-heading-6-font-family;
|
|
331
|
+
$typography-heading-6-font-weight: var(--typography-heading-6-font-weight, 700);
|
|
332
|
+
$typography-heading-6-font-weight-id: --typography-heading-6-font-weight;
|
|
333
|
+
$typography-heading-6-font-size: var(
|
|
334
|
+
--typography-heading-6-font-size,
|
|
335
|
+
0.875rem
|
|
336
|
+
);
|
|
337
|
+
$typography-heading-6-font-size-id: --typography-heading-6-font-size;
|
|
338
|
+
$typography-heading-6-line-height: var(
|
|
339
|
+
--typography-heading-6-line-height,
|
|
340
|
+
1.5rem
|
|
341
|
+
);
|
|
342
|
+
$typography-heading-6-line-height-id: --typography-heading-6-line-height;
|
|
343
|
+
$typography-heading-6-letter-spacing: var(
|
|
344
|
+
--typography-heading-6-letter-spacing,
|
|
345
|
+
normal
|
|
346
|
+
);
|
|
347
|
+
$typography-heading-6-letter-spacing-id: --typography-heading-6-letter-spacing;
|
|
348
|
+
$typography-paragraph-intro-lede-font-family: var(
|
|
349
|
+
--typography-paragraph-intro-lede-font-family,
|
|
350
|
+
"Inter",
|
|
351
|
+
"Noto Sans",
|
|
352
|
+
Helvetica,
|
|
353
|
+
Arial,
|
|
354
|
+
sans-serif
|
|
355
|
+
);
|
|
356
|
+
$typography-paragraph-intro-lede-font-family-id: --typography-paragraph-intro-lede-font-family;
|
|
357
|
+
$typography-paragraph-intro-lede-font-weight: var(
|
|
358
|
+
--typography-paragraph-intro-lede-font-weight,
|
|
359
|
+
400
|
|
360
|
+
);
|
|
361
|
+
$typography-paragraph-intro-lede-font-weight-id: --typography-paragraph-intro-lede-font-weight;
|
|
362
|
+
$typography-paragraph-intro-lede-font-size: var(
|
|
363
|
+
--typography-paragraph-intro-lede-font-size,
|
|
364
|
+
1.25rem
|
|
365
|
+
);
|
|
366
|
+
$typography-paragraph-intro-lede-font-size-id: --typography-paragraph-intro-lede-font-size;
|
|
367
|
+
$typography-paragraph-intro-lede-line-height: var(
|
|
368
|
+
--typography-paragraph-intro-lede-line-height,
|
|
369
|
+
1.875rem
|
|
370
|
+
);
|
|
371
|
+
$typography-paragraph-intro-lede-line-height-id: --typography-paragraph-intro-lede-line-height;
|
|
372
|
+
$typography-paragraph-intro-lede-letter-spacing: var(
|
|
373
|
+
--typography-paragraph-intro-lede-letter-spacing,
|
|
374
|
+
-0.5px
|
|
375
|
+
);
|
|
376
|
+
$typography-paragraph-intro-lede-letter-spacing-id: --typography-paragraph-intro-lede-letter-spacing;
|
|
377
|
+
$typography-paragraph-body-font-family: var(
|
|
378
|
+
--typography-paragraph-body-font-family,
|
|
379
|
+
"Inter",
|
|
380
|
+
"Noto Sans",
|
|
381
|
+
Helvetica,
|
|
382
|
+
Arial,
|
|
383
|
+
sans-serif
|
|
384
|
+
);
|
|
385
|
+
$typography-paragraph-body-font-family-id: --typography-paragraph-body-font-family;
|
|
386
|
+
$typography-paragraph-body-font-weight: var(
|
|
387
|
+
--typography-paragraph-body-font-weight,
|
|
388
|
+
400
|
|
389
|
+
);
|
|
390
|
+
$typography-paragraph-body-font-weight-id: --typography-paragraph-body-font-weight;
|
|
391
|
+
$typography-paragraph-body-font-size: var(
|
|
392
|
+
--typography-paragraph-body-font-size,
|
|
393
|
+
1rem
|
|
394
|
+
);
|
|
395
|
+
$typography-paragraph-body-font-size-id: --typography-paragraph-body-font-size;
|
|
396
|
+
$typography-paragraph-body-line-height: var(
|
|
397
|
+
--typography-paragraph-body-line-height,
|
|
398
|
+
1.5rem
|
|
399
|
+
);
|
|
400
|
+
$typography-paragraph-body-line-height-id: --typography-paragraph-body-line-height;
|
|
401
|
+
$typography-paragraph-body-letter-spacing: var(
|
|
402
|
+
--typography-paragraph-body-letter-spacing,
|
|
403
|
+
normal
|
|
404
|
+
);
|
|
405
|
+
$typography-paragraph-body-letter-spacing-id: --typography-paragraph-body-letter-spacing;
|
|
406
|
+
$typography-paragraph-small-font-family: var(
|
|
407
|
+
--typography-paragraph-small-font-family,
|
|
408
|
+
"Inter",
|
|
409
|
+
"Noto Sans",
|
|
410
|
+
Helvetica,
|
|
411
|
+
Arial,
|
|
412
|
+
sans-serif
|
|
413
|
+
);
|
|
414
|
+
$typography-paragraph-small-font-family-id: --typography-paragraph-small-font-family;
|
|
415
|
+
$typography-paragraph-small-font-weight: var(
|
|
416
|
+
--typography-paragraph-small-font-weight,
|
|
417
|
+
400
|
|
418
|
+
);
|
|
419
|
+
$typography-paragraph-small-font-weight-id: --typography-paragraph-small-font-weight;
|
|
420
|
+
$typography-paragraph-small-font-size: var(
|
|
421
|
+
--typography-paragraph-small-font-size,
|
|
422
|
+
0.875rem
|
|
423
|
+
);
|
|
424
|
+
$typography-paragraph-small-font-size-id: --typography-paragraph-small-font-size;
|
|
425
|
+
$typography-paragraph-small-line-height: var(
|
|
426
|
+
--typography-paragraph-small-line-height,
|
|
427
|
+
1.125rem
|
|
428
|
+
);
|
|
429
|
+
$typography-paragraph-small-line-height-id: --typography-paragraph-small-line-height;
|
|
430
|
+
$typography-paragraph-small-letter-spacing: var(
|
|
431
|
+
--typography-paragraph-small-letter-spacing,
|
|
432
|
+
normal
|
|
433
|
+
);
|
|
434
|
+
$typography-paragraph-small-letter-spacing-id: --typography-paragraph-small-letter-spacing;
|
|
435
|
+
$typography-paragraph-extra-small-font-family: var(
|
|
436
|
+
--typography-paragraph-extra-small-font-family,
|
|
437
|
+
"Inter",
|
|
438
|
+
"Noto Sans",
|
|
439
|
+
Helvetica,
|
|
440
|
+
Arial,
|
|
441
|
+
sans-serif
|
|
442
|
+
);
|
|
443
|
+
$typography-paragraph-extra-small-font-family-id: --typography-paragraph-extra-small-font-family;
|
|
444
|
+
$typography-paragraph-extra-small-font-weight: var(
|
|
445
|
+
--typography-paragraph-extra-small-font-weight,
|
|
446
|
+
400
|
|
447
|
+
);
|
|
448
|
+
$typography-paragraph-extra-small-font-weight-id: --typography-paragraph-extra-small-font-weight;
|
|
449
|
+
$typography-paragraph-extra-small-font-size: var(
|
|
450
|
+
--typography-paragraph-extra-small-font-size,
|
|
451
|
+
0.75rem
|
|
452
|
+
);
|
|
453
|
+
$typography-paragraph-extra-small-font-size-id: --typography-paragraph-extra-small-font-size;
|
|
454
|
+
$typography-paragraph-extra-small-line-height: var(
|
|
455
|
+
--typography-paragraph-extra-small-line-height,
|
|
456
|
+
1.125rem
|
|
457
|
+
);
|
|
458
|
+
$typography-paragraph-extra-small-line-height-id: --typography-paragraph-extra-small-line-height;
|
|
459
|
+
$typography-paragraph-extra-small-letter-spacing: var(
|
|
460
|
+
--typography-paragraph-extra-small-letter-spacing,
|
|
461
|
+
normal
|
|
462
|
+
);
|
|
463
|
+
$typography-paragraph-extra-small-letter-spacing-id: --typography-paragraph-extra-small-letter-spacing;
|
|
464
|
+
$typography-paragraph-bold-font-weight: var(
|
|
465
|
+
--typography-paragraph-bold-font-weight,
|
|
466
|
+
600
|
|
467
|
+
);
|
|
468
|
+
$typography-paragraph-bold-font-weight-id: --typography-paragraph-bold-font-weight;
|
|
469
|
+
$typography-button-primary-font-family: var(
|
|
470
|
+
--typography-button-primary-font-family,
|
|
471
|
+
"Inter",
|
|
472
|
+
"Noto Sans",
|
|
473
|
+
Helvetica,
|
|
474
|
+
Arial,
|
|
475
|
+
sans-serif
|
|
476
|
+
);
|
|
477
|
+
$typography-button-primary-font-family-id: --typography-button-primary-font-family;
|
|
478
|
+
$typography-button-primary-font-weight: var(
|
|
479
|
+
--typography-button-primary-font-weight,
|
|
480
|
+
700
|
|
481
|
+
);
|
|
482
|
+
$typography-button-primary-font-weight-id: --typography-button-primary-font-weight;
|
|
483
|
+
$typography-button-primary-font-size: var(
|
|
484
|
+
--typography-button-primary-font-size,
|
|
485
|
+
1.125rem
|
|
486
|
+
);
|
|
487
|
+
$typography-button-primary-font-size-id: --typography-button-primary-font-size;
|
|
488
|
+
$typography-button-primary-line-height: var(
|
|
489
|
+
--typography-button-primary-line-height,
|
|
490
|
+
1.5rem
|
|
491
|
+
);
|
|
492
|
+
$typography-button-primary-line-height-id: --typography-button-primary-line-height;
|
|
493
|
+
$typography-button-primary-letter-spacing: var(
|
|
494
|
+
--typography-button-primary-letter-spacing,
|
|
495
|
+
normal
|
|
496
|
+
);
|
|
497
|
+
$typography-button-primary-letter-spacing-id: --typography-button-primary-letter-spacing;
|
|
498
|
+
$typography-button-secondary-font-family: var(
|
|
499
|
+
--typography-button-secondary-font-family,
|
|
500
|
+
"Inter",
|
|
501
|
+
"Noto Sans",
|
|
502
|
+
Helvetica,
|
|
503
|
+
Arial,
|
|
504
|
+
sans-serif
|
|
505
|
+
);
|
|
506
|
+
$typography-button-secondary-font-family-id: --typography-button-secondary-font-family;
|
|
507
|
+
$typography-button-secondary-font-weight: var(
|
|
508
|
+
--typography-button-secondary-font-weight,
|
|
509
|
+
500
|
|
510
|
+
);
|
|
511
|
+
$typography-button-secondary-font-weight-id: --typography-button-secondary-font-weight;
|
|
512
|
+
$typography-button-secondary-font-size: var(
|
|
513
|
+
--typography-button-secondary-font-size,
|
|
514
|
+
1rem
|
|
515
|
+
);
|
|
516
|
+
$typography-button-secondary-font-size-id: --typography-button-secondary-font-size;
|
|
517
|
+
$typography-button-secondary-line-height: var(
|
|
518
|
+
--typography-button-secondary-line-height,
|
|
519
|
+
1.5rem
|
|
520
|
+
);
|
|
521
|
+
$typography-button-secondary-line-height-id: --typography-button-secondary-line-height;
|
|
522
|
+
$typography-button-secondary-letter-spacing: var(
|
|
523
|
+
--typography-button-secondary-letter-spacing,
|
|
524
|
+
normal
|
|
525
|
+
);
|
|
526
|
+
$typography-button-secondary-letter-spacing-id: --typography-button-secondary-letter-spacing;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Theme as BaseTheme } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Use this class to set and apply themes, and to access or subscribe to the currently active one.
|
|
4
|
+
* This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,
|
|
5
|
+
* and the ability to update them in JavaScript - a framework agnostic method.
|
|
6
|
+
*
|
|
7
|
+
* It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ThemeManager<Theme extends BaseTheme = BaseTheme> {
|
|
10
|
+
private themeChangeListeners;
|
|
11
|
+
private theme;
|
|
12
|
+
private rootElement;
|
|
13
|
+
constructor(theme: Theme, rootElement?: HTMLElement, apply?: boolean);
|
|
14
|
+
getRootElement: () => HTMLElement;
|
|
15
|
+
getCurrentTheme: () => Theme;
|
|
16
|
+
setRootElement: (element: HTMLElement) => void;
|
|
17
|
+
setAndApplyTheme: (theme: Theme, force?: boolean | undefined) => void;
|
|
18
|
+
addThemeChangeListener: (listener: (theme: Theme) => void) => void;
|
|
19
|
+
removeThemeChangeListener: (listener: (theme: Theme) => void) => void;
|
|
20
|
+
applyCurrentTheme: () => void;
|
|
21
|
+
private notifyThemeChangeListeners;
|
|
22
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.ThemeManager = void 0;
|
|
4
|
+
var makeCssVariableDefinitionsMap_1 = require("./lib/makeCssVariableDefinitionsMap");
|
|
5
|
+
/**
|
|
6
|
+
* Use this class to set and apply themes, and to access or subscribe to the currently active one.
|
|
7
|
+
* This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,
|
|
8
|
+
* and the ability to update them in JavaScript - a framework agnostic method.
|
|
9
|
+
*
|
|
10
|
+
* It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.
|
|
11
|
+
*/
|
|
12
|
+
var ThemeManager = /** @class */ (function () {
|
|
13
|
+
function ThemeManager(theme, rootElement,
|
|
14
|
+
/* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */
|
|
15
|
+
apply) {
|
|
16
|
+
var _this = this;
|
|
17
|
+
if (rootElement === void 0) { rootElement = document.documentElement; }
|
|
18
|
+
if (apply === void 0) { apply = true; }
|
|
19
|
+
this.themeChangeListeners = [];
|
|
20
|
+
this.rootElement = document.documentElement;
|
|
21
|
+
this.getRootElement = function () { return _this.rootElement; };
|
|
22
|
+
this.getCurrentTheme = function () { return _this.theme; };
|
|
23
|
+
this.setRootElement = function (element) {
|
|
24
|
+
_this.rootElement = element;
|
|
25
|
+
};
|
|
26
|
+
this.setAndApplyTheme = function (theme, force) {
|
|
27
|
+
if (!force) {
|
|
28
|
+
if (_this.theme === theme)
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
_this.theme = theme;
|
|
32
|
+
_this.applyCurrentTheme();
|
|
33
|
+
_this.notifyThemeChangeListeners(theme);
|
|
34
|
+
};
|
|
35
|
+
this.addThemeChangeListener = function (listener) {
|
|
36
|
+
_this.themeChangeListeners.push(listener);
|
|
37
|
+
};
|
|
38
|
+
this.removeThemeChangeListener = function (listener) {
|
|
39
|
+
_this.themeChangeListeners = _this.themeChangeListeners.filter(function (l) { return l !== listener; });
|
|
40
|
+
};
|
|
41
|
+
this.applyCurrentTheme = function () {
|
|
42
|
+
var cssVariableDefinitions = makeCssVariableDefinitionsMap_1.makeCssVariableDefinitionsMap(_this.theme);
|
|
43
|
+
Object.entries(cssVariableDefinitions).forEach(function (_a) {
|
|
44
|
+
var key = _a[0], value = _a[1];
|
|
45
|
+
if (_this.theme.themeKey === "zen") {
|
|
46
|
+
_this.rootElement.style.removeProperty(key);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
_this.rootElement.style.setProperty(key, value);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
this.notifyThemeChangeListeners = function (theme) {
|
|
54
|
+
_this.themeChangeListeners.forEach(function (listener) { return listener(theme); });
|
|
55
|
+
};
|
|
56
|
+
/*
|
|
57
|
+
For some reason, storybook likes this way of defining class properties better.
|
|
58
|
+
If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.
|
|
59
|
+
*/
|
|
60
|
+
this.theme = theme;
|
|
61
|
+
this.rootElement = rootElement;
|
|
62
|
+
if (apply)
|
|
63
|
+
this.applyCurrentTheme();
|
|
64
|
+
}
|
|
65
|
+
return ThemeManager;
|
|
66
|
+
}());
|
|
67
|
+
exports.ThemeManager = ThemeManager;
|
|
68
|
+
// I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.
|
|
69
|
+
// For now it is not exposed, but we might come back to it, as it makes sense to have a singleton ThemeManager in almost all cases
|
|
70
|
+
/* export const defaultThemeManager = new ThemeManager(defaultTheme) */
|
|
71
|
+
//# sourceMappingURL=ThemeManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeManager.js","sourceRoot":"","sources":["ThemeManager.ts"],"names":[],"mappings":";;;AACA,qFAAmF;AACnF;;;;;;GAMG;AACH;IAIE,sBACE,KAAY,EACZ,WAAsC;IACtC,oHAAoH;IACpH,KAAqB;QAJvB,iBAaC;QAXC,4BAAA,EAAA,cAAc,QAAQ,CAAC,eAAe;QAEtC,sBAAA,EAAA,YAAqB;QAPf,yBAAoB,GAAG,EAAmC,CAAA;QAE1D,gBAAW,GAAG,QAAQ,CAAC,eAAe,CAAA;QAgBvC,mBAAc,GAAG,cAAM,OAAA,KAAI,CAAC,WAAW,EAAhB,CAAgB,CAAA;QACvC,oBAAe,GAAG,cAAM,OAAA,KAAI,CAAC,KAAK,EAAV,CAAU,CAAA;QAElC,mBAAc,GAAG,UAAC,OAAoB;YAC3C,KAAI,CAAC,WAAW,GAAG,OAAO,CAAA;QAC5B,CAAC,CAAA;QACM,qBAAgB,GAAG,UAAC,KAAY,EAAE,KAAe;YACtD,IAAI,CAAC,KAAK,EAAE;gBACV,IAAI,KAAI,CAAC,KAAK,KAAK,KAAK;oBAAE,OAAM;aACjC;YACD,KAAI,CAAC,KAAK,GAAG,KAAK,CAAA;YAClB,KAAI,CAAC,iBAAiB,EAAE,CAAA;YACxB,KAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC,CAAA;QAEM,2BAAsB,GAAG,UAAC,QAAgC;YAC/D,KAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC1C,CAAC,CAAA;QACM,8BAAyB,GAAG,UAAC,QAAgC;YAClE,KAAI,CAAC,oBAAoB,GAAG,KAAI,CAAC,oBAAoB,CAAC,MAAM,CAC1D,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,QAAQ,EAAd,CAAc,CACpB,CAAA;QACH,CAAC,CAAA;QACM,sBAAiB,GAAG;YACzB,IAAM,sBAAsB,GAAG,6DAA6B,CAAC,KAAI,CAAC,KAAK,CAAC,CAAA;YACxE,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,OAAO,CAAC,UAAC,EAAY;oBAAX,GAAG,QAAA,EAAE,KAAK,QAAA;gBACzD,IAAI,KAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,KAAK,EAAE;oBACjC,KAAI,CAAC,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;iBAC3C;qBAAM;oBACL,KAAI,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;iBAC/C;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;QAEO,+BAA0B,GAAG,UAAC,KAAY;YAChD,KAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,CAAC,KAAK,CAAC,EAAf,CAAe,CAAC,CAAA;QAChE,CAAC,CAAA;QA7CC;;;UAGE;QACF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,KAAK;YAAE,IAAI,CAAC,iBAAiB,EAAE,CAAA;IACrC,CAAC;IAuCH,mBAAC;AAAD,CAAC,AAxDD,IAwDC;AAxDY,oCAAY;AA0DzB,gIAAgI;AAChI,kIAAkI;AAClI,uEAAuE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Theme as BaseTheme } from "./types"
|
|
2
|
+
import { makeCssVariableDefinitionsMap } from "./lib/makeCssVariableDefinitionsMap"
|
|
3
|
+
/**
|
|
4
|
+
* Use this class to set and apply themes, and to access or subscribe to the currently active one.
|
|
5
|
+
* This class fulfills the idea of theming and runtime theme switching by relying on CSS variables,
|
|
6
|
+
* and the ability to update them in JavaScript - a framework agnostic method.
|
|
7
|
+
*
|
|
8
|
+
* It works by converting a Theme interface to a flattened map of CSS variable keys and values, then calling `document.documentElement.style.setProperty(key, value)`.
|
|
9
|
+
*/
|
|
10
|
+
export class ThemeManager<Theme extends BaseTheme = BaseTheme> {
|
|
11
|
+
private themeChangeListeners = [] as Array<(theme: Theme) => void>
|
|
12
|
+
private theme: Theme
|
|
13
|
+
private rootElement = document.documentElement
|
|
14
|
+
constructor(
|
|
15
|
+
theme: Theme,
|
|
16
|
+
rootElement = document.documentElement,
|
|
17
|
+
/* This allows you to stop the class from applying the theme automatically during construction. Defaults to true */
|
|
18
|
+
apply: boolean = true
|
|
19
|
+
) {
|
|
20
|
+
/*
|
|
21
|
+
For some reason, storybook likes this way of defining class properties better.
|
|
22
|
+
If you use `constructor( private theme: Theme, ...)` - theme becomes undefined within the class's methods.
|
|
23
|
+
*/
|
|
24
|
+
this.theme = theme
|
|
25
|
+
this.rootElement = rootElement
|
|
26
|
+
if (apply) this.applyCurrentTheme()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public getRootElement = () => this.rootElement
|
|
30
|
+
public getCurrentTheme = () => this.theme
|
|
31
|
+
|
|
32
|
+
public setRootElement = (element: HTMLElement) => {
|
|
33
|
+
this.rootElement = element
|
|
34
|
+
}
|
|
35
|
+
public setAndApplyTheme = (theme: Theme, force?: boolean) => {
|
|
36
|
+
if (!force) {
|
|
37
|
+
if (this.theme === theme) return
|
|
38
|
+
}
|
|
39
|
+
this.theme = theme
|
|
40
|
+
this.applyCurrentTheme()
|
|
41
|
+
this.notifyThemeChangeListeners(theme)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public addThemeChangeListener = (listener: (theme: Theme) => void) => {
|
|
45
|
+
this.themeChangeListeners.push(listener)
|
|
46
|
+
}
|
|
47
|
+
public removeThemeChangeListener = (listener: (theme: Theme) => void) => {
|
|
48
|
+
this.themeChangeListeners = this.themeChangeListeners.filter(
|
|
49
|
+
l => l !== listener
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
public applyCurrentTheme = () => {
|
|
53
|
+
const cssVariableDefinitions = makeCssVariableDefinitionsMap(this.theme)
|
|
54
|
+
Object.entries(cssVariableDefinitions).forEach(([key, value]) => {
|
|
55
|
+
if (this.theme.themeKey === "zen") {
|
|
56
|
+
this.rootElement.style.removeProperty(key)
|
|
57
|
+
} else {
|
|
58
|
+
this.rootElement.style.setProperty(key, value)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private notifyThemeChangeListeners = (theme: Theme) => {
|
|
64
|
+
this.themeChangeListeners.forEach(listener => listener(theme))
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// I would like to expose this, but instantiating ThemeManager in some situations or runtimes (such as nodejs) cause exceptions.
|
|
69
|
+
// For now it is not exposed, but we might come back to it, as it makes sense to have a singleton ThemeManager in almost all cases
|
|
70
|
+
/* export const defaultThemeManager = new ThemeManager(defaultTheme) */
|