@frontile/theme 0.18.11 → 0.18.12
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/declarations/components/badge.d.ts +15 -0
- package/declarations/components/badge.d.ts.map +1 -1
- package/declarations/components/button.d.ts +13 -1
- package/declarations/components/button.d.ts.map +1 -1
- package/declarations/components/card.d.ts +76 -0
- package/declarations/components/card.d.ts.map +1 -0
- package/declarations/components/chip.d.ts +18 -0
- package/declarations/components/chip.d.ts.map +1 -1
- package/declarations/components/icon.d.ts +37 -0
- package/declarations/components/icon.d.ts.map +1 -0
- package/declarations/components/index.d.ts +2 -0
- package/declarations/components/index.d.ts.map +1 -1
- package/dist/index.js +535 -46
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/styles/theme.css +14 -9
package/dist/index.js
CHANGED
|
@@ -423,7 +423,9 @@ const avatar = tv({
|
|
|
423
423
|
|
|
424
424
|
const badge = tv({
|
|
425
425
|
slots: {
|
|
426
|
-
|
|
426
|
+
// Regular weight; the `text-strong-*` size tokens would set bold, so the
|
|
427
|
+
// weight is pinned here and only `value` is heavier.
|
|
428
|
+
base: 'inline-flex items-center whitespace-nowrap font-label font-normal leading-none',
|
|
427
429
|
// emphasized value, e.g. a price
|
|
428
430
|
value: 'font-bold tabular-nums leading-none',
|
|
429
431
|
// unit following the value, e.g. "/mo"
|
|
@@ -457,32 +459,49 @@ const badge = tv({
|
|
|
457
459
|
dot: 'bg-danger'
|
|
458
460
|
}
|
|
459
461
|
},
|
|
460
|
-
//
|
|
461
|
-
//
|
|
462
|
-
//
|
|
463
|
-
//
|
|
464
|
-
//
|
|
465
|
-
//
|
|
462
|
+
// Text follows Button's ramp: the same `@size` gives the same
|
|
463
|
+
// `text-strong-*` token on Badge, Chip and Button. Value and unit share
|
|
464
|
+
// the label's font size so their baselines line up; the value is set apart
|
|
465
|
+
// by weight only. Heights and padding are Badge's own, chosen so the text
|
|
466
|
+
// fits. Radius steps with size and is never a pill: that shape belongs
|
|
467
|
+
// to Chip.
|
|
466
468
|
size: {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
+
// Smaller than Button's smallest size: the next `text-strong-*` step
|
|
470
|
+
// down (12.3px), 20px tall.
|
|
471
|
+
'2xs': {
|
|
472
|
+
base: 'text-strong-2xs h-5 px-1.5 gap-1 rounded-sm',
|
|
469
473
|
dot: 'size-1.5',
|
|
470
474
|
icon: 'size-3'
|
|
471
475
|
},
|
|
476
|
+
xs: {
|
|
477
|
+
base: 'text-strong-xs h-6 px-2 gap-1 rounded-sm',
|
|
478
|
+
dot: 'size-2',
|
|
479
|
+
icon: 'size-3.5'
|
|
480
|
+
},
|
|
472
481
|
sm: {
|
|
473
|
-
base: 'text-
|
|
474
|
-
dot: 'size-
|
|
475
|
-
icon: 'size-
|
|
482
|
+
base: 'text-strong-sm h-7 px-2.5 gap-1.5 rounded-sm',
|
|
483
|
+
dot: 'size-2',
|
|
484
|
+
icon: 'size-4'
|
|
476
485
|
},
|
|
477
486
|
md: {
|
|
478
|
-
base: 'text-
|
|
487
|
+
base: 'text-strong-md h-8 px-3 gap-1.5 rounded-md',
|
|
479
488
|
dot: 'size-2',
|
|
480
|
-
icon: 'size-
|
|
489
|
+
icon: 'size-4'
|
|
481
490
|
},
|
|
482
491
|
lg: {
|
|
483
|
-
base: 'text-
|
|
492
|
+
base: 'text-strong-lg h-10 px-4 gap-2 rounded-md',
|
|
484
493
|
dot: 'size-2.5',
|
|
485
|
-
icon: 'size-
|
|
494
|
+
icon: 'size-5'
|
|
495
|
+
},
|
|
496
|
+
xl: {
|
|
497
|
+
base: 'text-strong-xl h-11 px-5 gap-2 rounded-lg',
|
|
498
|
+
dot: 'size-3',
|
|
499
|
+
icon: 'size-6'
|
|
500
|
+
},
|
|
501
|
+
'2xl': {
|
|
502
|
+
base: 'text-strong-2xl h-14 px-6 gap-2.5 rounded-lg',
|
|
503
|
+
dot: 'size-3.5',
|
|
504
|
+
icon: 'size-8'
|
|
486
505
|
}
|
|
487
506
|
}
|
|
488
507
|
},
|
|
@@ -564,7 +583,7 @@ const badge = tv({
|
|
|
564
583
|
}
|
|
565
584
|
}],
|
|
566
585
|
defaultVariants: {
|
|
567
|
-
size: '
|
|
586
|
+
size: 'xs',
|
|
568
587
|
color: 'neutral',
|
|
569
588
|
variant: 'soft'
|
|
570
589
|
}
|
|
@@ -668,7 +687,7 @@ const breadcrumbs = tv({
|
|
|
668
687
|
});
|
|
669
688
|
|
|
670
689
|
const baseButton = tv({
|
|
671
|
-
base: ['inline-flex items-center justify-center', '[&_svg]:size-[1em]', 'font-header', 'border', 'border-transparent', 'disabled:cursor-not-allowed', 'disabled:opacity-disabled', ...focusVisibleRing],
|
|
690
|
+
base: ['inline-flex items-center justify-center', '[&_svg]:size-[1em]', 'font-header', 'border', 'border-transparent', 'cursor-pointer', 'disabled:cursor-not-allowed', 'disabled:opacity-disabled', ...focusVisibleRing],
|
|
672
691
|
variants: {
|
|
673
692
|
variant: {
|
|
674
693
|
outline: ''
|
|
@@ -728,6 +747,7 @@ const baseButton = tv({
|
|
|
728
747
|
color: 'neutral'
|
|
729
748
|
}
|
|
730
749
|
});
|
|
750
|
+
const glassColors = ['neutral', 'primary', 'secondary', 'tertiary', 'success', 'warning', 'danger'];
|
|
731
751
|
const button = tv({
|
|
732
752
|
extend: baseButton,
|
|
733
753
|
base: [''],
|
|
@@ -739,7 +759,9 @@ const button = tv({
|
|
|
739
759
|
outline: '',
|
|
740
760
|
ghost: '',
|
|
741
761
|
plain: '',
|
|
742
|
-
custom: ''
|
|
762
|
+
custom: '',
|
|
763
|
+
glass: '',
|
|
764
|
+
link: ''
|
|
743
765
|
},
|
|
744
766
|
isLoading: {
|
|
745
767
|
true: 'disabled:cursor-progress'
|
|
@@ -792,7 +814,7 @@ const button = tv({
|
|
|
792
814
|
}, {
|
|
793
815
|
variant: 'subtle',
|
|
794
816
|
color: 'tertiary',
|
|
795
|
-
class: 'bg-tertiary-soft border-tertiary-strong text-tertiary-strong hover:bg-tertiary-subtle hover:border-tertiary-firm hover:text-tertiary active:bg-tertiary-muted active:border-tertiary-bolder active:text-tertiary-bolder'
|
|
817
|
+
class: 'bg-tertiary-soft border-tertiary-strong text-tertiary-strong hover:bg-tertiary-subtle hover:border-tertiary-firm hover:text-tertiary-firm active:bg-tertiary-muted active:border-tertiary-bolder active:text-tertiary-bolder'
|
|
796
818
|
}, {
|
|
797
819
|
variant: 'subtle',
|
|
798
820
|
color: 'success',
|
|
@@ -822,7 +844,7 @@ const button = tv({
|
|
|
822
844
|
}, {
|
|
823
845
|
variant: 'plain',
|
|
824
846
|
color: 'tertiary',
|
|
825
|
-
class: 'text-tertiary-strong hover:text-tertiary active:text-tertiary-bolder'
|
|
847
|
+
class: 'text-tertiary-strong hover:text-tertiary-firm active:text-tertiary-bolder'
|
|
826
848
|
}, {
|
|
827
849
|
variant: 'plain',
|
|
828
850
|
color: 'success',
|
|
@@ -841,7 +863,7 @@ const button = tv({
|
|
|
841
863
|
{
|
|
842
864
|
variant: 'ghost',
|
|
843
865
|
color: 'neutral',
|
|
844
|
-
class: 'text-neutral-bolder hover:bg-neutral-subtle hover:text-neutral-
|
|
866
|
+
class: 'text-neutral-bolder hover:bg-neutral-subtle hover:text-neutral-strong active:bg-neutral-muted active:text-neutral-firm'
|
|
845
867
|
}, {
|
|
846
868
|
variant: 'ghost',
|
|
847
869
|
color: 'primary',
|
|
@@ -926,7 +948,28 @@ const button = tv({
|
|
|
926
948
|
variant: 'custom',
|
|
927
949
|
color: 'danger',
|
|
928
950
|
class: 'text-danger-strong'
|
|
929
|
-
}
|
|
951
|
+
},
|
|
952
|
+
// VARIANT: link — ink only, no side padding, underline on hover, so it sits
|
|
953
|
+
// inline with text. Ink steps follow `plain`; neutral keeps its ink on hover
|
|
954
|
+
// and only underlines. `px-0` comes after the size's `px-*`, so
|
|
955
|
+
// tailwind-merge drops the size padding.
|
|
956
|
+
...[['neutral', 'text-on-neutral-subtle active:text-neutral-firm'], ['primary', 'text-primary hover:text-primary-mild active:text-primary-firm'], ['secondary', 'text-secondary-strong hover:text-secondary-firm active:text-secondary-bolder'], ['tertiary', 'text-tertiary-strong hover:text-tertiary-firm active:text-tertiary-bolder'], ['success', 'text-success-strong hover:text-success-firm active:text-success-bolder'], ['warning', 'text-warning-strong hover:text-warning-firm active:text-warning-bolder'], ['danger', 'text-danger hover:text-danger-mild active:text-danger-firm']].map(([color, ink]) => ({
|
|
957
|
+
variant: 'link',
|
|
958
|
+
color,
|
|
959
|
+
class: [ink, 'px-0 hover:underline underline-offset-4 disabled:no-underline']
|
|
960
|
+
})),
|
|
961
|
+
// VARIANT: glass — a translucent scrim for use over a colored or imaged
|
|
962
|
+
// surface: black with white ink in light mode, white with black ink in
|
|
963
|
+
// dark mode. It flips with the app theme, but deliberately not through the
|
|
964
|
+
// scope tokens: brand fills go dark in light mode and light in dark mode,
|
|
965
|
+
// so the page's own ink (`on-surface`) would be the wrong pairing for them. `color` is ignored: every
|
|
966
|
+
// color gets the same classes, and the non-neutral ones also reset the
|
|
967
|
+
// focus ring that `baseButton` tints per color.
|
|
968
|
+
...glassColors.map(color => ({
|
|
969
|
+
variant: 'glass',
|
|
970
|
+
color,
|
|
971
|
+
class: ['bg-black/20 text-white backdrop-blur-md', 'hover:bg-black/30 active:bg-black/40', 'dark:bg-white/20 dark:text-black dark:hover:bg-white/30 dark:active:bg-white/40', color === 'neutral' ? '' : 'focus-visible:ring-focus']
|
|
972
|
+
}))],
|
|
930
973
|
defaultVariants: {
|
|
931
974
|
size: 'md',
|
|
932
975
|
color: 'primary',
|
|
@@ -998,11 +1041,37 @@ const buttonSpinner = tv({
|
|
|
998
1041
|
base: 'size-[1em] text-current/25 fill-current'
|
|
999
1042
|
});
|
|
1000
1043
|
|
|
1044
|
+
// An icon-only button is a circle. IconButton passes this recipe's classes as
|
|
1045
|
+
// Button's `class`, where tailwind-merge lets `px-0` replace Button's
|
|
1046
|
+
// horizontal padding. Without text there is no line to give the height, and CSS cannot derive a width from an auto height, so each
|
|
1047
|
+
// size sets both dimensions to Button's own height at that size: one line, plus the
|
|
1048
|
+
// two vertical paddings (Button's `py-*` times two, in spacing units), plus the
|
|
1049
|
+
// 1px borders. The height is therefore Button's, and an IconButton lines up
|
|
1050
|
+
// with a Button of the same size. If Button's vertical padding changes, change
|
|
1051
|
+
// the multipliers here; the "as tall as a Button" test catches a mismatch.
|
|
1052
|
+
// Written out in full so Tailwind sees each class.
|
|
1053
|
+
const iconButton$1 = tv({
|
|
1054
|
+
base: 'px-0',
|
|
1055
|
+
variants: {
|
|
1056
|
+
size: {
|
|
1057
|
+
xs: 'size-[calc(1lh+var(--spacing)*1+2px)]',
|
|
1058
|
+
sm: 'size-[calc(1lh+var(--spacing)*2+2px)]',
|
|
1059
|
+
md: 'size-[calc(1lh+var(--spacing)*3+2px)]',
|
|
1060
|
+
lg: 'size-[calc(1lh+var(--spacing)*4+2px)]',
|
|
1061
|
+
xl: 'size-[calc(1lh+var(--spacing)*5+2px)]',
|
|
1062
|
+
'2xl': 'size-[calc(1lh+var(--spacing)*6+2px)]'
|
|
1063
|
+
}
|
|
1064
|
+
},
|
|
1065
|
+
defaultVariants: {
|
|
1066
|
+
size: 'md'
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1001
1070
|
const chip = tv({
|
|
1002
1071
|
slots: {
|
|
1003
1072
|
base: ['whitespace-nowrap', 'inline-flex items-center justify-between box-border rounded-full',
|
|
1004
|
-
// Regular weight, matching Badge (the `text-
|
|
1005
|
-
//
|
|
1073
|
+
// Regular weight, matching Badge (the `text-strong-*` sizes would set
|
|
1074
|
+
// bold). Text size follows Button's ramp; heights are Chip's own.
|
|
1006
1075
|
'font-normal'],
|
|
1007
1076
|
// label text role (size set per size variant)
|
|
1008
1077
|
content: ['flex-1 text-inherit font-label'],
|
|
@@ -1056,35 +1125,56 @@ const chip = tv({
|
|
|
1056
1125
|
closeButton: 'bg-danger-muted text-on-danger-muted'
|
|
1057
1126
|
}
|
|
1058
1127
|
},
|
|
1128
|
+
// Text follows Button's ramp (`2xs` extends it one step below Button's `xs`): the same `@size` gives the same
|
|
1129
|
+
// `text-strong-*` token on Chip, Badge and Button. `xs`, the default, keeps
|
|
1130
|
+
// the geometry of the old `md` for dense UI (table cells, list rows,
|
|
1131
|
+
// multi-select fields). The close button takes only the label's font size
|
|
1132
|
+
// (not the weight or line-height that `text-strong-*` bundles), so its
|
|
1133
|
+
// circle (icon plus `p-0.5`) stays round and fits the chip.
|
|
1059
1134
|
size: {
|
|
1060
|
-
//
|
|
1061
|
-
// `
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
// chip.
|
|
1065
|
-
xs: {
|
|
1066
|
-
base: 'text-label-2xs px-0.5 h-5',
|
|
1135
|
+
// Smaller than Button's smallest size, for the densest UI. Text is the
|
|
1136
|
+
// next `text-strong-*` step down (12.3px) and the chip is 20px tall.
|
|
1137
|
+
'2xs': {
|
|
1138
|
+
base: 'text-strong-2xs px-0.5 h-5',
|
|
1067
1139
|
content: 'px-1 leading-4',
|
|
1068
1140
|
dot: 'size-1.5',
|
|
1069
|
-
closeButton: 'text-
|
|
1141
|
+
closeButton: 'text-(length:--text-strong-3xs)'
|
|
1070
1142
|
},
|
|
1071
|
-
|
|
1072
|
-
base: 'text-
|
|
1073
|
-
content: 'px-
|
|
1074
|
-
dot: 'size-
|
|
1075
|
-
closeButton: 'text-
|
|
1143
|
+
xs: {
|
|
1144
|
+
base: 'text-strong-xs px-1 h-7',
|
|
1145
|
+
content: 'px-2 leading-5',
|
|
1146
|
+
dot: 'size-2',
|
|
1147
|
+
closeButton: 'text-(length:--text-strong-xs)'
|
|
1076
1148
|
},
|
|
1077
|
-
|
|
1078
|
-
base: 'text-
|
|
1149
|
+
sm: {
|
|
1150
|
+
base: 'text-strong-sm px-1 h-8',
|
|
1079
1151
|
content: 'px-2 leading-5',
|
|
1080
1152
|
dot: 'size-2',
|
|
1081
|
-
closeButton: 'text-
|
|
1153
|
+
closeButton: 'text-(length:--text-strong-sm)'
|
|
1082
1154
|
},
|
|
1083
|
-
|
|
1084
|
-
base: 'text-
|
|
1085
|
-
content: 'px-2 leading-6',
|
|
1155
|
+
md: {
|
|
1156
|
+
base: 'text-strong-md px-1.5 h-9',
|
|
1157
|
+
content: 'px-2.5 leading-6',
|
|
1086
1158
|
dot: 'size-2.5',
|
|
1087
|
-
closeButton: 'text-
|
|
1159
|
+
closeButton: 'text-(length:--text-strong-md)'
|
|
1160
|
+
},
|
|
1161
|
+
lg: {
|
|
1162
|
+
base: 'text-strong-lg px-2 h-11',
|
|
1163
|
+
content: 'px-3 leading-7',
|
|
1164
|
+
dot: 'size-3',
|
|
1165
|
+
closeButton: 'text-(length:--text-strong-lg)'
|
|
1166
|
+
},
|
|
1167
|
+
xl: {
|
|
1168
|
+
base: 'text-strong-xl px-2 h-12',
|
|
1169
|
+
content: 'px-4 leading-8',
|
|
1170
|
+
dot: 'size-3.5',
|
|
1171
|
+
closeButton: 'text-(length:--text-strong-xl)'
|
|
1172
|
+
},
|
|
1173
|
+
'2xl': {
|
|
1174
|
+
base: 'text-strong-2xl px-3 h-14',
|
|
1175
|
+
content: 'px-5 leading-9',
|
|
1176
|
+
dot: 'size-4',
|
|
1177
|
+
closeButton: 'text-(length:--text-strong-2xl)'
|
|
1088
1178
|
}
|
|
1089
1179
|
}
|
|
1090
1180
|
},
|
|
@@ -1256,12 +1346,213 @@ const chip = tv({
|
|
|
1256
1346
|
}
|
|
1257
1347
|
}],
|
|
1258
1348
|
defaultVariants: {
|
|
1259
|
-
size: '
|
|
1349
|
+
size: 'xs',
|
|
1260
1350
|
color: 'neutral',
|
|
1261
1351
|
variant: 'solid'
|
|
1262
1352
|
}
|
|
1263
1353
|
});
|
|
1264
1354
|
|
|
1355
|
+
const ROLES = ['neutral', 'primary', 'secondary', 'tertiary', 'success', 'warning', 'danger'];
|
|
1356
|
+
// Fill and ink per color and variant, from the design artifact's Icon spec.
|
|
1357
|
+
// The artifact picks a different level per role (soft is `*-soft` for most and
|
|
1358
|
+
// `*-muted` for neutral and warning), so these are tables, not a rule. Where
|
|
1359
|
+
// Frontile's auto-generated `on-*` token differs from the artifact's ink (the
|
|
1360
|
+
// artifact has `on-neutral` white on its mid-gray fill, Frontile black), the
|
|
1361
|
+
// level that gives the artifact's ink is used instead, and the tests check the
|
|
1362
|
+
// ink itself. Every class is written out in full so Tailwind can find it.
|
|
1363
|
+
const SOLID = {
|
|
1364
|
+
neutral: 'bg-on-neutral-subtle text-on-neutral-strong',
|
|
1365
|
+
primary: 'bg-primary text-on-primary',
|
|
1366
|
+
secondary: 'bg-secondary text-on-secondary',
|
|
1367
|
+
tertiary: 'bg-tertiary text-on-tertiary',
|
|
1368
|
+
success: 'bg-success text-on-success',
|
|
1369
|
+
warning: 'bg-warning text-on-warning',
|
|
1370
|
+
danger: 'bg-danger text-on-danger'
|
|
1371
|
+
};
|
|
1372
|
+
const SOFT = {
|
|
1373
|
+
neutral: 'bg-neutral-muted text-on-neutral-muted',
|
|
1374
|
+
primary: 'bg-primary-soft text-on-primary-soft',
|
|
1375
|
+
secondary: 'bg-secondary-soft text-on-secondary-soft',
|
|
1376
|
+
tertiary: 'bg-tertiary-soft text-on-tertiary-soft',
|
|
1377
|
+
success: 'bg-success-soft text-on-success-soft',
|
|
1378
|
+
warning: 'bg-warning-muted text-on-warning-soft',
|
|
1379
|
+
danger: 'bg-danger-soft text-on-danger-soft'
|
|
1380
|
+
};
|
|
1381
|
+
const SUBTLE = {
|
|
1382
|
+
neutral: 'bg-neutral-subtle text-neutral-strong',
|
|
1383
|
+
primary: 'bg-primary-soft text-primary',
|
|
1384
|
+
secondary: 'bg-secondary-soft text-secondary',
|
|
1385
|
+
tertiary: 'bg-tertiary-muted text-tertiary-strong',
|
|
1386
|
+
success: 'bg-success-muted text-success-strong',
|
|
1387
|
+
warning: 'bg-warning-subtle text-warning',
|
|
1388
|
+
danger: 'bg-danger-muted text-danger'
|
|
1389
|
+
};
|
|
1390
|
+
|
|
1391
|
+
// The icon color for the variants with no fill behind it. The outline ring
|
|
1392
|
+
// takes the same color.
|
|
1393
|
+
const INK = {
|
|
1394
|
+
neutral: 'text-on-neutral-subtle',
|
|
1395
|
+
primary: 'text-primary',
|
|
1396
|
+
secondary: 'text-secondary',
|
|
1397
|
+
tertiary: 'text-tertiary-strong',
|
|
1398
|
+
success: 'text-success-strong',
|
|
1399
|
+
warning: 'text-warning',
|
|
1400
|
+
danger: 'text-danger'
|
|
1401
|
+
};
|
|
1402
|
+
const BY_VARIANT = {
|
|
1403
|
+
solid: SOLID,
|
|
1404
|
+
soft: SOFT,
|
|
1405
|
+
subtle: SUBTLE,
|
|
1406
|
+
outline: INK,
|
|
1407
|
+
plain: INK
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
// A circle that centers an icon, sized from the design artifact: the circle
|
|
1411
|
+
// diameter, the icon inside it, and for `plain` a tighter box with no circle.
|
|
1412
|
+
// The icon is the `svg` the block contains, so it needs no size class of its
|
|
1413
|
+
// own. These are the artifact's pixel values, not the `size-icon-*` ramp, which
|
|
1414
|
+
// follows the label text. Outline draws its ring as an inset shadow in the
|
|
1415
|
+
// icon color, 0.5px at 4xs up to 2.5px at 3xl.
|
|
1416
|
+
//
|
|
1417
|
+
// One deliberate difference from the artifact: it has `xl` the same as `lg`
|
|
1418
|
+
// (64px circle, 40px plain box), which looks like a Figma slip, so `xl` is 72px
|
|
1419
|
+
// and 44px, between `lg` and `2xl`. Confirm with the designer.
|
|
1420
|
+
const icon = tv({
|
|
1421
|
+
base: 'box-border inline-flex shrink-0 items-center justify-center rounded-full align-middle',
|
|
1422
|
+
variants: {
|
|
1423
|
+
size: {
|
|
1424
|
+
'4xs': 'size-4 [&_svg]:size-[8px]',
|
|
1425
|
+
'3xs': 'size-5 [&_svg]:size-[10px]',
|
|
1426
|
+
'2xs': 'size-6 [&_svg]:size-[12px]',
|
|
1427
|
+
xs: 'size-8 [&_svg]:size-[16px]',
|
|
1428
|
+
sm: 'size-10 [&_svg]:size-[20px]',
|
|
1429
|
+
md: 'size-12 [&_svg]:size-[28px]',
|
|
1430
|
+
lg: 'size-16 [&_svg]:size-[32px]',
|
|
1431
|
+
xl: 'size-18 [&_svg]:size-[40px]',
|
|
1432
|
+
'2xl': 'size-20 [&_svg]:size-[48px]',
|
|
1433
|
+
'3xl': 'size-24 [&_svg]:size-[56px]'
|
|
1434
|
+
},
|
|
1435
|
+
color: {
|
|
1436
|
+
neutral: '',
|
|
1437
|
+
primary: '',
|
|
1438
|
+
secondary: '',
|
|
1439
|
+
tertiary: '',
|
|
1440
|
+
success: '',
|
|
1441
|
+
warning: '',
|
|
1442
|
+
danger: ''
|
|
1443
|
+
},
|
|
1444
|
+
variant: {
|
|
1445
|
+
solid: '',
|
|
1446
|
+
soft: '',
|
|
1447
|
+
subtle: '',
|
|
1448
|
+
outline: '',
|
|
1449
|
+
plain: ''
|
|
1450
|
+
},
|
|
1451
|
+
// For an icon on a surface of the other scheme. See the compound variants.
|
|
1452
|
+
inverse: {
|
|
1453
|
+
true: ''
|
|
1454
|
+
}
|
|
1455
|
+
},
|
|
1456
|
+
compoundVariants: [...ROLES.flatMap(color => Object.keys(BY_VARIANT).map(variant => ({
|
|
1457
|
+
color,
|
|
1458
|
+
variant,
|
|
1459
|
+
class: BY_VARIANT[variant][color]
|
|
1460
|
+
}))),
|
|
1461
|
+
// Inverse. Neutral solid, outline and plain swap their tokens, as the
|
|
1462
|
+
// artifact does: the fill and the icon change places, and the ink takes
|
|
1463
|
+
// `on-neutral`. Everything else re-resolves its tokens to the opposite
|
|
1464
|
+
// scheme with `theme-inverse`.
|
|
1465
|
+
{
|
|
1466
|
+
inverse: true,
|
|
1467
|
+
color: 'neutral',
|
|
1468
|
+
variant: 'solid',
|
|
1469
|
+
class: 'bg-on-neutral-strong text-on-neutral-subtle'
|
|
1470
|
+
}, {
|
|
1471
|
+
inverse: true,
|
|
1472
|
+
color: 'neutral',
|
|
1473
|
+
variant: ['outline', 'plain'],
|
|
1474
|
+
class: 'text-on-neutral-strong'
|
|
1475
|
+
}, {
|
|
1476
|
+
inverse: true,
|
|
1477
|
+
color: 'neutral',
|
|
1478
|
+
variant: ['soft', 'subtle'],
|
|
1479
|
+
class: 'theme-inverse'
|
|
1480
|
+
}, {
|
|
1481
|
+
inverse: true,
|
|
1482
|
+
color: ['primary', 'secondary', 'tertiary', 'success', 'warning', 'danger'],
|
|
1483
|
+
class: 'theme-inverse'
|
|
1484
|
+
},
|
|
1485
|
+
// Plain has no circle, so its box is tighter. The icon size is unchanged.
|
|
1486
|
+
{
|
|
1487
|
+
variant: 'plain',
|
|
1488
|
+
size: '4xs',
|
|
1489
|
+
class: 'size-3'
|
|
1490
|
+
}, {
|
|
1491
|
+
variant: 'plain',
|
|
1492
|
+
size: '3xs',
|
|
1493
|
+
class: 'size-3.5'
|
|
1494
|
+
}, {
|
|
1495
|
+
variant: 'plain',
|
|
1496
|
+
size: '2xs',
|
|
1497
|
+
class: 'size-4'
|
|
1498
|
+
}, {
|
|
1499
|
+
variant: 'plain',
|
|
1500
|
+
size: 'xs',
|
|
1501
|
+
class: 'size-5'
|
|
1502
|
+
}, {
|
|
1503
|
+
variant: 'plain',
|
|
1504
|
+
size: 'sm',
|
|
1505
|
+
class: 'size-6'
|
|
1506
|
+
}, {
|
|
1507
|
+
variant: 'plain',
|
|
1508
|
+
size: 'md',
|
|
1509
|
+
class: 'size-8'
|
|
1510
|
+
}, {
|
|
1511
|
+
variant: 'plain',
|
|
1512
|
+
size: 'lg',
|
|
1513
|
+
class: 'size-10'
|
|
1514
|
+
}, {
|
|
1515
|
+
variant: 'plain',
|
|
1516
|
+
size: 'xl',
|
|
1517
|
+
class: 'size-11'
|
|
1518
|
+
}, {
|
|
1519
|
+
variant: 'plain',
|
|
1520
|
+
size: '2xl',
|
|
1521
|
+
class: 'size-12'
|
|
1522
|
+
}, {
|
|
1523
|
+
variant: 'plain',
|
|
1524
|
+
size: '3xl',
|
|
1525
|
+
class: 'size-14'
|
|
1526
|
+
},
|
|
1527
|
+
// The ring, in the icon color.
|
|
1528
|
+
{
|
|
1529
|
+
variant: 'outline',
|
|
1530
|
+
size: ['4xs', '3xs'],
|
|
1531
|
+
class: 'shadow-[inset_0_0_0_0.5px_currentColor]'
|
|
1532
|
+
}, {
|
|
1533
|
+
variant: 'outline',
|
|
1534
|
+
size: ['2xs', 'xs'],
|
|
1535
|
+
class: 'shadow-[inset_0_0_0_1px_currentColor]'
|
|
1536
|
+
}, {
|
|
1537
|
+
variant: 'outline',
|
|
1538
|
+
size: 'sm',
|
|
1539
|
+
class: 'shadow-[inset_0_0_0_1.5px_currentColor]'
|
|
1540
|
+
}, {
|
|
1541
|
+
variant: 'outline',
|
|
1542
|
+
size: ['md', 'lg', 'xl', '2xl'],
|
|
1543
|
+
class: 'shadow-[inset_0_0_0_2px_currentColor]'
|
|
1544
|
+
}, {
|
|
1545
|
+
variant: 'outline',
|
|
1546
|
+
size: '3xl',
|
|
1547
|
+
class: 'shadow-[inset_0_0_0_2.5px_currentColor]'
|
|
1548
|
+
}],
|
|
1549
|
+
// `color` has no default: a plain icon without one inherits the text color.
|
|
1550
|
+
defaultVariants: {
|
|
1551
|
+
size: 'md',
|
|
1552
|
+
variant: 'plain'
|
|
1553
|
+
}
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1265
1556
|
const progressBar = tv({
|
|
1266
1557
|
slots: {
|
|
1267
1558
|
base: ['overflow-hidden w-full bg-surface-overlay-soft'],
|
|
@@ -1981,6 +2272,200 @@ const divider = tv({
|
|
|
1981
2272
|
}
|
|
1982
2273
|
});
|
|
1983
2274
|
|
|
2275
|
+
/**
|
|
2276
|
+
* Card is a surface and nothing else: it owns the fill, border, radius,
|
|
2277
|
+
* padding and the states a surface can be in. What goes inside is the call
|
|
2278
|
+
* site's business, and so is selection behaviour — `isSelected` only changes
|
|
2279
|
+
* how the surface looks.
|
|
2280
|
+
*
|
|
2281
|
+
* The border is `border` (1px) in every variant and state, so moving between
|
|
2282
|
+
* states never shifts the contents. `flat` and `soft` keep the same border
|
|
2283
|
+
* width but make it transparent. Hover and selected add weight without
|
|
2284
|
+
* changing that width: a second 1px layer, drawn inside the border in the same
|
|
2285
|
+
* colour with `inset-shadow-[0_0_0_1px_…]`, so the edge reads as 2px.
|
|
2286
|
+
*
|
|
2287
|
+
* That layer is an `inset-shadow`, not a `ring` or an `outline`. `ring-*`
|
|
2288
|
+
* shares its `--tw-ring-*` variables with the focus ring (`focusVisibleRing`),
|
|
2289
|
+
* so a focused selected card would get an inset focus ring; `outline` is the
|
|
2290
|
+
* focus indicator in forced-colors (`outline-hidden`). `inset-shadow` has its
|
|
2291
|
+
* own variable and stacks with `shadow-elevation-*` and the focus ring.
|
|
2292
|
+
*
|
|
2293
|
+
* `box-shadow` is not drawn in forced-colors, so a selected card widens its
|
|
2294
|
+
* border to 3px in that mode instead (`forced-colors:border-[3px]`). A layout
|
|
2295
|
+
* shift is acceptable there; losing the selected cue is not.
|
|
2296
|
+
*
|
|
2297
|
+
* Everything that depends on more than one variant lives in
|
|
2298
|
+
* `compoundVariants`. tv() applies those after the plain variants and
|
|
2299
|
+
* resolves conflicts with tailwind-merge, so a state's border or fill wins
|
|
2300
|
+
* over the variant's resting one without relying on declaration order.
|
|
2301
|
+
*/
|
|
2302
|
+
const card = tv({
|
|
2303
|
+
base: [
|
|
2304
|
+
// A positioning context for the selection indicator.
|
|
2305
|
+
'relative', 'border rounded-[20px]', 'transition-[color,background-color,border-color,box-shadow] duration-200', 'motion-reduce:transition-none'],
|
|
2306
|
+
variants: {
|
|
2307
|
+
variant: {
|
|
2308
|
+
outline: 'bg-surface-card',
|
|
2309
|
+
flat: 'bg-surface-card border-transparent',
|
|
2310
|
+
// `overlay-soft`, not `-subtle`: in dark mode `surface-card` and
|
|
2311
|
+
// `surface-overlay-subtle` are the same colour (white @ 7%), which would
|
|
2312
|
+
// make `soft` identical to `flat`. The same pairing rules out
|
|
2313
|
+
// `overlay-subtle` for any hover or pressed fill below.
|
|
2314
|
+
soft: 'bg-surface-overlay-soft border-transparent'
|
|
2315
|
+
},
|
|
2316
|
+
// Colour only steers the hover and selected border. The resting border
|
|
2317
|
+
// is neutral for both, as in the design.
|
|
2318
|
+
color: {
|
|
2319
|
+
neutral: '',
|
|
2320
|
+
primary: ''
|
|
2321
|
+
},
|
|
2322
|
+
density: {
|
|
2323
|
+
compact: 'p-3',
|
|
2324
|
+
comfortable: 'p-5',
|
|
2325
|
+
spacious: 'p-8'
|
|
2326
|
+
},
|
|
2327
|
+
// Only `outline` is ever raised; `flat` and `soft` have no shadow in
|
|
2328
|
+
// either setting.
|
|
2329
|
+
elevation: {
|
|
2330
|
+
raised: '',
|
|
2331
|
+
none: ''
|
|
2332
|
+
},
|
|
2333
|
+
isSelected: {
|
|
2334
|
+
true: '',
|
|
2335
|
+
false: ''
|
|
2336
|
+
},
|
|
2337
|
+
isInteractive: {
|
|
2338
|
+
true: '',
|
|
2339
|
+
false: ''
|
|
2340
|
+
},
|
|
2341
|
+
isDisabled: {
|
|
2342
|
+
true: 'opacity-disabled cursor-not-allowed',
|
|
2343
|
+
false: ''
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
2346
|
+
compoundVariants: [
|
|
2347
|
+
// RESTING SURFACE
|
|
2348
|
+
{
|
|
2349
|
+
variant: 'outline',
|
|
2350
|
+
isSelected: false,
|
|
2351
|
+
class: 'border-neutral-muted'
|
|
2352
|
+
}, {
|
|
2353
|
+
variant: 'outline',
|
|
2354
|
+
elevation: 'raised',
|
|
2355
|
+
class: 'shadow-elevation-2'
|
|
2356
|
+
},
|
|
2357
|
+
// SELECTED. The fill is unchanged; the border takes the colour and a
|
|
2358
|
+
// second 1px layer inside it makes the edge read as 2px. Forced-colors
|
|
2359
|
+
// draws no box-shadow, so it gets a real, thicker border instead.
|
|
2360
|
+
{
|
|
2361
|
+
isSelected: true,
|
|
2362
|
+
color: 'primary',
|
|
2363
|
+
class: ['border-primary', 'inset-shadow-[0_0_0_1px_var(--color-primary)]', 'forced-colors:border-[3px]']
|
|
2364
|
+
}, {
|
|
2365
|
+
isSelected: true,
|
|
2366
|
+
color: 'neutral',
|
|
2367
|
+
class: ['border-neutral-bolder', 'inset-shadow-[0_0_0_1px_var(--color-neutral-bolder)]', 'forced-colors:border-[3px]']
|
|
2368
|
+
},
|
|
2369
|
+
// INTERACTIVE. Disabled wins: no hover, pressed, focus ring or pointer.
|
|
2370
|
+
{
|
|
2371
|
+
isInteractive: true,
|
|
2372
|
+
isDisabled: false,
|
|
2373
|
+
class: ['cursor-pointer', ...focusVisibleRing]
|
|
2374
|
+
},
|
|
2375
|
+
// PRESSED sits one overlay level above each variant's hover, so it is a
|
|
2376
|
+
// distinct step in light and dark. Outline has no hover fill, so it goes
|
|
2377
|
+
// straight to `overlay-soft` off the card fill.
|
|
2378
|
+
{
|
|
2379
|
+
variant: 'outline',
|
|
2380
|
+
isInteractive: true,
|
|
2381
|
+
isDisabled: false,
|
|
2382
|
+
class: 'active:bg-surface-overlay-soft'
|
|
2383
|
+
}, {
|
|
2384
|
+
variant: 'flat',
|
|
2385
|
+
isInteractive: true,
|
|
2386
|
+
isDisabled: false,
|
|
2387
|
+
class: 'active:bg-surface-overlay-mild'
|
|
2388
|
+
}, {
|
|
2389
|
+
variant: 'soft',
|
|
2390
|
+
isInteractive: true,
|
|
2391
|
+
isDisabled: false,
|
|
2392
|
+
class: 'active:bg-surface-overlay-firm'
|
|
2393
|
+
},
|
|
2394
|
+
// HOVER, unselected. Hover is scoped to the unselected state so it never
|
|
2395
|
+
// ties on specificity with the selected border. The border colour is
|
|
2396
|
+
// joined by a 1px inset layer in the same colour, so it reads as 2px.
|
|
2397
|
+
{
|
|
2398
|
+
variant: 'outline',
|
|
2399
|
+
isInteractive: true,
|
|
2400
|
+
isDisabled: false,
|
|
2401
|
+
isSelected: false,
|
|
2402
|
+
color: 'primary',
|
|
2403
|
+
class: ['hover:border-primary-muted', 'hover:inset-shadow-[0_0_0_1px_var(--color-primary-muted)]']
|
|
2404
|
+
}, {
|
|
2405
|
+
variant: 'outline',
|
|
2406
|
+
isInteractive: true,
|
|
2407
|
+
isDisabled: false,
|
|
2408
|
+
isSelected: false,
|
|
2409
|
+
color: 'neutral',
|
|
2410
|
+
class: ['hover:border-neutral-soft', 'hover:inset-shadow-[0_0_0_1px_var(--color-neutral-soft)]']
|
|
2411
|
+
}, {
|
|
2412
|
+
variant: 'flat',
|
|
2413
|
+
isInteractive: true,
|
|
2414
|
+
isDisabled: false,
|
|
2415
|
+
isSelected: false,
|
|
2416
|
+
class: 'hover:bg-surface-overlay-soft'
|
|
2417
|
+
}, {
|
|
2418
|
+
variant: 'soft',
|
|
2419
|
+
isInteractive: true,
|
|
2420
|
+
isDisabled: false,
|
|
2421
|
+
isSelected: false,
|
|
2422
|
+
class: 'hover:bg-surface-overlay-mild'
|
|
2423
|
+
},
|
|
2424
|
+
// HOVER LIFT. Raised outline cards step up an elevation level, selected
|
|
2425
|
+
// or not.
|
|
2426
|
+
{
|
|
2427
|
+
variant: 'outline',
|
|
2428
|
+
elevation: 'raised',
|
|
2429
|
+
isInteractive: true,
|
|
2430
|
+
isDisabled: false,
|
|
2431
|
+
class: 'hover:shadow-elevation-3'
|
|
2432
|
+
}],
|
|
2433
|
+
defaultVariants: {
|
|
2434
|
+
variant: 'outline',
|
|
2435
|
+
color: 'neutral',
|
|
2436
|
+
density: 'comfortable',
|
|
2437
|
+
elevation: 'raised',
|
|
2438
|
+
isSelected: false,
|
|
2439
|
+
isInteractive: false,
|
|
2440
|
+
isDisabled: false
|
|
2441
|
+
}
|
|
2442
|
+
});
|
|
2443
|
+
|
|
2444
|
+
/**
|
|
2445
|
+
* The selection indicator: a small solid circle overhanging a card's top-right
|
|
2446
|
+
* corner, holding whatever icon the call site passes in the `indicator` block.
|
|
2447
|
+
* Card renders it only while selected, so it has no state of its own. The
|
|
2448
|
+
* overhang is why `card` is `relative` and has no `overflow-hidden`.
|
|
2449
|
+
*
|
|
2450
|
+
* `starting:` gives it a short fade and scale in when it mounts; reduced
|
|
2451
|
+
* motion drops the transition.
|
|
2452
|
+
*/
|
|
2453
|
+
const cardIndicator = tv({
|
|
2454
|
+
base: [
|
|
2455
|
+
// Offsets are measured from the padding box, inside the 1px border, so
|
|
2456
|
+
// 1.25 (5px) leaves the circle 4px past the card's outer edge.
|
|
2457
|
+
'pointer-events-none absolute -top-1.25 -right-1.25 z-10', 'inline-flex size-5 items-center justify-center rounded-full', '[&>svg]:size-3', 'transition-[opacity,scale] duration-200', 'starting:opacity-0 starting:scale-75', 'motion-reduce:transition-none'],
|
|
2458
|
+
variants: {
|
|
2459
|
+
color: {
|
|
2460
|
+
neutral: 'bg-neutral-bolder text-on-neutral-bolder',
|
|
2461
|
+
primary: 'bg-primary text-on-primary'
|
|
2462
|
+
}
|
|
2463
|
+
},
|
|
2464
|
+
defaultVariants: {
|
|
2465
|
+
color: 'neutral'
|
|
2466
|
+
}
|
|
2467
|
+
});
|
|
2468
|
+
|
|
1984
2469
|
const externalLink = tv({
|
|
1985
2470
|
slots: {
|
|
1986
2471
|
// `inline`, not `inline-flex`. An external link's home is running text, and
|
|
@@ -5887,6 +6372,8 @@ var components = /*#__PURE__*/Object.freeze({
|
|
|
5887
6372
|
buttonGroup: buttonGroup,
|
|
5888
6373
|
buttonSpinner: buttonSpinner,
|
|
5889
6374
|
calendar: calendar,
|
|
6375
|
+
card: card,
|
|
6376
|
+
cardIndicator: cardIndicator,
|
|
5890
6377
|
checkbox: checkbox,
|
|
5891
6378
|
checkboxGroup: checkboxGroup,
|
|
5892
6379
|
chip: chip,
|
|
@@ -5908,6 +6395,8 @@ var components = /*#__PURE__*/Object.freeze({
|
|
|
5908
6395
|
formRadioGroup: formRadioGroup,
|
|
5909
6396
|
formSelect: formSelect,
|
|
5910
6397
|
formTextarea: formTextarea,
|
|
6398
|
+
icon: icon,
|
|
6399
|
+
iconButton: iconButton$1,
|
|
5911
6400
|
input: input,
|
|
5912
6401
|
inputOtp: inputOtp,
|
|
5913
6402
|
kbd: kbd,
|