@digdir/designsystemet 0.1.0-next.21 → 0.1.0-next.23

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.
Files changed (96) hide show
  1. package/dist/bin/designsystemet.js +2 -2
  2. package/dist/src/colors/colorUtils.js +10 -10
  3. package/dist/src/init/createTokensPackage.js +27 -4
  4. package/dist/src/init/generateMetadataJson.js +6 -4
  5. package/dist/src/init/generateThemesJson.js +56 -5
  6. package/dist/src/init/nextStepsMarkdown.js +2 -2
  7. package/dist/src/init/template/default-files/design-tokens/primitives/globals.json +32 -68
  8. package/dist/src/init/template/default-files/design-tokens/primitives/size/default.json +175 -0
  9. package/dist/src/init/template/default-files/design-tokens/semantic/color.json +280 -270
  10. package/dist/src/init/template/default-files/design-tokens/semantic/style.json +307 -286
  11. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/contrast/theme-template.json +314 -0
  12. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/dark/global.json +376 -0
  13. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/dark/theme-template.json +314 -0
  14. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/light/global.json +376 -0
  15. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/light/theme-template.json +314 -0
  16. package/dist/src/init/template/template-files/design-tokens/primitives/modes/typography/primary/theme-template.json +30 -0
  17. package/dist/src/init/template/template-files/design-tokens/primitives/modes/typography/secondary/theme-template.json +30 -0
  18. package/dist/src/init/template/template-files/design-tokens/themes/theme-template.json +170 -150
  19. package/dist/src/init/template/template-files/package.json +1 -1
  20. package/dist/src/migrations/codemods/css/plugins.js +14 -15
  21. package/dist/src/migrations/codemods/jsx/classname-prefix.js +8 -7
  22. package/dist/src/tokens/actions.js +1 -1
  23. package/dist/src/tokens/build.js +26 -15
  24. package/dist/src/tokens/configs.js +20 -16
  25. package/dist/src/tokens/formats/css.js +42 -31
  26. package/dist/src/tokens/formats/js-tokens.js +8 -4
  27. package/dist/src/tokens/transformers.js +7 -3
  28. package/dist/src/tokens/utils/entryfile.js +31 -0
  29. package/dist/src/tokens/utils/permutateThemes.js +2 -2
  30. package/dist/src/tokens/utils/utils.js +11 -0
  31. package/dist/types/bin/designsystemet.d.ts +3 -0
  32. package/dist/types/bin/designsystemet.d.ts.map +1 -0
  33. package/dist/types/src/colors/colorUtils.d.ts +126 -0
  34. package/dist/types/src/colors/colorUtils.d.ts.map +1 -0
  35. package/dist/types/src/colors/index.d.ts +4 -0
  36. package/dist/types/src/colors/index.d.ts.map +1 -0
  37. package/dist/types/src/colors/themeUtils.d.ts +102 -0
  38. package/dist/types/src/colors/themeUtils.d.ts.map +1 -0
  39. package/dist/types/src/colors/types.d.ts +16 -0
  40. package/dist/types/src/colors/types.d.ts.map +1 -0
  41. package/dist/types/src/init/createTokensPackage.d.ts +5 -0
  42. package/dist/types/src/init/createTokensPackage.d.ts.map +1 -0
  43. package/dist/types/src/init/generateMetadataJson.d.ts +6 -0
  44. package/dist/types/src/init/generateMetadataJson.d.ts.map +1 -0
  45. package/dist/types/src/init/generateThemesJson.d.ts +3 -0
  46. package/dist/types/src/init/generateThemesJson.d.ts.map +1 -0
  47. package/dist/types/src/init/index.d.ts +3 -0
  48. package/dist/types/src/init/index.d.ts.map +1 -0
  49. package/dist/types/src/init/nextStepsMarkdown.d.ts +3 -0
  50. package/dist/types/src/init/nextStepsMarkdown.d.ts.map +1 -0
  51. package/dist/types/src/init/template/prettier.config.d.mts +9 -0
  52. package/dist/types/src/init/template/prettier.config.d.mts.map +1 -0
  53. package/dist/types/src/init/utils.d.ts +4 -0
  54. package/dist/types/src/init/utils.d.ts.map +1 -0
  55. package/dist/types/src/migrations/beta-to-v1.d.ts +3 -0
  56. package/dist/types/src/migrations/beta-to-v1.d.ts.map +1 -0
  57. package/dist/types/src/migrations/codemods/css/plugins.d.ts +6 -0
  58. package/dist/types/src/migrations/codemods/css/plugins.d.ts.map +1 -0
  59. package/dist/types/src/migrations/codemods/css/run.d.ts +8 -0
  60. package/dist/types/src/migrations/codemods/css/run.d.ts.map +1 -0
  61. package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts +10 -0
  62. package/dist/types/src/migrations/codemods/jsx/classname-prefix.d.ts.map +1 -0
  63. package/dist/types/src/migrations/codemods/jsx/run.d.ts +7 -0
  64. package/dist/types/src/migrations/codemods/jsx/run.d.ts.map +1 -0
  65. package/dist/types/src/migrations/index.d.ts +6 -0
  66. package/dist/types/src/migrations/index.d.ts.map +1 -0
  67. package/dist/types/src/migrations/react-beta-to-v1.d.ts +3 -0
  68. package/dist/types/src/migrations/react-beta-to-v1.d.ts.map +1 -0
  69. package/dist/types/src/tokens/actions.d.ts +6 -0
  70. package/dist/types/src/tokens/actions.d.ts.map +1 -0
  71. package/dist/types/src/tokens/build.d.ts +11 -0
  72. package/dist/types/src/tokens/build.d.ts.map +1 -0
  73. package/dist/types/src/tokens/configs.d.ts +31 -0
  74. package/dist/types/src/tokens/configs.d.ts.map +1 -0
  75. package/dist/types/src/tokens/formats/css.d.ts +5 -0
  76. package/dist/types/src/tokens/formats/css.d.ts.map +1 -0
  77. package/dist/types/src/tokens/formats/js-tokens.d.ts +6 -0
  78. package/dist/types/src/tokens/formats/js-tokens.d.ts.map +1 -0
  79. package/dist/types/src/tokens/transformers.d.ts +5 -0
  80. package/dist/types/src/tokens/transformers.d.ts.map +1 -0
  81. package/dist/types/src/tokens/utils/entryfile.d.ts +11 -0
  82. package/dist/types/src/tokens/utils/entryfile.d.ts.map +1 -0
  83. package/dist/types/src/tokens/utils/noCase.d.ts +11 -0
  84. package/dist/types/src/tokens/utils/noCase.d.ts.map +1 -0
  85. package/dist/types/src/tokens/utils/permutateThemes.d.ts +17 -0
  86. package/dist/types/src/tokens/utils/permutateThemes.d.ts.map +1 -0
  87. package/dist/types/src/tokens/utils/utils.d.ts +25 -0
  88. package/dist/types/src/tokens/utils/utils.d.ts.map +1 -0
  89. package/package.json +24 -22
  90. package/dist/src/init/template/default-files/design-tokens/primitives/typography/default.json +0 -86
  91. package/dist/src/init/template/template-files/design-tokens/primitives/colors/contrast/theme-template.json +0 -314
  92. package/dist/src/init/template/template-files/design-tokens/primitives/colors/dark/global.json +0 -376
  93. package/dist/src/init/template/template-files/design-tokens/primitives/colors/dark/theme-template.json +0 -314
  94. package/dist/src/init/template/template-files/design-tokens/primitives/colors/light/global.json +0 -376
  95. package/dist/src/init/template/template-files/design-tokens/primitives/colors/light/theme-template.json +0 -314
  96. /package/dist/src/init/template/template-files/design-tokens/primitives/{colors → modes/colors}/contrast/global.json +0 -0
