@ponti-studios/ui 0.1.2 → 0.3.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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -7
  3. package/THIRD_PARTY_NOTICES.md +17 -0
  4. package/dist/index.js +1028 -638
  5. package/dist/index.js.map +1 -1
  6. package/package.json +30 -32
  7. package/src/animations.css +16 -434
  8. package/src/components/data-display/accordion.tsx +10 -7
  9. package/src/components/data-display/filter-chip.tsx +2 -2
  10. package/src/components/data-display/index.ts +5 -0
  11. package/src/components/data-display/metric-card.stories.tsx +48 -0
  12. package/src/components/data-display/metric-card.tsx +20 -0
  13. package/src/components/data-display/sort-controls.stories.tsx +45 -0
  14. package/src/components/data-display/sort-controls.tsx +99 -0
  15. package/src/components/data-display/sort-row.tsx +74 -0
  16. package/src/components/data-display/table.tsx +5 -5
  17. package/src/components/feedback/alert.tsx +4 -4
  18. package/src/components/feedback/empty-state.tsx +6 -6
  19. package/src/components/feedback/file-upload-status-badge.stories.tsx +28 -0
  20. package/src/components/feedback/file-upload-status-badge.tsx +33 -0
  21. package/src/components/feedback/file-upload-status.stories.tsx +57 -0
  22. package/src/components/feedback/file-upload-status.tsx +152 -0
  23. package/src/components/feedback/index.ts +9 -0
  24. package/src/components/feedback/progress-bar.stories.tsx +39 -0
  25. package/src/components/feedback/progress-bar.tsx +21 -0
  26. package/src/components/feedback/progress.stories.tsx +8 -6
  27. package/src/components/feedback/progress.tsx +1 -1
  28. package/src/components/feedback/skeleton.stories.tsx +36 -0
  29. package/src/components/feedback/skeleton.tsx +7 -0
  30. package/src/components/feedback/spinner.tsx +2 -2
  31. package/src/components/feedback/update-guard.stories.tsx +32 -0
  32. package/src/components/feedback/update-guard.tsx +280 -0
  33. package/src/components/forms/calendar.tsx +11 -11
  34. package/src/components/forms/date-month-select.stories.tsx +26 -0
  35. package/src/components/forms/date-month-select.tsx +70 -0
  36. package/src/components/forms/date-picker.tsx +3 -3
  37. package/src/components/forms/drop-zone.stories.tsx +56 -0
  38. package/src/components/forms/drop-zone.tsx +146 -0
  39. package/src/components/forms/entity-select.stories.tsx +65 -0
  40. package/src/components/forms/entity-select.tsx +79 -0
  41. package/src/components/forms/field.tsx +3 -3
  42. package/src/components/forms/group-by-select.stories.tsx +26 -0
  43. package/src/components/forms/group-by-select.tsx +47 -0
  44. package/src/components/forms/index.ts +10 -0
  45. package/src/components/forms/input.stories.tsx +4 -4
  46. package/src/components/forms/input.tsx +1 -1
  47. package/src/components/forms/passkey-management.stories.tsx +81 -0
  48. package/src/components/forms/passkey-management.tsx +138 -0
  49. package/src/components/forms/radio-group.tsx +14 -13
  50. package/src/components/forms/select.stories.tsx +4 -4
  51. package/src/components/forms/select.tsx +45 -53
  52. package/src/components/forms/slider.stories.tsx +5 -2
  53. package/src/components/forms/slider.tsx +27 -17
  54. package/src/components/forms/stepper.tsx +4 -4
  55. package/src/components/forms/switch.stories.tsx +1 -1
  56. package/src/components/forms/switch.tsx +2 -2
  57. package/src/components/forms/textarea.stories.tsx +2 -2
  58. package/src/components/forms/textarea.tsx +1 -1
  59. package/src/components/layout/index.ts +3 -0
  60. package/src/components/layout/scroll-area.stories.tsx +4 -4
  61. package/src/components/layout/scroll-area.tsx +23 -21
  62. package/src/components/layout/section-intro.stories.tsx +29 -0
  63. package/src/components/layout/section-intro.tsx +31 -0
  64. package/src/components/layout/surface-panel.stories.tsx +32 -0
  65. package/src/components/layout/surface-panel.tsx +15 -0
  66. package/src/components/navigation/app-navigation.stories.tsx +2 -2
  67. package/src/components/navigation/app-navigation.tsx +13 -13
  68. package/src/components/navigation/index.ts +4 -0
  69. package/src/components/navigation/pagination-controls.stories.tsx +41 -0
  70. package/src/components/navigation/pagination-controls.tsx +50 -0
  71. package/src/components/navigation/route-link.stories.tsx +30 -0
  72. package/src/components/navigation/route-link.tsx +42 -0
  73. package/src/components/navigation/tabs.stories.tsx +5 -5
  74. package/src/components/navigation/tabs.tsx +7 -7
  75. package/src/components/overlays/alert-dialog.tsx +21 -46
  76. package/src/components/overlays/command.tsx +51 -82
  77. package/src/components/overlays/dialog.tsx +5 -5
  78. package/src/components/overlays/dropdown-menu.stories.tsx +0 -5
  79. package/src/components/overlays/dropdown-menu.tsx +44 -142
  80. package/src/components/overlays/popover.stories.tsx +2 -2
  81. package/src/components/overlays/popover.tsx +34 -16
  82. package/src/components/overlays/sheet.stories.tsx +2 -2
  83. package/src/components/overlays/sheet.tsx +35 -17
  84. package/src/components/primitives/avatar.tsx +3 -3
  85. package/src/components/primitives/badge.tsx +7 -11
  86. package/src/components/primitives/button.tsx +41 -13
  87. package/src/components/primitives/card.stories.tsx +2 -2
  88. package/src/components/primitives/card.tsx +2 -2
  89. package/src/components/primitives/index.ts +2 -0
  90. package/src/components/primitives/label.stories.tsx +1 -1
  91. package/src/components/primitives/label.tsx +5 -6
  92. package/src/components/primitives/status-badge.stories.tsx +52 -0
  93. package/src/components/primitives/status-badge.tsx +33 -0
  94. package/src/constants/chart-colors.ts +5 -5
  95. package/src/hooks/index.ts +1 -0
  96. package/src/hooks/use-sort.ts +20 -0
  97. package/src/index.ts +30 -11
  98. package/src/styles.css +76 -1040
  99. package/src/tokens/color-systems.stories.tsx +9 -119
  100. package/src/tokens/foundations.stories.tsx +21 -113
  101. package/src/tokens/generated/dark.colors.generated.ts +56 -0
  102. package/src/tokens/generated/dark.css +54 -0
  103. package/src/tokens/generated/foundations.css +148 -0
  104. package/src/tokens/generated/foundations.generated.ts +443 -0
  105. package/src/tokens/generated/light.colors.generated.ts +56 -0
  106. package/src/tokens/generated/light.css +54 -0
  107. package/src/tokens/index.ts +74 -16
  108. package/src/tokens/layout.stories.tsx +3 -108
  109. package/src/tokens/colors.ts +0 -156
  110. package/src/tokens/motion.ts +0 -51
  111. package/src/tokens/radii.ts +0 -10
  112. package/src/tokens/shadows.ts +0 -34
  113. package/src/tokens/spacing.ts +0 -30
  114. package/src/tokens/typography.ts +0 -42
