@sofya-ds/tokens 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.cjs +521 -59
- package/dist/index.d.cts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +517 -59
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,93 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var sofyaTextStyleNames = [
|
|
3
|
+
"display-xl",
|
|
4
|
+
"display-lg",
|
|
5
|
+
"heading-xl",
|
|
6
|
+
"heading-lg",
|
|
7
|
+
"heading-md",
|
|
3
8
|
"h1",
|
|
4
9
|
"h2",
|
|
5
10
|
"h3",
|
|
6
11
|
"h4",
|
|
7
12
|
"h5",
|
|
13
|
+
"encounter-title",
|
|
14
|
+
"title-md",
|
|
15
|
+
"title-sm",
|
|
16
|
+
"body-lg",
|
|
17
|
+
"body-md",
|
|
18
|
+
"body-sm",
|
|
8
19
|
"body",
|
|
20
|
+
"label-md",
|
|
21
|
+
"section-label",
|
|
22
|
+
"eyebrow-md",
|
|
23
|
+
"overline-md",
|
|
24
|
+
"sidebar-title",
|
|
25
|
+
"sidebar-title-regular",
|
|
26
|
+
"sidebar-title-strong",
|
|
27
|
+
"sidebar-label",
|
|
28
|
+
"sidebar-label-strong",
|
|
29
|
+
"sidebar-body",
|
|
30
|
+
"sidebar-tag",
|
|
31
|
+
"encounter-chip",
|
|
32
|
+
"encounter-history",
|
|
33
|
+
"caption",
|
|
34
|
+
"eyebrow",
|
|
9
35
|
"tiny",
|
|
10
|
-
"extra-tiny"
|
|
36
|
+
"extra-tiny",
|
|
37
|
+
"code-sm"
|
|
11
38
|
];
|
|
12
|
-
var sofyaSurfaceNames = [
|
|
39
|
+
var sofyaSurfaceNames = [
|
|
40
|
+
"appBackground",
|
|
41
|
+
"auth",
|
|
42
|
+
"card",
|
|
43
|
+
"dataTable",
|
|
44
|
+
"dialog",
|
|
45
|
+
"documentCard",
|
|
46
|
+
"documentCardSelected",
|
|
47
|
+
"focus",
|
|
48
|
+
"mainContent",
|
|
49
|
+
"panel",
|
|
50
|
+
"proseDialog",
|
|
51
|
+
"rightPanel",
|
|
52
|
+
"sidebar"
|
|
53
|
+
];
|
|
54
|
+
var sofyaSpaceNames = [
|
|
55
|
+
"0",
|
|
56
|
+
"0-5",
|
|
57
|
+
"1",
|
|
58
|
+
"1-5",
|
|
59
|
+
"2",
|
|
60
|
+
"2-5",
|
|
61
|
+
"3",
|
|
62
|
+
"4",
|
|
63
|
+
"5",
|
|
64
|
+
"6",
|
|
65
|
+
"8",
|
|
66
|
+
"10",
|
|
67
|
+
"12",
|
|
68
|
+
"16"
|
|
69
|
+
];
|
|
70
|
+
var sofyaGapNames = [
|
|
71
|
+
"tight",
|
|
72
|
+
"compact",
|
|
73
|
+
"default",
|
|
74
|
+
"comfortable",
|
|
75
|
+
"section",
|
|
76
|
+
"page"
|
|
77
|
+
];
|
|
78
|
+
var sofyaRhythmNames = [
|
|
79
|
+
"labelToControl",
|
|
80
|
+
"controlToHelp",
|
|
81
|
+
"titleToDescription",
|
|
82
|
+
"titleToBody",
|
|
83
|
+
"fieldset",
|
|
84
|
+
"fieldsetCompact",
|
|
85
|
+
"group",
|
|
86
|
+
"groupCompact",
|
|
87
|
+
"paragraphFlow",
|
|
88
|
+
"sectionContent"
|
|
89
|
+
];
|
|
90
|
+
var sofyaMeasureNames = ["reading", "compact", "wide"];
|
|
13
91
|
var sharedTypography = {
|
|
14
92
|
sans: '"Schibsted Grotesk", "Avenir Next", "Segoe UI", sans-serif',
|
|
15
93
|
display: '"Schibsted Grotesk", "Avenir Next", "Segoe UI", sans-serif',
|
|
@@ -197,6 +275,41 @@ function createFocusShadow(color) {
|
|
|
197
275
|
}
|
|
198
276
|
function createTextStyleScale(typography) {
|
|
199
277
|
return {
|
|
278
|
+
"display-xl": {
|
|
279
|
+
fontFamily: typography.display,
|
|
280
|
+
fontSize: "60px",
|
|
281
|
+
fontWeight: "400",
|
|
282
|
+
lineHeight: "64px",
|
|
283
|
+
letterSpacing: "-0.02em"
|
|
284
|
+
},
|
|
285
|
+
"display-lg": {
|
|
286
|
+
fontFamily: typography.display,
|
|
287
|
+
fontSize: "48px",
|
|
288
|
+
fontWeight: "400",
|
|
289
|
+
lineHeight: "52px",
|
|
290
|
+
letterSpacing: "-0.02em"
|
|
291
|
+
},
|
|
292
|
+
"heading-xl": {
|
|
293
|
+
fontFamily: typography.display,
|
|
294
|
+
fontSize: "36px",
|
|
295
|
+
fontWeight: "500",
|
|
296
|
+
lineHeight: "40px",
|
|
297
|
+
letterSpacing: "-0.01em"
|
|
298
|
+
},
|
|
299
|
+
"heading-lg": {
|
|
300
|
+
fontFamily: typography.display,
|
|
301
|
+
fontSize: "30px",
|
|
302
|
+
fontWeight: "500",
|
|
303
|
+
lineHeight: "36px",
|
|
304
|
+
letterSpacing: "-0.01em"
|
|
305
|
+
},
|
|
306
|
+
"heading-md": {
|
|
307
|
+
fontFamily: typography.display,
|
|
308
|
+
fontSize: "24px",
|
|
309
|
+
fontWeight: "600",
|
|
310
|
+
lineHeight: "30px",
|
|
311
|
+
letterSpacing: "-0.01em"
|
|
312
|
+
},
|
|
200
313
|
h1: {
|
|
201
314
|
fontFamily: typography.display,
|
|
202
315
|
fontSize: "48px",
|
|
@@ -232,6 +345,48 @@ function createTextStyleScale(typography) {
|
|
|
232
345
|
lineHeight: "23px",
|
|
233
346
|
letterSpacing: "0"
|
|
234
347
|
},
|
|
348
|
+
"encounter-title": {
|
|
349
|
+
fontFamily: typography.display,
|
|
350
|
+
fontSize: "22px",
|
|
351
|
+
fontWeight: "500",
|
|
352
|
+
lineHeight: "28px",
|
|
353
|
+
letterSpacing: "-0.022px"
|
|
354
|
+
},
|
|
355
|
+
"title-md": {
|
|
356
|
+
fontFamily: typography.display,
|
|
357
|
+
fontSize: "20px",
|
|
358
|
+
fontWeight: "500",
|
|
359
|
+
lineHeight: "28px",
|
|
360
|
+
letterSpacing: "0"
|
|
361
|
+
},
|
|
362
|
+
"title-sm": {
|
|
363
|
+
fontFamily: typography.display,
|
|
364
|
+
fontSize: "16px",
|
|
365
|
+
fontWeight: "500",
|
|
366
|
+
lineHeight: "24px",
|
|
367
|
+
letterSpacing: "0"
|
|
368
|
+
},
|
|
369
|
+
"body-lg": {
|
|
370
|
+
fontFamily: typography.sans,
|
|
371
|
+
fontSize: "18px",
|
|
372
|
+
fontWeight: "400",
|
|
373
|
+
lineHeight: "28px",
|
|
374
|
+
letterSpacing: "0"
|
|
375
|
+
},
|
|
376
|
+
"body-md": {
|
|
377
|
+
fontFamily: typography.sans,
|
|
378
|
+
fontSize: "16px",
|
|
379
|
+
fontWeight: "400",
|
|
380
|
+
lineHeight: "24px",
|
|
381
|
+
letterSpacing: "0"
|
|
382
|
+
},
|
|
383
|
+
"body-sm": {
|
|
384
|
+
fontFamily: typography.sans,
|
|
385
|
+
fontSize: "14px",
|
|
386
|
+
fontWeight: "400",
|
|
387
|
+
lineHeight: "20px",
|
|
388
|
+
letterSpacing: "0"
|
|
389
|
+
},
|
|
235
390
|
body: {
|
|
236
391
|
fontFamily: typography.sans,
|
|
237
392
|
fontSize: "16px",
|
|
@@ -239,6 +394,111 @@ function createTextStyleScale(typography) {
|
|
|
239
394
|
lineHeight: "26px",
|
|
240
395
|
letterSpacing: "0"
|
|
241
396
|
},
|
|
397
|
+
"label-md": {
|
|
398
|
+
fontFamily: typography.sans,
|
|
399
|
+
fontSize: "14px",
|
|
400
|
+
fontWeight: "500",
|
|
401
|
+
lineHeight: "20px",
|
|
402
|
+
letterSpacing: "0"
|
|
403
|
+
},
|
|
404
|
+
"section-label": {
|
|
405
|
+
fontFamily: typography.sans,
|
|
406
|
+
fontSize: "14px",
|
|
407
|
+
fontWeight: "600",
|
|
408
|
+
lineHeight: "18px",
|
|
409
|
+
letterSpacing: "0"
|
|
410
|
+
},
|
|
411
|
+
"eyebrow-md": {
|
|
412
|
+
fontFamily: typography.sans,
|
|
413
|
+
fontSize: "14px",
|
|
414
|
+
fontWeight: "500",
|
|
415
|
+
lineHeight: "20px",
|
|
416
|
+
letterSpacing: "0.08em"
|
|
417
|
+
},
|
|
418
|
+
"overline-md": {
|
|
419
|
+
fontFamily: typography.sans,
|
|
420
|
+
fontSize: "14px",
|
|
421
|
+
fontWeight: "500",
|
|
422
|
+
lineHeight: "20px",
|
|
423
|
+
letterSpacing: "0"
|
|
424
|
+
},
|
|
425
|
+
"sidebar-title": {
|
|
426
|
+
fontFamily: typography.sans,
|
|
427
|
+
fontSize: "14px",
|
|
428
|
+
fontWeight: "500",
|
|
429
|
+
lineHeight: "18px",
|
|
430
|
+
letterSpacing: "0.014px"
|
|
431
|
+
},
|
|
432
|
+
"sidebar-title-regular": {
|
|
433
|
+
fontFamily: typography.sans,
|
|
434
|
+
fontSize: "14px",
|
|
435
|
+
fontWeight: "400",
|
|
436
|
+
lineHeight: "18px",
|
|
437
|
+
letterSpacing: "0.014px"
|
|
438
|
+
},
|
|
439
|
+
"sidebar-title-strong": {
|
|
440
|
+
fontFamily: typography.sans,
|
|
441
|
+
fontSize: "14px",
|
|
442
|
+
fontWeight: "600",
|
|
443
|
+
lineHeight: "18px",
|
|
444
|
+
letterSpacing: "0.014px"
|
|
445
|
+
},
|
|
446
|
+
"sidebar-label": {
|
|
447
|
+
fontFamily: typography.sans,
|
|
448
|
+
fontSize: "12px",
|
|
449
|
+
fontWeight: "500",
|
|
450
|
+
lineHeight: "18px",
|
|
451
|
+
letterSpacing: "0.36px"
|
|
452
|
+
},
|
|
453
|
+
"sidebar-label-strong": {
|
|
454
|
+
fontFamily: typography.sans,
|
|
455
|
+
fontSize: "12px",
|
|
456
|
+
fontWeight: "600",
|
|
457
|
+
lineHeight: "18px",
|
|
458
|
+
letterSpacing: "0.36px"
|
|
459
|
+
},
|
|
460
|
+
"sidebar-body": {
|
|
461
|
+
fontFamily: typography.sans,
|
|
462
|
+
fontSize: "12px",
|
|
463
|
+
fontWeight: "400",
|
|
464
|
+
lineHeight: "18px",
|
|
465
|
+
letterSpacing: "0.012px"
|
|
466
|
+
},
|
|
467
|
+
"sidebar-tag": {
|
|
468
|
+
fontFamily: typography.sans,
|
|
469
|
+
fontSize: "13px",
|
|
470
|
+
fontWeight: "500",
|
|
471
|
+
lineHeight: "20px",
|
|
472
|
+
letterSpacing: "0.013px"
|
|
473
|
+
},
|
|
474
|
+
"encounter-chip": {
|
|
475
|
+
fontFamily: typography.sans,
|
|
476
|
+
fontSize: "13px",
|
|
477
|
+
fontWeight: "500",
|
|
478
|
+
lineHeight: "20px",
|
|
479
|
+
letterSpacing: "0"
|
|
480
|
+
},
|
|
481
|
+
"encounter-history": {
|
|
482
|
+
fontFamily: typography.sans,
|
|
483
|
+
fontSize: "12px",
|
|
484
|
+
fontWeight: "600",
|
|
485
|
+
lineHeight: "18px",
|
|
486
|
+
letterSpacing: "0.012px"
|
|
487
|
+
},
|
|
488
|
+
caption: {
|
|
489
|
+
fontFamily: typography.sans,
|
|
490
|
+
fontSize: "12px",
|
|
491
|
+
fontWeight: "400",
|
|
492
|
+
lineHeight: "16px",
|
|
493
|
+
letterSpacing: "0"
|
|
494
|
+
},
|
|
495
|
+
eyebrow: {
|
|
496
|
+
fontFamily: typography.sans,
|
|
497
|
+
fontSize: "12px",
|
|
498
|
+
fontWeight: "600",
|
|
499
|
+
lineHeight: "16px",
|
|
500
|
+
letterSpacing: "0.08em"
|
|
501
|
+
},
|
|
242
502
|
tiny: {
|
|
243
503
|
fontFamily: typography.sans,
|
|
244
504
|
fontSize: "14px",
|
|
@@ -252,11 +512,32 @@ function createTextStyleScale(typography) {
|
|
|
252
512
|
fontWeight: "400",
|
|
253
513
|
lineHeight: "18px",
|
|
254
514
|
letterSpacing: "0.012px"
|
|
515
|
+
},
|
|
516
|
+
"code-sm": {
|
|
517
|
+
fontFamily: typography.mono,
|
|
518
|
+
fontSize: "13px",
|
|
519
|
+
fontWeight: "400",
|
|
520
|
+
lineHeight: "20px",
|
|
521
|
+
letterSpacing: "0"
|
|
255
522
|
}
|
|
256
523
|
};
|
|
257
524
|
}
|
|
258
525
|
function createSurfaceScale(colors, radii, shadows) {
|
|
259
526
|
return {
|
|
527
|
+
appBackground: {
|
|
528
|
+
background: colors.background,
|
|
529
|
+
borderColor: colors.background,
|
|
530
|
+
borderWidth: "0",
|
|
531
|
+
radius: "0",
|
|
532
|
+
shadow: "none"
|
|
533
|
+
},
|
|
534
|
+
auth: {
|
|
535
|
+
background: colors.background,
|
|
536
|
+
borderColor: colors.background,
|
|
537
|
+
borderWidth: "0",
|
|
538
|
+
radius: radii.xl,
|
|
539
|
+
shadow: "none"
|
|
540
|
+
},
|
|
260
541
|
card: {
|
|
261
542
|
background: colors.card,
|
|
262
543
|
borderColor: colors.subtle,
|
|
@@ -264,11 +545,32 @@ function createSurfaceScale(colors, radii, shadows) {
|
|
|
264
545
|
radius: radii.xl,
|
|
265
546
|
shadow: "none"
|
|
266
547
|
},
|
|
267
|
-
|
|
548
|
+
dataTable: {
|
|
268
549
|
background: colors.card,
|
|
269
550
|
borderColor: colors.subtle,
|
|
270
551
|
borderWidth: "1px",
|
|
271
|
-
radius: radii.
|
|
552
|
+
radius: radii.md,
|
|
553
|
+
shadow: "none"
|
|
554
|
+
},
|
|
555
|
+
dialog: {
|
|
556
|
+
background: colors.card,
|
|
557
|
+
borderColor: colors.subtle,
|
|
558
|
+
borderWidth: "1px",
|
|
559
|
+
radius: radii.xl,
|
|
560
|
+
shadow: "none"
|
|
561
|
+
},
|
|
562
|
+
documentCard: {
|
|
563
|
+
background: colors.card,
|
|
564
|
+
borderColor: colors.subtle,
|
|
565
|
+
borderWidth: "1px",
|
|
566
|
+
radius: radii.md,
|
|
567
|
+
shadow: "none"
|
|
568
|
+
},
|
|
569
|
+
documentCardSelected: {
|
|
570
|
+
background: colors.muted,
|
|
571
|
+
borderColor: colors.subtle,
|
|
572
|
+
borderWidth: "1px",
|
|
573
|
+
radius: radii.md,
|
|
272
574
|
shadow: "none"
|
|
273
575
|
},
|
|
274
576
|
focus: {
|
|
@@ -277,6 +579,102 @@ function createSurfaceScale(colors, radii, shadows) {
|
|
|
277
579
|
borderWidth: "1px",
|
|
278
580
|
radius: radii.sm,
|
|
279
581
|
shadow: shadows.focus
|
|
582
|
+
},
|
|
583
|
+
mainContent: {
|
|
584
|
+
background: colors.background,
|
|
585
|
+
borderColor: colors.background,
|
|
586
|
+
borderWidth: "0",
|
|
587
|
+
radius: "0",
|
|
588
|
+
shadow: "none"
|
|
589
|
+
},
|
|
590
|
+
panel: {
|
|
591
|
+
background: colors.card,
|
|
592
|
+
borderColor: colors.subtle,
|
|
593
|
+
borderWidth: "1px",
|
|
594
|
+
radius: radii.sm,
|
|
595
|
+
shadow: "none"
|
|
596
|
+
},
|
|
597
|
+
proseDialog: {
|
|
598
|
+
background: colors.card,
|
|
599
|
+
borderColor: colors.subtle,
|
|
600
|
+
borderWidth: "1px",
|
|
601
|
+
radius: radii.xl,
|
|
602
|
+
shadow: "none"
|
|
603
|
+
},
|
|
604
|
+
rightPanel: {
|
|
605
|
+
background: colors.background,
|
|
606
|
+
borderColor: colors.subtle,
|
|
607
|
+
borderWidth: "1px",
|
|
608
|
+
radius: radii.xl,
|
|
609
|
+
shadow: "none"
|
|
610
|
+
},
|
|
611
|
+
sidebar: {
|
|
612
|
+
background: colors.background,
|
|
613
|
+
borderColor: colors.subtle,
|
|
614
|
+
borderWidth: "0",
|
|
615
|
+
radius: "0",
|
|
616
|
+
shadow: "none"
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function createSpacingScale() {
|
|
621
|
+
return {
|
|
622
|
+
space: {
|
|
623
|
+
"0": "0rem",
|
|
624
|
+
"0-5": "0.125rem",
|
|
625
|
+
"1": "0.25rem",
|
|
626
|
+
"1-5": "0.375rem",
|
|
627
|
+
"2": "0.5rem",
|
|
628
|
+
"2-5": "0.625rem",
|
|
629
|
+
"3": "0.75rem",
|
|
630
|
+
"4": "1rem",
|
|
631
|
+
"5": "1.25rem",
|
|
632
|
+
"6": "1.5rem",
|
|
633
|
+
"8": "2rem",
|
|
634
|
+
"10": "2.5rem",
|
|
635
|
+
"12": "3rem",
|
|
636
|
+
"16": "4rem"
|
|
637
|
+
},
|
|
638
|
+
gap: {
|
|
639
|
+
tight: "0.375rem",
|
|
640
|
+
compact: "0.5rem",
|
|
641
|
+
default: "0.75rem",
|
|
642
|
+
comfortable: "1rem",
|
|
643
|
+
section: "2rem",
|
|
644
|
+
page: "3rem"
|
|
645
|
+
},
|
|
646
|
+
rhythm: {
|
|
647
|
+
labelToControl: "0.5rem",
|
|
648
|
+
controlToHelp: "0.5rem",
|
|
649
|
+
titleToDescription: "0.5rem",
|
|
650
|
+
titleToBody: "0.5rem",
|
|
651
|
+
fieldset: "1.5rem",
|
|
652
|
+
fieldsetCompact: "0.75rem",
|
|
653
|
+
group: "1.5rem",
|
|
654
|
+
groupCompact: "1rem",
|
|
655
|
+
paragraphFlow: "1.5rem",
|
|
656
|
+
sectionContent: "2rem"
|
|
657
|
+
},
|
|
658
|
+
measure: {
|
|
659
|
+
reading: "65ch",
|
|
660
|
+
compact: "60ch",
|
|
661
|
+
wide: "72ch"
|
|
662
|
+
},
|
|
663
|
+
control: {
|
|
664
|
+
xs: "2rem",
|
|
665
|
+
sm: "2.25rem",
|
|
666
|
+
md: "2.5rem",
|
|
667
|
+
lg: "2.75rem"
|
|
668
|
+
},
|
|
669
|
+
iconButton: {
|
|
670
|
+
sm: "2rem",
|
|
671
|
+
md: "2.5rem",
|
|
672
|
+
lg: "3rem"
|
|
673
|
+
},
|
|
674
|
+
layout: {
|
|
675
|
+
sidebarWidth: "18.75rem",
|
|
676
|
+
rightRailWidth: "4.625rem",
|
|
677
|
+
proseDialogWidth: "53.125rem"
|
|
280
678
|
}
|
|
281
679
|
};
|
|
282
680
|
}
|
|
@@ -302,6 +700,38 @@ function mergeSurfaceScale(baseScale, overrides) {
|
|
|
302
700
|
])
|
|
303
701
|
);
|
|
304
702
|
}
|
|
703
|
+
function mergeSpacingScale(baseScale, overrides) {
|
|
704
|
+
return {
|
|
705
|
+
space: {
|
|
706
|
+
...baseScale.space,
|
|
707
|
+
...overrides?.space
|
|
708
|
+
},
|
|
709
|
+
gap: {
|
|
710
|
+
...baseScale.gap,
|
|
711
|
+
...overrides?.gap
|
|
712
|
+
},
|
|
713
|
+
rhythm: {
|
|
714
|
+
...baseScale.rhythm,
|
|
715
|
+
...overrides?.rhythm
|
|
716
|
+
},
|
|
717
|
+
measure: {
|
|
718
|
+
...baseScale.measure,
|
|
719
|
+
...overrides?.measure
|
|
720
|
+
},
|
|
721
|
+
control: {
|
|
722
|
+
...baseScale.control,
|
|
723
|
+
...overrides?.control
|
|
724
|
+
},
|
|
725
|
+
iconButton: {
|
|
726
|
+
...baseScale.iconButton,
|
|
727
|
+
...overrides?.iconButton
|
|
728
|
+
},
|
|
729
|
+
layout: {
|
|
730
|
+
...baseScale.layout,
|
|
731
|
+
...overrides?.layout
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
}
|
|
305
735
|
var sofyaColors = createColorScale(sofyaSemanticColorHex);
|
|
306
736
|
var sofyaRadii = {
|
|
307
737
|
sm: "0.5rem",
|
|
@@ -418,7 +848,8 @@ var sofyaTheme = {
|
|
|
418
848
|
shadows: sofyaShadows,
|
|
419
849
|
typography: sharedTypography,
|
|
420
850
|
textStyles: createTextStyleScale(sharedTypography),
|
|
421
|
-
surfaces: createSurfaceScale(sofyaColors, sofyaRadii, sofyaShadows)
|
|
851
|
+
surfaces: createSurfaceScale(sofyaColors, sofyaRadii, sofyaShadows),
|
|
852
|
+
spacing: createSpacingScale()
|
|
422
853
|
};
|
|
423
854
|
var oceanTheme = {
|
|
424
855
|
name: "ocean",
|
|
@@ -427,7 +858,8 @@ var oceanTheme = {
|
|
|
427
858
|
shadows: oceanShadows,
|
|
428
859
|
typography: sharedTypography,
|
|
429
860
|
textStyles: createTextStyleScale(sharedTypography),
|
|
430
|
-
surfaces: createSurfaceScale(oceanColors, oceanRadii, oceanShadows)
|
|
861
|
+
surfaces: createSurfaceScale(oceanColors, oceanRadii, oceanShadows),
|
|
862
|
+
spacing: createSpacingScale()
|
|
431
863
|
};
|
|
432
864
|
var midnightTheme = {
|
|
433
865
|
name: "midnight",
|
|
@@ -436,7 +868,8 @@ var midnightTheme = {
|
|
|
436
868
|
shadows: midnightShadows,
|
|
437
869
|
typography: sharedTypography,
|
|
438
870
|
textStyles: createTextStyleScale(sharedTypography),
|
|
439
|
-
surfaces: createSurfaceScale(midnightColors, midnightRadii, midnightShadows)
|
|
871
|
+
surfaces: createSurfaceScale(midnightColors, midnightRadii, midnightShadows),
|
|
872
|
+
spacing: createSpacingScale()
|
|
440
873
|
};
|
|
441
874
|
var themePresets = {
|
|
442
875
|
sofya: sofyaTheme,
|
|
@@ -460,7 +893,8 @@ function mergeTheme(baseTheme, overrides) {
|
|
|
460
893
|
shadows: { ...baseTheme.shadows },
|
|
461
894
|
typography: { ...baseTheme.typography },
|
|
462
895
|
textStyles: mergeTextStyleScale(baseTheme.textStyles),
|
|
463
|
-
surfaces: mergeSurfaceScale(baseTheme.surfaces)
|
|
896
|
+
surfaces: mergeSurfaceScale(baseTheme.surfaces),
|
|
897
|
+
spacing: mergeSpacingScale(baseTheme.spacing)
|
|
464
898
|
};
|
|
465
899
|
}
|
|
466
900
|
const colors = {
|
|
@@ -488,6 +922,7 @@ function mergeTheme(baseTheme, overrides) {
|
|
|
488
922
|
createSurfaceScale(colors, radii, shadows),
|
|
489
923
|
overrides.surfaces
|
|
490
924
|
);
|
|
925
|
+
const spacing = mergeSpacingScale(createSpacingScale(), overrides.spacing);
|
|
491
926
|
return {
|
|
492
927
|
name: overrides.name ?? baseTheme.name,
|
|
493
928
|
colors,
|
|
@@ -495,7 +930,8 @@ function mergeTheme(baseTheme, overrides) {
|
|
|
495
930
|
shadows,
|
|
496
931
|
typography,
|
|
497
932
|
textStyles,
|
|
498
|
-
surfaces
|
|
933
|
+
surfaces,
|
|
934
|
+
spacing
|
|
499
935
|
};
|
|
500
936
|
}
|
|
501
937
|
function resolveTheme(preset = defaultTheme, overrides) {
|
|
@@ -513,6 +949,71 @@ function themeDecorativeCssVariables(theme) {
|
|
|
513
949
|
"--sofya-logo-soft": `hsl(${theme.colors.primary} / 0.45)`
|
|
514
950
|
};
|
|
515
951
|
}
|
|
952
|
+
function toCssTokenName(name) {
|
|
953
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
954
|
+
}
|
|
955
|
+
function textStyleCssVariables(textStyles) {
|
|
956
|
+
return Object.fromEntries(
|
|
957
|
+
sofyaTextStyleNames.flatMap((name) => {
|
|
958
|
+
const cssName = toCssTokenName(name);
|
|
959
|
+
const style = textStyles[name];
|
|
960
|
+
return [
|
|
961
|
+
[`--sofya-text-${cssName}-font-family`, style.fontFamily],
|
|
962
|
+
[`--sofya-text-${cssName}-font-size`, style.fontSize],
|
|
963
|
+
[`--sofya-text-${cssName}-font-weight`, style.fontWeight],
|
|
964
|
+
[`--sofya-text-${cssName}-line-height`, style.lineHeight],
|
|
965
|
+
[`--sofya-text-${cssName}-letter-spacing`, style.letterSpacing]
|
|
966
|
+
];
|
|
967
|
+
})
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
function surfaceCssVariables(surfaces) {
|
|
971
|
+
return Object.fromEntries(
|
|
972
|
+
sofyaSurfaceNames.flatMap((name) => {
|
|
973
|
+
const cssName = toCssTokenName(name);
|
|
974
|
+
const surface = surfaces[name];
|
|
975
|
+
return [
|
|
976
|
+
[`--sofya-surface-${cssName}-background`, surface.background],
|
|
977
|
+
[`--sofya-surface-${cssName}-border-color`, surface.borderColor],
|
|
978
|
+
[`--sofya-surface-${cssName}-border-width`, surface.borderWidth],
|
|
979
|
+
[`--sofya-surface-${cssName}-radius`, surface.radius],
|
|
980
|
+
[`--sofya-surface-${cssName}-shadow`, surface.shadow]
|
|
981
|
+
];
|
|
982
|
+
})
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
function spacingCssVariables(spacing) {
|
|
986
|
+
return {
|
|
987
|
+
...Object.fromEntries(
|
|
988
|
+
sofyaSpaceNames.map((name) => [`--sofya-space-${name}`, spacing.space[name]])
|
|
989
|
+
),
|
|
990
|
+
...Object.fromEntries(
|
|
991
|
+
sofyaGapNames.map((name) => [`--sofya-gap-${name}`, spacing.gap[name]])
|
|
992
|
+
),
|
|
993
|
+
...Object.fromEntries(
|
|
994
|
+
sofyaRhythmNames.map((name) => [
|
|
995
|
+
`--sofya-rhythm-${toCssTokenName(name)}`,
|
|
996
|
+
spacing.rhythm[name]
|
|
997
|
+
])
|
|
998
|
+
),
|
|
999
|
+
...Object.fromEntries(
|
|
1000
|
+
sofyaMeasureNames.map((name) => [
|
|
1001
|
+
`--sofya-measure-${name}`,
|
|
1002
|
+
spacing.measure[name]
|
|
1003
|
+
])
|
|
1004
|
+
),
|
|
1005
|
+
"--sofya-control-height-xs": spacing.control.xs,
|
|
1006
|
+
"--sofya-control-height-sm": spacing.control.sm,
|
|
1007
|
+
"--sofya-control-height-md": spacing.control.md,
|
|
1008
|
+
"--sofya-control-height-lg": spacing.control.lg,
|
|
1009
|
+
"--sofya-icon-button-size-sm": spacing.iconButton.sm,
|
|
1010
|
+
"--sofya-icon-button-size-md": spacing.iconButton.md,
|
|
1011
|
+
"--sofya-icon-button-size-lg": spacing.iconButton.lg,
|
|
1012
|
+
"--sofya-layout-sidebar-width": spacing.layout.sidebarWidth,
|
|
1013
|
+
"--sofya-layout-right-rail-width": spacing.layout.rightRailWidth,
|
|
1014
|
+
"--sofya-layout-prose-dialog-width": spacing.layout.proseDialogWidth
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
516
1017
|
function themeToCssVariables(theme) {
|
|
517
1018
|
const textStyles = Object.fromEntries(
|
|
518
1019
|
sofyaTextStyleNames.map((name) => [name, resolveTextStyle(name, theme)])
|
|
@@ -564,56 +1065,9 @@ function themeToCssVariables(theme) {
|
|
|
564
1065
|
"--sofya-font-sans": theme.typography.sans,
|
|
565
1066
|
"--sofya-font-display": theme.typography.display,
|
|
566
1067
|
"--sofya-font-mono": theme.typography.mono,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
"--sofya-text-h1-line-height": textStyles.h1.lineHeight,
|
|
571
|
-
"--sofya-text-h1-letter-spacing": textStyles.h1.letterSpacing,
|
|
572
|
-
"--sofya-text-h2-font-family": textStyles.h2.fontFamily,
|
|
573
|
-
"--sofya-text-h2-font-size": textStyles.h2.fontSize,
|
|
574
|
-
"--sofya-text-h2-font-weight": textStyles.h2.fontWeight,
|
|
575
|
-
"--sofya-text-h2-line-height": textStyles.h2.lineHeight,
|
|
576
|
-
"--sofya-text-h2-letter-spacing": textStyles.h2.letterSpacing,
|
|
577
|
-
"--sofya-text-h3-font-family": textStyles.h3.fontFamily,
|
|
578
|
-
"--sofya-text-h3-font-size": textStyles.h3.fontSize,
|
|
579
|
-
"--sofya-text-h3-font-weight": textStyles.h3.fontWeight,
|
|
580
|
-
"--sofya-text-h3-line-height": textStyles.h3.lineHeight,
|
|
581
|
-
"--sofya-text-h3-letter-spacing": textStyles.h3.letterSpacing,
|
|
582
|
-
"--sofya-text-h4-font-family": textStyles.h4.fontFamily,
|
|
583
|
-
"--sofya-text-h4-font-size": textStyles.h4.fontSize,
|
|
584
|
-
"--sofya-text-h4-font-weight": textStyles.h4.fontWeight,
|
|
585
|
-
"--sofya-text-h4-line-height": textStyles.h4.lineHeight,
|
|
586
|
-
"--sofya-text-h4-letter-spacing": textStyles.h4.letterSpacing,
|
|
587
|
-
"--sofya-text-h5-font-family": textStyles.h5.fontFamily,
|
|
588
|
-
"--sofya-text-h5-font-size": textStyles.h5.fontSize,
|
|
589
|
-
"--sofya-text-h5-font-weight": textStyles.h5.fontWeight,
|
|
590
|
-
"--sofya-text-h5-line-height": textStyles.h5.lineHeight,
|
|
591
|
-
"--sofya-text-h5-letter-spacing": textStyles.h5.letterSpacing,
|
|
592
|
-
"--sofya-text-body-font-family": textStyles.body.fontFamily,
|
|
593
|
-
"--sofya-text-body-font-size": textStyles.body.fontSize,
|
|
594
|
-
"--sofya-text-body-font-weight": textStyles.body.fontWeight,
|
|
595
|
-
"--sofya-text-body-line-height": textStyles.body.lineHeight,
|
|
596
|
-
"--sofya-text-body-letter-spacing": textStyles.body.letterSpacing,
|
|
597
|
-
"--sofya-text-tiny-font-family": textStyles.tiny.fontFamily,
|
|
598
|
-
"--sofya-text-tiny-font-size": textStyles.tiny.fontSize,
|
|
599
|
-
"--sofya-text-tiny-font-weight": textStyles.tiny.fontWeight,
|
|
600
|
-
"--sofya-text-tiny-line-height": textStyles.tiny.lineHeight,
|
|
601
|
-
"--sofya-text-tiny-letter-spacing": textStyles.tiny.letterSpacing,
|
|
602
|
-
"--sofya-surface-card-background": surfaces.card.background,
|
|
603
|
-
"--sofya-surface-card-border-color": surfaces.card.borderColor,
|
|
604
|
-
"--sofya-surface-card-border-width": surfaces.card.borderWidth,
|
|
605
|
-
"--sofya-surface-card-radius": surfaces.card.radius,
|
|
606
|
-
"--sofya-surface-card-shadow": surfaces.card.shadow,
|
|
607
|
-
"--sofya-surface-panel-background": surfaces.panel.background,
|
|
608
|
-
"--sofya-surface-panel-border-color": surfaces.panel.borderColor,
|
|
609
|
-
"--sofya-surface-panel-border-width": surfaces.panel.borderWidth,
|
|
610
|
-
"--sofya-surface-panel-radius": surfaces.panel.radius,
|
|
611
|
-
"--sofya-surface-panel-shadow": surfaces.panel.shadow,
|
|
612
|
-
"--sofya-surface-focus-background": surfaces.focus.background,
|
|
613
|
-
"--sofya-surface-focus-border-color": surfaces.focus.borderColor,
|
|
614
|
-
"--sofya-surface-focus-border-width": surfaces.focus.borderWidth,
|
|
615
|
-
"--sofya-surface-focus-radius": surfaces.focus.radius,
|
|
616
|
-
"--sofya-surface-focus-shadow": surfaces.focus.shadow
|
|
1068
|
+
...textStyleCssVariables(textStyles),
|
|
1069
|
+
...surfaceCssVariables(surfaces),
|
|
1070
|
+
...spacingCssVariables(theme.spacing)
|
|
617
1071
|
};
|
|
618
1072
|
}
|
|
619
1073
|
function createWhitelabelTheme(overrides, preset = defaultTheme) {
|
|
@@ -631,7 +1085,11 @@ export {
|
|
|
631
1085
|
resolveTheme,
|
|
632
1086
|
sofyaBrandPalette,
|
|
633
1087
|
sofyaColorPalette,
|
|
1088
|
+
sofyaGapNames,
|
|
1089
|
+
sofyaMeasureNames,
|
|
1090
|
+
sofyaRhythmNames,
|
|
634
1091
|
sofyaSemanticColorHex,
|
|
1092
|
+
sofyaSpaceNames,
|
|
635
1093
|
sofyaSurfaceNames,
|
|
636
1094
|
sofyaTextStyleNames,
|
|
637
1095
|
themePresetNames,
|