@@ -2,313 +2,333 @@
2
2
  "color": {
3
3
  "accent": {
4
4
  "1": {
5
- "type": "color",
6
- "value": "{<theme>.accent.1}"
5
+ "$type": "color",
6
+ "$value": "{<theme>.accent.1}"
7
7
  },
8
8
  "2": {
9
- "type": "color",
10
- "value": "{<theme>.accent.2}"
9
+ "$type": "color",
10
+ "$value": "{<theme>.accent.2}"
11
11
  },
12
12
  "3": {
13
- "type": "color",
14
- "value": "{<theme>.accent.3}"
13
+ "$type": "color",
14
+ "$value": "{<theme>.accent.3}"
15
15
  },
16
16
  "4": {
17
- "type": "color",
18
- "value": "{<theme>.accent.4}"
17
+ "$type": "color",
18
+ "$value": "{<theme>.accent.4}"
19
19
  },
20
20
  "5": {
21
- "type": "color",
22
- "value": "{<theme>.accent.5}"
21
+ "$type": "color",
22
+ "$value": "{<theme>.accent.5}"
23
23
  },
24
24
  "6": {
25
- "type": "color",
26
- "value": "{<theme>.accent.6}"
25
+ "$type": "color",
26
+ "$value": "{<theme>.accent.6}"
27
27
  },
28
28
  "7": {
29
- "type": "color",
30
- "value": "{<theme>.accent.7}"
29
+ "$type": "color",
30
+ "$value": "{<theme>.accent.7}"
31
31
  },
32
32
  "8": {
33
- "type": "color",
34
- "value": "{<theme>.accent.8}"
33
+ "$type": "color",
34
+ "$value": "{<theme>.accent.8}"
35
35
  },
36
36
  "9": {
37
- "type": "color",
38
- "value": "{<theme>.accent.9}"
37
+ "$type": "color",
38
+ "$value": "{<theme>.accent.9}"
39
39
  },
40
40
  "10": {
41
- "type": "color",
42
- "value": "{<theme>.accent.10}"
41
+ "$type": "color",
42
+ "$value": "{<theme>.accent.10}"
43
43
  },
44
44
  "11": {
45
- "type": "color",
46
- "value": "{<theme>.accent.11}"
45
+ "$type": "color",
46
+ "$value": "{<theme>.accent.11}"
47
47
  },
48
48
  "12": {
49
- "type": "color",
50
- "value": "{<theme>.accent.12}"
49
+ "$type": "color",
50
+ "$value": "{<theme>.accent.12}"
51
51
  },
52
52
  "13": {
53
- "type": "color",
54
- "value": "{<theme>.accent.13}"
53
+ "$type": "color",
54
+ "$value": "{<theme>.accent.13}"
55
55
  },
56
56
  "contrast-1": {
57
- "type": "color",
58
- "value": "{<theme>.accent.contrast-1}"
57
+ "$type": "color",
58
+ "$value": "{<theme>.accent.contrast-1}"
59
59
  },
60
60
  "contrast-2": {
61
- "type": "color",
62
- "value": "{<theme>.accent.contrast-2}"
61
+ "$type": "color",
62
+ "$value": "{<theme>.accent.contrast-2}"
63
63
  }
64
64
  },
65
65
  "neutral": {
66
66
  "1": {
67
- "type": "color",
68
- "value": "{<theme>.neutral.1}"
67
+ "$type": "color",
68
+ "$value": "{<theme>.neutral.1}"
69
69
  },
70
70
  "2": {
71
- "type": "color",
72
- "value": "{<theme>.neutral.2}"
71
+ "$type": "color",
72
+ "$value": "{<theme>.neutral.2}"
73
73
  },
74
74
  "3": {
75
- "type": "color",
76
- "value": "{<theme>.neutral.3}"
75
+ "$type": "color",
76
+ "$value": "{<theme>.neutral.3}"
77
77
  },
78
78
  "4": {
79
- "type": "color",
80
- "value": "{<theme>.neutral.4}"
79
+ "$type": "color",
80
+ "$value": "{<theme>.neutral.4}"
81
81
  },
82
82
  "5": {
83
- "type": "color",
84
- "value": "{<theme>.neutral.5}"
83
+ "$type": "color",
84
+ "$value": "{<theme>.neutral.5}"
85
85
  },
86
86
  "6": {
87
- "type": "color",
88
- "value": "{<theme>.neutral.6}"
87
+ "$type": "color",
88
+ "$value": "{<theme>.neutral.6}"
89
89
  },
90
90
  "7": {
91
- "type": "color",
92
- "value": "{<theme>.neutral.7}"
91
+ "$type": "color",
92
+ "$value": "{<theme>.neutral.7}"
93
93
  },
94
94
  "8": {
95
- "type": "color",
96
- "value": "{<theme>.neutral.8}"
95
+ "$type": "color",
96
+ "$value": "{<theme>.neutral.8}"
97
97
  },
98
98
  "9": {
99
- "type": "color",
100
- "value": "{<theme>.neutral.9}"
99
+ "$type": "color",
100
+ "$value": "{<theme>.neutral.9}"
101
101
  },
102
102
  "10": {
103
- "type": "color",
104
- "value": "{<theme>.neutral.10}"
103
+ "$type": "color",
104
+ "$value": "{<theme>.neutral.10}"
105
105
  },
106
106
  "11": {
107
- "type": "color",
108
- "value": "{<theme>.neutral.11}"
107
+ "$type": "color",
108
+ "$value": "{<theme>.neutral.11}"
109
109
  },
110
110
  "12": {
111
- "type": "color",
112
- "value": "{<theme>.neutral.12}"
111
+ "$type": "color",
112
+ "$value": "{<theme>.neutral.12}"
113
113
  },
114
114
  "13": {
115
- "type": "color",
116
- "value": "{<theme>.neutral.13}"
115
+ "$type": "color",
116
+ "$value": "{<theme>.neutral.13}"
117
117
  },
118
118
  "contrast-1": {
119
- "type": "color",
120
- "value": "{<theme>.neutral.contrast-1}"
119
+ "$type": "color",
120
+ "$value": "{<theme>.neutral.contrast-1}"
121
121
  },
122
122
  "contrast-2": {
123
- "type": "color",
124
- "value": "{<theme>.neutral.contrast-2}"
123
+ "$type": "color",
124
+ "$value": "{<theme>.neutral.contrast-2}"
125
125
  }
126
126
  },
127
127
  "brand1": {
128
128
  "1": {
129
- "type": "color",
130
- "value": "{<theme>.brand1.1}"
129
+ "$type": "color",
130
+ "$value": "{<theme>.brand1.1}"
131
131
  },
132
132
  "2": {
133
- "type": "color",
134
- "value": "{<theme>.brand1.2}"
133
+ "$type": "color",
134
+ "$value": "{<theme>.brand1.2}"
135
135
  },
136
136
  "3": {
137
- "type": "color",
138
- "value": "{<theme>.brand1.3}"
137
+ "$type": "color",
138
+ "$value": "{<theme>.brand1.3}"
139
139
  },
140
140
  "4": {
141
- "type": "color",
142
- "value": "{<theme>.brand1.4}"
141
+ "$type": "color",
142
+ "$value": "{<theme>.brand1.4}"
143
143
  },
144
144
  "5": {
145
- "type": "color",
146
- "value": "{<theme>.brand1.5}"
145
+ "$type": "color",
146
+ "$value": "{<theme>.brand1.5}"
147
147
  },
148
148
  "6": {
149
- "type": "color",
150
- "value": "{<theme>.brand1.6}"
149
+ "$type": "color",
150
+ "$value": "{<theme>.brand1.6}"
151
151
  },
152
152
  "7": {
153
- "type": "color",
154
- "value": "{<theme>.brand1.7}"
153
+ "$type": "color",
154
+ "$value": "{<theme>.brand1.7}"
155
155
  },
156
156
  "8": {
157
- "type": "color",
158
- "value": "{<theme>.brand1.8}"
157
+ "$type": "color",
158
+ "$value": "{<theme>.brand1.8}"
159
159
  },
160
160
  "9": {
161
- "type": "color",
162
- "value": "{<theme>.brand1.9}"
161
+ "$type": "color",
162
+ "$value": "{<theme>.brand1.9}"
163
163
  },
164
164
  "10": {
165
- "type": "color",
166
- "value": "{<theme>.brand1.10}"
165
+ "$type": "color",
166
+ "$value": "{<theme>.brand1.10}"
167
167
  },
168
168
  "11": {
169
- "type": "color",
170
- "value": "{<theme>.brand1.11}"
169
+ "$type": "color",
170
+ "$value": "{<theme>.brand1.11}"
171
171
  },
172
172
  "12": {
173
- "type": "color",
174
- "value": "{<theme>.brand1.12}"
173
+ "$type": "color",
174
+ "$value": "{<theme>.brand1.12}"
175
175
  },
176
176
  "13": {
177
- "type": "color",
178
- "value": "{<theme>.brand1.13}"
177
+ "$type": "color",
178
+ "$value": "{<theme>.brand1.13}"
179
179
  },
180
180
  "contrast-1": {
181
- "type": "color",
182
- "value": "{<theme>.brand1.contrast-1}"
181
+ "$type": "color",
182
+ "$value": "{<theme>.brand1.contrast-1}"
183
183
  },
184
184
  "contrast-2": {
185
- "type": "color",
186
- "value": "{<theme>.brand1.contrast-2}"
185
+ "$type": "color",
186
+ "$value": "{<theme>.brand1.contrast-2}"
187
187
  }
188
188
  },
189
189
  "brand2": {
190
190
  "1": {
191
- "type": "color",
192
- "value": "{<theme>.brand2.1}"
191
+ "$type": "color",
192
+ "$value": "{<theme>.brand2.1}"
193
193
  },
194
194
  "2": {
195
- "type": "color",
196
- "value": "{<theme>.brand2.2}"
195
+ "$type": "color",
196
+ "$value": "{<theme>.brand2.2}"
197
197
  },
198
198
  "3": {
199
- "type": "color",
200
- "value": "{<theme>.brand2.3}"
199
+ "$type": "color",
200
+ "$value": "{<theme>.brand2.3}"
201
201
  },
202
202
  "4": {
203
- "type": "color",
204
- "value": "{<theme>.brand2.4}"
203
+ "$type": "color",
204
+ "$value": "{<theme>.brand2.4}"
205
205
  },
206
206
  "5": {
207
- "type": "color",
208
- "value": "{<theme>.brand2.5}"
207
+ "$type": "color",
208
+ "$value": "{<theme>.brand2.5}"
209
209
  },
210
210
  "6": {
211
- "type": "color",
212
- "value": "{<theme>.brand2.6}"
211
+ "$type": "color",
212
+ "$value": "{<theme>.brand2.6}"
213
213
  },
214
214
  "7": {
215
- "type": "color",
216
- "value": "{<theme>.brand2.7}"
215
+ "$type": "color",
216
+ "$value": "{<theme>.brand2.7}"
217
217
  },
218
218
  "8": {
219
- "type": "color",
220
- "value": "{<theme>.brand2.8}"
219
+ "$type": "color",
220
+ "$value": "{<theme>.brand2.8}"
221
221
  },
222
222
  "9": {
223
- "type": "color",
224
- "value": "{<theme>.brand2.9}"
223
+ "$type": "color",
224
+ "$value": "{<theme>.brand2.9}"
225
225
  },
226
226
  "10": {
227
- "type": "color",
228
- "value": "{<theme>.brand2.10}"
227
+ "$type": "color",
228
+ "$value": "{<theme>.brand2.10}"
229
229
  },
230
230
  "11": {
231
- "type": "color",
232
- "value": "{<theme>.brand2.11}"
231
+ "$type": "color",
232
+ "$value": "{<theme>.brand2.11}"
233
233
  },
234
234
  "12": {
235
- "type": "color",
236
- "value": "{<theme>.brand2.12}"
235
+ "$type": "color",
236
+ "$value": "{<theme>.brand2.12}"
237
237
  },
238
238
  "13": {
239
- "type": "color",
240
- "value": "{<theme>.brand2.13}"
239
+ "$type": "color",
240
+ "$value": "{<theme>.brand2.13}"
241
241
  },
242
242
  "contrast-1": {
243
- "type": "color",
244
- "value": "{<theme>.brand2.contrast-1}"
243
+ "$type": "color",
244
+ "$value": "{<theme>.brand2.contrast-1}"
245
245
  },
246
246
  "contrast-2": {
247
- "type": "color",
248
- "value": "{<theme>.brand2.contrast-2}"
247
+ "$type": "color",
248
+ "$value": "{<theme>.brand2.contrast-2}"
249
249
  }
250
250
  },
251
251
  "brand3": {
252
252
  "1": {
253
- "type": "color",
254
- "value": "{<theme>.brand3.1}"
253
+ "$type": "color",
254
+ "$value": "{<theme>.brand3.1}"
255
255
  },
256
256
  "2": {
257
- "type": "color",
258
- "value": "{<theme>.brand3.2}"
257
+ "$type": "color",
258
+ "$value": "{<theme>.brand3.2}"
259
259
  },
260
260
  "3": {
261
- "type": "color",
262
- "value": "{<theme>.brand3.3}"
261
+ "$type": "color",
262
+ "$value": "{<theme>.brand3.3}"
263
263
  },
264
264
  "4": {
265
- "type": "color",
266
- "value": "{<theme>.brand3.4}"
265
+ "$type": "color",
266
+ "$value": "{<theme>.brand3.4}"
267
267
  },
268
268
  "5": {
269
- "type": "color",
270
- "value": "{<theme>.brand3.5}"
269
+ "$type": "color",
270
+ "$value": "{<theme>.brand3.5}"
271
271
  },
272
272
  "6": {
273
- "type": "color",
274
- "value": "{<theme>.brand3.6}"
273
+ "$type": "color",
274
+ "$value": "{<theme>.brand3.6}"
275
275
  },
276
276
  "7": {
277
- "type": "color",
278
- "value": "{<theme>.brand3.7}"
277
+ "$type": "color",
278
+ "$value": "{<theme>.brand3.7}"
279
279
  },
280
280
  "8": {
281
- "type": "color",
282
- "value": "{<theme>.brand3.8}"
281
+ "$type": "color",
282
+ "$value": "{<theme>.brand3.8}"
283
283
  },
284
284
  "9": {
285
- "type": "color",
286
- "value": "{<theme>.brand3.9}"
285
+ "$type": "color",
286
+ "$value": "{<theme>.brand3.9}"
287
287
  },
288
288
  "10": {
289
- "type": "color",
290
- "value": "{<theme>.brand3.10}"
289
+ "$type": "color",
290
+ "$value": "{<theme>.brand3.10}"
291
291
  },
292
292
  "11": {
293
- "type": "color",
294
- "value": "{<theme>.brand3.11}"
293
+ "$type": "color",
294
+ "$value": "{<theme>.brand3.11}"
295
295
  },
296
296
  "12": {
297
- "type": "color",
298
- "value": "{<theme>.brand3.12}"
297
+ "$type": "color",
298
+ "$value": "{<theme>.brand3.12}"
299
299
  },
300
300
  "13": {
301
- "type": "color",
302
- "value": "{<theme>.brand3.13}"
301
+ "$type": "color",
302
+ "$value": "{<theme>.brand3.13}"
303
303
  },
304
304
  "contrast-1": {
305
- "type": "color",
306
- "value": "{<theme>.brand3.contrast-1}"
305
+ "$type": "color",
306
+ "$value": "{<theme>.brand3.contrast-1}"
307
307
  },
308
308
  "contrast-2": {
309
- "type": "color",
310
- "value": "{<theme>.brand3.contrast-2}"
309
+ "$type": "color",
310
+ "$value": "{<theme>.brand3.contrast-2}"
311
311
  }
312
312
  }
313
+ },
314
+ "font": {
315
+ "family": {
316
+ "$type": "fontFamilies",
317
+ "$value": "{<theme>.main}"
318
+ }
319
+ },
320
+ "font-weight": {
321
+ "medium": {
322
+ "$type": "fontWeights",
323
+ "$value": "{<theme>.bold}"
324
+ },
325
+ "semibold": {
326
+ "$type": "fontWeights",
327
+ "$value": "{<theme>.extra-bold}"
328
+ },
329
+ "regular": {
330
+ "$type": "fontWeights",
331
+ "$value": "{<theme>.regular}"
332
+ }
313
333
  }
