@digigov/css 2.0.0-60d81ed8 → 2.0.0-6452adf3
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/dist/base/index.css +1 -1
- package/dist/base.js +1 -1
- package/dist/components.js +1 -1
- package/dist/digigov.css +3 -3
- package/dist/utilities/index.css +1 -1
- package/dist/utilities.js +1 -1
- package/index.js +99 -69
- package/package.json +11 -11
- package/postcss.config.js +4 -4
- package/src/base/index.css +1 -0
- package/src/base/postcss.config.js +11 -10
- package/src/base/tailwind.config.js +4 -11
- package/src/components/button.common.css +1 -1
- package/src/components/button.css +1 -1
- package/src/components/button.native.css +2 -3
- package/src/components/copy-to-clipboard.css +1 -1
- package/src/components/drawer.css +23 -3
- package/src/components/filter.css +71 -22
- package/src/components/kitchensink.css +2 -2
- package/src/components/loader.common.css +7 -0
- package/src/components/loader.css +3 -1
- package/src/components/loader.native.css +5 -0
- package/src/components/modal.common.css +2 -2
- package/src/components/modal.css +9 -9
- package/src/components/modal.native.css +3 -3
- package/src/components/pagination.css +19 -3
- package/src/components/postcss.config.js +7 -6
- package/src/components/stack.common.css +67 -0
- package/src/components/stack.css +23 -21
- package/src/components/stack.native.css +68 -0
- package/src/components/typography.common.css +1 -4
- package/src/components/typography.css +5 -1
- package/src/index.native.css +2 -0
- package/src/utilities/postcss.config.js +7 -6
- package/tailwind.config.js +102 -106
- package/theming.js +121 -0
- package/defaultTheme/accordion.json +0 -16
- package/defaultTheme/back-to-top.json +0 -27
- package/defaultTheme/brandConfig.json +0 -147
- package/defaultTheme/breadcrumbs.json +0 -8
- package/defaultTheme/button.json +0 -94
- package/defaultTheme/card.json +0 -23
- package/defaultTheme/form.json +0 -132
- package/defaultTheme/globals.json +0 -81
- package/defaultTheme/index.js +0 -27
- package/defaultTheme/layout.json +0 -55
- package/defaultTheme/misc.json +0 -68
- package/defaultTheme/panel.json +0 -48
- package/defaultTheme/phase-banner.json +0 -8
- package/defaultTheme/radios.json +0 -8
- package/defaultTheme/summary-list.json +0 -8
- package/defaultTheme/typography.json +0 -295
- package/themes.plugin.js +0 -148
package/defaultTheme/layout.json
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"footer__copyright": {
|
|
3
|
-
"font-size": {
|
|
4
|
-
"xs": "var(--text-sm)",
|
|
5
|
-
"md": "var(--text-base)"
|
|
6
|
-
}
|
|
7
|
-
},
|
|
8
|
-
"footer": {
|
|
9
|
-
"border": {
|
|
10
|
-
"xs": "solid var(--color-tertiary)"
|
|
11
|
-
},
|
|
12
|
-
"border-width": {
|
|
13
|
-
"xs": "4px 0 0 0"
|
|
14
|
-
},
|
|
15
|
-
"background-color": {
|
|
16
|
-
"xs": "var(--color-base-200)"
|
|
17
|
-
},
|
|
18
|
-
"color": {
|
|
19
|
-
"xs": "var(--color-base-800)"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"footer__link": {
|
|
23
|
-
"text-decoration": {
|
|
24
|
-
"xs": "underline"
|
|
25
|
-
},
|
|
26
|
-
"text-decoration-hover": {
|
|
27
|
-
"xs": "underline"
|
|
28
|
-
},
|
|
29
|
-
"color-hover": {
|
|
30
|
-
"xs": "var(--link-color-hover)"
|
|
31
|
-
},
|
|
32
|
-
"color-focus": {
|
|
33
|
-
"xs": "var(--link-color-active)"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"header": {
|
|
37
|
-
"border": {
|
|
38
|
-
"xs": "solid var(--color-tertiary)"
|
|
39
|
-
},
|
|
40
|
-
"border-width": {
|
|
41
|
-
"xs": "0 0 8px 0"
|
|
42
|
-
},
|
|
43
|
-
"background": {
|
|
44
|
-
"xs": "var(--color-primary)"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"header__title": {
|
|
48
|
-
"color": {
|
|
49
|
-
"xs": "var(--color-header-text)"
|
|
50
|
-
},
|
|
51
|
-
"color-hover": {
|
|
52
|
-
"xs": "var(--color-header-text-hover)"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
package/defaultTheme/misc.json
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"warning-text": {
|
|
3
|
-
"font-size": {
|
|
4
|
-
"xs": "var(--text-base)",
|
|
5
|
-
"md": "var(--text-lg)"
|
|
6
|
-
}
|
|
7
|
-
},
|
|
8
|
-
"details": {
|
|
9
|
-
"font-size": {
|
|
10
|
-
"xs": "var(--text-base)",
|
|
11
|
-
"md": "var(--text-lg)"
|
|
12
|
-
},
|
|
13
|
-
"line-height": {
|
|
14
|
-
"xs": "var(--line-h-base)",
|
|
15
|
-
"md": "var(--line-h-lg)"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"details__summary": {
|
|
19
|
-
"font-size": {
|
|
20
|
-
"xs": "var(--text-base)",
|
|
21
|
-
"md": "var(--text-lg)"
|
|
22
|
-
},
|
|
23
|
-
"line-height": {
|
|
24
|
-
"xs": "var(--line-h-base)",
|
|
25
|
-
"md": "var(--line-h-lg)"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"details__summary--lg": {
|
|
29
|
-
"font-size": {
|
|
30
|
-
"xs": "var(--text-lg)",
|
|
31
|
-
"md": "var(--text-xl)"
|
|
32
|
-
},
|
|
33
|
-
"line-height": {
|
|
34
|
-
"xs": "var(--line-h-lg)",
|
|
35
|
-
"md": "var(--line-h-xl)"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"blockquote": {
|
|
39
|
-
"font-size": {
|
|
40
|
-
"xs": "var(--text-base)",
|
|
41
|
-
"md": "var(--text-lg)"
|
|
42
|
-
},
|
|
43
|
-
"line-height": {
|
|
44
|
-
"xs": "var(--line-h-base)",
|
|
45
|
-
"md": "var(--line-h-lg)"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"notification-banner": {
|
|
49
|
-
"border-radius": {
|
|
50
|
-
"xs": "var(--border-radius-md)"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"circular-progress__circle--1": {
|
|
54
|
-
"stroke": {
|
|
55
|
-
"xs": "var(--color-secondary)"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"circular-progress__circle--2": {
|
|
59
|
-
"stroke": {
|
|
60
|
-
"xs": "var(--color-primary)"
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"tabs__panel": {
|
|
64
|
-
"border-radius": {
|
|
65
|
-
"xs": "0"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
package/defaultTheme/panel.json
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"panel": {
|
|
3
|
-
"border-radius": {
|
|
4
|
-
"xs": "var(--border-radius-md)"
|
|
5
|
-
}
|
|
6
|
-
},
|
|
7
|
-
"panel__title": {
|
|
8
|
-
"font-size": {
|
|
9
|
-
"xs": "var(--text-4xl)",
|
|
10
|
-
"md": "var(--text-5xl)",
|
|
11
|
-
"print": "var(--text-4xl)"
|
|
12
|
-
},
|
|
13
|
-
"line-height": {
|
|
14
|
-
"xs": "var(--line-h-4xl)",
|
|
15
|
-
"md": "var(--line-h-5xl)",
|
|
16
|
-
"print": "var(--line-h-4xl)"
|
|
17
|
-
},
|
|
18
|
-
"margin-bottom": {
|
|
19
|
-
"xs": "1rem",
|
|
20
|
-
"md": "1.5rem",
|
|
21
|
-
"print": "1.5rem"
|
|
22
|
-
},
|
|
23
|
-
"font-weight": {
|
|
24
|
-
"xs": "700"
|
|
25
|
-
},
|
|
26
|
-
"letter-spacing": {
|
|
27
|
-
"xs": "var(--letter-spacing-normal)"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"panel__body": {
|
|
31
|
-
"font-size": {
|
|
32
|
-
"xs": "var(--text-2xl)",
|
|
33
|
-
"md": "var(--text-4xl)",
|
|
34
|
-
"print": "var(--text-2xl)"
|
|
35
|
-
},
|
|
36
|
-
"line-height": {
|
|
37
|
-
"xs": "var(--line-h-2xl)",
|
|
38
|
-
"md": "var(--line-h-4xl)",
|
|
39
|
-
"print": "var(--line-h-2xl)"
|
|
40
|
-
},
|
|
41
|
-
"margin": {
|
|
42
|
-
"xs": "auto"
|
|
43
|
-
},
|
|
44
|
-
"letter-spacing": {
|
|
45
|
-
"xs": "var(--letter-spacing-normal)"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
package/defaultTheme/radios.json
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"heading-xl": {
|
|
3
|
-
"font-size": {
|
|
4
|
-
"xs": "var(--text-3xl)",
|
|
5
|
-
"md": "var(--text-5xl)"
|
|
6
|
-
},
|
|
7
|
-
"line-height": {
|
|
8
|
-
"xs": "var(--line-h-3xl)",
|
|
9
|
-
"md": "var(--line-h-5xl)"
|
|
10
|
-
},
|
|
11
|
-
"margin-bottom": {
|
|
12
|
-
"xs": "2rem",
|
|
13
|
-
"md": "3rem"
|
|
14
|
-
},
|
|
15
|
-
"font-weight": {
|
|
16
|
-
"xs": "700"
|
|
17
|
-
},
|
|
18
|
-
"letter-spacing": {
|
|
19
|
-
"xs": "var(--letter-spacing-normal)"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"heading-lg": {
|
|
23
|
-
"font-size": {
|
|
24
|
-
"xs": "var(--text-2xl)",
|
|
25
|
-
"md": "var(--text-4xl)"
|
|
26
|
-
},
|
|
27
|
-
"line-height": {
|
|
28
|
-
"xs": "var(--line-h-2xl)",
|
|
29
|
-
"md": "var(--line-h-4xl)"
|
|
30
|
-
},
|
|
31
|
-
"margin-bottom": {
|
|
32
|
-
"xs": "2rem",
|
|
33
|
-
"md": "2.5rem"
|
|
34
|
-
},
|
|
35
|
-
"font-weight": {
|
|
36
|
-
"xs": "700"
|
|
37
|
-
},
|
|
38
|
-
"letter-spacing": {
|
|
39
|
-
"xs": "var(--letter-spacing-normal)"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"heading-md": {
|
|
43
|
-
"font-size": {
|
|
44
|
-
"xs": "var(--text-xl)",
|
|
45
|
-
"md": "var(--text-2xl)"
|
|
46
|
-
},
|
|
47
|
-
"line-height": {
|
|
48
|
-
"xs": "var(--line-h-xl)",
|
|
49
|
-
"md": "var(--line-h-2xl)"
|
|
50
|
-
},
|
|
51
|
-
"margin-bottom": {
|
|
52
|
-
"xs": "1.5rem",
|
|
53
|
-
"md": "2rem"
|
|
54
|
-
},
|
|
55
|
-
"font-weight": {
|
|
56
|
-
"xs": "700"
|
|
57
|
-
},
|
|
58
|
-
"letter-spacing": {
|
|
59
|
-
"xs": "var(--letter-spacing-normal)"
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"heading-sm": {
|
|
63
|
-
"font-size": {
|
|
64
|
-
"xs": "var(--text-base)",
|
|
65
|
-
"md": "var(--text-lg)"
|
|
66
|
-
},
|
|
67
|
-
"line-height": {
|
|
68
|
-
"xs": "var(--line-h-base)",
|
|
69
|
-
"md": "var(--line-h-lg)"
|
|
70
|
-
},
|
|
71
|
-
"margin-bottom": {
|
|
72
|
-
"xs": "0.75rem",
|
|
73
|
-
"md": "1.25rem"
|
|
74
|
-
},
|
|
75
|
-
"font-weight": {
|
|
76
|
-
"xs": "700"
|
|
77
|
-
},
|
|
78
|
-
"letter-spacing": {
|
|
79
|
-
"xs": "var(--letter-spacing-normal)"
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
"heading-xs": {
|
|
83
|
-
"font-size": {
|
|
84
|
-
"xs": "var(--text-sm)",
|
|
85
|
-
"md": "var(--text-base)"
|
|
86
|
-
},
|
|
87
|
-
"line-height": {
|
|
88
|
-
"xs": "var(--line-h-sm)",
|
|
89
|
-
"md": "var(--line-h-base)"
|
|
90
|
-
},
|
|
91
|
-
"margin-bottom": {
|
|
92
|
-
"xs": "0.5rem",
|
|
93
|
-
"md": "1rem"
|
|
94
|
-
},
|
|
95
|
-
"font-weight": {
|
|
96
|
-
"xs": "700"
|
|
97
|
-
},
|
|
98
|
-
"letter-spacing": {
|
|
99
|
-
"xs": "var(--letter-spacing-normal)"
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
"caption-xl": {
|
|
103
|
-
"font-size": {
|
|
104
|
-
"xs": "var(--text-xl)",
|
|
105
|
-
"md": "var(--text-2xl)"
|
|
106
|
-
},
|
|
107
|
-
"line-height": {
|
|
108
|
-
"xs": "var(--line-h-xl)",
|
|
109
|
-
"md": "var(--line-h-2xl)"
|
|
110
|
-
},
|
|
111
|
-
"margin-bottom": {
|
|
112
|
-
"xs": "0.25rem",
|
|
113
|
-
"md": "0.5rem"
|
|
114
|
-
},
|
|
115
|
-
"color": {
|
|
116
|
-
"xs": "var(--color-base-800)"
|
|
117
|
-
},
|
|
118
|
-
"font-weight": {
|
|
119
|
-
"xs": "400"
|
|
120
|
-
},
|
|
121
|
-
"letter-spacing": {
|
|
122
|
-
"xs": "var(--letter-spacing-normal)"
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
"caption-lg": {
|
|
126
|
-
"font-size": {
|
|
127
|
-
"xs": "var(--text-lg)",
|
|
128
|
-
"md": "var(--text-xl)"
|
|
129
|
-
},
|
|
130
|
-
"line-height": {
|
|
131
|
-
"xs": "var(--line-h-lg)",
|
|
132
|
-
"md": "var(--line-h-xl)"
|
|
133
|
-
},
|
|
134
|
-
"margin-bottom": {
|
|
135
|
-
"xs": "0rem"
|
|
136
|
-
},
|
|
137
|
-
"color": {
|
|
138
|
-
"xs": "var(--color-base-800)"
|
|
139
|
-
},
|
|
140
|
-
"font-weight": {
|
|
141
|
-
"xs": "400"
|
|
142
|
-
},
|
|
143
|
-
"letter-spacing": {
|
|
144
|
-
"xs": "var(--letter-spacing-normal)"
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
"caption-md": {
|
|
148
|
-
"font-size": {
|
|
149
|
-
"xs": "var(--text-base)",
|
|
150
|
-
"md": "var(--text-lg)"
|
|
151
|
-
},
|
|
152
|
-
"line-height": {
|
|
153
|
-
"xs": "var(--line-h-base)",
|
|
154
|
-
"md": "var(--line-h-lg)"
|
|
155
|
-
},
|
|
156
|
-
"margin-bottom": {
|
|
157
|
-
"xs": "0rem"
|
|
158
|
-
},
|
|
159
|
-
"color": {
|
|
160
|
-
"xs": "var(--color-base-800)"
|
|
161
|
-
},
|
|
162
|
-
"font-weight": {
|
|
163
|
-
"xs": "400"
|
|
164
|
-
},
|
|
165
|
-
"letter-spacing": {
|
|
166
|
-
"xs": "var(--letter-spacing-normal)"
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
"body": {
|
|
170
|
-
"font-size": {
|
|
171
|
-
"xs": "var(--text-base)",
|
|
172
|
-
"md": "var(--text-lg)"
|
|
173
|
-
},
|
|
174
|
-
"line-height": {
|
|
175
|
-
"xs": "var(--line-h-base)",
|
|
176
|
-
"md": "var(--line-h-lg)"
|
|
177
|
-
},
|
|
178
|
-
"margin-bottom": {
|
|
179
|
-
"xs": "1rem",
|
|
180
|
-
"md": "2rem"
|
|
181
|
-
},
|
|
182
|
-
"color": {
|
|
183
|
-
"xs": "var(--color-base-content)"
|
|
184
|
-
},
|
|
185
|
-
"letter-spacing": {
|
|
186
|
-
"xs": "var(--letter-spacing-normal)"
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
"body--lg": {
|
|
190
|
-
"font-size": {
|
|
191
|
-
"xs": "var(--text-lg)",
|
|
192
|
-
"md": "var(--text-2xl)"
|
|
193
|
-
},
|
|
194
|
-
"line-height": {
|
|
195
|
-
"xs": "var(--line-h-lg)",
|
|
196
|
-
"md": "var(--line-h-2xl)"
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
"body--sm": {
|
|
200
|
-
"font-size": {
|
|
201
|
-
"xs": "var(--text-sm)",
|
|
202
|
-
"md": "var(--text-base)"
|
|
203
|
-
},
|
|
204
|
-
"line-height": {
|
|
205
|
-
"xs": "var(--line-h-sm)",
|
|
206
|
-
"md": "var(--text-base)"
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
"hint": {
|
|
210
|
-
"font-size": {
|
|
211
|
-
"xs": "var(--text-base)",
|
|
212
|
-
"md": "var(--text-lg)"
|
|
213
|
-
},
|
|
214
|
-
"line-height": {
|
|
215
|
-
"xs": "var(--line-h-base)",
|
|
216
|
-
"md": "var(--line-h-lg)"
|
|
217
|
-
},
|
|
218
|
-
"margin-bottom": {
|
|
219
|
-
"xs": "1rem"
|
|
220
|
-
},
|
|
221
|
-
"color": {
|
|
222
|
-
"xs": "var(--color-base-800)"
|
|
223
|
-
},
|
|
224
|
-
"letter-spacing": {
|
|
225
|
-
"xs": "var(--letter-spacing-normal)"
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
"hint--lg": {
|
|
229
|
-
"font-size": {
|
|
230
|
-
"xs": "var(--text-lg)",
|
|
231
|
-
"md": "var(--text-2xl)"
|
|
232
|
-
},
|
|
233
|
-
"line-height": {
|
|
234
|
-
"xs": "var(--line-h-lg)",
|
|
235
|
-
"md": "var(--line-h-2xl)"
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
"hint--sm": {
|
|
239
|
-
"font-size": {
|
|
240
|
-
"xs": "var(--text-sm)",
|
|
241
|
-
"md": "var(--text-base)"
|
|
242
|
-
},
|
|
243
|
-
"line-height": {
|
|
244
|
-
"xs": "var(--line-h-sm)",
|
|
245
|
-
"md": "var(--text-lg)"
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
"link": {
|
|
249
|
-
"color": {
|
|
250
|
-
"xs": "var(--color-link)"
|
|
251
|
-
},
|
|
252
|
-
"color-active": {
|
|
253
|
-
"xs": "var(--color-link-active)"
|
|
254
|
-
},
|
|
255
|
-
"color-hover": {
|
|
256
|
-
"xs": "var(--color-link-hover)"
|
|
257
|
-
},
|
|
258
|
-
"padding": {
|
|
259
|
-
"xs": "0px"
|
|
260
|
-
},
|
|
261
|
-
"font-size": {
|
|
262
|
-
"xs": "var(--text-base)",
|
|
263
|
-
"md": "var(--text-lg)"
|
|
264
|
-
},
|
|
265
|
-
"line-height": {
|
|
266
|
-
"xs": "var(--line-h-base)",
|
|
267
|
-
"md": "var(--line-h-lg)"
|
|
268
|
-
},
|
|
269
|
-
"letter-spacing": {
|
|
270
|
-
"xs": "var(--letter-spacing-normal)"
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
"back-link": {
|
|
274
|
-
"font-size": {
|
|
275
|
-
"xs": "var(--text-base)",
|
|
276
|
-
"md": "var(--text-lg)"
|
|
277
|
-
},
|
|
278
|
-
"letter-spacing": {
|
|
279
|
-
"xs": "var(--letter-spacing-normal)"
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
"list": {
|
|
283
|
-
"font-size": {
|
|
284
|
-
"xs": "var(--text-base)",
|
|
285
|
-
"md": "var(--text-lg)"
|
|
286
|
-
},
|
|
287
|
-
"line-height": {
|
|
288
|
-
"xs": "var(--line-h-base)",
|
|
289
|
-
"md": "var(--line-h-lg)"
|
|
290
|
-
},
|
|
291
|
-
"letter-spacing": {
|
|
292
|
-
"xs": "var(--letter-spacing-normal)"
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
package/themes.plugin.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const postcss = require("postcss");
|
|
4
|
-
const postcssrc = require("postcss-load-config");
|
|
5
|
-
const postcssJs = require("postcss-js");
|
|
6
|
-
|
|
7
|
-
const prefix = "ds";
|
|
8
|
-
const mediaQueriesMapping = {
|
|
9
|
-
xs: "@media (min-width: 0px)",
|
|
10
|
-
sm: "@media (min-width: 640px)",
|
|
11
|
-
md: "@media (min-width: 768px)",
|
|
12
|
-
lg: "@media (min-width: 1024px)",
|
|
13
|
-
print: "@media print",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
let hasRun = false;
|
|
17
|
-
|
|
18
|
-
module.exports = function addThemes({ addBase, config }) {
|
|
19
|
-
if (hasRun) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
hasRun = true;
|
|
23
|
-
|
|
24
|
-
let base = {};
|
|
25
|
-
const themes = config("themes");
|
|
26
|
-
const defaultTheme = config("defaultTheme");
|
|
27
|
-
for (const customTheme in themes) {
|
|
28
|
-
const customThemeObject = require(themes[customTheme]);
|
|
29
|
-
if (customThemeObject.overrides) {
|
|
30
|
-
console.log("Loading theme css from source...");
|
|
31
|
-
const css = fs
|
|
32
|
-
.readFileSync(
|
|
33
|
-
path.resolve(
|
|
34
|
-
path.dirname(themes[customTheme]),
|
|
35
|
-
"overrides/index.css",
|
|
36
|
-
),
|
|
37
|
-
)
|
|
38
|
-
.toString();
|
|
39
|
-
const ctx = {};
|
|
40
|
-
const { plugins, options } = postcssrc.sync(ctx);
|
|
41
|
-
const result = postcss(plugins).process(css, options).result.root;
|
|
42
|
-
const cssJs = postcssJs.objectify(result);
|
|
43
|
-
base[`.${customTheme}`] = cssJs;
|
|
44
|
-
}
|
|
45
|
-
if (customTheme === defaultTheme) {
|
|
46
|
-
base[`:root,:root.${customTheme},::before,::after`] =
|
|
47
|
-
extractVars(customThemeObject);
|
|
48
|
-
} else {
|
|
49
|
-
base[
|
|
50
|
-
`:root.${customTheme},.${customTheme},.${customTheme} *::before,.${customTheme} *::after`
|
|
51
|
-
] = extractVars(customThemeObject);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (customThemeObject.variables && customThemeObject.variables.components) {
|
|
55
|
-
const extractedVariables = extractMediaQueriesFromComponentVars(
|
|
56
|
-
customThemeObject.variables.components,
|
|
57
|
-
customTheme,
|
|
58
|
-
defaultTheme,
|
|
59
|
-
);
|
|
60
|
-
Object.keys(extractedVariables).forEach((key) => {
|
|
61
|
-
if (base[key]) {
|
|
62
|
-
base[key] = { ...base[key], ...extractedVariables[key] };
|
|
63
|
-
} else {
|
|
64
|
-
base[key] = extractedVariables[key];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
addBase(base);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
function extractVars(themeObj) {
|
|
73
|
-
const colorVars = extractColorVars(themeObj.colors);
|
|
74
|
-
const globalVars =
|
|
75
|
-
themeObj.variables && themeObj.variables.globals
|
|
76
|
-
? extractGlobalVars(themeObj.variables.globals)
|
|
77
|
-
: {};
|
|
78
|
-
return { ...colorVars, ...globalVars };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function extractColorVars(colorObj, colorGroup = "") {
|
|
82
|
-
return Object.keys(colorObj).reduce((vars, colorKey) => {
|
|
83
|
-
const value = colorObj[colorKey];
|
|
84
|
-
const colorName =
|
|
85
|
-
colorKey == "default"
|
|
86
|
-
? `--color${colorGroup}`
|
|
87
|
-
: `--color${colorGroup}-${colorKey}`;
|
|
88
|
-
const newVars =
|
|
89
|
-
typeof value === "string"
|
|
90
|
-
? {
|
|
91
|
-
[colorName]: value,
|
|
92
|
-
[`${colorName}-rgb`]: hexToRGB(value),
|
|
93
|
-
}
|
|
94
|
-
: extractColorVars(value, `-${colorKey}`);
|
|
95
|
-
return { ...vars, ...newVars };
|
|
96
|
-
}, {});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function extractGlobalVars(globalVarsObj) {
|
|
100
|
-
return Object.keys(globalVarsObj).reduce((vars, varKey) => {
|
|
101
|
-
const value = globalVarsObj[varKey];
|
|
102
|
-
vars[`--${varKey}`] = value;
|
|
103
|
-
return vars;
|
|
104
|
-
}, {});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function hexToRGB(hex) {
|
|
108
|
-
const r = parseInt(hex.slice(1, 3), 16),
|
|
109
|
-
g = parseInt(hex.slice(3, 5), 16),
|
|
110
|
-
b = parseInt(hex.slice(5, 7), 16);
|
|
111
|
-
|
|
112
|
-
return r + ", " + g + ", " + b;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function extractMediaQueriesFromComponentVars(
|
|
116
|
-
componentObj,
|
|
117
|
-
customTheme,
|
|
118
|
-
defaultTheme,
|
|
119
|
-
) {
|
|
120
|
-
let mediaObj = {};
|
|
121
|
-
Object.keys(componentObj).forEach((componentClass) => {
|
|
122
|
-
Object.keys(componentObj[componentClass]).forEach((componentAttr) => {
|
|
123
|
-
Object.keys(componentObj[componentClass][componentAttr]).forEach(
|
|
124
|
-
(componentMedia) => {
|
|
125
|
-
const newAttrKey = `--${componentClass}-${componentAttr}`;
|
|
126
|
-
const newAttrValue =
|
|
127
|
-
componentObj[componentClass][componentAttr][componentMedia];
|
|
128
|
-
const newAttr = { [newAttrKey]: newAttrValue };
|
|
129
|
-
const newClass = `.${prefix}-${componentClass}`;
|
|
130
|
-
const newMedia = mediaQueriesMapping[componentMedia];
|
|
131
|
-
const newTheme =
|
|
132
|
-
customTheme === defaultTheme ? "" : `.${customTheme}`;
|
|
133
|
-
|
|
134
|
-
if (mediaObj[newMedia]) {
|
|
135
|
-
if (mediaObj[newMedia][newTheme][newClass]) {
|
|
136
|
-
mediaObj[newMedia][newTheme][newClass][newAttrKey] = newAttrValue;
|
|
137
|
-
} else {
|
|
138
|
-
mediaObj[newMedia][newTheme][newClass] = newAttr;
|
|
139
|
-
}
|
|
140
|
-
} else {
|
|
141
|
-
mediaObj[newMedia] = { [newTheme]: { [newClass]: newAttr } };
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
return mediaObj;
|
|
148
|
-
}
|