@@ -0,0 +1,443 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ export default {
6
+ spacing: "0.25rem",
7
+ "spacing-scale": {
8
+ 0: "0rem",
9
+ 1: "0.25rem",
10
+ 2: "0.5rem",
11
+ 3: "0.75rem",
12
+ 4: "1rem",
13
+ 5: "1.25rem",
14
+ 6: "1.5rem",
15
+ 7: "1.75rem",
16
+ 8: "2rem",
17
+ 9: "2.25rem",
18
+ 10: "2.5rem",
19
+ 11: "2.75rem",
20
+ 12: "3rem",
21
+ 14: "3.5rem",
22
+ 16: "4rem",
23
+ 20: "5rem",
24
+ 24: "6rem",
25
+ 28: "7rem",
26
+ 32: "8rem",
27
+ 36: "9rem",
28
+ 40: "10rem",
29
+ 44: "11rem",
30
+ 48: "12rem",
31
+ 52: "13rem",
32
+ 56: "14rem",
33
+ 60: "15rem",
34
+ 64: "16rem",
35
+ 72: "18rem",
36
+ 80: "20rem",
37
+ 96: "24rem",
38
+ px: "1px",
39
+ "0-5": "0.125rem",
40
+ "1-5": "0.375rem",
41
+ "2-5": "0.625rem",
42
+ "3-5": "0.875rem",
43
+ },
44
+ font: {
45
+ sans: [
46
+ "-apple-system",
47
+ "BlinkMacSystemFont",
48
+ "Segoe UI",
49
+ "Roboto",
50
+ "Helvetica Neue",
51
+ "Noto Sans",
52
+ "Arial",
53
+ "sans-serif",
54
+ "Apple Color Emoji",
55
+ "Segoe UI Emoji",
56
+ "Segoe UI Symbol",
57
+ "Noto Color Emoji",
58
+ ],
59
+ serif: [
60
+ "ui-serif",
61
+ "Georgia",
62
+ "Cambria",
63
+ "Times New Roman",
64
+ "Times",
65
+ "serif",
66
+ ],
67
+ mono: [
68
+ "ui-monospace",
69
+ "SFMono-Regular",
70
+ "Menlo",
71
+ "Monaco",
72
+ "Consolas",
73
+ "Liberation Mono",
74
+ "Courier New",
75
+ "monospace",
76
+ ],
77
+ },
78
+ text: {
79
+ xs: "0.75rem",
80
+ sm: "0.875rem",
81
+ base: "1rem",
82
+ lg: "1.125rem",
83
+ xl: "1.25rem",
84
+ "2xl": "1.5rem",
85
+ "3xl": "1.875rem",
86
+ "4xl": "2.25rem",
87
+ "5xl": "3rem",
88
+ "6xl": "3.75rem",
89
+ "7xl": "4.5rem",
90
+ "8xl": "6rem",
91
+ "9xl": "8rem",
92
+ },
93
+ "text-line-height": {
94
+ xs: 1.3333333333,
95
+ sm: 1.4285714286,
96
+ base: 1.5,
97
+ lg: 1.5555555556,
98
+ xl: 1.4,
99
+ "2xl": 1.3333333333,
100
+ "3xl": 1.2,
101
+ "4xl": 1.1111111111,
102
+ "5xl": 1,
103
+ "6xl": 1,
104
+ "7xl": 1,
105
+ "8xl": 1,
106
+ "9xl": 1,
107
+ },
108
+ "font-weight": {
109
+ thin: 100,
110
+ extralight: 200,
111
+ light: 300,
112
+ normal: 400,
113
+ medium: 500,
114
+ semibold: 600,
115
+ bold: 700,
116
+ extrabold: 800,
117
+ black: 900,
118
+ },
119
+ tracking: {
120
+ tighter: "-0.05em",
121
+ tight: "-0.025em",
122
+ normal: "0em",
123
+ wide: "0.025em",
124
+ wider: "0.05em",
125
+ widest: "0.1em",
126
+ },
127
+ leading: {
128
+ tight: 1.25,
129
+ snug: 1.375,
130
+ normal: 1.5,
131
+ relaxed: 1.625,
132
+ loose: 2,
133
+ },
134
+ radius: {
135
+ xs: "0.125rem",
136
+ sm: "0.25rem",
137
+ md: "0.375rem",
138
+ lg: "0.5rem",
139
+ xl: "0.75rem",
140
+ "2xl": "1rem",
141
+ "3xl": "1.5rem",
142
+ "4xl": "2rem",
143
+ full: "9999px",
144
+ },
145
+ shadow: {
146
+ "2xs": [
147
+ {
148
+ color: "rgb(0 0 0 / 0.05)",
149
+ offsetX: {
150
+ value: 0,
151
+ unit: "px",
152
+ },
153
+ offsetY: {
154
+ value: 1,
155
+ unit: "px",
156
+ },
157
+ blur: {
158
+ value: 0,
159
+ unit: "px",
160
+ },
161
+ spread: {
162
+ value: 0,
163
+ unit: "px",
164
+ },
165
+ },
166
+ ],
167
+ xs: [
168
+ {
169
+ color: "rgb(0 0 0 / 0.05)",
170
+ offsetX: {
171
+ value: 0,
172
+ unit: "px",
173
+ },
174
+ offsetY: {
175
+ value: 1,
176
+ unit: "px",
177
+ },
178
+ blur: {
179
+ value: 2,
180
+ unit: "px",
181
+ },
182
+ spread: {
183
+ value: 0,
184
+ unit: "px",
185
+ },
186
+ },
187
+ ],
188
+ sm: [
189
+ {
190
+ color: "rgb(0 0 0 / 0.1)",
191
+ offsetX: {
192
+ value: 0,
193
+ unit: "px",
194
+ },
195
+ offsetY: {
196
+ value: 1,
197
+ unit: "px",
198
+ },
199
+ blur: {
200
+ value: 3,
201
+ unit: "px",
202
+ },
203
+ spread: {
204
+ value: 0,
205
+ unit: "px",
206
+ },
207
+ },
208
+ {
209
+ color: "rgb(0 0 0 / 0.1)",
210
+ offsetX: {
211
+ value: 0,
212
+ unit: "px",
213
+ },
214
+ offsetY: {
215
+ value: 1,
216
+ unit: "px",
217
+ },
218
+ blur: {
219
+ value: 2,
220
+ unit: "px",
221
+ },
222
+ spread: {
223
+ value: -1,
224
+ unit: "px",
225
+ },
226
+ },
227
+ ],
228
+ md: [
229
+ {
230
+ color: "rgb(0 0 0 / 0.1)",
231
+ offsetX: {
232
+ value: 0,
233
+ unit: "px",
234
+ },
235
+ offsetY: {
236
+ value: 4,
237
+ unit: "px",
238
+ },
239
+ blur: {
240
+ value: 6,
241
+ unit: "px",
242
+ },
243
+ spread: {
244
+ value: -1,
245
+ unit: "px",
246
+ },
247
+ },
248
+ {
249
+ color: "rgb(0 0 0 / 0.1)",
250
+ offsetX: {
251
+ value: 0,
252
+ unit: "px",
253
+ },
254
+ offsetY: {
255
+ value: 2,
256
+ unit: "px",
257
+ },
258
+ blur: {
259
+ value: 4,
260
+ unit: "px",
261
+ },
262
+ spread: {
263
+ value: -2,
264
+ unit: "px",
265
+ },
266
+ },
267
+ ],
268
+ lg: [
269
+ {
270
+ color: "rgb(0 0 0 / 0.1)",
271
+ offsetX: {
272
+ value: 0,
273
+ unit: "px",
274
+ },
275
+ offsetY: {
276
+ value: 10,
277
+ unit: "px",
278
+ },
279
+ blur: {
280
+ value: 15,
281
+ unit: "px",
282
+ },
283
+ spread: {
284
+ value: -3,
285
+ unit: "px",
286
+ },
287
+ },
288
+ {
289
+ color: "rgb(0 0 0 / 0.1)",
290
+ offsetX: {
291
+ value: 0,
292
+ unit: "px",
293
+ },
294
+ offsetY: {
295
+ value: 4,
296
+ unit: "px",
297
+ },
298
+ blur: {
299
+ value: 6,
300
+ unit: "px",
301
+ },
302
+ spread: {
303
+ value: -4,
304
+ unit: "px",
305
+ },
306
+ },
307
+ ],
308
+ xl: [
309
+ {
310
+ color: "rgb(0 0 0 / 0.1)",
311
+ offsetX: {
312
+ value: 0,
313
+ unit: "px",
314
+ },
315
+ offsetY: {
316
+ value: 20,
317
+ unit: "px",
318
+ },
319
+ blur: {
320
+ value: 25,
321
+ unit: "px",
322
+ },
323
+ spread: {
324
+ value: -5,
325
+ unit: "px",
326
+ },
327
+ },
328
+ {
329
+ color: "rgb(0 0 0 / 0.1)",
330
+ offsetX: {
331
+ value: 0,
332
+ unit: "px",
333
+ },
334
+ offsetY: {
335
+ value: 8,
336
+ unit: "px",
337
+ },
338
+ blur: {
339
+ value: 10,
340
+ unit: "px",
341
+ },
342
+ spread: {
343
+ value: -6,
344
+ unit: "px",
345
+ },
346
+ },
347
+ ],
348
+ "2xl": [
349
+ {
350
+ color: "rgb(0 0 0 / 0.25)",
351
+ offsetX: {
352
+ value: 0,
353
+ unit: "px",
354
+ },
355
+ offsetY: {
356
+ value: 25,
357
+ unit: "px",
358
+ },
359
+ blur: {
360
+ value: 50,
361
+ unit: "px",
362
+ },
363
+ spread: {
364
+ value: -12,
365
+ unit: "px",
366
+ },
367
+ },
368
+ ],
369
+ none: [
370
+ {
371
+ color: "transparent",
372
+ offsetX: {
373
+ value: 0,
374
+ unit: "px",
375
+ },
376
+ offsetY: {
377
+ value: 0,
378
+ unit: "px",
379
+ },
380
+ blur: {
381
+ value: 0,
382
+ unit: "px",
383
+ },
384
+ spread: {
385
+ value: 0,
386
+ unit: "px",
387
+ },
388
+ },
389
+ ],
390
+ },
391
+ breakpoint: {
392
+ sm: "40rem",
393
+ md: "48rem",
394
+ lg: "64rem",
395
+ xl: "80rem",
396
+ "2xl": "96rem",
397
+ },
398
+ container: {
399
+ "3xs": "16rem",
400
+ "2xs": "18rem",
401
+ xs: "20rem",
402
+ sm: "24rem",
403
+ md: "28rem",
404
+ lg: "32rem",
405
+ xl: "36rem",
406
+ "2xl": "42rem",
407
+ "3xl": "48rem",
408
+ "4xl": "56rem",
409
+ "5xl": "64rem",
410
+ "6xl": "72rem",
411
+ "7xl": "80rem",
412
+ },
413
+ "z-index": {
414
+ 0: 0,
415
+ 10: 10,
416
+ 20: 20,
417
+ 30: 30,
418
+ 40: 40,
419
+ 50: 50,
420
+ auto: "auto",
421
+ },
422
+ ease: {
423
+ in: [0.4, 0, 1, 1],
424
+ out: [0, 0, 0.2, 1],
425
+ "in-out": [0.4, 0, 0.2, 1],
426
+ },
427
+ duration: {
428
+ 75: "75ms",
429
+ 100: "100ms",
430
+ 150: "150ms",
431
+ 200: "200ms",
432
+ 300: "300ms",
433
+ 500: "500ms",
434
+ 700: "700ms",
435
+ 1000: "1000ms",
436
+ },
437
+ animate: {
438
+ spin: "spin 1s linear infinite",
439
+ ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite",
440
+ pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
441
+ bounce: "bounce 1s infinite",
442
+ },
443
+ };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ export default {
6
+ color: {
7
+ "surface-canvas": "#ffffff",
8
+ "surface-panel": "#f8f8f8",
9
+ "surface-raised": "#ffffff",
10
+ "surface-inset": "#ffffff",
11
+ "surface-hover": "#e9e9e9",
12
+ "surface-pressed": "#505050",
13
+ "surface-selected": "#e5f0fe",
14
+ "surface-disabled": "#e9e9e9",
15
+ "overlay-scrim": "#000000",
16
+ "text-primary": "#131313",
17
+ "text-secondary": "#505050",
18
+ "text-tertiary": "#717171",
19
+ "text-disabled": "#8f8f8f",
20
+ "text-accent": "#3b63fb",
21
+ "text-destructive": "#d73220",
22
+ "text-success": "#079355",
23
+ "text-warning": "#d45b00",
24
+ "text-on-accent": "#ffffff",
25
+ "text-on-destructive": "#ffffff",
26
+ "text-on-success": "#ffffff",
27
+ "text-on-warning": "#000000",
28
+ "border-subtle": "#dadada",
29
+ "border-default": "#c6c6c6",
30
+ "border-strong": "#8f8f8f",
31
+ "border-focus": "#4b75ff",
32
+ "border-accent": "#3b63fb",
33
+ "border-destructive": "#d73220",
34
+ accent: "#3b63fb",
35
+ "accent-hover": "#274dea",
36
+ "accent-pressed": "#274dea",
37
+ "accent-subtle": "#e5f0fe",
38
+ destructive: "#d73220",
39
+ "destructive-hover": "#b72818",
40
+ "destructive-pressed": "#b72818",
41
+ "destructive-subtle": "#ffebe8",
42
+ success: "#05834e",
43
+ "success-subtle": "#d7f7e1",
44
+ warning: "#fc7d00",
45
+ "warning-subtle": "#ffeccf",
46
+ "ring-focus": "#4b75ff",
47
+ "chart-1": "#4b75ff",
48
+ "chart-2": "#079355",
49
+ "chart-3": "#4b75ff",
50
+ "chart-4": "#d45b00",
51
+ "chart-5": "#8f8f8f",
52
+ "chart-positive": "#079355",
53
+ "chart-negative": "#f03823",
54
+ "chart-neutral": "#8f8f8f",
55
+ },
56
+ };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ :root {
6
+ --color-surface-canvas: #ffffff;
7
+ --color-surface-panel: #f8f8f8;
8
+ --color-surface-raised: #ffffff;
9
+ --color-surface-inset: #ffffff;
10
+ --color-surface-hover: #e9e9e9;
11
+ --color-surface-pressed: #505050;
12
+ --color-surface-selected: #e5f0fe;
13
+ --color-surface-disabled: #e9e9e9;
14
+ --color-overlay-scrim: #000000;
15
+ --color-text-primary: #131313;
16
+ --color-text-secondary: #505050;
17
+ --color-text-tertiary: #717171;
18
+ --color-text-disabled: #8f8f8f;
19
+ --color-text-accent: #3b63fb;
20
+ --color-text-destructive: #d73220;
21
+ --color-text-success: #079355;
22
+ --color-text-warning: #d45b00;
23
+ --color-text-on-accent: #ffffff;
24
+ --color-text-on-destructive: #ffffff;
25
+ --color-text-on-success: #ffffff;
26
+ --color-text-on-warning: #000000;
27
+ --color-border-subtle: #dadada;
28
+ --color-border-default: #c6c6c6;
29
+ --color-border-strong: #8f8f8f;
30
+ --color-border-focus: #4b75ff;
31
+ --color-border-accent: #3b63fb;
32
+ --color-border-destructive: #d73220;
33
+ --color-accent: #3b63fb;
34
+ --color-accent-hover: #274dea;
35
+ --color-accent-pressed: #274dea;
36
+ --color-accent-subtle: #e5f0fe;
37
+ --color-destructive: #d73220;
38
+ --color-destructive-hover: #b72818;
39
+ --color-destructive-pressed: #b72818;
40
+ --color-destructive-subtle: #ffebe8;
41
+ --color-success: #05834e;
42
+ --color-success-subtle: #d7f7e1;
43
+ --color-warning: #fc7d00;
44
+ --color-warning-subtle: #ffeccf;
45
+ --color-ring-focus: #4b75ff;
46
+ --color-chart-1: #4b75ff;
47
+ --color-chart-2: #079355;
48
+ --color-chart-3: #4b75ff;
49
+ --color-chart-4: #d45b00;
50
+ --color-chart-5: #8f8f8f;
51
+ --color-chart-positive: #079355;
52
+ --color-chart-negative: #f03823;
53
+ --color-chart-neutral: #8f8f8f;
54
+ }
@@ -1,16 +1,74 @@
1
- export { colors } from "./colors";
2
- export {
3
- COLOR_MODE_ATTRIBUTE,
4
- COLOR_SYSTEM_ATTRIBUTE,
5
- colorSystems,
6
- colorTokenNames,
7
- } from "./colors";
8
- export type { ColorMode, ColorSystem, ColorToken } from "./colors";
9
- export { durations, easingWeb, translateDistances } from "./motion";
10
- export { radii } from "./radii";
11
- export { shadowsNative, shadowsWeb } from "./shadows";
12
- export { contentWidths, spacing } from "./spacing";
13
- export { fontFamilies, fontSizes, fontWeights, letterSpacing, lineHeights } from "./typography";
14
- export type { RadiusToken } from "./radii";
15
- export type { ContentWidthToken, SpacingToken } from "./spacing";
16
- export type { FontSizeToken, FontWeightToken } from "./typography";
1
+ import darkTokens from "./generated/dark.colors.generated";
2
+ import foundations from "./generated/foundations.generated";
3
+ import lightTokens from "./generated/light.colors.generated";
4
+
5
+ const toPixels = (value: string) => {
6
+ if (value.endsWith("rem")) return Number.parseFloat(value) * 16;
7
+ if (value.endsWith("px")) return Number.parseFloat(value);
8
+ throw new Error(`Unsupported foundation dimension: ${value}`);
9
+ };
10
+
11
+ const toMilliseconds = (value: string) => Number.parseFloat(value);
12
+ const toBezier = (value: number[]) => `cubic-bezier(${value.join(", ")})`;
13
+ type NormalizedSpacingKey<Key extends string> = Key extends `${infer Whole}-${infer Fraction}`
14
+ ? `${Whole}.${Fraction}`
15
+ : Key;
16
+ export type SpacingToken = NormalizedSpacingKey<keyof typeof foundations["spacing-scale"] & string>;
17
+
18
+ export const colorTokenNames = Object.keys(lightTokens.color) as Array<keyof typeof lightTokens.color>;
19
+ export type ColorToken = keyof typeof lightTokens.color;
20
+ export type ColorMode = "light" | "dark";
21
+ export type ColorTheme = Readonly<Record<ColorToken, string>>;
22
+
23
+ export const colorThemes = {
24
+ light: lightTokens.color,
25
+ dark: darkTokens.color,
26
+ } as const satisfies Record<ColorMode, ColorTheme>;
27
+
28
+ export const colors = colorTokenNames.reduce(
29
+ (accumulator, token) => {
30
+ accumulator[token] = `var(--color-${token})`;
31
+ return accumulator;
32
+ },
33
+ {} as Record<ColorToken, `var(--color-${string})`>,
34
+ );
35
+
36
+ export const spacing = Object.fromEntries(
37
+ Object.entries(foundations["spacing-scale"]).map(([key, value]) => [key.replace("-", "."), toPixels(value)]),
38
+ ) as Record<SpacingToken, number>;
39
+
40
+ export const fontFamilies = Object.fromEntries(
41
+ Object.entries(foundations.font).map(([key, value]) => [key, value.join(", ")]),
42
+ ) as Record<keyof typeof foundations.font, string>;
43
+
44
+ export const fontFamiliesNative = { sans: "System", serif: "serif", mono: "monospace" } as const;
45
+ export const textSizes = Object.fromEntries(
46
+ Object.entries(foundations.text).map(([key, value]) => [key, toPixels(value)]),
47
+ ) as Record<keyof typeof foundations.text, number>;
48
+ export const textLineHeights = foundations["text-line-height"];
49
+ export const fontWeights = Object.fromEntries(
50
+ Object.entries(foundations["font-weight"]).map(([key, value]) => [key, String(value)]),
51
+ ) as Record<keyof typeof foundations["font-weight"], string>;
52
+ export const tracking = foundations.tracking;
53
+ export const leading = foundations.leading;
54
+ export const radii = Object.fromEntries(
55
+ Object.entries(foundations.radius).map(([key, value]) => [key, toPixels(value)]),
56
+ ) as Record<keyof typeof foundations.radius, number>;
57
+ export const shadows = foundations.shadow;
58
+ export const breakpoints = foundations.breakpoint;
59
+ export const containers = foundations.container;
60
+ export const zIndices = foundations["z-index"];
61
+ export const easing = Object.fromEntries(
62
+ Object.entries(foundations.ease).map(([key, value]) => [key, toBezier(value)]),
63
+ ) as Record<keyof typeof foundations.ease, string>;
64
+ export const transitionDurations = Object.fromEntries(
65
+ Object.entries(foundations.duration).map(([key, value]) => [key, toMilliseconds(value)]),
66
+ ) as Record<keyof typeof foundations.duration, number>;
67
+ export const animations = foundations.animate;
68
+
69
+ export type RadiusToken = keyof typeof radii;
70
+ export type TextSizeToken = keyof typeof textSizes;
71
+ export type FontWeightToken = keyof typeof fontWeights;
72
+ export type TrackingToken = keyof typeof tracking;
73
+ export type LeadingToken = keyof typeof leading;
74
+ export type ShadowToken = keyof typeof shadows;