314
334
  }
@@ -18,7 +18,7 @@
18
18
  "author": "",
19
19
  "license": "ISC",
20
20
  "devDependencies": {
21
- "@digdir/designsystemet": "^0.1.0-alpha.7",
21
+ "@digdir/designsystemet": "^0.1.0-next.22",
22
22
  "rimraf": "^5.0.7"
23
23
  }
24
24
  }
@@ -8,11 +8,11 @@ const cssClassRename = (dictionary) => ({
8
8
  Rule(rule) {
9
9
  const selector = rule.selector;
10
10
  if (!selector) return;
11
- Object.entries(dictionary).forEach(([from, to]) => {
11
+ for (const [from, to] of Object.entries(dictionary)) {
12
12
  if (!selector.includes(from)) return;
13
13
  const newSelector = selector.replace(new RegExp(from, "g"), to);
14
14
  rule.selector = newSelector;
15
- });
15
+ }
16
16
  }
17
17
  });
18
18
  const cssVarRename = (dictionary) => ({
@@ -20,22 +20,21 @@ const cssVarRename = (dictionary) => ({
20
20
  Declaration(decl) {
21
21
  const { value, prop } = decl;
22
22
  const deleted = /* @__PURE__ */ new Set();
23
- Object.entries(dictionary).forEach(([from, to]) => {
23
+ for (const [from, to] of Object.entries(dictionary)) {
24
24
  if (!R.isEmpty(to)) {
25
- switch (true) {
26
- case R.includes(from, value):
27
- to === "[delete]" && deleted.add(deleteMsg(decl, from));
28
- decl.value = value.replace(from, to);
29
- break;
30
- case R.includes(from, prop):
31
- if (decl.variable) {
32
- to === "[delete]" && deleted.add(deleteMsg(decl, from));
33
- decl.prop = prop.replace(from, to);
34
- break;
35
- }
25
+ if (R.includes(from, value)) {
26
+ if (to === "[delete]") {
27
+ deleted.add(deleteMsg(decl, from));
28
+ }
29
+ decl.value = value.replace(from, to);
30
+ } else if (R.includes(from, prop) && decl.variable) {
31
+ if (to === "[delete]") {
32
+ deleted.add(deleteMsg(decl, from));
33
+ }
34
+ decl.prop = prop.replace(from, to);
36
35
  }
37
36
  }
38
- });
37
+ }
39
38
  if (deleted.size > 0) {
40
39
  Array.from(deleted).forEach(printDelete);
41
40
  }
@@ -5,11 +5,11 @@ const replaceInLiteral = (node) => {
5
5
  return node;
6
6
  };
7
7
  const replaceInTemplateLiteral = (node) => {
8
- node.forEach((element) => {
8
+ for (const element of node) {
9
9
  const value = element.value.raw;
10
- if (typeof value !== "string") return;
10
+ if (typeof value !== "string") continue;
11
11
  element.value.raw = replaceInLiteral(value);
12
- });
12
+ }
13
13
  };
14
14
  const processNode = (node) => {
15
15
  if (!node) return;
@@ -46,11 +46,12 @@ const processNode = (node) => {
46
46
  function replaceClassNamePrefix(file, api) {
47
47
  const j = api.jscodeshift;
48
48
  const root = j(file.source);
49
- root.find(j.JSXElement).forEach((path) => {
50
- j(path).find(j.JSXAttribute, { name: { name: "className" } }).forEach((nodePath) => {
49
+ for (const path of root.find(j.JSXElement).paths()) {
50
+ const nodes = j(path).find(j.JSXAttribute, { name: { name: "className" } });
51
+ for (const nodePath of nodes.paths()) {
51
52
  processNode(nodePath.value.value);
52
- });
53
- });
53
+ }
54
+ }
54
55
  return root.toSource({
55
56
  quote: "single",
56
57
  reuseWhitespace: true,
@@ -18,7 +18,7 @@ const makeEntryFile = {
18
18
  }
19
19
  const generateImportUrls = R.pipe(
20
20
  sortLightmodeFirst,
21
- R.map((file) => `@import url('./${theme}/${file.toString()}');`),
21
+ R.map((file) => `@import url('${theme}/${file.toString()}');`),
22
22
  R.join("\n")
23
23
  );
24
24
  const files = await glob(`**/*`, { cwd: platform.buildPath });
@@ -4,12 +4,13 @@ import chalk from "chalk";
4
4
  import * as R from "ramda";
5
5
  import StyleDictionary from "style-dictionary";
6
6
  import * as configs from "./configs.js";
7
+ import { makeEntryFile } from "./utils/entryfile.js";
7
8
  const { permutateThemes, getConfigs } = configs;
8
9
  const sd = new StyleDictionary();
9
10
  async function run(options) {
10
11
  const tokensDir = options.tokens;
11
12
  const storefrontOutDir = path.resolve("../../apps/storefront/tokens");
12
- const tokensOutDir = path.resolve(options.out);
13
+ const outPath = path.resolve(options.out);
13
14
  const $themes = JSON.parse(fs.readFileSync(path.resolve(`${tokensDir}/$themes.json`), "utf-8"));
14
15
  const relevant$themes = $themes.filter((theme) => {
15
16
  const group = R.toLower(R.defaultTo("")(theme.group));
@@ -20,9 +21,9 @@ async function run(options) {
20
21
  const typographyThemes = R.filter((val) => val.mode === "light", themes);
21
22
  const colormodeThemes = R.filter((val) => val.typography === "primary", themes);
22
23
  const semanticThemes = R.filter((val) => val.mode === "light" && val.typography === "primary", themes);
23
- const colorModeConfigs = getConfigs(configs.colorModeVariables, tokensOutDir, tokensDir, colormodeThemes);
24
- const semanticConfigs = getConfigs(configs.semanticVariables, tokensOutDir, tokensDir, semanticThemes);
25
- const typographyConfigs = getConfigs(configs.typographyCSS, tokensOutDir, tokensDir, typographyThemes);
24
+ const colorModeConfigs = getConfigs(configs.colorModeVariables, outPath, tokensDir, colormodeThemes);
25
+ const semanticConfigs = getConfigs(configs.semanticVariables, outPath, tokensDir, semanticThemes);
26
+ const typographyConfigs = getConfigs(configs.typographyCSS, outPath, tokensDir, typographyThemes);
26
27
  const storefrontConfigs = getConfigs(configs.typescriptTokens, storefrontOutDir, tokensDir, colormodeThemes);
27
28
  if (typographyConfigs.length > 0) {
28
29
  console.log(`
@@ -35,17 +36,6 @@ async function run(options) {
35
36
  })
36
37
  );
37
38
  }
38
- if (semanticConfigs.length > 0) {
39
- console.log(`
40
- \u{1F371} Building ${chalk.green("semantic")}`);
41
- await Promise.all(
42
- semanticConfigs.map(async ({ theme, config, semantic }) => {
43
- console.log(`\u{1F477} ${theme} - ${semantic}`);
44
- const typographyClasses = await sd.extend(config);
45
- return typographyClasses.buildAllPlatforms();
46
- })
47
- );
48
- }
49
39
  if (colorModeConfigs.length > 0) {
50
40
  console.log(`
51
41
  \u{1F371} Building ${chalk.green("color-mode")}`);
@@ -57,6 +47,17 @@ async function run(options) {
57
47
  })
58
48
  );
59
49
  }
50
+ if (semanticConfigs.length > 0) {
51
+ console.log(`
52
+ \u{1F371} Building ${chalk.green("semantic")}`);
53
+ await Promise.all(
54
+ semanticConfigs.map(async ({ theme, config, semantic }) => {
55
+ console.log(`\u{1F477} ${theme} - ${semantic}`);
56
+ const typographyClasses = await sd.extend(config);
57
+ return typographyClasses.buildAllPlatforms();
58
+ })
59
+ );
60
+ }
60
61
  if (storefrontConfigs.length > 0 && options.preview) {
61
62
  console.log(`
62
63
  \u{1F371} Building ${chalk.green("Storefront preview tokens")}`);
@@ -68,6 +69,16 @@ async function run(options) {
68
69
  })
69
70
  );
70
71
  }
72
+ if (semanticConfigs.length > 0) {
73
+ console.log(`
74
+ \u{1F371} Building ${chalk.green("CSS file")}`);
75
+ await Promise.all(
76
+ semanticConfigs.map(async ({ theme }) => {
77
+ console.log(`\u{1F477} ${theme}.css`);
78
+ return makeEntryFile({ theme, outPath, buildPath: path.resolve(`${outPath}/${theme}`) });
79
+ })
80
+ );
81
+ }
71
82
  }
72
83
  export {
73
84
  run