@leitware/composables 1.5.0 → 1.6.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.
@@ -0,0 +1,360 @@
1
+ import { defaultPreset, defaultPresetDark } from './default'
2
+
3
+ /**
4
+ * Inspired by Cloudflare Kumo's theme and button treatments:
5
+ * https://github.com/cloudflare/kumo/blob/main/packages/kumo/scripts/theme-generator/config.ts
6
+ * https://github.com/cloudflare/kumo/blob/main/packages/kumo/src/components/button/button.tsx
7
+ *
8
+ * Kumo's blue action colour (oklch(0.5772 0.2324 260)) is #056dff in sRGB.
9
+ * Orange is the Cloudflare brand accent; primary actions remain blue.
10
+ * Semantic status surfaces stay tinted; action and brand buttons use solid fills.
11
+ */
12
+ type BrandButton = 'brand' | 'brand-2' | 'brand-3' | 'brand-4' | 'brand-5'
13
+
14
+ function emphasisFinish(
15
+ kind: 'primary' | 'destructive' | BrandButton,
16
+ fill: string,
17
+ gradientMix = { start: 15, hover: 30 },
18
+ ): Record<string, string> {
19
+ const edge = `color-mix(in oklch, ${fill}, black 10%)`
20
+ const highlight = `color-mix(in oklch, ${fill}, white 30%)`
21
+ return {
22
+ [`--button-${kind}-border`]: edge,
23
+ [`--button-${kind}-hover-border`]: edge,
24
+ [`--button-${kind}-background-image`]: `linear-gradient(to bottom, color-mix(in oklch, ${fill}, white ${gradientMix.start}%), ${fill})`,
25
+ [`--button-${kind}-hover-background-image`]: `linear-gradient(to bottom, color-mix(in oklch, ${fill}, white ${gradientMix.hover}%), ${fill})`,
26
+ [`--button-${kind}-shadow`]: `inset 0 1px 0 ${highlight}, 0 1px 2px #0000000d`,
27
+ [`--button-${kind}-hover-shadow`]: `inset 0 1px 0 ${highlight}, 0 1px 2px #0000000d`,
28
+ }
29
+ }
30
+
31
+ function brandFinishes(
32
+ text: Record<BrandButton, string>,
33
+ fills: Partial<Record<BrandButton, string>> = {},
34
+ ): Record<string, string> {
35
+ const variants = ['brand', 'brand-2', 'brand-3', 'brand-4', 'brand-5'] as const
36
+ return Object.assign(
37
+ {},
38
+ ...variants.map((variant) => {
39
+ const fill = fills[variant] ?? `var(--bg-fill-${variant})`
40
+ return {
41
+ // White labels need a restrained gradient to keep contrast
42
+ // above 4.5:1, including the brightest hover stop.
43
+ ...emphasisFinish(
44
+ variant,
45
+ fill,
46
+ variant === 'brand' || variant === 'brand-2' || variant === 'brand-5'
47
+ ? { start: 1, hover: 2 }
48
+ : text[variant] === '#FFFFFF'
49
+ ? { start: 3, hover: 5 }
50
+ : { start: 5, hover: 10 },
51
+ ),
52
+ [`--button-${variant}-bg`]: fill,
53
+ [`--button-${variant}-text`]: text[variant],
54
+ }
55
+ }),
56
+ )
57
+ }
58
+
59
+ // Saturated action fills keep their energy in both themes. Orange, turquoise,
60
+ // and green use deeper shades than the shared accents for readable white labels.
61
+ const brandButtonFills: Record<BrandButton, string> = {
62
+ brand: '#D43C00',
63
+ 'brand-2': '#008090',
64
+ 'brand-3': '#8A00F5',
65
+ 'brand-4': '#0057FF',
66
+ 'brand-5': '#008700',
67
+ }
68
+
69
+ const shape: Record<string, string> = {
70
+ '--spacing': '0.25rem',
71
+ '--border-width-base': '0.0625rem',
72
+ '--radius': '0.5rem',
73
+ '--font-size-base': '0.875rem',
74
+ '--text-xs': '0.75rem',
75
+ '--text-xs--line-height': '1.333333',
76
+ '--text-sm': '0.8125rem',
77
+ '--text-sm--line-height': '1.5',
78
+ '--leading-base': '1.5',
79
+ '--letter-spacing-base': '0.01em',
80
+ '--font-sans': '"Inter Variable", ui-sans-serif, system-ui, sans-serif',
81
+ '--font-heading': '"Inter Variable", ui-sans-serif, system-ui, sans-serif',
82
+ '--font-brand': '"Inter Variable", ui-sans-serif, system-ui, sans-serif',
83
+ '--button-radius': 'var(--radius-lg)',
84
+ '--button-radius-xs': '0.25rem',
85
+ '--button-radius-sm': '0.375rem',
86
+ '--button-height': 'calc(var(--spacing) * 9)',
87
+ '--button-height-xs': 'calc(var(--spacing) * 5)',
88
+ '--button-height-sm': 'calc(var(--spacing) * 6.5)',
89
+ '--button-height-lg': 'calc(var(--spacing) * 10)',
90
+ '--button-font-size': 'var(--text-base)',
91
+ '--button-font-size-xs': 'var(--text-xs)',
92
+ '--button-font-size-sm': 'var(--text-xs)',
93
+ '--button-gap': 'calc(var(--spacing) * 1.5)',
94
+ '--card-radius': 'var(--radius-xl)',
95
+ '--input-radius': 'var(--radius-lg)',
96
+ '--input-height': 'calc(var(--spacing) * 9)',
97
+ '--badge-radius': 'var(--radius-md)',
98
+ '--opacity-disabled': '0.5',
99
+ '--shadow-offset-y': '1px',
100
+ '--shadow-blur': '2px',
101
+ '--shadow-spread': '0px',
102
+ '--shadow-base-color': '#0000000D',
103
+ '--button-secondary-border': 'var(--border-secondary)',
104
+ '--button-secondary-hover-bg': 'var(--bg-surface-hover)',
105
+ '--button-secondary-shadow': '0 1px 2px #0000000d',
106
+ '--button-secondary-hover-shadow': '0 1px 2px #0000000d',
107
+ '--button-outline-shadow': '0 1px 2px #0000000d',
108
+ '--button-outline-hover-shadow': '0 1px 2px #0000000d',
109
+ '--button-quiet-hover-bg': 'var(--bg-surface-hover)',
110
+ '--button-destructive-bg': 'var(--bg-fill-critical)',
111
+ '--button-destructive-text': '#FFFFFF',
112
+ '--focus-ring-width': '2px',
113
+ '--focus-ring-color': 'var(--border-focus)',
114
+ '--hover-ring-width': '0px',
115
+ '--hover-ring-color': 'var(--border-secondary)',
116
+ '--hover-transform': 'none',
117
+ '--hover-shadow': 'none',
118
+ '--active-scale': '1',
119
+ '--heading-font-weight': '600',
120
+ '--hero-font-weight': '600',
121
+ '--section-title-font-weight': '600',
122
+ '--card-title-font-weight': '600',
123
+ }
124
+
125
+ export const kumo: Record<string, string> = {
126
+ ...defaultPreset,
127
+ ...shape,
128
+ ...emphasisFinish('primary', 'var(--bg-fill-primary)'),
129
+ ...emphasisFinish('destructive', 'var(--bg-fill-critical)'),
130
+ ...brandFinishes(
131
+ {
132
+ brand: '#FFFFFF',
133
+ 'brand-2': '#FFFFFF',
134
+ 'brand-3': '#FFFFFF',
135
+ 'brand-4': '#FFFFFF',
136
+ 'brand-5': '#FFFFFF',
137
+ },
138
+ brandButtonFills,
139
+ ),
140
+
141
+ '--bg-default': '#FBFBFB',
142
+ '--bg-inverse': '#080808',
143
+ '--bg-muted': '#F2F2F2',
144
+ '--bg-surface-default': '#FFFFFF',
145
+ '--bg-surface-popover': '#FFFFFF',
146
+ '--bg-surface-accent': '#F8F8F8',
147
+ '--bg-surface-field': '#FFFFFF',
148
+ '--bg-surface-hover': '#F5F5F5',
149
+ '--bg-surface-inverse': '#080808',
150
+ '--bg-surface-transparent': '#0000000D',
151
+ '--bg-overlay': '#00000080',
152
+ '--bg-surface-info': '#EFF6FF',
153
+ '--bg-surface-success': '#ECFDF5',
154
+ '--bg-surface-warning': '#FFFBEB',
155
+ '--bg-surface-critical': '#FEF2F2',
156
+ '--bg-surface-emphasis': '#EFF6FF',
157
+ '--bg-surface-brand': '#FFF2E8',
158
+ '--bg-surface-brand-2': '#E7FCFF',
159
+ '--bg-surface-brand-3': '#F6EBFF',
160
+ '--bg-surface-brand-4': '#EDF3FF',
161
+ '--bg-surface-brand-5': '#EBFFF0',
162
+ '--bg-fill-default': '#FFFFFF',
163
+ '--bg-fill-primary': '#056DFF',
164
+ '--bg-fill-secondary': '#FFFFFF',
165
+ '--bg-fill-secondary-inverse': '#171717',
166
+ '--bg-fill-transparent': '#0000000D',
167
+ '--bg-fill-brand': '#FF6A00',
168
+ '--bg-fill-brand-2': '#00C2D6',
169
+ '--bg-fill-brand-3': '#8A00F5',
170
+ '--bg-fill-brand-4': '#0057FF',
171
+ '--bg-fill-brand-5': '#00B83F',
172
+ '--bg-fill-info': '#3B82F6',
173
+ '--bg-fill-success': '#059669',
174
+ '--bg-fill-warning': '#F59E0B',
175
+ '--bg-fill-critical': 'oklch(63.7% 0.237 25.331)',
176
+ '--bg-fill-emphasis': '#056DFF',
177
+ '--text-default': '#171717',
178
+ '--text-secondary': '#737373',
179
+ '--text-muted': '#737373',
180
+ '--text-disabled': '#D4D4D4',
181
+ '--text-inverse': '#F5F5F5',
182
+ '--text-on-fill-primary': '#FFFFFF',
183
+ '--text-on-fill-brand': '#171717',
184
+ '--text-on-fill-secondary': '#171717',
185
+ '--text-on-surface-accent': '#171717',
186
+ '--text-info': '#1E40AF',
187
+ '--text-success': '#065F46',
188
+ '--text-warning': '#A16207',
189
+ '--text-critical': '#B91C1C',
190
+ '--text-emphasis': '#1E40AF',
191
+ '--text-brand': '#A93600',
192
+ '--text-brand-2': '#006778',
193
+ '--text-brand-3': '#7200CA',
194
+ '--text-brand-4': '#0042CC',
195
+ '--text-brand-5': '#006E23',
196
+ '--text-link': '#1E40AF',
197
+ '--icon-default': '#171717',
198
+ '--icon-secondary': '#737373',
199
+ '--icon-disabled': '#D4D4D4',
200
+ '--icon-inverse': '#F5F5F5',
201
+ '--icon-info': '#3B82F6',
202
+ '--icon-success': '#059669',
203
+ '--icon-warning': '#D97706',
204
+ '--icon-critical': '#EF4444',
205
+ '--icon-emphasis': '#056DFF',
206
+ '--icon-brand': '#FF6A00',
207
+ '--icon-brand-2': '#00A5BA',
208
+ '--icon-brand-3': '#8A00F5',
209
+ '--icon-brand-4': '#0057FF',
210
+ '--icon-brand-5': '#00A536',
211
+ '--border-default': '#E9E9E9',
212
+ '--border-secondary': '#1717171A',
213
+ '--border-input': '#1717171A',
214
+ '--border-tertiary': '#D4D4D4',
215
+ '--border-disabled': '#E5E5E5',
216
+ '--border-inverse': '#525252',
217
+ '--border-focus': '#056DFF',
218
+ '--border-info': '#BFDBFE',
219
+ '--border-success': '#A7F3D0',
220
+ '--border-warning': '#FDE68A',
221
+ '--border-critical': '#FECACA',
222
+ '--border-emphasis': '#BFDBFE',
223
+ '--border-brand': '#FFBB8A',
224
+ '--border-brand-2': '#71E5F2',
225
+ '--border-brand-3': '#D1A3FF',
226
+ '--border-brand-4': '#9ABBFF',
227
+ '--border-brand-5': '#80EFA4',
228
+ '--chart-1': '#056DFF',
229
+ '--chart-2': '#FF6A00',
230
+ '--chart-3': '#00B83F',
231
+ '--chart-4': '#8A00F5',
232
+ '--chart-5': '#EF4444',
233
+ '--sidebar-background': '#FBFBFB',
234
+ '--sidebar-foreground': '#171717',
235
+ '--sidebar-primary': '#056DFF',
236
+ '--sidebar-primary-foreground': '#FFFFFF',
237
+ '--sidebar-accent': '#F5F5F5',
238
+ '--sidebar-accent-foreground': '#171717',
239
+ '--sidebar-border': '#E9E9E9',
240
+ '--sidebar-ring': '#056DFF',
241
+ }
242
+
243
+ export const kumoDark: Record<string, string> = {
244
+ ...defaultPresetDark,
245
+ ...shape,
246
+ ...emphasisFinish('primary', 'var(--bg-fill-primary)'),
247
+ ...emphasisFinish('destructive', 'var(--bg-fill-critical)'),
248
+ ...brandFinishes(
249
+ {
250
+ brand: '#FFFFFF',
251
+ 'brand-2': '#FFFFFF',
252
+ 'brand-3': '#FFFFFF',
253
+ 'brand-4': '#FFFFFF',
254
+ 'brand-5': '#FFFFFF',
255
+ },
256
+ brandButtonFills,
257
+ ),
258
+
259
+ '--shadow-base-color': '#0000004D',
260
+ '--bg-default': '#030303',
261
+ '--bg-inverse': '#FBFBFB',
262
+ '--bg-muted': '#0B0B0B',
263
+ '--bg-surface-default': '#0F0F0F',
264
+ '--bg-surface-popover': '#0F0F0F',
265
+ '--bg-surface-accent': '#060606',
266
+ '--bg-surface-field': '#171717',
267
+ '--bg-surface-hover': '#262626',
268
+ '--bg-surface-inverse': '#FBFBFB',
269
+ '--bg-surface-transparent': '#FFFFFF0D',
270
+ '--bg-overlay': '#000000B3',
271
+ '--bg-surface-info': '#101B35',
272
+ '--bg-surface-success': '#0B241B',
273
+ '--bg-surface-warning': '#2B2111',
274
+ '--bg-surface-critical': '#2C1415',
275
+ '--bg-surface-emphasis': '#101B35',
276
+ '--bg-surface-brand': '#311A0A',
277
+ '--bg-surface-brand-2': '#062B31',
278
+ '--bg-surface-brand-3': '#291039',
279
+ '--bg-surface-brand-4': '#0B1C3D',
280
+ '--bg-surface-brand-5': '#082B13',
281
+ '--bg-fill-default': '#0F0F0F',
282
+ '--bg-fill-primary': '#045EDE',
283
+ '--bg-fill-secondary': '#0F0F0F',
284
+ '--bg-fill-secondary-inverse': '#F5F5F5',
285
+ '--bg-fill-transparent': '#FFFFFF0D',
286
+ '--bg-fill-brand': '#FF6A00',
287
+ '--bg-fill-brand-2': '#00D9ED',
288
+ '--bg-fill-brand-3': '#B35CFF',
289
+ '--bg-fill-brand-4': '#4791FF',
290
+ '--bg-fill-brand-5': '#22E65F',
291
+ '--bg-fill-info': '#3B82F6',
292
+ '--bg-fill-success': '#34D399',
293
+ '--bg-fill-warning': '#EA580C',
294
+ '--bg-fill-critical': 'oklch(57.7% 0.245 27.325)',
295
+ '--bg-fill-emphasis': '#045EDE',
296
+ '--text-default': '#F5F5F5',
297
+ '--text-secondary': '#A3A3A3',
298
+ '--text-muted': '#A3A3A3',
299
+ '--text-disabled': '#525252',
300
+ '--text-inverse': '#171717',
301
+ '--text-on-fill-primary': '#FFFFFF',
302
+ '--text-on-fill-brand': '#171717',
303
+ '--text-on-fill-secondary': '#F5F5F5',
304
+ '--text-on-surface-accent': '#F5F5F5',
305
+ '--text-info': '#60A5FA',
306
+ '--text-success': '#A7F3D0',
307
+ '--text-warning': '#FB923C',
308
+ '--text-critical': '#F87171',
309
+ '--text-emphasis': '#60A5FA',
310
+ '--text-brand': '#FFAE70',
311
+ '--text-brand-2': '#66EDFF',
312
+ '--text-brand-3': '#D49AFF',
313
+ '--text-brand-4': '#80B3FF',
314
+ '--text-brand-5': '#6BF593',
315
+ '--text-link': '#60A5FA',
316
+ '--icon-default': '#F5F5F5',
317
+ '--icon-secondary': '#A3A3A3',
318
+ '--icon-disabled': '#525252',
319
+ '--icon-inverse': '#171717',
320
+ '--icon-info': '#60A5FA',
321
+ '--icon-success': '#34D399',
322
+ '--icon-warning': '#FB923C',
323
+ '--icon-critical': '#F87171',
324
+ '--icon-emphasis': '#60A5FA',
325
+ '--icon-brand': '#FF842E',
326
+ '--icon-brand-2': '#00D9ED',
327
+ '--icon-brand-3': '#B35CFF',
328
+ '--icon-brand-4': '#4791FF',
329
+ '--icon-brand-5': '#22E65F',
330
+ '--border-default': '#262626',
331
+ '--border-secondary': '#333333',
332
+ '--border-input': '#333333',
333
+ '--border-tertiary': '#404040',
334
+ '--border-disabled': '#262626',
335
+ '--border-inverse': '#D4D4D4',
336
+ '--border-focus': '#60A5FA',
337
+ '--border-info': '#1E3A8A',
338
+ '--border-success': '#065F46',
339
+ '--border-warning': '#78350F',
340
+ '--border-critical': '#7F1D1D',
341
+ '--border-emphasis': '#1E3A8A',
342
+ '--border-brand': '#A23B00',
343
+ '--border-brand-2': '#007B8A',
344
+ '--border-brand-3': '#7222A8',
345
+ '--border-brand-4': '#174FAD',
346
+ '--border-brand-5': '#00732A',
347
+ '--chart-1': '#60A5FA',
348
+ '--chart-2': '#FF6A00',
349
+ '--chart-3': '#22E65F',
350
+ '--chart-4': '#B35CFF',
351
+ '--chart-5': '#F87171',
352
+ '--sidebar-background': '#030303',
353
+ '--sidebar-foreground': '#F5F5F5',
354
+ '--sidebar-primary': '#045EDE',
355
+ '--sidebar-primary-foreground': '#FFFFFF',
356
+ '--sidebar-accent': '#262626',
357
+ '--sidebar-accent-foreground': '#F5F5F5',
358
+ '--sidebar-border': '#262626',
359
+ '--sidebar-ring': '#60A5FA',
360
+ }
@@ -25,6 +25,82 @@
25
25
 
