typewritingclass 0.2.0 → 0.2.2

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.
@@ -2,6 +2,7 @@ import type { StyleRule } from '../types.ts'
2
2
  import type { DynamicValue } from '../dynamic.ts'
3
3
  import { createRule, createDynamicRule } from '../rule.ts'
4
4
  import { isDynamic } from '../dynamic.ts'
5
+ import { resolveColor } from './colors.ts'
5
6
 
6
7
  export function bgAttachment(value: string): StyleRule {
7
8
  return createRule({ 'background-attachment': value })
@@ -51,7 +52,7 @@ export function bgImage(value: string | DynamicValue): StyleRule {
51
52
 
52
53
  export function bgGradient(direction: string = 'to right'): StyleRule {
53
54
  return createRule({
54
- 'background-image': `linear-gradient(${direction}, var(--twc-gradient-from, transparent), var(--twc-gradient-via, transparent), var(--twc-gradient-to, transparent))`,
55
+ 'background-image': `linear-gradient(${direction}, var(--twc-gradient-stops, var(--twc-gradient-from, transparent), var(--twc-gradient-to, transparent)))`,
55
56
  })
56
57
  }
57
58
 
@@ -62,17 +63,17 @@ export function gradientFrom(color: string | DynamicValue): StyleRule {
62
63
  { [color.__id]: String(color.__value) },
63
64
  )
64
65
  }
65
- return createRule({ '--twc-gradient-from': color })
66
+ return createRule({ '--twc-gradient-from': resolveColor(color) })
66
67
  }
67
68
 
68
69
  export function gradientVia(color: string | DynamicValue): StyleRule {
69
70
  if (isDynamic(color)) {
70
71
  return createDynamicRule(
71
- { '--twc-gradient-via': `var(${color.__id})` },
72
+ { '--twc-gradient-via': `var(${color.__id})`, '--twc-gradient-stops': 'var(--twc-gradient-from, transparent), var(--twc-gradient-via), var(--twc-gradient-to, transparent)' },
72
73
  { [color.__id]: String(color.__value) },
73
74
  )
74
75
  }
75
- return createRule({ '--twc-gradient-via': color })
76
+ return createRule({ '--twc-gradient-via': resolveColor(color), '--twc-gradient-stops': 'var(--twc-gradient-from, transparent), var(--twc-gradient-via), var(--twc-gradient-to, transparent)' })
76
77
  }
77
78
 
78
79
  export function gradientTo(color: string | DynamicValue): StyleRule {
@@ -82,5 +83,5 @@ export function gradientTo(color: string | DynamicValue): StyleRule {
82
83
  { [color.__id]: String(color.__value) },
83
84
  )
84
85
  }
85
- return createRule({ '--twc-gradient-to': color })
86
+ return createRule({ '--twc-gradient-to': resolveColor(color) })
86
87
  }
@@ -1,8 +1,25 @@
1
1
  import type { StyleRule } from '../types.ts'
2
2
  import type { DynamicValue } from '../dynamic.ts'
3
3
  import { createRule, createDynamicRule, wrapWithSelectorTemplate } from '../rule.ts'
4
- import { DEFAULT as defaultRadius } from '../theme/borders.ts'
4
+ import * as borderRadii from '../theme/borders.ts'
5
5
  import { isDynamic } from '../dynamic.ts'
6
+ import { resolveColor } from './colors.ts'
7
+
8
+ function px(value: string | number): string {
9
+ return typeof value === 'number' ? `${value}px` : value
10
+ }
11
+
12
+ const radiusMap: Record<string, string> = {
13
+ none: borderRadii.none, sm: borderRadii.sm, DEFAULT: borderRadii.DEFAULT,
14
+ md: borderRadii.md, lg: borderRadii.lg, xl: borderRadii.xl,
15
+ '2xl': borderRadii._2xl, '3xl': borderRadii._3xl, full: borderRadii.full,
16
+ }
17
+
18
+ function resolveRadius(value?: string | DynamicValue): string {
19
+ if (value == null) return borderRadii.DEFAULT
20
+ if (typeof value === 'string') return radiusMap[value] ?? value
21
+ return value as unknown as string // DynamicValue handled before this
22
+ }
6
23
 
