@digdir/designsystemet 1.11.0 → 1.12.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.
Files changed (100) hide show
  1. package/dist/bin/config.js +24 -4
  2. package/dist/bin/designsystemet.js +912 -1223
  3. package/dist/src/colors/index.js +27 -1
  4. package/dist/src/colors/types.d.ts +24 -21
  5. package/dist/src/colors/types.d.ts.map +1 -1
  6. package/dist/src/colors/types.js +27 -0
  7. package/dist/src/config.js +24 -4
  8. package/dist/src/index.js +818 -1122
  9. package/dist/src/scripts/createJsonSchema.js +24 -4
  10. package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -1
  11. package/dist/src/scripts/update-preview-tokens.js +1363 -1667
  12. package/dist/src/tokens/build.js +7 -8
  13. package/dist/src/tokens/create/generators/$designsystemet.js +7 -8
  14. package/dist/src/tokens/create/generators/$metadata.d.ts +2 -2
  15. package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -1
  16. package/dist/src/tokens/create/generators/$metadata.js +3 -7
  17. package/dist/src/tokens/create/generators/$themes.d.ts +17 -2
  18. package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -1
  19. package/dist/src/tokens/create/generators/$themes.js +3 -3
  20. package/dist/src/tokens/create/generators/primitives/color-scheme.d.ts +5 -0
  21. package/dist/src/tokens/create/generators/primitives/color-scheme.d.ts.map +1 -0
  22. package/dist/src/tokens/create/generators/{color.js → primitives/color-scheme.js} +29 -6
  23. package/dist/src/tokens/create/generators/primitives/globals.d.ts +3 -0
  24. package/dist/src/tokens/create/generators/primitives/globals.d.ts.map +1 -0
  25. package/dist/src/tokens/create/generators/primitives/globals.js +148 -0
  26. package/dist/src/tokens/create/generators/primitives/size.d.ts +4 -0
  27. package/dist/src/tokens/create/generators/primitives/size.d.ts.map +1 -0
  28. package/dist/src/tokens/create/generators/primitives/size.js +157 -0
  29. package/dist/src/tokens/create/generators/primitives/typography.d.ts +4 -0
  30. package/dist/src/tokens/create/generators/primitives/typography.d.ts.map +1 -0
  31. package/dist/src/tokens/create/generators/primitives/typography.js +220 -0
  32. package/dist/src/tokens/create/generators/semantic/color-modes.d.ts +8 -0
  33. package/dist/src/tokens/create/generators/semantic/color-modes.d.ts.map +1 -0
  34. package/dist/src/tokens/create/generators/semantic/color-modes.js +61 -0
  35. package/dist/src/tokens/create/generators/semantic/color.d.ts +5 -0
  36. package/dist/src/tokens/create/generators/semantic/color.d.ts.map +1 -0
  37. package/dist/src/tokens/create/generators/{semantic.js → semantic/color.js} +50 -194
  38. package/dist/src/tokens/create/generators/semantic/style.d.ts +3 -0
  39. package/dist/src/tokens/create/generators/semantic/style.d.ts.map +1 -0
  40. package/dist/src/tokens/create/generators/semantic/style.js +384 -0
  41. package/dist/src/tokens/create/generators/{theme.d.ts → themes/theme.d.ts} +1 -1
  42. package/dist/src/tokens/create/generators/themes/theme.d.ts.map +1 -0
  43. package/dist/src/tokens/create/generators/{theme.js → themes/theme.js} +87 -129
  44. package/dist/src/tokens/create/write.d.ts.map +1 -1
  45. package/dist/src/tokens/create/write.js +16 -20
  46. package/dist/src/tokens/create.d.ts +1 -1
  47. package/dist/src/tokens/create.d.ts.map +1 -1
  48. package/dist/src/tokens/create.js +1340 -1647
  49. package/dist/src/tokens/format.d.ts.map +1 -1
  50. package/dist/src/tokens/format.js +1363 -1670
  51. package/dist/src/tokens/index.js +1363 -1670
  52. package/dist/src/tokens/process/output/declarations.js +7 -8
  53. package/dist/src/tokens/process/output/theme.js +7 -8
  54. package/dist/src/tokens/types.d.ts +7 -0
  55. package/dist/src/tokens/types.d.ts.map +1 -1
  56. package/package.json +8 -9
  57. package/dist/color.base.template-Z7YWN2TF.json +0 -22
  58. package/dist/color.template-LMPUQ72A.json +0 -66
  59. package/dist/color.template-XQNSHLTU.json +0 -66
  60. package/dist/global-Y35YADVH.json +0 -100
  61. package/dist/globals-76VAFMDF.json +0 -143
  62. package/dist/large-CIIHO7AY.json +0 -96
  63. package/dist/large-UUOZ6DYI.json +0 -16
  64. package/dist/medium-OQ7S7P4P.json +0 -16
  65. package/dist/medium-VSB2S4X3.json +0 -96
  66. package/dist/small-AEXJ6U7Z.json +0 -96
  67. package/dist/small-ZY4KOJWX.json +0 -16
  68. package/dist/src/scripts/update-template.d.ts +0 -2
  69. package/dist/src/scripts/update-template.d.ts.map +0 -1
  70. package/dist/src/scripts/update-template.js +0 -1366
  71. package/dist/src/tokens/create/defaults.d.ts +0 -7
  72. package/dist/src/tokens/create/defaults.d.ts.map +0 -1
  73. package/dist/src/tokens/create/defaults.js +0 -998
  74. package/dist/src/tokens/create/generators/color.d.ts +0 -5
  75. package/dist/src/tokens/create/generators/color.d.ts.map +0 -1
  76. package/dist/src/tokens/create/generators/semantic.d.ts +0 -32
  77. package/dist/src/tokens/create/generators/semantic.d.ts.map +0 -1
  78. package/dist/src/tokens/create/generators/theme.d.ts.map +0 -1
  79. package/dist/src/tokens/create/generators/typography.d.ts +0 -3
  80. package/dist/src/tokens/create/generators/typography.d.ts.map +0 -1
  81. package/dist/src/tokens/create/generators/typography.js +0 -33
  82. package/dist/src/tokens/template/design-tokens/primitives/globals.js +0 -5
  83. package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +0 -5
  84. package/dist/src/tokens/template/design-tokens/primitives/modes/size/large.js +0 -5
  85. package/dist/src/tokens/template/design-tokens/primitives/modes/size/medium.js +0 -5
  86. package/dist/src/tokens/template/design-tokens/primitives/modes/size/small.js +0 -5
  87. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/large.js +0 -5
  88. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/medium.js +0 -5
  89. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/small.js +0 -5
  90. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/typography.template.js +0 -5
  91. package/dist/src/tokens/template/design-tokens/semantic/color.base.template.js +0 -5
  92. package/dist/src/tokens/template/design-tokens/semantic/color.template.js +0 -5
  93. package/dist/src/tokens/template/design-tokens/semantic/modes/color.template.js +0 -5
  94. package/dist/src/tokens/template/design-tokens/semantic/style.js +0 -5
  95. package/dist/src/tokens/template/design-tokens/themes/theme.base.template.js +0 -5
  96. package/dist/src/tokens/template/design-tokens/themes/theme.template.js +0 -5
  97. package/dist/style-FP5XVCUD.json +0 -378
  98. package/dist/theme.base.template-Y4RMFBQY.json +0 -55
  99. package/dist/theme.template-CTQRNOMO.json +0 -66
  100. package/dist/typography.template-4N5YLH7F.json +0 -22