26
26
  /* ── Component dimensions ──────────────────────────────────────────── */
27
27
  --button-radius: var(--radius-md);
28
+ --button-radius-xs: var(--button-radius);
29
+ --button-radius-sm: var(--button-radius);
30
+ --button-height: calc(var(--spacing) * 7);
31
+ --button-height-xs: calc(var(--spacing) * 5);
32
+ --button-height-sm: calc(var(--spacing) * 6);
33
+ --button-height-lg: calc(var(--spacing) * 8);
34
+ --button-font-size: var(--text-xs);
35
+ --button-font-size-xs: var(--text-2xs);
36
+ --button-font-size-sm: var(--text-xs);
37
+ --button-gap: var(--spacing);
38
+
39
+ /* Optional button finishes. `initial` makes var() use its fallback
40
+ on the button, so semantic colours still resolve in scoped themes. */
41
+ --button-primary-border: transparent;
42
+ --button-primary-hover-border: initial;
43
+ --button-primary-background-image: none;
44
+ --button-primary-hover-background-image: none;
45
+ --button-primary-shadow: none;
46
+ --button-primary-hover-shadow: initial;
47
+ --button-destructive-bg: initial;
48
+ --button-destructive-text: initial;
49
+ --button-destructive-border: initial;
50
+ --button-destructive-hover-border: initial;
51
+ --button-destructive-background-image: none;
52
+ --button-destructive-hover-background-image: none;
53
+ --button-destructive-shadow: none;
54
+ --button-destructive-hover-shadow: initial;
55
+ --button-secondary-border: transparent;
56
+ --button-secondary-hover-bg: initial;
57
+ --button-secondary-shadow: none;
58
+ --button-secondary-hover-shadow: initial;
59
+ --button-outline-shadow: none;
60
+ --button-outline-hover-shadow: initial;
61
+ --button-quiet-hover-bg: initial;
62
+
63
+ /* Brand buttons can opt into the same filled finishes per colour. */
64
+ --button-brand-bg: initial;
65
+ --button-brand-text: initial;
66
+ --button-brand-border: initial;
67
+ --button-brand-hover-border: initial;
68
+ --button-brand-background-image: none;
69
+ --button-brand-hover-background-image: none;
70
+ --button-brand-shadow: none;
71
+ --button-brand-hover-shadow: initial;
72
+ --button-brand-2-bg: initial;
73
+ --button-brand-2-text: initial;
74
+ --button-brand-2-border: initial;
75
+ --button-brand-2-hover-border: initial;
76
+ --button-brand-2-background-image: none;
77
+ --button-brand-2-hover-background-image: none;
78
+ --button-brand-2-shadow: none;
79
+ --button-brand-2-hover-shadow: initial;
80
+ --button-brand-3-bg: initial;
81
+ --button-brand-3-text: initial;
82
+ --button-brand-3-border: initial;
83
+ --button-brand-3-hover-border: initial;
84
+ --button-brand-3-background-image: none;
85
+ --button-brand-3-hover-background-image: none;
86
+ --button-brand-3-shadow: none;
87
+ --button-brand-3-hover-shadow: initial;
88
+ --button-brand-4-bg: initial;
89
+ --button-brand-4-text: initial;
90
+ --button-brand-4-border: initial;
91
+ --button-brand-4-hover-border: initial;
92
+ --button-brand-4-background-image: none;
93
+ --button-brand-4-hover-background-image: none;
94
+ --button-brand-4-shadow: none;
95
+ --button-brand-4-hover-shadow: initial;
96
+ --button-brand-5-bg: initial;
97
+ --button-brand-5-text: initial;
98
+ --button-brand-5-border: initial;
99
+ --button-brand-5-hover-border: initial;
100
+ --button-brand-5-background-image: none;
101
+ --button-brand-5-hover-background-image: none;
102
+ --button-brand-5-shadow: none;
103
+ --button-brand-5-hover-shadow: initial;
28
104
  --card-radius: var(--radius-lg);
29
105
  --card-padding: calc(var(--spacing) * 4);
30
106
  --input-radius: var(--radius-md);