7
24
  /**
8
25
  * Sets the `border-radius` on all corners of an element.
@@ -49,7 +66,7 @@ export function rounded(value?: string | DynamicValue): StyleRule {
49
66
  { [value.__id]: String(value.__value) },
50
67
  )
51
68
  }
52
- return createRule({ 'border-radius': (value as string | undefined) ?? defaultRadius })
69
+ return createRule({ 'border-radius': resolveRadius(value) })
53
70
  }
54
71
 
55
72
  /**
@@ -91,7 +108,7 @@ export function roundedT(value?: string | DynamicValue): StyleRule {
91
108
  { [value.__id]: String(value.__value) },
92
109
  )
93
110
  }
94
- const v = (value as string | undefined) ?? defaultRadius
111
+ const v = resolveRadius(value)
95
112
  return createRule({ 'border-top-left-radius': v, 'border-top-right-radius': v })
96
113
  }
97
114
 
@@ -134,7 +151,7 @@ export function roundedB(value?: string | DynamicValue): StyleRule {
134
151
  { [value.__id]: String(value.__value) },
135
152
  )
136
153
  }
137
- const v = (value as string | undefined) ?? defaultRadius
154
+ const v = resolveRadius(value)
138
155
  return createRule({ 'border-bottom-left-radius': v, 'border-bottom-right-radius': v })
139
156
  }
140
157
 
@@ -177,7 +194,7 @@ export function roundedL(value?: string | DynamicValue): StyleRule {
177
194
  { [value.__id]: String(value.__value) },
178
195
  )
179
196
  }
180
- const v = (value as string | undefined) ?? defaultRadius
197
+ const v = resolveRadius(value)
181
198
  return createRule({ 'border-top-left-radius': v, 'border-bottom-left-radius': v })
182
199
  }
183
200
 
@@ -220,7 +237,7 @@ export function roundedR(value?: string | DynamicValue): StyleRule {
220
237
  { [value.__id]: String(value.__value) },
221
238
  )
222
239
  }
223
- const v = (value as string | undefined) ?? defaultRadius
240
+ const v = resolveRadius(value)
224
241
  return createRule({ 'border-top-right-radius': v, 'border-bottom-right-radius': v })
225
242
  }
226
243
 
@@ -247,8 +264,8 @@ export function roundedR(value?: string | DynamicValue): StyleRule {
247
264
  * // CSS: border-width: 2px; border-style: solid;
248
265
  * ```
249
266
  */