@@ -1,1366 +0,0 @@
1
- // src/scripts/update-template.ts
2
- import path from "path";
3
- import pc2 from "picocolors";
4
- import * as R from "ramda";
5
-
6
- // ../../design-tokens/semantic/color.json
7
- var color_default = {
8
- color: {
9
- accent: {
10
- "background-default": {
11
- $type: "color",
12
- $value: "{color.accent.1}"
13
- },
14
- "background-tinted": {
15
- $type: "color",
16
- $value: "{color.accent.2}"
17
- },
18
- "surface-default": {
19
- $type: "color",
20
- $value: "{color.accent.3}"
21
- },
22
- "surface-tinted": {
23
- $type: "color",
24
- $value: "{color.accent.4}"
25
- },
26
- "surface-hover": {
27
- $type: "color",
28
- $value: "{color.accent.5}"
29
- },
30
- "surface-active": {
31
- $type: "color",
32
- $value: "{color.accent.6}"
33
- },
34
- "border-subtle": {
35
- $type: "color",
36
- $value: "{color.accent.7}"
37
- },
38
- "border-default": {
39
- $type: "color",
40
- $value: "{color.accent.8}"
41
- },
42
- "border-strong": {
43
- $type: "color",
44
- $value: "{color.accent.9}"
45
- },
46
- "text-subtle": {
47
- $type: "color",
48
- $value: "{color.accent.10}"
49
- },
50
- "text-default": {
51
- $type: "color",
52
- $value: "{color.accent.11}"
53
- },
54
- "base-default": {
55
- $type: "color",
56
- $value: "{color.accent.12}"
57
- },
58
- "base-hover": {
59
- $type: "color",
60
- $value: "{color.accent.13}"
61
- },
62
- "base-active": {
63
- $type: "color",
64
- $value: "{color.accent.14}"
65
- },
66
- "base-contrast-subtle": {
67
- $type: "color",
68
- $value: "{color.accent.15}"
69
- },
70
- "base-contrast-default": {
71
- $type: "color",
72
- $value: "{color.accent.16}"
73
- }
74
- },
75
- neutral: {
76
- "background-default": {
77
- $type: "color",
78
- $value: "{color.neutral.1}"
79
- },
80
- "background-tinted": {
81
- $type: "color",
82
- $value: "{color.neutral.2}"
83
- },
84
- "surface-default": {
85
- $type: "color",
86
- $value: "{color.neutral.3}"
87
- },
88
- "surface-tinted": {
89
- $type: "color",
90
- $value: "{color.neutral.4}"
91
- },
92
- "surface-hover": {
93
- $type: "color",
94
- $value: "{color.neutral.5}"
95
- },
96
- "surface-active": {
97
- $type: "color",
98
- $value: "{color.neutral.6}"
99
- },
100
- "border-subtle": {
101
- $type: "color",
102
- $value: "{color.neutral.7}"
103
- },
104
- "border-default": {
105
- $type: "color",
106
- $value: "{color.neutral.8}"
107
- },
108
- "border-strong": {
109
- $type: "color",
110
- $value: "{color.neutral.9}"
111
- },
112
- "text-subtle": {
113
- $type: "color",
114
- $value: "{color.neutral.10}"
115
- },
116
- "text-default": {
117
- $type: "color",
118
- $value: "{color.neutral.11}"
119
- },
120
- "base-default": {
121
- $type: "color",
122
- $value: "{color.neutral.12}"
123
- },
124
- "base-hover": {
125
- $type: "color",
126
- $value: "{color.neutral.13}"
127
- },
128
- "base-active": {
129
- $type: "color",
130
- $value: "{color.neutral.14}"
131
- },
132
- "base-contrast-subtle": {
133
- $type: "color",
134
- $value: "{color.neutral.15}"
135
- },
136
- "base-contrast-default": {
137
- $type: "color",
138
- $value: "{color.neutral.16}"
139
- }
140
- },
141
- brand1: {
142
- "background-default": {
143
- $type: "color",
144
- $value: "{color.brand1.1}"
145
- },
146
- "background-tinted": {
147
- $type: "color",
148
- $value: "{color.brand1.2}"
149
- },
150
- "surface-default": {
151
- $type: "color",
152
- $value: "{color.brand1.3}"
153
- },
154
- "surface-tinted": {
155
- $type: "color",
156
- $value: "{color.brand1.4}"
157
- },
158
- "surface-hover": {
159
- $type: "color",
160
- $value: "{color.brand1.5}"
161
- },
162
- "surface-active": {
163
- $type: "color",
164
- $value: "{color.brand1.6}"
165
- },
166
- "border-subtle": {
167
- $type: "color",
168
- $value: "{color.brand1.7}"
169
- },
170
- "border-default": {
171
- $type: "color",
172
- $value: "{color.brand1.8}"
173
- },
174
- "border-strong": {
175
- $type: "color",
176
- $value: "{color.brand1.9}"
177
- },
178
- "text-subtle": {
179
- $type: "color",
180
- $value: "{color.brand1.10}"
181
- },
182
- "text-default": {
183
- $type: "color",
184
- $value: "{color.brand1.11}"
185
- },
186
- "base-default": {
187
- $type: "color",
188
- $value: "{color.brand1.12}"
189
- },
190
- "base-hover": {
191
- $type: "color",
192
- $value: "{color.brand1.13}"
193
- },
194
- "base-active": {
195
- $type: "color",
196
- $value: "{color.brand1.14}"
197
- },
198
- "base-contrast-subtle": {
199
- $type: "color",
200
- $value: "{color.brand1.15}"
201
- },
202
- "base-contrast-default": {
203
- $type: "color",
204
- $value: "{color.brand1.16}"
205
- }
206
- },
207
- brand2: {
208
- "background-default": {
209
- $type: "color",
210
- $value: "{color.brand2.1}"
211
- },
212
- "background-tinted": {
213
- $type: "color",
214
- $value: "{color.brand2.2}"
215
- },
216
- "surface-default": {
217
- $type: "color",
218
- $value: "{color.brand2.3}"
219
- },
220
- "surface-tinted": {
221
- $type: "color",
222
- $value: "{color.brand2.4}"
223
- },
224
- "surface-hover": {
225
- $type: "color",
226
- $value: "{color.brand2.5}"
227
- },
228
- "surface-active": {
229
- $type: "color",
230
- $value: "{color.brand2.6}"
231
- },
232
- "border-subtle": {
233
- $type: "color",
234
- $value: "{color.brand2.7}"
235
- },
236
- "border-default": {
237
- $type: "color",
238
- $value: "{color.brand2.8}"
239
- },
240
- "border-strong": {
241
- $type: "color",
242
- $value: "{color.brand2.9}"
243
- },
244
- "text-subtle": {
245
- $type: "color",
246
- $value: "{color.brand2.10}"
247
- },
248
- "text-default": {
249
- $type: "color",
250
- $value: "{color.brand2.11}"
251
- },
252
- "base-default": {
253
- $type: "color",
254
- $value: "{color.brand2.12}"
255
- },
256
- "base-hover": {
257
- $type: "color",
258
- $value: "{color.brand2.13}"
259
- },
260
- "base-active": {
261
- $type: "color",
262
- $value: "{color.brand2.14}"
263
- },
264
- "base-contrast-subtle": {
265
- $type: "color",
266
- $value: "{color.brand2.15}"
267
- },
268
- "base-contrast-default": {
269
- $type: "color",
270
- $value: "{color.brand2.16}"
271
- }
272
- },
273
- info: {
274
- "background-default": {
275
- $type: "color",
276
- $value: "{color.info.1}"
277
- },
278
- "background-tinted": {
279
- $type: "color",
280
- $value: "{color.info.2}"
281
- },
282
- "surface-default": {
283
- $type: "color",
284
- $value: "{color.info.3}"
285
- },
286
- "surface-tinted": {
287
- $type: "color",
288
- $value: "{color.info.4}"
289
- },
290
- "surface-hover": {
291
- $type: "color",
292
- $value: "{color.info.5}"
293
- },
294
- "surface-active": {
295
- $type: "color",
296
- $value: "{color.info.6}"
297
- },
298
- "border-subtle": {
299
- $type: "color",
300
- $value: "{color.info.7}"
301
- },
302
- "border-default": {
303
- $type: "color",
304
- $value: "{color.info.8}"
305
- },
306
- "border-strong": {
307
- $type: "color",
308
- $value: "{color.info.9}"
309
- },
310
- "text-subtle": {
311
- $type: "color",
312
- $value: "{color.info.10}"
313
- },
314
- "text-default": {
315
- $type: "color",
316
- $value: "{color.info.11}"
317
- },
318
- "base-default": {
319
- $type: "color",
320
- $value: "{color.info.12}"
321
- },
322
- "base-hover": {
323
- $type: "color",
324
- $value: "{color.info.13}"
325
- },
326
- "base-active": {
327
- $type: "color",
328
- $value: "{color.info.14}"
329
- },
330
- "base-contrast-subtle": {
331
- $type: "color",
332
- $value: "{color.info.15}"
333
- },
334
- "base-contrast-default": {
335
- $type: "color",
336
- $value: "{color.info.16}"
337
- }
338
- },
339
- success: {
340
- "background-default": {
341
- $type: "color",
342
- $value: "{color.success.1}"
343
- },
344
- "background-tinted": {
345
- $type: "color",
346
- $value: "{color.success.2}"
347
- },
348
- "surface-default": {
349
- $type: "color",
350
- $value: "{color.success.3}"
351
- },
352
- "surface-tinted": {
353
- $type: "color",
354
- $value: "{color.success.4}"
355
- },
356
- "surface-hover": {
357
- $type: "color",
358
- $value: "{color.success.5}"
359
- },
360
- "surface-active": {
361
- $type: "color",
362
- $value: "{color.success.6}"
363
- },
364
- "border-subtle": {
365
- $type: "color",
366
- $value: "{color.success.7}"
367
- },
368
- "border-default": {
369
- $type: "color",
370
- $value: "{color.success.8}"
371
- },
372
- "border-strong": {
373
- $type: "color",
374
- $value: "{color.success.9}"
375
- },
376
- "text-subtle": {
377
- $type: "color",
378
- $value: "{color.success.10}"
379
- },
380
- "text-default": {
381
- $type: "color",
382
- $value: "{color.success.11}"
383
- },
384
- "base-default": {
385
- $type: "color",
386
- $value: "{color.success.12}"
387
- },
388
- "base-hover": {
389
- $type: "color",
390
- $value: "{color.success.13}"
391
- },
392
- "base-active": {
393
- $type: "color",
394
- $value: "{color.success.14}"
395
- },
396
- "base-contrast-subtle": {
397
- $type: "color",
398
- $value: "{color.success.15}"
399
- },
400
- "base-contrast-default": {
401
- $type: "color",
402
- $value: "{color.success.16}"
403
- }
404
- },
405
- warning: {
406
- "background-default": {
407
- $type: "color",
408
- $value: "{color.warning.1}"
409
- },
410
- "background-tinted": {
411
- $type: "color",
412
- $value: "{color.warning.2}"
413
- },
414
- "surface-default": {
415
- $type: "color",
416
- $value: "{color.warning.3}"
417
- },
418
- "surface-tinted": {
419
- $type: "color",
420
- $value: "{color.warning.4}"
421
- },
422
- "surface-hover": {
423
- $type: "color",
424
- $value: "{color.warning.5}"
425
- },
426
- "surface-active": {
427
- $type: "color",
428
- $value: "{color.warning.6}"
429
- },
430
- "border-subtle": {
431
- $type: "color",
432
- $value: "{color.warning.7}"
433
- },
434
- "border-default": {
435
- $type: "color",
436
- $value: "{color.warning.8}"
437
- },
438
- "border-strong": {
439
- $type: "color",
440
- $value: "{color.warning.9}"
441
- },
442
- "text-subtle": {
443
- $type: "color",
444
- $value: "{color.warning.10}"
445
- },
446
- "text-default": {
447
- $type: "color",
448
- $value: "{color.warning.11}"
449
- },
450
- "base-default": {
451
- $type: "color",
452
- $value: "{color.warning.12}"
453
- },
454
- "base-hover": {
455
- $type: "color",
456
- $value: "{color.warning.13}"
457
- },
458
- "base-active": {
459
- $type: "color",
460
- $value: "{color.warning.14}"
461
- },
462
- "base-contrast-subtle": {
463
- $type: "color",
464
- $value: "{color.warning.15}"
465
- },
466
- "base-contrast-default": {
467
- $type: "color",
468
- $value: "{color.warning.16}"
469
- }
470
- },
471
- danger: {
472
- "background-default": {
473
- $type: "color",
474
- $value: "{color.danger.1}"
475
- },
476
- "background-tinted": {
477
- $type: "color",
478
- $value: "{color.danger.2}"
479
- },
480
- "surface-default": {
481
- $type: "color",
482
- $value: "{color.danger.3}"
483
- },
484
- "surface-tinted": {
485
- $type: "color",
486
- $value: "{color.danger.4}"
487
- },
488
- "surface-hover": {
489
- $type: "color",
490
- $value: "{color.danger.5}"
491
- },
492
- "surface-active": {
493
- $type: "color",
494
- $value: "{color.danger.6}"
495
- },
496
- "border-subtle": {
497
- $type: "color",
498
- $value: "{color.danger.7}"
499
- },
500
- "border-default": {
501
- $type: "color",
502
- $value: "{color.danger.8}"
503
- },
504
- "border-strong": {
505
- $type: "color",
506
- $value: "{color.danger.9}"
507
- },
508
- "text-subtle": {
509
- $type: "color",
510
- $value: "{color.danger.10}"
511
- },
512
- "text-default": {
513
- $type: "color",
514
- $value: "{color.danger.11}"
515
- },
516
- "base-default": {
517
- $type: "color",
518
- $value: "{color.danger.12}"
519
- },
520
- "base-hover": {
521
- $type: "color",
522
- $value: "{color.danger.13}"
523
- },
524
- "base-active": {
525
- $type: "color",
526
- $value: "{color.danger.14}"
527
- },
528
- "base-contrast-subtle": {
529
- $type: "color",
530
- $value: "{color.danger.15}"
531
- },
532
- "base-contrast-default": {
533
- $type: "color",
534
- $value: "{color.danger.16}"
535
- }
536
- },
537
- focus: {
538
- inner: {
539
- $type: "color",
540
- $value: "{color.focus.inner-color}"
541
- },
542
- outer: {
543
- $type: "color",
544
- $value: "{color.focus.outer-color}"
545
- }
546
- }
547
- },
548
- link: {
549
- color: {
550
- visited: {
551
- $type: "color",
552
- $value: "{color.link.visited}"
553
- }
554
- }
555
- }
556
- };
557
-
558
- // ../../design-tokens/semantic/modes/main-color/accent.json
559
- var accent_default = {
560
- color: {
561
- main: {
562
- "background-default": {
563
- $type: "color",
564
- $value: "{color.accent.background-default}"
565
- },
566
- "background-tinted": {
567
- $type: "color",
568
- $value: "{color.accent.background-tinted}"
569
- },
570
- "surface-default": {
571
- $type: "color",
572
- $value: "{color.accent.surface-default}"
573
- },
574
- "surface-tinted": {
575
- $type: "color",
576
- $value: "{color.accent.surface-tinted}"
577
- },
578
- "surface-hover": {
579
- $type: "color",
580
- $value: "{color.accent.surface-hover}"
581
- },
582
- "surface-active": {
583
- $type: "color",
584
- $value: "{color.accent.surface-active}"
585
- },
586
- "border-subtle": {
587
- $type: "color",
588
- $value: "{color.accent.border-subtle}"
589
- },
590
- "border-default": {
591
- $type: "color",
592
- $value: "{color.accent.border-default}"
593
- },
594
- "border-strong": {
595
- $type: "color",
596
- $value: "{color.accent.border-strong}"
597
- },
598
- "text-subtle": {
599
- $type: "color",
600
- $value: "{color.accent.text-subtle}"
601
- },
602
- "text-default": {
603
- $type: "color",
604
- $value: "{color.accent.text-default}"
605
- },
606
- "base-default": {
607
- $type: "color",
608
- $value: "{color.accent.base-default}"
609
- },
610
- "base-hover": {
611
- $type: "color",
612
- $value: "{color.accent.base-hover}"
613
- },
614
- "base-active": {
615
- $type: "color",
616
- $value: "{color.accent.base-active}"
617
- },
618
- "base-contrast-subtle": {
619
- $type: "color",
620
- $value: "{color.accent.base-contrast-subtle}"
621
- },
622
- "base-contrast-default": {
623
- $type: "color",
624
- $value: "{color.accent.base-contrast-default}"
625
- }
626
- }
627
- }
628
- };
629
-
630
- // ../../design-tokens/themes/designsystemet.json
631
- var designsystemet_default = {
632
- color: {
633
- accent: {
634
- "1": {
635
- $type: "color",
636
- $value: "{designsystemet.accent.1}"
637
- },
638
- "2": {
639
- $type: "color",
640
- $value: "{designsystemet.accent.2}"
641
- },
642
- "3": {
643
- $type: "color",
644
- $value: "{designsystemet.accent.3}"
645
- },
646
- "4": {
647
- $type: "color",
648
- $value: "{designsystemet.accent.4}"
649
- },
650
- "5": {
651
- $type: "color",
652
- $value: "{designsystemet.accent.5}"
653
- },
654
- "6": {
655
- $type: "color",
656
- $value: "{designsystemet.accent.6}"
657
- },
658
- "7": {
659
- $type: "color",
660
- $value: "{designsystemet.accent.7}"
661
- },
662
- "8": {
663
- $type: "color",
664
- $value: "{designsystemet.accent.8}"
665
- },
666
- "9": {
667
- $type: "color",
668
- $value: "{designsystemet.accent.9}"
669
- },
670
- "10": {
671
- $type: "color",
672
- $value: "{designsystemet.accent.10}"
673
- },
674
- "11": {
675
- $type: "color",
676
- $value: "{designsystemet.accent.11}"
677
- },
678
- "12": {
679
- $type: "color",
680
- $value: "{designsystemet.accent.12}"
681
- },
682
- "13": {
683
- $type: "color",
684
- $value: "{designsystemet.accent.13}"
685
- },
686
- "14": {
687
- $type: "color",
688
- $value: "{designsystemet.accent.14}"
689
- },
690
- "15": {
691
- $type: "color",
692
- $value: "{designsystemet.accent.15}"
693
- },
694
- "16": {
695
- $type: "color",
696
- $value: "{designsystemet.accent.16}"
697
- }
698
- },
699
- neutral: {
700
- "1": {
701
- $type: "color",
702
- $value: "{designsystemet.neutral.1}"
703
- },
704
- "2": {
705
- $type: "color",
706
- $value: "{designsystemet.neutral.2}"
707
- },
708
- "3": {
709
- $type: "color",
710
- $value: "{designsystemet.neutral.3}"
711
- },
712
- "4": {
713
- $type: "color",
714
- $value: "{designsystemet.neutral.4}"
715
- },
716
- "5": {
717
- $type: "color",
718
- $value: "{designsystemet.neutral.5}"
719
- },
720
- "6": {
721
- $type: "color",
722
- $value: "{designsystemet.neutral.6}"
723
- },
724
- "7": {
725
- $type: "color",
726
- $value: "{designsystemet.neutral.7}"
727
- },
728
- "8": {
729
- $type: "color",
730
- $value: "{designsystemet.neutral.8}"
731
- },
732
- "9": {
733
- $type: "color",
734
- $value: "{designsystemet.neutral.9}"
735
- },
736
- "10": {
737
- $type: "color",
738
- $value: "{designsystemet.neutral.10}"
739
- },
740
- "11": {
741
- $type: "color",
742
- $value: "{designsystemet.neutral.11}"
743
- },
744
- "12": {
745
- $type: "color",
746
- $value: "{designsystemet.neutral.12}"
747
- },
748
- "13": {
749
- $type: "color",
750
- $value: "{designsystemet.neutral.13}"
751
- },
752
- "14": {
753
- $type: "color",
754
- $value: "{designsystemet.neutral.14}"
755
- },
756
- "15": {
757
- $type: "color",
758
- $value: "{designsystemet.neutral.15}"
759
- },
760
- "16": {
761
- $type: "color",
762
- $value: "{designsystemet.neutral.16}"
763
- }
764
- },
765
- brand1: {
766
- "1": {
767
- $type: "color",
768
- $value: "{designsystemet.brand1.1}"
769
- },
770
- "2": {
771
- $type: "color",
772
- $value: "{designsystemet.brand1.2}"
773
- },
774
- "3": {
775
- $type: "color",
776
- $value: "{designsystemet.brand1.3}"
777
- },
778
- "4": {
779
- $type: "color",
780
- $value: "{designsystemet.brand1.4}"
781
- },
782
- "5": {
783
- $type: "color",
784
- $value: "{designsystemet.brand1.5}"
785
- },
786
- "6": {
787
- $type: "color",
788
- $value: "{designsystemet.brand1.6}"
789
- },
790
- "7": {
791
- $type: "color",
792
- $value: "{designsystemet.brand1.7}"
793
- },
794
- "8": {
795
- $type: "color",
796
- $value: "{designsystemet.brand1.8}"
797
- },
798
- "9": {
799
- $type: "color",
800
- $value: "{designsystemet.brand1.9}"
801
- },
802
- "10": {
803
- $type: "color",
804
- $value: "{designsystemet.brand1.10}"
805
- },
806
- "11": {
807
- $type: "color",
808
- $value: "{designsystemet.brand1.11}"
809
- },
810
- "12": {
811
- $type: "color",
812
- $value: "{designsystemet.brand1.12}"
813
- },
814
- "13": {
815
- $type: "color",
816
- $value: "{designsystemet.brand1.13}"
817
- },
818
- "14": {
819
- $type: "color",
820
- $value: "{designsystemet.brand1.14}"
821
- },
822
- "15": {
823
- $type: "color",
824
- $value: "{designsystemet.brand1.15}"
825
- },
826
- "16": {
827
- $type: "color",
828
- $value: "{designsystemet.brand1.16}"
829
- }
830
- },
831
- brand2: {
832
- "1": {
833
- $type: "color",
834
- $value: "{designsystemet.brand2.1}"
835
- },
836
- "2": {
837
- $type: "color",
838
- $value: "{designsystemet.brand2.2}"
839
- },
840
- "3": {
841
- $type: "color",
842
- $value: "{designsystemet.brand2.3}"
843
- },
844
- "4": {
845
- $type: "color",
846
- $value: "{designsystemet.brand2.4}"
847
- },
848
- "5": {
849
- $type: "color",
850
- $value: "{designsystemet.brand2.5}"
851
- },
852
- "6": {
853
- $type: "color",
854
- $value: "{designsystemet.brand2.6}"
855
- },
856
- "7": {
857
- $type: "color",
858
- $value: "{designsystemet.brand2.7}"
859
- },
860
- "8": {
861
- $type: "color",
862
- $value: "{designsystemet.brand2.8}"
863
- },
864
- "9": {
865
- $type: "color",
866
- $value: "{designsystemet.brand2.9}"
867
- },
868
- "10": {
869
- $type: "color",
870
- $value: "{designsystemet.brand2.10}"
871
- },
872
- "11": {
873
- $type: "color",
874
- $value: "{designsystemet.brand2.11}"
875
- },
876
- "12": {
877
- $type: "color",
878
- $value: "{designsystemet.brand2.12}"
879
- },
880
- "13": {
881
- $type: "color",
882
- $value: "{designsystemet.brand2.13}"
883
- },
884
- "14": {
885
- $type: "color",
886
- $value: "{designsystemet.brand2.14}"
887
- },
888
- "15": {
889
- $type: "color",
890
- $value: "{designsystemet.brand2.15}"
891
- },
892
- "16": {
893
- $type: "color",
894
- $value: "{designsystemet.brand2.16}"
895
- }
896
- },
897
- info: {
898
- "1": {
899
- $type: "color",
900
- $value: "{designsystemet.info.1}"
901
- },
902
- "2": {
903
- $type: "color",
904
- $value: "{designsystemet.info.2}"
905
- },
906
- "3": {
907
- $type: "color",
908
- $value: "{designsystemet.info.3}"
909
- },
910
- "4": {
911
- $type: "color",
912
- $value: "{designsystemet.info.4}"
913
- },
914
- "5": {
915
- $type: "color",
916
- $value: "{designsystemet.info.5}"
917
- },
918
- "6": {
919
- $type: "color",
920
- $value: "{designsystemet.info.6}"
921
- },
922
- "7": {
923
- $type: "color",
924
- $value: "{designsystemet.info.7}"
925
- },
926
- "8": {
927
- $type: "color",
928
- $value: "{designsystemet.info.8}"
929
- },
930
- "9": {
931
- $type: "color",
932
- $value: "{designsystemet.info.9}"
933
- },
934
- "10": {
935
- $type: "color",
936
- $value: "{designsystemet.info.10}"
937
- },
938
- "11": {
939
- $type: "color",
940
- $value: "{designsystemet.info.11}"
941
- },
942
- "12": {
943
- $type: "color",
944
- $value: "{designsystemet.info.12}"
945
- },
946
- "13": {
947
- $type: "color",
948
- $value: "{designsystemet.info.13}"
949
- },
950
- "14": {
951
- $type: "color",
952
- $value: "{designsystemet.info.14}"
953
- },
954
- "15": {
955
- $type: "color",
956
- $value: "{designsystemet.info.15}"
957
- },
958
- "16": {
959
- $type: "color",
960
- $value: "{designsystemet.info.16}"
961
- }
962
- },
963
- success: {
964
- "1": {
965
- $type: "color",
966
- $value: "{designsystemet.success.1}"
967
- },
968
- "2": {
969
- $type: "color",
970
- $value: "{designsystemet.success.2}"
971
- },
972
- "3": {
973
- $type: "color",
974
- $value: "{designsystemet.success.3}"
975
- },
976
- "4": {
977
- $type: "color",
978
- $value: "{designsystemet.success.4}"
979
- },
980
- "5": {
981
- $type: "color",
982
- $value: "{designsystemet.success.5}"
983
- },
984
- "6": {
985
- $type: "color",
986
- $value: "{designsystemet.success.6}"
987
- },
988
- "7": {
989
- $type: "color",
990
- $value: "{designsystemet.success.7}"
991
- },
992
- "8": {
993
- $type: "color",
994
- $value: "{designsystemet.success.8}"
995
- },
996
- "9": {
997
- $type: "color",
998
- $value: "{designsystemet.success.9}"
999
- },
1000
- "10": {
1001
- $type: "color",
1002
- $value: "{designsystemet.success.10}"
1003
- },
1004
- "11": {
1005
- $type: "color",
1006
- $value: "{designsystemet.success.11}"
1007
- },
1008
- "12": {
1009
- $type: "color",
1010
- $value: "{designsystemet.success.12}"
1011
- },
1012
- "13": {
1013
- $type: "color",
1014
- $value: "{designsystemet.success.13}"
1015
- },
1016
- "14": {
1017
- $type: "color",
1018
- $value: "{designsystemet.success.14}"
1019
- },
1020
- "15": {
1021
- $type: "color",
1022
- $value: "{designsystemet.success.15}"
1023
- },
1024
- "16": {
1025
- $type: "color",
1026
- $value: "{designsystemet.success.16}"
1027
- }
1028
- },
1029
- warning: {
1030
- "1": {
1031
- $type: "color",
1032
- $value: "{designsystemet.warning.1}"
1033
- },
1034
- "2": {
1035
- $type: "color",
1036
- $value: "{designsystemet.warning.2}"
1037
- },
1038
- "3": {
1039
- $type: "color",
1040
- $value: "{designsystemet.warning.3}"
1041
- },
1042
- "4": {
1043
- $type: "color",
1044
- $value: "{designsystemet.warning.4}"
1045
- },
1046
- "5": {
1047
- $type: "color",
1048
- $value: "{designsystemet.warning.5}"
1049
- },
1050
- "6": {
1051
- $type: "color",
1052
- $value: "{designsystemet.warning.6}"
1053
- },
1054
- "7": {
1055
- $type: "color",
1056
- $value: "{designsystemet.warning.7}"
1057
- },
1058
- "8": {
1059
- $type: "color",
1060
- $value: "{designsystemet.warning.8}"
1061
- },
1062
- "9": {
1063
- $type: "color",
1064
- $value: "{designsystemet.warning.9}"
1065
- },
1066
- "10": {
1067
- $type: "color",
1068
- $value: "{designsystemet.warning.10}"
1069
- },
1070
- "11": {
1071
- $type: "color",
1072
- $value: "{designsystemet.warning.11}"
1073
- },
1074
- "12": {
1075
- $type: "color",
1076
- $value: "{designsystemet.warning.12}"
1077
- },
1078
- "13": {
1079
- $type: "color",
1080
- $value: "{designsystemet.warning.13}"
1081
- },
1082
- "14": {
1083
- $type: "color",
1084
- $value: "{designsystemet.warning.14}"
1085
- },
1086
- "15": {
1087
- $type: "color",
1088
- $value: "{designsystemet.warning.15}"
1089
- },
1090
- "16": {
1091
- $type: "color",
1092
- $value: "{designsystemet.warning.16}"
1093
- }
1094
- },
1095
- danger: {
1096
- "1": {
1097
- $type: "color",
1098
- $value: "{designsystemet.danger.1}"
1099
- },
1100
- "2": {
1101
- $type: "color",
1102
- $value: "{designsystemet.danger.2}"
1103
- },
1104
- "3": {
1105
- $type: "color",
1106
- $value: "{designsystemet.danger.3}"
1107
- },
1108
- "4": {
1109
- $type: "color",
1110
- $value: "{designsystemet.danger.4}"
1111
- },
1112
- "5": {
1113
- $type: "color",
1114
- $value: "{designsystemet.danger.5}"
1115
- },
1116
- "6": {
1117
- $type: "color",
1118
- $value: "{designsystemet.danger.6}"
1119
- },
1120
- "7": {
1121
- $type: "color",
1122
- $value: "{designsystemet.danger.7}"
1123
- },
1124
- "8": {
1125
- $type: "color",
1126
- $value: "{designsystemet.danger.8}"
1127
- },
1128
- "9": {
1129
- $type: "color",
1130
- $value: "{designsystemet.danger.9}"
1131
- },
1132
- "10": {
1133
- $type: "color",
1134
- $value: "{designsystemet.danger.10}"
1135
- },
1136
- "11": {
1137
- $type: "color",
1138
- $value: "{designsystemet.danger.11}"
1139
- },
1140
- "12": {
1141
- $type: "color",
1142
- $value: "{designsystemet.danger.12}"
1143
- },
1144
- "13": {
1145
- $type: "color",
1146
- $value: "{designsystemet.danger.13}"
1147
- },
1148
- "14": {
1149
- $type: "color",
1150
- $value: "{designsystemet.danger.14}"
1151
- },
1152
- "15": {
1153
- $type: "color",
1154
- $value: "{designsystemet.danger.15}"
1155
- },
1156
- "16": {
1157
- $type: "color",
1158
- $value: "{designsystemet.danger.16}"
1159
- }
1160
- },
1161
- link: {
1162
- visited: {
1163
- $type: "color",
1164
- $value: "{designsystemet.link.visited}"
1165
- }
1166
- },
1167
- focus: {
1168
- "inner-color": {
1169
- $type: "color",
1170
- $value: "{designsystemet.focus.inner}"
1171
- },
1172
- "outer-color": {
1173
- $type: "color",
1174
- $value: "{designsystemet.focus.outer}"
1175
- }
1176
- }
1177
- },
1178
- "font-family": {
1179
- $type: "fontFamilies",
1180
- $value: "{designsystemet.font-family}"
1181
- },
1182
- "font-weight": {
1183
- medium: {
1184
- $type: "fontWeights",
1185
- $value: "{designsystemet.font-weight.medium}"
1186
- },
1187
- semibold: {
1188
- $type: "fontWeights",
1189
- $value: "{designsystemet.font-weight.semibold}"
1190
- },
1191
- regular: {
1192
- $type: "fontWeights",
1193
- $value: "{designsystemet.font-weight.regular}"
1194
- }
1195
- },
1196
- "border-radius": {
1197
- "1": {
1198
- $type: "dimension",
1199
- $value: "min({border-radius.base}*0.5,{border-radius.scale})"
1200
- },
1201
- "2": {
1202
- $type: "dimension",
1203
- $value: "min({border-radius.base},{border-radius.scale}*2)"
1204
- },
1205
- "3": {
1206
- $type: "dimension",
1207
- $value: "min({border-radius.base}*2,{border-radius.scale}*5)"
1208
- },
1209
- "4": {
1210
- $type: "dimension",
1211
- $value: "min({border-radius.base}*3,{border-radius.scale}*7)"
1212
- },
1213
- "5": {
1214
- $type: "dimension",
1215
- $value: "{border-radius.base}"
1216
- },
1217
- "6": {
1218
- $type: "dimension",
1219
- $value: "9999"
1220
- },
1221
- base: {
1222
- $type: "dimension",
1223
- $value: "4"
1224
- },
1225
- scale: {
1226
- $type: "dimension",
1227
- $value: "4"
1228
- }
1229
- }
1230
- };
1231
-
1232
- // src/utils.ts
1233
- import fs from "fs/promises";
1234
- import pc from "picocolors";
1235
- var mkdir = async (dir, dry) => {
1236
- if (dry) {
1237
- console.log(`${pc.blue("mkdir")} ${dir}`);
1238
- return Promise.resolve();
1239
- }
1240
- const exists = await fs.access(dir, fs.constants.F_OK).then(() => true).catch(() => false);
1241
- if (exists) {
1242
- return Promise.resolve();
1243
- }
1244
- return fs.mkdir(dir, { recursive: true });
1245
- };
1246
- var writeFile = async (path2, data, dry) => {
1247
- if (dry) {
1248
- console.log(`${pc.blue("writeFile")} ${path2}`);
1249
- return Promise.resolve();
1250
- }
1251
- return fs.writeFile(path2, data, { encoding: "utf-8" }).catch((error) => {
1252
- console.error(pc.red(`Error writing file: ${path2}`));
1253
- console.error(pc.red(error));
1254
- throw error;
1255
- });
1256
- };
1257
- var cp = async (src, dest, dry, filter) => {
1258
- if (dry) {
1259
- console.log(`${pc.blue("cp")} ${src} ${dest}`);
1260
- return Promise.resolve();
1261
- }
1262
- return fs.cp(src, dest, { recursive: true, filter });
1263
- };
1264
- var cleanDir = async (dir, dry) => {
1265
- if (dry) {
1266
- console.log(`${pc.blue("cleanDir")} ${dir}`);
1267
- return Promise.resolve();
1268
- }
1269
- console.log(`
1270
- \u{1F525} Cleaning dir ${pc.red(`${dir.trim()}`)} `);
1271
- return fs.rm(dir, { recursive: true, force: true });
1272
- };
1273
- var readFile = async (path2, dry, allowFileNotFound) => {
1274
- if (dry) {
1275
- console.log(`${pc.blue("readFile")} ${path2}`);
1276
- return Promise.resolve("");
1277
- }
1278
- try {
1279
- return await fs.readFile(path2, "utf-8");
1280
- } catch (error) {
1281
- if (allowFileNotFound && error.code === "ENOENT") {
1282
- return "";
1283
- }
1284
- throw error;
1285
- }
1286
- };
1287
-
1288
- // src/scripts/update-template.ts
1289
- var DIRNAME = import.meta.dirname || __dirname;
1290
- var themeName = "designsystemet";
1291
- var SOURCE_FILES_PATH = path.join(DIRNAME, "../../../../design-tokens");
1292
- var TEMPLATE_FILES_PATH = path.join(DIRNAME, "../tokens/template/design-tokens");
1293
- var designTokensPath = (_path) => path.join(SOURCE_FILES_PATH, _path);
1294
- var argsFromToPaths = (path_) => [
1295
- path.join(SOURCE_FILES_PATH, path_),
1296
- path.join(TEMPLATE_FILES_PATH, path_)
1297
- ];
1298
- var updateTemplates = async () => {
1299
- await cleanDir(TEMPLATE_FILES_PATH);
1300
- await cp(...argsFromToPaths("primitives/globals.json"));
1301
- await cp(...argsFromToPaths("primitives/modes/size"));
1302
- await cp(...argsFromToPaths("primitives/modes/typography/size"));
1303
- await cp(...argsFromToPaths("semantic/style.json"));
1304
- const designsystemetTypographyJson = await readFile(
1305
- designTokensPath(`primitives/modes/typography/primary/${themeName}.json`)
1306
- );
1307
- const typographyTemplate = R.set(
1308
- R.lensPath([themeName, "font-family", "$value"]),
1309
- "<font-family>",
1310
- JSON.parse(designsystemetTypographyJson)
1311
- );
1312
- const typographyDir = path.join(TEMPLATE_FILES_PATH, "primitives/modes/typography/");
1313
- await mkdir(typographyDir);
1314
- await writeFile(
1315
- path.join(typographyDir, "typography.template.json"),
1316
- JSON.stringify(typographyTemplate, null, 2).replaceAll(themeName, "<theme>")
1317
- );
1318
- const categoryColorTemplate = accent_default.color.main;
1319
- const categoryDir = path.join(TEMPLATE_FILES_PATH, "semantic/modes");
1320
- await mkdir(categoryDir);
1321
- await writeFile(
1322
- path.join(categoryDir, "color.template.json"),
1323
- JSON.stringify(categoryColorTemplate, null, 2).replaceAll("color.accent", "color.<color>")
1324
- );
1325
- const colorBaseFile = {
1326
- ...color_default,
1327
- // Remove custom colors and severity colors as they are defined by theme
1328
- color: R.pick(["focus"], color_default.color),
1329
- link: {
1330
- color: {
1331
- visited: {
1332
- $type: "color",
1333
- $value: "{color.link.visited}"
1334
- }
1335
- }
1336
- }
1337
- };
1338
- await writeFile(
1339
- path.join(TEMPLATE_FILES_PATH, `semantic/color.base.template.json`),
1340
- JSON.stringify(colorBaseFile, null, 2)
1341
- );
1342
- const semanticColorTemplate = color_default.color.accent;
1343
- await writeFile(
1344
- path.join(TEMPLATE_FILES_PATH, `semantic/color.template.json`),
1345
- JSON.stringify(semanticColorTemplate, null, 2).replaceAll("color.accent", "color.<color>")
1346
- );
1347
- const themeBaseFile = {
1348
- color: {},
1349
- ...R.omit(["color"], designsystemet_default)
1350
- };
1351
- await mkdir(path.join(TEMPLATE_FILES_PATH, "themes"));
1352
- await writeFile(
1353
- path.join(TEMPLATE_FILES_PATH, `themes/theme.base.template.json`),
1354
- JSON.stringify(themeBaseFile, null, 2).replaceAll(themeName, "<theme>")
1355
- );
1356
- const themeColorTemplate = designsystemet_default.color.accent;
1357
- await writeFile(
1358
- path.join(TEMPLATE_FILES_PATH, `themes/theme.template.json`),
1359
- JSON.stringify(themeColorTemplate, null, 2).replaceAll(`${themeName}.accent`, "<theme>.<color>")
1360
- );
1361
- console.log(pc2.green("Templates updated"));
1362
- };
1363
- await updateTemplates();
1364
- export {
1365
- updateTemplates
1366
- };