@primitiv-ui/tokens 0.1.29 → 0.1.30
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/README.md +2 -2
- package/package.json +1 -1
- package/src/breakpoint.json +10 -0
- package/src/code-typography.test.ts +64 -0
- package/src/context.json +2610 -226
- package/src/dark-mode-content.test.ts +128 -12
- package/src/dtcg.ts +1 -1
- package/src/heading-tracking.test.ts +88 -0
- package/src/intent.json +342 -86
- package/src/palette.json +167 -83
- package/src/primitives.json +8 -0
- package/src/swatch-sizing.test.ts +76 -0
package/src/palette.json
CHANGED
|
@@ -138,23 +138,23 @@
|
|
|
138
138
|
"brand": {
|
|
139
139
|
"50": {
|
|
140
140
|
"$type": "color",
|
|
141
|
-
"$value": "#
|
|
141
|
+
"$value": "#f0f5ff"
|
|
142
142
|
},
|
|
143
143
|
"100": {
|
|
144
144
|
"$type": "color",
|
|
145
|
-
"$value": "#
|
|
145
|
+
"$value": "#d2e3fe"
|
|
146
146
|
},
|
|
147
147
|
"200": {
|
|
148
148
|
"$type": "color",
|
|
149
|
-
"$value": "#
|
|
149
|
+
"$value": "#aac9fc"
|
|
150
150
|
},
|
|
151
151
|
"300": {
|
|
152
152
|
"$type": "color",
|
|
153
|
-
"$value": "#
|
|
153
|
+
"$value": "#86b3fb"
|
|
154
154
|
},
|
|
155
155
|
"400": {
|
|
156
156
|
"$type": "color",
|
|
157
|
-
"$value": "#
|
|
157
|
+
"$value": "#5794fa"
|
|
158
158
|
},
|
|
159
159
|
"500": {
|
|
160
160
|
"$type": "color",
|
|
@@ -162,41 +162,83 @@
|
|
|
162
162
|
},
|
|
163
163
|
"600": {
|
|
164
164
|
"$type": "color",
|
|
165
|
-
"$value": "#
|
|
165
|
+
"$value": "#104fb2"
|
|
166
166
|
},
|
|
167
167
|
"700": {
|
|
168
168
|
"$type": "color",
|
|
169
|
-
"$value": "#
|
|
169
|
+
"$value": "#032e71"
|
|
170
170
|
},
|
|
171
171
|
"800": {
|
|
172
172
|
"$type": "color",
|
|
173
|
-
"$value": "#
|
|
173
|
+
"$value": "#011841"
|
|
174
174
|
},
|
|
175
175
|
"900": {
|
|
176
176
|
"$type": "color",
|
|
177
|
-
"$value": "#
|
|
177
|
+
"$value": "#000923"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"brand-alpha": {
|
|
181
|
+
"50": {
|
|
182
|
+
"$type": "color",
|
|
183
|
+
"$value": "#236ce108"
|
|
184
|
+
},
|
|
185
|
+
"100": {
|
|
186
|
+
"$type": "color",
|
|
187
|
+
"$value": "#236ce10f"
|
|
188
|
+
},
|
|
189
|
+
"200": {
|
|
190
|
+
"$type": "color",
|
|
191
|
+
"$value": "#236ce11a"
|
|
192
|
+
},
|
|
193
|
+
"300": {
|
|
194
|
+
"$type": "color",
|
|
195
|
+
"$value": "#236ce124"
|
|
196
|
+
},
|
|
197
|
+
"400": {
|
|
198
|
+
"$type": "color",
|
|
199
|
+
"$value": "#236ce133"
|
|
200
|
+
},
|
|
201
|
+
"500": {
|
|
202
|
+
"$type": "color",
|
|
203
|
+
"$value": "#236ce14d"
|
|
204
|
+
},
|
|
205
|
+
"600": {
|
|
206
|
+
"$type": "color",
|
|
207
|
+
"$value": "#236ce16b"
|
|
208
|
+
},
|
|
209
|
+
"700": {
|
|
210
|
+
"$type": "color",
|
|
211
|
+
"$value": "#236ce18c"
|
|
212
|
+
},
|
|
213
|
+
"800": {
|
|
214
|
+
"$type": "color",
|
|
215
|
+
"$value": "#236ce1b8"
|
|
216
|
+
},
|
|
217
|
+
"900": {
|
|
218
|
+
"$type": "color",
|
|
219
|
+
"$value": "#236ce1eb"
|
|
178
220
|
}
|
|
179
221
|
},
|
|
180
222
|
"danger": {
|
|
181
223
|
"50": {
|
|
182
224
|
"$type": "color",
|
|
183
|
-
"$value": "#
|
|
225
|
+
"$value": "#fff2f0"
|
|
184
226
|
},
|
|
185
227
|
"100": {
|
|
186
228
|
"$type": "color",
|
|
187
|
-
"$value": "#
|
|
229
|
+
"$value": "#fed8d3"
|
|
188
230
|
},
|
|
189
231
|
"200": {
|
|
190
232
|
"$type": "color",
|
|
191
|
-
"$value": "#
|
|
233
|
+
"$value": "#fdb5ac"
|
|
192
234
|
},
|
|
193
235
|
"300": {
|
|
194
236
|
"$type": "color",
|
|
195
|
-
"$value": "#
|
|
237
|
+
"$value": "#fc9487"
|
|
196
238
|
},
|
|
197
239
|
"400": {
|
|
198
240
|
"$type": "color",
|
|
199
|
-
"$value": "#
|
|
241
|
+
"$value": "#f96156"
|
|
200
242
|
},
|
|
201
243
|
"500": {
|
|
202
244
|
"$type": "color",
|
|
@@ -204,19 +246,19 @@
|
|
|
204
246
|
},
|
|
205
247
|
"600": {
|
|
206
248
|
"$type": "color",
|
|
207
|
-
"$value": "#
|
|
249
|
+
"$value": "#a91215"
|
|
208
250
|
},
|
|
209
251
|
"700": {
|
|
210
252
|
"$type": "color",
|
|
211
|
-
"$value": "#
|
|
253
|
+
"$value": "#680709"
|
|
212
254
|
},
|
|
213
255
|
"800": {
|
|
214
256
|
"$type": "color",
|
|
215
|
-
"$value": "#
|
|
257
|
+
"$value": "#3b0203"
|
|
216
258
|
},
|
|
217
259
|
"900": {
|
|
218
260
|
"$type": "color",
|
|
219
|
-
"$value": "#
|
|
261
|
+
"$value": "#1e0101"
|
|
220
262
|
}
|
|
221
263
|
},
|
|
222
264
|
"success": {
|
|
@@ -226,19 +268,19 @@
|
|
|
226
268
|
},
|
|
227
269
|
"100": {
|
|
228
270
|
"$type": "color",
|
|
229
|
-
"$value": "#
|
|
271
|
+
"$value": "#caedc8"
|
|
230
272
|
},
|
|
231
273
|
"200": {
|
|
232
274
|
"$type": "color",
|
|
233
|
-
"$value": "#
|
|
275
|
+
"$value": "#9bdb98"
|
|
234
276
|
},
|
|
235
277
|
"300": {
|
|
236
278
|
"$type": "color",
|
|
237
|
-
"$value": "#
|
|
279
|
+
"$value": "#79c976"
|
|
238
280
|
},
|
|
239
281
|
"400": {
|
|
240
282
|
"$type": "color",
|
|
241
|
-
"$value": "#
|
|
283
|
+
"$value": "#50af4f"
|
|
242
284
|
},
|
|
243
285
|
"500": {
|
|
244
286
|
"$type": "color",
|
|
@@ -246,41 +288,41 @@
|
|
|
246
288
|
},
|
|
247
289
|
"600": {
|
|
248
290
|
"$type": "color",
|
|
249
|
-
"$value": "#
|
|
291
|
+
"$value": "#0e6913"
|
|
250
292
|
},
|
|
251
293
|
"700": {
|
|
252
294
|
"$type": "color",
|
|
253
|
-
"$value": "#
|
|
295
|
+
"$value": "#053f08"
|
|
254
296
|
},
|
|
255
297
|
"800": {
|
|
256
298
|
"$type": "color",
|
|
257
|
-
"$value": "#
|
|
299
|
+
"$value": "#022202"
|
|
258
300
|
},
|
|
259
301
|
"900": {
|
|
260
302
|
"$type": "color",
|
|
261
|
-
"$value": "#
|
|
303
|
+
"$value": "#001001"
|
|
262
304
|
}
|
|
263
305
|
},
|
|
264
306
|
"warning": {
|
|
265
307
|
"50": {
|
|
266
308
|
"$type": "color",
|
|
267
|
-
"$value": "#
|
|
309
|
+
"$value": "#fef3e9"
|
|
268
310
|
},
|
|
269
311
|
"100": {
|
|
270
312
|
"$type": "color",
|
|
271
|
-
"$value": "#
|
|
313
|
+
"$value": "#fee5cc"
|
|
272
314
|
},
|
|
273
315
|
"200": {
|
|
274
316
|
"$type": "color",
|
|
275
|
-
"$value": "#
|
|
317
|
+
"$value": "#fdd1a5"
|
|
276
318
|
},
|
|
277
319
|
"300": {
|
|
278
320
|
"$type": "color",
|
|
279
|
-
"$value": "#
|
|
321
|
+
"$value": "#fdbf7f"
|
|
280
322
|
},
|
|
281
323
|
"400": {
|
|
282
324
|
"$type": "color",
|
|
283
|
-
"$value": "#
|
|
325
|
+
"$value": "#f8a84e"
|
|
284
326
|
},
|
|
285
327
|
"500": {
|
|
286
328
|
"$type": "color",
|
|
@@ -288,41 +330,41 @@
|
|
|
288
330
|
},
|
|
289
331
|
"600": {
|
|
290
332
|
"$type": "color",
|
|
291
|
-
"$value": "#
|
|
333
|
+
"$value": "#aa6a14"
|
|
292
334
|
},
|
|
293
335
|
"700": {
|
|
294
336
|
"$type": "color",
|
|
295
|
-
"$value": "#
|
|
337
|
+
"$value": "#643c07"
|
|
296
338
|
},
|
|
297
339
|
"800": {
|
|
298
340
|
"$type": "color",
|
|
299
|
-
"$value": "#
|
|
341
|
+
"$value": "#321c02"
|
|
300
342
|
},
|
|
301
343
|
"900": {
|
|
302
344
|
"$type": "color",
|
|
303
|
-
"$value": "#
|
|
345
|
+
"$value": "#140800"
|
|
304
346
|
}
|
|
305
347
|
},
|
|
306
348
|
"info": {
|
|
307
349
|
"50": {
|
|
308
350
|
"$type": "color",
|
|
309
|
-
"$value": "#
|
|
351
|
+
"$value": "#edf7f9"
|
|
310
352
|
},
|
|
311
353
|
"100": {
|
|
312
354
|
"$type": "color",
|
|
313
|
-
"$value": "#
|
|
355
|
+
"$value": "#caeaef"
|
|
314
356
|
},
|
|
315
357
|
"200": {
|
|
316
358
|
"$type": "color",
|
|
317
|
-
"$value": "#
|
|
359
|
+
"$value": "#9bd8e1"
|
|
318
360
|
},
|
|
319
361
|
"300": {
|
|
320
362
|
"$type": "color",
|
|
321
|
-
"$value": "#
|
|
363
|
+
"$value": "#7ac6d1"
|
|
322
364
|
},
|
|
323
365
|
"400": {
|
|
324
366
|
"$type": "color",
|
|
325
|
-
"$value": "#
|
|
367
|
+
"$value": "#52aebb"
|
|
326
368
|
},
|
|
327
369
|
"500": {
|
|
328
370
|
"$type": "color",
|
|
@@ -330,19 +372,19 @@
|
|
|
330
372
|
},
|
|
331
373
|
"600": {
|
|
332
374
|
"$type": "color",
|
|
333
|
-
"$value": "#
|
|
375
|
+
"$value": "#106a75"
|
|
334
376
|
},
|
|
335
377
|
"700": {
|
|
336
378
|
"$type": "color",
|
|
337
|
-
"$value": "#
|
|
379
|
+
"$value": "#063f46"
|
|
338
380
|
},
|
|
339
381
|
"800": {
|
|
340
382
|
"$type": "color",
|
|
341
|
-
"$value": "#
|
|
383
|
+
"$value": "#022125"
|
|
342
384
|
},
|
|
343
385
|
"900": {
|
|
344
386
|
"$type": "color",
|
|
345
|
-
"$value": "#
|
|
387
|
+
"$value": "#000e10"
|
|
346
388
|
}
|
|
347
389
|
},
|
|
348
390
|
"transparent": {
|
|
@@ -506,15 +548,15 @@
|
|
|
506
548
|
},
|
|
507
549
|
"200": {
|
|
508
550
|
"$type": "color",
|
|
509
|
-
"$value": "#
|
|
551
|
+
"$value": "#032967"
|
|
510
552
|
},
|
|
511
553
|
"300": {
|
|
512
554
|
"$type": "color",
|
|
513
|
-
"$value": "#
|
|
555
|
+
"$value": "#053a8a"
|
|
514
556
|
},
|
|
515
557
|
"400": {
|
|
516
558
|
"$type": "color",
|
|
517
|
-
"$value": "#
|
|
559
|
+
"$value": "#1452b5"
|
|
518
560
|
},
|
|
519
561
|
"500": {
|
|
520
562
|
"$type": "color",
|
|
@@ -526,15 +568,57 @@
|
|
|
526
568
|
},
|
|
527
569
|
"700": {
|
|
528
570
|
"$type": "color",
|
|
529
|
-
"$value": "#
|
|
571
|
+
"$value": "#8bb6fb"
|
|
572
|
+
},
|
|
573
|
+
"800": {
|
|
574
|
+
"$type": "color",
|
|
575
|
+
"$value": "#bed6fd"
|
|
576
|
+
},
|
|
577
|
+
"900": {
|
|
578
|
+
"$type": "color",
|
|
579
|
+
"$value": "#e1ecfe"
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
"brand-alpha": {
|
|
583
|
+
"50": {
|
|
584
|
+
"$type": "color",
|
|
585
|
+
"$value": "#236ce108"
|
|
586
|
+
},
|
|
587
|
+
"100": {
|
|
588
|
+
"$type": "color",
|
|
589
|
+
"$value": "#236ce10f"
|
|
590
|
+
},
|
|
591
|
+
"200": {
|
|
592
|
+
"$type": "color",
|
|
593
|
+
"$value": "#236ce11a"
|
|
594
|
+
},
|
|
595
|
+
"300": {
|
|
596
|
+
"$type": "color",
|
|
597
|
+
"$value": "#236ce124"
|
|
598
|
+
},
|
|
599
|
+
"400": {
|
|
600
|
+
"$type": "color",
|
|
601
|
+
"$value": "#236ce133"
|
|
602
|
+
},
|
|
603
|
+
"500": {
|
|
604
|
+
"$type": "color",
|
|
605
|
+
"$value": "#236ce14d"
|
|
606
|
+
},
|
|
607
|
+
"600": {
|
|
608
|
+
"$type": "color",
|
|
609
|
+
"$value": "#236ce16b"
|
|
610
|
+
},
|
|
611
|
+
"700": {
|
|
612
|
+
"$type": "color",
|
|
613
|
+
"$value": "#236ce18c"
|
|
530
614
|
},
|
|
531
615
|
"800": {
|
|
532
616
|
"$type": "color",
|
|
533
|
-
"$value": "#
|
|
617
|
+
"$value": "#236ce1b8"
|
|
534
618
|
},
|
|
535
619
|
"900": {
|
|
536
620
|
"$type": "color",
|
|
537
|
-
"$value": "#
|
|
621
|
+
"$value": "#236ce1eb"
|
|
538
622
|
}
|
|
539
623
|
},
|
|
540
624
|
"danger": {
|
|
@@ -548,15 +632,15 @@
|
|
|
548
632
|
},
|
|
549
633
|
"200": {
|
|
550
634
|
"$type": "color",
|
|
551
|
-
"$value": "#
|
|
635
|
+
"$value": "#5d0607"
|
|
552
636
|
},
|
|
553
637
|
"300": {
|
|
554
638
|
"$type": "color",
|
|
555
|
-
"$value": "#
|
|
639
|
+
"$value": "#7f0b0d"
|
|
556
640
|
},
|
|
557
641
|
"400": {
|
|
558
642
|
"$type": "color",
|
|
559
|
-
"$value": "#
|
|
643
|
+
"$value": "#ad1316"
|
|
560
644
|
},
|
|
561
645
|
"500": {
|
|
562
646
|
"$type": "color",
|
|
@@ -568,37 +652,37 @@
|
|
|
568
652
|
},
|
|
569
653
|
"700": {
|
|
570
654
|
"$type": "color",
|
|
571
|
-
"$value": "#
|
|
655
|
+
"$value": "#fc988c"
|
|
572
656
|
},
|
|
573
657
|
"800": {
|
|
574
658
|
"$type": "color",
|
|
575
|
-
"$value": "#
|
|
659
|
+
"$value": "#fdc6bf"
|
|
576
660
|
},
|
|
577
661
|
"900": {
|
|
578
662
|
"$type": "color",
|
|
579
|
-
"$value": "#
|
|
663
|
+
"$value": "#fee4e1"
|
|
580
664
|
}
|
|
581
665
|
},
|
|
582
666
|
"success": {
|
|
583
667
|
"50": {
|
|
584
668
|
"$type": "color",
|
|
585
|
-
"$value": "#
|
|
669
|
+
"$value": "#131b12"
|
|
586
670
|
},
|
|
587
671
|
"100": {
|
|
588
672
|
"$type": "color",
|
|
589
|
-
"$value": "#
|
|
673
|
+
"$value": "#0d290c"
|
|
590
674
|
},
|
|
591
675
|
"200": {
|
|
592
676
|
"$type": "color",
|
|
593
|
-
"$value": "#
|
|
677
|
+
"$value": "#043906"
|
|
594
678
|
},
|
|
595
679
|
"300": {
|
|
596
680
|
"$type": "color",
|
|
597
|
-
"$value": "#
|
|
681
|
+
"$value": "#084f0c"
|
|
598
682
|
},
|
|
599
683
|
"400": {
|
|
600
684
|
"$type": "color",
|
|
601
|
-
"$value": "#
|
|
685
|
+
"$value": "#0f6c14"
|
|
602
686
|
},
|
|
603
687
|
"500": {
|
|
604
688
|
"$type": "color",
|
|
@@ -606,41 +690,41 @@
|
|
|
606
690
|
},
|
|
607
691
|
"600": {
|
|
608
692
|
"$type": "color",
|
|
609
|
-
"$value": "#
|
|
693
|
+
"$value": "#4dab4c"
|
|
610
694
|
},
|
|
611
695
|
"700": {
|
|
612
696
|
"$type": "color",
|
|
613
|
-
"$value": "#
|
|
697
|
+
"$value": "#7ccc78"
|
|
614
698
|
},
|
|
615
699
|
"800": {
|
|
616
700
|
"$type": "color",
|
|
617
|
-
"$value": "#
|
|
701
|
+
"$value": "#a7e8a4"
|
|
618
702
|
},
|
|
619
703
|
"900": {
|
|
620
704
|
"$type": "color",
|
|
621
|
-
"$value": "#
|
|
705
|
+
"$value": "#c9fbc6"
|
|
622
706
|
}
|
|
623
707
|
},
|
|
624
708
|
"warning": {
|
|
625
709
|
"50": {
|
|
626
710
|
"$type": "color",
|
|
627
|
-
"$value": "#
|
|
711
|
+
"$value": "#1e170f"
|
|
628
712
|
},
|
|
629
713
|
"100": {
|
|
630
714
|
"$type": "color",
|
|
631
|
-
"$value": "#
|
|
715
|
+
"$value": "#382105"
|
|
632
716
|
},
|
|
633
717
|
"200": {
|
|
634
718
|
"$type": "color",
|
|
635
|
-
"$value": "#
|
|
719
|
+
"$value": "#533105"
|
|
636
720
|
},
|
|
637
721
|
"300": {
|
|
638
722
|
"$type": "color",
|
|
639
|
-
"$value": "#
|
|
723
|
+
"$value": "#79490b"
|
|
640
724
|
},
|
|
641
725
|
"400": {
|
|
642
726
|
"$type": "color",
|
|
643
|
-
"$value": "#
|
|
727
|
+
"$value": "#ad6c14"
|
|
644
728
|
},
|
|
645
729
|
"500": {
|
|
646
730
|
"$type": "color",
|
|
@@ -648,41 +732,41 @@
|
|
|
648
732
|
},
|
|
649
733
|
"600": {
|
|
650
734
|
"$type": "color",
|
|
651
|
-
"$value": "#
|
|
735
|
+
"$value": "#f5a54b"
|
|
652
736
|
},
|
|
653
737
|
"700": {
|
|
654
738
|
"$type": "color",
|
|
655
|
-
"$value": "#
|
|
739
|
+
"$value": "#fdbe7e"
|
|
656
740
|
},
|
|
657
741
|
"800": {
|
|
658
742
|
"$type": "color",
|
|
659
|
-
"$value": "#
|
|
743
|
+
"$value": "#fdd7b0"
|
|
660
744
|
},
|
|
661
745
|
"900": {
|
|
662
746
|
"$type": "color",
|
|
663
|
-
"$value": "#
|
|
747
|
+
"$value": "#fee7d0"
|
|
664
748
|
}
|
|
665
749
|
},
|
|
666
750
|
"info": {
|
|
667
751
|
"50": {
|
|
668
752
|
"$type": "color",
|
|
669
|
-
"$value": "#
|
|
753
|
+
"$value": "#121a1b"
|
|
670
754
|
},
|
|
671
755
|
"100": {
|
|
672
756
|
"$type": "color",
|
|
673
|
-
"$value": "#
|
|
757
|
+
"$value": "#0c272b"
|
|
674
758
|
},
|
|
675
759
|
"200": {
|
|
676
760
|
"$type": "color",
|
|
677
|
-
"$value": "#
|
|
761
|
+
"$value": "#05383e"
|
|
678
762
|
},
|
|
679
763
|
"300": {
|
|
680
764
|
"$type": "color",
|
|
681
|
-
"$value": "#
|
|
765
|
+
"$value": "#094e57"
|
|
682
766
|
},
|
|
683
767
|
"400": {
|
|
684
768
|
"$type": "color",
|
|
685
|
-
"$value": "#
|
|
769
|
+
"$value": "#116d78"
|
|
686
770
|
},
|
|
687
771
|
"500": {
|
|
688
772
|
"$type": "color",
|
|
@@ -690,19 +774,19 @@
|
|
|
690
774
|
},
|
|
691
775
|
"600": {
|
|
692
776
|
"$type": "color",
|
|
693
|
-
"$value": "#
|
|
777
|
+
"$value": "#4fabb8"
|
|
694
778
|
},
|
|
695
779
|
"700": {
|
|
696
780
|
"$type": "color",
|
|
697
|
-
"$value": "#
|
|
781
|
+
"$value": "#7cc8d4"
|
|
698
782
|
},
|
|
699
783
|
"800": {
|
|
700
784
|
"$type": "color",
|
|
701
|
-
"$value": "#
|
|
785
|
+
"$value": "#a6e3ec"
|
|
702
786
|
},
|
|
703
787
|
"900": {
|
|
704
788
|
"$type": "color",
|
|
705
|
-
"$value": "#
|
|
789
|
+
"$value": "#c7f5fc"
|
|
706
790
|
}
|
|
707
791
|
},
|
|
708
792
|
"transparent": {
|
package/src/primitives.json
CHANGED
|
@@ -456,6 +456,14 @@
|
|
|
456
456
|
"$type": "number",
|
|
457
457
|
"$value": 1.2000000476837158
|
|
458
458
|
},
|
|
459
|
+
"normal": {
|
|
460
|
+
"$type": "number",
|
|
461
|
+
"$value": 0
|
|
462
|
+
},
|
|
463
|
+
"snug": {
|
|
464
|
+
"$type": "number",
|
|
465
|
+
"$value": -0.6000000238418579
|
|
466
|
+
},
|
|
459
467
|
"tight": {
|
|
460
468
|
"$type": "number",
|
|
461
469
|
"$value": -1.2000000476837158
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import context from './context.json'
|
|
2
|
+
import primitives from './primitives.json'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* `swatch.*` — the geometry of a Harmoni colour swatch.
|
|
6
|
+
*
|
|
7
|
+
* Why it needs its own family rather than borrowing one: a swatch is not a
|
|
8
|
+
* control (`framed-control.*` is a thing you click) and not a surface
|
|
9
|
+
* (`surface.*` is a thing you put content on). It is a specimen — a colour
|
|
10
|
+
* box that prints facts about itself — and its box wants to grow far past any
|
|
11
|
+
* control height at `xl` while its padding stays tight. Borrowing either
|
|
12
|
+
* family would have coupled it to a scale chosen for a different job.
|
|
13
|
+
*
|
|
14
|
+
* The two ladders below are what make the `Size` and density axes mean
|
|
15
|
+
* anything. They are asserted rather than eyeballed because a single
|
|
16
|
+
* mis-keyed alias — `{space.space-8}` where `{space.space-4}` belongs — is
|
|
17
|
+
* invisible in a 120-cell table and shows up only as one size looking wrong.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
type Mode = 'dense' | 'compact' | 'comfortable' | 'spacious'
|
|
21
|
+
type DtcgNode = { $type?: string; $value?: unknown; [key: string]: unknown }
|
|
22
|
+
|
|
23
|
+
/** Ascending by design: each mode is roomier than the one before it. */
|
|
24
|
+
const MODES: Mode[] = ['dense', 'compact', 'comfortable', 'spacious']
|
|
25
|
+
/** Ascending by design: each size is larger than the one before it. */
|
|
26
|
+
const SIZES = ['xs', 'sm', 'md', 'lg', 'xl'] as const
|
|
27
|
+
const MEMBERS = ['box', 'panel-cap', 'sample-size', 'sample-caption-size', 'min-height', 'radius', 'padding-inline', 'padding-block', 'gap'] as const
|
|
28
|
+
|
|
29
|
+
function member(mode: Mode, size: string, name: string): DtcgNode | undefined {
|
|
30
|
+
const swatch = (context as Record<Mode, DtcgNode>)[mode].swatch as DtcgNode | undefined
|
|
31
|
+
return (swatch?.[size] as DtcgNode | undefined)?.[name] as DtcgNode | undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Resolve a DTCG alias (`{space.space-8}`) against the primitive tree. */
|
|
35
|
+
function resolvePrimitive(ref: string): number {
|
|
36
|
+
const path = ref.slice(1, -1).split('.')
|
|
37
|
+
let node: DtcgNode = primitives as DtcgNode
|
|
38
|
+
for (const key of path) node = node[key] as DtcgNode
|
|
39
|
+
return node.$value as number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function value(mode: Mode, size: string, name: string): number {
|
|
43
|
+
return resolvePrimitive(member(mode, size, name)?.$value as string)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('swatch sizing', () => {
|
|
47
|
+
for (const mode of MODES) {
|
|
48
|
+
for (const size of SIZES) {
|
|
49
|
+
it(`${mode} / swatch / ${size} carries every member, aliased to a primitive`, () => {
|
|
50
|
+
for (const name of MEMBERS) {
|
|
51
|
+
const node = member(mode, size, name)
|
|
52
|
+
expect(node, `${mode}.swatch.${size}.${name} is missing`).toBeDefined()
|
|
53
|
+
expect(node?.$type).toBe('number')
|
|
54
|
+
expect(String(node?.$value)).toMatch(/^\{[a-z-]+\.[a-z0-9-]+\}$/)
|
|
55
|
+
expect(typeof resolvePrimitive(node?.$value as string)).toBe('number')
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (const name of MEMBERS) {
|
|
62
|
+
it(`${name} never shrinks as the size grows`, () => {
|
|
63
|
+
for (const mode of MODES) {
|
|
64
|
+
const ladder = SIZES.map((size) => value(mode, size, name))
|
|
65
|
+
expect(ladder, `${mode}.swatch.*.${name}`).toEqual([...ladder].sort((a, b) => a - b))
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it(`${name} never shrinks as the density loosens`, () => {
|
|
70
|
+
for (const size of SIZES) {
|
|
71
|
+
const ladder = MODES.map((mode) => value(mode, size, name))
|
|
72
|
+
expect(ladder, `*.swatch.${size}.${name}`).toEqual([...ladder].sort((a, b) => a - b))
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
})
|