250
- export function border(width?: string): StyleRule {
251
- return createRule({ 'border-width': width ?? '1px', 'border-style': 'solid' })
267
+ export function border(width?: string | number): StyleRule {
268
+ return createRule({ 'border-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
252
269
  }
253
270
 
254
271
  /**
@@ -274,8 +291,8 @@ export function border(width?: string): StyleRule {
274
291
  * // CSS: border-top-width: 2px; border-style: solid;
275
292
  * ```
276
293
  */
277
- export function borderT(width?: string): StyleRule {
278
- return createRule({ 'border-top-width': width ?? '1px', 'border-style': 'solid' })
294
+ export function borderT(width?: string | number): StyleRule {
295
+ return createRule({ 'border-top-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
279
296
  }
280
297
 
281
298
  /**
@@ -301,8 +318,8 @@ export function borderT(width?: string): StyleRule {
301
318
  * // CSS: border-right-width: 3px; border-style: solid;
302
319
  * ```
303
320
  */
304
- export function borderR(width?: string): StyleRule {
305
- return createRule({ 'border-right-width': width ?? '1px', 'border-style': 'solid' })
321
+ export function borderR(width?: string | number): StyleRule {
322
+ return createRule({ 'border-right-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
306
323
  }
307
324
 
308
325
  /**
@@ -328,8 +345,8 @@ export function borderR(width?: string): StyleRule {
328
345
  * // CSS: border-bottom-width: 2px; border-style: solid;
329
346
  * ```
330
347
  */
331
- export function borderB(width?: string): StyleRule {
332
- return createRule({ 'border-bottom-width': width ?? '1px', 'border-style': 'solid' })
348
+ export function borderB(width?: string | number): StyleRule {
349
+ return createRule({ 'border-bottom-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
333
350
  }
334
351
 
335
352
  /**
@@ -355,8 +372,8 @@ export function borderB(width?: string): StyleRule {
355
372
  * // CSS: border-left-width: 4px; border-style: solid;
356
373
  * ```
357
374
  */
358
- export function borderL(width?: string): StyleRule {
359
- return createRule({ 'border-left-width': width ?? '1px', 'border-style': 'solid' })
375
+ export function borderL(width?: string | number): StyleRule {
376
+ return createRule({ 'border-left-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
360
377
  }
361
378
 
362
379
  /**
@@ -389,8 +406,8 @@ export function borderL(width?: string): StyleRule {
389
406
  * // CSS: box-shadow: 0 0 0 1px #3b82f6;
390
407
  * ```
391
408
  */
392
- export function ring(width?: string, color?: string): StyleRule {
393
- const w = width ?? '3px'
409
+ export function ring(width?: string | number, color?: string): StyleRule {
410
+ const w = width != null ? px(width) : '3px'
394
411
  const c = color ?? '#3b82f6'
395
412
  return createRule({ 'box-shadow': `0 0 0 ${w} ${c}` })
396
413
  }
@@ -404,7 +421,7 @@ export function roundedTL(value?: string | DynamicValue): StyleRule {
404
421
  { [value.__id]: String(value.__value) },
405
422
  )
406
423
  }
407
- return createRule({ 'border-top-left-radius': (value as string | undefined) ?? defaultRadius })
424
+ return createRule({ 'border-top-left-radius': resolveRadius(value) })
408
425
  }
409
426
 
410
427
  export function roundedTR(value?: string | DynamicValue): StyleRule {
@@ -414,7 +431,7 @@ export function roundedTR(value?: string | DynamicValue): StyleRule {
414
431
  { [value.__id]: String(value.__value) },
415
432
  )
416
433
  }
417
- return createRule({ 'border-top-right-radius': (value as string | undefined) ?? defaultRadius })
434
+ return createRule({ 'border-top-right-radius': resolveRadius(value) })
418
435
  }
419
436
 
420
437
  export function roundedBR(value?: string | DynamicValue): StyleRule {
@@ -424,7 +441,7 @@ export function roundedBR(value?: string | DynamicValue): StyleRule {
424
441
  { [value.__id]: String(value.__value) },
425
442
  )
426
443
  }
427
- return createRule({ 'border-bottom-right-radius': (value as string | undefined) ?? defaultRadius })
444
+ return createRule({ 'border-bottom-right-radius': resolveRadius(value) })
428
445
  }
429
446
 
430
447
  export function roundedBL(value?: string | DynamicValue): StyleRule {
@@ -434,7 +451,7 @@ export function roundedBL(value?: string | DynamicValue): StyleRule {
434
451
  { [value.__id]: String(value.__value) },
435
452
  )
436
453
  }
437
- return createRule({ 'border-bottom-left-radius': (value as string | undefined) ?? defaultRadius })
454
+ return createRule({ 'border-bottom-left-radius': resolveRadius(value) })
438
455
  }
439
456
 
440
457
  export function roundedSS(value?: string | DynamicValue): StyleRule {
@@ -444,7 +461,7 @@ export function roundedSS(value?: string | DynamicValue): StyleRule {
444
461
  { [value.__id]: String(value.__value) },
445
462
  )
446
463
  }
447
- const v = (value as string | undefined) ?? defaultRadius
464
+ const v = resolveRadius(value)
448
465
  return createRule({ 'border-start-start-radius': v, 'border-end-start-radius': v })
449
466
  }
450
467
 
@@ -455,7 +472,7 @@ export function roundedSE(value?: string | DynamicValue): StyleRule {
455
472
  { [value.__id]: String(value.__value) },
456
473
  )
457
474
  }
458
- const v = (value as string | undefined) ?? defaultRadius
475
+ const v = resolveRadius(value)
459
476
  return createRule({ 'border-start-end-radius': v, 'border-end-end-radius': v })
460
477
  }
461
478
 
@@ -466,7 +483,7 @@ export function roundedEE(value?: string | DynamicValue): StyleRule {
466
483
  { [value.__id]: String(value.__value) },
467
484
  )
468
485
  }
469
- const v = (value as string | undefined) ?? defaultRadius
486
+ const v = resolveRadius(value)
470
487
  return createRule({ 'border-start-end-radius': v, 'border-end-end-radius': v })
471
488
  }
472
489
 
@@ -477,26 +494,28 @@ export function roundedES(value?: string | DynamicValue): StyleRule {
477
494
  { [value.__id]: String(value.__value) },
478
495
  )
479
496
  }
480
- const v = (value as string | undefined) ?? defaultRadius
497
+ const v = resolveRadius(value)
481
498
  return createRule({ 'border-end-start-radius': v, 'border-start-start-radius': v })
482
499
  }
483
500
 
484
501
  // --- Directional border width utilities ---
485
502
 
486
- export function borderX(width?: string): StyleRule {
487
- return createRule({ 'border-left-width': width ?? '1px', 'border-right-width': width ?? '1px', 'border-style': 'solid' })
503
+ export function borderX(width?: string | number): StyleRule {
504
+ const w = width != null ? px(width) : '1px'
505
+ return createRule({ 'border-left-width': w, 'border-right-width': w, 'border-style': 'solid' })
488
506
  }
489
507
 
490
- export function borderY(width?: string): StyleRule {
491
- return createRule({ 'border-top-width': width ?? '1px', 'border-bottom-width': width ?? '1px', 'border-style': 'solid' })
508
+ export function borderY(width?: string | number): StyleRule {
509
+ const w = width != null ? px(width) : '1px'
510
+ return createRule({ 'border-top-width': w, 'border-bottom-width': w, 'border-style': 'solid' })
492
511
  }
493
512
 
494
- export function borderS(width?: string): StyleRule {
495
- return createRule({ 'border-inline-start-width': width ?? '1px', 'border-style': 'solid' })
513
+ export function borderS(width?: string | number): StyleRule {
514
+ return createRule({ 'border-inline-start-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
496
515
  }
497
516
 
498
- export function borderE(width?: string): StyleRule {
499
- return createRule({ 'border-inline-end-width': width ?? '1px', 'border-style': 'solid' })
517
+ export function borderE(width?: string | number): StyleRule {
518
+ return createRule({ 'border-inline-end-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
500
519
  }
501
520
 
502
521
  export function borderStyle(value: string): StyleRule {
@@ -505,8 +524,8 @@ export function borderStyle(value: string): StyleRule {
505
524
 
506
525
  // --- Outline utilities ---
507
526
 
508
- export function outlineWidth(value: string): StyleRule {
509
- return createRule({ 'outline-width': value })
527
+ export function outlineWidth(value: string | number): StyleRule {
528
+ return createRule({ 'outline-width': px(value) })
510
529
  }
511
530
 
512
531
  export function outlineColor(value: string | DynamicValue): StyleRule {
@@ -516,20 +535,20 @@ export function outlineColor(value: string | DynamicValue): StyleRule {
516
535
  { [value.__id]: String(value.__value) },
517
536
  )
518
537
  }
519
- return createRule({ 'outline-color': value })
538
+ return createRule({ 'outline-color': resolveColor(value) })
520
539
  }
521
540
 
522
541
  export function outlineStyle(value: string): StyleRule {
523
542
  return createRule({ 'outline-style': value })
524
543
  }
525
544
 
526
- export function outlineOffset(value: string): StyleRule {
527
- return createRule({ 'outline-offset': value })
545
+ export function outlineOffset(value: string | number): StyleRule {
546
+ return createRule({ 'outline-offset': px(value) })
528
547
  }
529
548
 
530
- export function outline(width?: string, style?: string, color?: string): StyleRule {
549
+ export function outline(width?: string | number, style?: string, color?: string): StyleRule {
531
550
  const decls: Record<string, string> = {}
532
- decls['outline-width'] = width ?? '1px'
551
+ decls['outline-width'] = width != null ? px(width) : '2px'
533
552
  decls['outline-style'] = style ?? 'solid'
534
553
  if (color) decls['outline-color'] = color
535
554
  return createRule(decls)
@@ -552,11 +571,11 @@ export function ringColor(value: string | DynamicValue): StyleRule {
552
571
  { [value.__id]: String(value.__value) },
553
572
  )
554
573
  }
555
- return createRule({ '--twc-ring-color': value })
574
+ return createRule({ '--twc-ring-color': resolveColor(value) })
556
575
  }
557
576
 
558
- export function ringOffsetWidth(value: string): StyleRule {
559
- return createRule({ '--twc-ring-offset-width': value })
577
+ export function ringOffsetWidth(value: string | number): StyleRule {
578
+ return createRule({ '--twc-ring-offset-width': px(value) })
560
579
  }
561
580
 
562
581
  export function ringOffsetColor(value: string | DynamicValue): StyleRule {
@@ -566,18 +585,18 @@ export function ringOffsetColor(value: string | DynamicValue): StyleRule {
566
585
  { [value.__id]: String(value.__value) },
567
586
  )
568
587
  }
569
- return createRule({ '--twc-ring-offset-color': value })
588
+ return createRule({ '--twc-ring-offset-color': resolveColor(value) })
570
589
  }
571
590
 
572
591
  // --- Divide utilities (selector-template-based) ---
573
592
 
574
- export function divideX(width?: string): StyleRule {
575
- const rule = createRule({ 'border-left-width': width ?? '1px', 'border-style': 'solid' })
593
+ export function divideX(width?: string | number): StyleRule {
594
+ const rule = createRule({ 'border-left-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
576
595
  return wrapWithSelectorTemplate(rule, '& > :not([hidden]) ~ :not([hidden])')
577
596
  }
578
597
 
579
- export function divideY(width?: string): StyleRule {
580
- const rule = createRule({ 'border-top-width': width ?? '1px', 'border-style': 'solid' })
598
+ export function divideY(width?: string | number): StyleRule {
599
+ const rule = createRule({ 'border-top-width': width != null ? px(width) : '1px', 'border-style': 'solid' })
581
600
  return wrapWithSelectorTemplate(rule, '& > :not([hidden]) ~ :not([hidden])')
582
601
  }
583
602
 
@@ -589,7 +608,7 @@ export function divideColor(value: string | DynamicValue): StyleRule {
589
608
  { [value.__id]: String(value.__value) },
590
609
  )
591
610
  } else {
592
- rule = createRule({ 'border-color': value })
611
+ rule = createRule({ 'border-color': resolveColor(value) })
593
612
  }
594
613
  return wrapWithSelectorTemplate(rule, '& > :not([hidden]) ~ :not([hidden])')
595
614
  }
@@ -2,6 +2,30 @@ import type { StyleRule } from '../types.ts'
2
2
  import type { DynamicValue } from '../dynamic.ts'
3
3
  import { createRule, createDynamicRule } from '../rule.ts'
4
4
  import { isDynamic } from '../dynamic.ts'
5
+ import * as colors from '../theme/colors.ts'
6
+
7
+ const colorMap: Record<string, string> = {}
8
+ const colorScales: Record<string, colors.ColorScale> = {
9
+ slate: colors.slate, gray: colors.gray, zinc: colors.zinc, neutral: colors.neutral,
10
+ stone: colors.stone, red: colors.red, orange: colors.orange, amber: colors.amber,
11
+ yellow: colors.yellow, lime: colors.lime, green: colors.green, emerald: colors.emerald,
12
+ teal: colors.teal, cyan: colors.cyan, sky: colors.sky, blue: colors.blue,
13
+ indigo: colors.indigo, violet: colors.violet, purple: colors.purple, fuchsia: colors.fuchsia,
14
+ pink: colors.pink, rose: colors.rose,
15
+ }
16
+ for (const [name, scale] of Object.entries(colorScales)) {
17
+ for (const [shade, hex] of Object.entries(scale)) {
18
+ colorMap[`${name}-${shade}`] = hex
19
+ }
20
+ }
21
+ colorMap['white'] = colors.white
22
+ colorMap['black'] = colors.black
23
+ colorMap['transparent'] = 'transparent'
24
+ colorMap['current'] = 'currentColor'
25
+
26
+ export function resolveColor(value: string): string {
27
+ return colorMap[value] ?? value
28
+ }
5
29
 
6
30
  /**
7
31
  * Sets the background color of an element.
@@ -41,7 +65,7 @@ export function bg(color: string | DynamicValue): StyleRule {
41
65
  { [color.__id]: String(color.__value) },
42
66
  )
43
67
  }
44
- return createRule({ 'background-color': color })
68
+ return createRule({ 'background-color': resolveColor(color) })
45
69
  }
46
70
 
47
71
  /**
@@ -82,7 +106,7 @@ export function textColor(color: string | DynamicValue): StyleRule {
82
106
  { [color.__id]: String(color.__value) },
83
107
  )
84
108
  }
85
- return createRule({ color })
109
+ return createRule({ color: resolveColor(color) })
86
110
  }
87
111
 
88
112
  /**
@@ -123,5 +147,5 @@ export function borderColor(color: string | DynamicValue): StyleRule {
123
147
  { [color.__id]: String(color.__value) },
124
148
  )
125
149
  }
126
- return createRule({ 'border-color': color })
150
+ return createRule({ 'border-color': resolveColor(color) })
127
151
  }
@@ -1,8 +1,20 @@
1
1
  import type { StyleRule } from '../types.ts'
2
2
  import type { DynamicValue } from '../dynamic.ts'
3
3
  import { createRule, createDynamicRule } from '../rule.ts'
4
- import { DEFAULT as defaultShadow } from '../theme/shadows.ts'
4
+ import * as shadows from '../theme/shadows.ts'
5
5
  import { isDynamic } from '../dynamic.ts'
6
+ import { resolveColor } from './colors.ts'
7
+
8
+ const shadowMap: Record<string, string> = {
9
+ sm: shadows.sm, DEFAULT: shadows.DEFAULT, md: shadows.md,
10
+ lg: shadows.lg, xl: shadows.xl, '2xl': shadows._2xl,
11
+ inner: shadows.inner, none: shadows.none,
12
+ }
13
+
14
+ function resolveShadow(value?: string): string {
15
+ if (value == null) return shadows.DEFAULT
16
+ return shadowMap[value] ?? value
17
+ }
6
18
 
7
19
  /**
8
20
  * Sets the `box-shadow` of an element.
@@ -50,7 +62,7 @@ export function shadow(value?: string | DynamicValue): StyleRule {
50
62
  { [value.__id]: String(value.__value) },
51
63
  )
52
64
  }
53
- return createRule({ 'box-shadow': (value as string | undefined) ?? defaultShadow })
65
+ return createRule({ 'box-shadow': resolveShadow(value as string | undefined) })
54
66
  }
55
67
 
56
68
  /**
@@ -157,7 +169,7 @@ export function shadowColor(value: string | DynamicValue): StyleRule {
157
169
  { [value.__id]: String(value.__value) },
158
170
  )
159
171
  }
160
- return createRule({ '--twc-shadow-color': value })
172
+ return createRule({ '--twc-shadow-color': resolveColor(value) })
161
173
  }
162
174
 
163
175
  export function mixBlendMode(value: string): StyleRule {
@@ -2,6 +2,20 @@ import type { StyleRule } from '../types.ts'
2
2
  import type { DynamicValue } from '../dynamic.ts'
3
3
  import { createRule, createDynamicRule } from '../rule.ts'
4
4
  import { isDynamic } from '../dynamic.ts'
5
+ import { blur as blurSizes, dropShadow as dropShadowSizes } from '../theme/filters.ts'
6
+
7
+ const blurMap: Record<string, string> = {
8
+ none: blurSizes.none, sm: blurSizes.sm, DEFAULT: blurSizes.DEFAULT,
9
+ md: blurSizes.md, lg: blurSizes.lg, xl: blurSizes.xl,
10
+ '2xl': blurSizes._2xl, '3xl': blurSizes._3xl,
11
+ }
12
+
13
+ const dropShadowMap: Record<string, string> = {
14
+ sm: dropShadowSizes.sm, DEFAULT: dropShadowSizes.DEFAULT,
15
+ md: dropShadowSizes.md, lg: dropShadowSizes.lg,
16
+ xl: dropShadowSizes.xl, '2xl': dropShadowSizes._2xl,
17
+ none: dropShadowSizes.none,
18
+ }
5
19
 
6
20
  function filterRule(fn: string, value: string | DynamicValue, prop: 'filter' | 'backdrop-filter' = 'filter'): StyleRule {
7
21
  if (isDynamic(value)) {
@@ -16,6 +30,7 @@ function filterRule(fn: string, value: string | DynamicValue, prop: 'filter' | '
16
30
  // --- Filter utilities ---
17
31
 
18
32
  export function blur(value: string | DynamicValue = '8px'): StyleRule {
33
+ if (!isDynamic(value)) return filterRule('blur', blurMap[value] ?? value)
19
34
  return filterRule('blur', value)
20
35
  }
21
36
 
@@ -27,14 +42,15 @@ export function contrast(value: string | DynamicValue): StyleRule {
27
42
  return filterRule('contrast', value)
28
43
  }
29
44
 
30
- export function dropShadow(value: string | DynamicValue): StyleRule {
45
+ export function dropShadow(value: string | DynamicValue = 'DEFAULT'): StyleRule {
31
46
  if (isDynamic(value)) {
32
47
  return createDynamicRule(
33
48
  { filter: `drop-shadow(var(${value.__id}))` },
34
49
  { [value.__id]: String(value.__value) },
35
50
  )
36
51
  }
37
- return createRule({ filter: `drop-shadow(${value})` })
52
+ const resolved = dropShadowMap[value] ?? value
53
+ return createRule({ filter: `drop-shadow(${resolved})` })
38
54
  }
39
55
 
40
56
  export function grayscale(value: string | DynamicValue = '100%'): StyleRule {
@@ -60,6 +76,7 @@ export function sepia(value: string | DynamicValue = '100%'): StyleRule {
60
76
  // --- Backdrop filter utilities ---
61
77
 
62
78
  export function backdropBlur(value: string | DynamicValue = '8px'): StyleRule {
79
+ if (!isDynamic(value)) return filterRule('blur', blurMap[value] ?? value, 'backdrop-filter')
63
80
  return filterRule('blur', value, 'backdrop-filter')
64
81
  }
65
82
 
@@ -3,6 +3,7 @@ import type { DynamicValue } from '../dynamic.ts'
3
3
  import { createRule, createDynamicRule } from '../rule.ts'
4
4
  import { isDynamic } from '../dynamic.ts'
5
5
  import { resolveSpacing } from '../theme/spacing.ts'
6
+ import { resolveColor } from './colors.ts'
6
7
 
7
8
  /**
8
9
  * Sets the `cursor` style of an element.
@@ -112,7 +113,7 @@ export function accentColor(value: string | DynamicValue): StyleRule {
112
113
  { [value.__id]: String(value.__value) },
113
114
  )
114
115
  }
115
- return createRule({ 'accent-color': value })
116
+ return createRule({ 'accent-color': resolveColor(value) })
116
117
  }
117
118
 
118
119
  export function appearance(value: string): StyleRule {
@@ -126,7 +127,7 @@ export function caretColor(value: string | DynamicValue): StyleRule {
126
127
  { [value.__id]: String(value.__value) },
127
128
  )
128
129
  }
129
- return createRule({ 'caret-color': value })
130
+ return createRule({ 'caret-color': resolveColor(value) })
130
131
  }
131
132
 
132
133
  export function resize(value: string): StyleRule {
@@ -3,15 +3,54 @@ import type { DynamicValue } from '../dynamic.ts'
3
3
  import { createRule, createDynamicRule } from '../rule.ts'
4
4
  import { resolveSpacing } from '../theme/spacing.ts'
5
5
  import { isDynamic } from '../dynamic.ts'
6
-
7
- function resolveSize(value: number | string | DynamicValue): string | DynamicValue {
6
+ import { maxWidths } from '../theme/sizes.ts'
7
+
8
+ const sizeMap: Record<string, string> = {
9
+ full: '100%',
10
+ auto: 'auto',
11
+ min: 'min-content',
12
+ max: 'max-content',
13
+ fit: 'fit-content',
14
+ '1/2': '50%',
15
+ '1/3': '33.333333%',
16
+ '2/3': '66.666667%',
17
+ '1/4': '25%',
18
+ '2/4': '50%',
19
+ '3/4': '75%',
20
+ '1/5': '20%',
21
+ '2/5': '40%',
22
+ '3/5': '60%',
23
+ '4/5': '80%',
24
+ '1/6': '16.666667%',
25
+ '2/6': '33.333333%',
26
+ '3/6': '50%',
27
+ '4/6': '66.666667%',
28
+ '5/6': '83.333333%',
29
+ '1/12': '8.333333%',
30
+ '2/12': '16.666667%',
31
+ '3/12': '25%',
32
+ '4/12': '33.333333%',
33
+ '5/12': '41.666667%',
34
+ '6/12': '50%',
35
+ '7/12': '58.333333%',
36
+ '8/12': '66.666667%',
37
+ '9/12': '75%',
38
+ '10/12': '83.333333%',
39
+ '11/12': '91.666667%',
40
+ }
41
+
42
+ const widthSizeMap: Record<string, string> = { ...sizeMap, screen: '100vw' }
43
+ const heightSizeMap: Record<string, string> = { ...sizeMap, screen: '100vh' }
44
+ const maxWidthMap: Record<string, string> = { ...sizeMap, ...maxWidths }
45
+
46
+ function resolveSize(value: number | string | DynamicValue, nameMap?: Record<string, string>): string | DynamicValue {
8
47
  if (isDynamic(value)) return value
9
- if (typeof value === 'string') return value
48
+ if (typeof value === 'string') return (nameMap && nameMap[value]) ?? sizeMap[value] ?? value
10
49
  return resolveSpacing(value)
11
50
  }
12
51
 
13
- function sizeRule(prop: string, value: number | string | DynamicValue): StyleRule {
14
- const v = resolveSize(value)
52
+ function sizeRule(prop: string, value: number | string | DynamicValue, nameMap?: Record<string, string>): StyleRule {
53
+ const v = resolveSize(value, nameMap)
15
54
  if (isDynamic(v)) {
16
55
  return createDynamicRule(
17
56
  { [prop]: `var(${v.__id})` },
@@ -21,8 +60,8 @@ function sizeRule(prop: string, value: number | string | DynamicValue): StyleRul
21
60
  return createRule({ [prop]: v as string })
22
61
  }
23
62
 
24
- function sizeRuleMulti(props: string[], value: number | string | DynamicValue): StyleRule {
25
- const v = resolveSize(value)
63
+ function sizeRuleMulti(props: string[], value: number | string | DynamicValue, nameMap?: Record<string, string>): StyleRule {
64
+ const v = resolveSize(value, nameMap)
26
65
  if (isDynamic(v)) {
27
66
  const decls: Record<string, string> = {}
28
67
  for (const prop of props) decls[prop] = `var(${v.__id})`
@@ -228,7 +267,7 @@ export function gridRows(n: number): StyleRule {
228
267
  * ```
229
268
  */
230
269
  export function w(value: number | string | DynamicValue): StyleRule {
231
- return sizeRule('width', value)
270
+ return sizeRule('width', value, widthSizeMap)
232
271
  }
233
272
 
234
273
  /**
@@ -264,7 +303,7 @@ export function w(value: number | string | DynamicValue): StyleRule {
264
303
  * ```
265
304
  */
266
305
  export function h(value: number | string | DynamicValue): StyleRule {
267
- return sizeRule('height', value)
306
+ return sizeRule('height', value, heightSizeMap)
268
307
  }
269
308
 
270
309
  /**
@@ -372,7 +411,7 @@ export function minW(value: number | string | DynamicValue): StyleRule {
372
411
  * ```
373
412
  */
374
413
  export function minH(value: number | string | DynamicValue): StyleRule {
375
- return sizeRule('min-height', value)
414
+ return sizeRule('min-height', value, heightSizeMap)
376
415
  }
377
416
 
378
417
  /**
@@ -408,7 +447,7 @@ export function minH(value: number | string | DynamicValue): StyleRule {
408
447
  * ```
409
448
  */
410
449
  export function maxW(value: number | string | DynamicValue): StyleRule {
411
- return sizeRule('max-width', value)
450
+ return sizeRule('max-width', value, maxWidthMap)
412
451
  }
413
452
 
414
453
  /**
@@ -444,7 +483,7 @@ export function maxW(value: number | string | DynamicValue): StyleRule {
444
483
  * ```
445
484
  */
446
485
  export function maxH(value: number | string | DynamicValue): StyleRule {
447
- return sizeRule('max-height', value)
486
+ return sizeRule('max-height', value, heightSizeMap)
448
487
  }
449
488
 
450
489
  /**
@@ -932,8 +971,14 @@ export function z(value: number | string | DynamicValue): StyleRule {
932
971
 
933
972
  // --- Additional layout utilities ---
934
973
 
974
+ const aspectRatioMap: Record<string, string> = {
975
+ auto: 'auto',
976
+ square: '1 / 1',
977
+ video: '16 / 9',
978
+ }
979
+
935
980
  export function aspectRatio(value: string): StyleRule {
936
- return createRule({ 'aspect-ratio': value })
981
+ return createRule({ 'aspect-ratio': aspectRatioMap[value] ?? value })
937
982
  }
938
983
 
939
984
  export function columns(value: string | number): StyleRule {