@rimelight/ui 0.0.23 → 0.0.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimelight/ui",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "private": false,
5
5
  "description": "Rimelight Entertainment UI Library.",
6
6
  "keywords": [
@@ -48,6 +48,7 @@
48
48
  "./middleware": "./src/middleware/index.ts",
49
49
  "./middleware/*": "./src/middleware/*",
50
50
  "./nuxt": "./src/nuxt.ts",
51
+ "./nuxt/types": "./src/nuxt-types.ts",
51
52
  "./presets": "./src/presets/index.ts",
52
53
  "./presets/*": "./src/presets/*",
53
54
  "./*": "./src/*"
@@ -15,36 +15,21 @@ const button = scv({
15
15
  });
16
16
 
17
17
  export interface RLAButtonProps {
18
- /**
19
- * Button variant style.
20
- * @default "solid"
21
- */
22
18
  variant?: keyof typeof buttonTheme.variants.variant;
23
- /**
24
- * Button color.
25
- * @default "primary"
26
- */
27
19
  color?: keyof typeof buttonTheme.variants.color;
28
- /**
29
- * Button size.
30
- * @default "md"
31
- */
32
20
  size?: keyof typeof buttonTheme.variants.size;
33
- /**
34
- * When provided, renders as <a> instead of <button>.
35
- */
36
21
  href?: string;
37
- /**
38
- * UI overrides for individual slots, derived from the button theme.
39
- */
40
- ui?: Partial<Record<keyof typeof buttonTheme.base, string>>;
41
- /**
42
- * External class — applied to the root element.
43
- */
22
+ label?: string;
23
+ leadingIcon?: string;
24
+ trailingIcon?: string;
25
+ loading?: boolean;
26
+ square?: boolean;
27
+ block?: boolean;
28
+ active?: boolean;
29
+ activeColor?: keyof typeof buttonTheme.variants.color;
30
+ activeVariant?: keyof typeof buttonTheme.variants.variant;
31
+ ui?: Partial<Record<string, string>>;
44
32
  class?: string;
45
- /**
46
- * Standard HTML attributes for <button>
47
- */
48
33
  [key: string]: unknown;
49
34
  }
50
35
 
@@ -55,6 +40,15 @@ const {
55
40
  class: className,
56
41
  ui: uiProp,
57
42
  href,
43
+ label,
44
+ leadingIcon,
45
+ trailingIcon,
46
+ loading = false,
47
+ square = false,
48
+ block = false,
49
+ active = false,
50
+ activeColor,
51
+ activeVariant,
58
52
  ...rest
59
53
  } = Astro.props as RLAButtonProps
60
54
 
@@ -63,23 +57,62 @@ const globalConfig = getUIConfig();
63
57
  const mergedUI = defu(
64
58
  uiProp ?? {},
65
59
  (globalConfig.button as Record<string, unknown>) ?? {},
66
- ) as Record<keyof typeof buttonTheme.base, string | undefined>;
60
+ ) as Record<string, string | undefined>;
67
61
 
68
- const { root } = button({
69
- variant,
70
- color,
62
+ const isLeading = (leadingIcon || Astro.slots.has("leading")) || loading
63
+ const isTrailing = (trailingIcon || Astro.slots.has("trailing")) || (loading && !isLeading)
64
+
65
+ const showLeadingIcon = loading
66
+ ? "i-lucide-loader-circle"
67
+ : leadingIcon
68
+
69
+ const showTrailingIcon = loading
70
+ ? "i-lucide-loader-circle"
71
+ : trailingIcon
72
+
73
+ const leadingClasses = loading ? "animate-spin" : ""
74
+ const trailingClasses = loading ? "animate-spin" : ""
75
+
76
+ const resolved = button({
77
+ variant: active && activeVariant ? activeVariant : variant,
78
+ color: active && activeColor ? activeColor : color,
71
79
  size,
80
+ block,
81
+ square: square || (!label && !Astro.slots.has("default")),
82
+ leading: isLeading,
83
+ trailing: isTrailing,
84
+ loading,
85
+ active
72
86
  });
73
87
 
74
- // Determine whether to render <a> or <button>
75
88
  const Tag = href ? "a" : "button";
76
89
  ---
77
-
78
90
  <Tag
79
- class={twMerge(root, mergedUI.root, className)}
91
+ class={twMerge(resolved.root, mergedUI.root, className)}
80
92
  data-slot="rla-button"
81
93
  {...(Tag === "a" ? { href } : {})}
82
94
  {...rest}
83
95
  >
84
- <slot />
96
+ <slot name="leading" {...{ ui: resolved }}>
97
+ {isLeading && (
98
+ <span class={twMerge(resolved.leadingIcon, mergedUI.leadingIcon)} data-slot="leading-icon">
99
+ <span class={twMerge(showLeadingIcon, leadingClasses)} aria-hidden="true" />
100
+ </span>
101
+ )}
102
+ </slot>
103
+
104
+ {label !== undefined && label !== null && (
105
+ <span class={twMerge(resolved.label, mergedUI.label)} data-slot="label">
106
+ {label}
107
+ </span>
108
+ )}
109
+ {!label && <slot />}
110
+
111
+ <slot name="trailing" {...{ ui: resolved }}>
112
+ {isTrailing && (
113
+ <span class={twMerge(resolved.trailingIcon, mergedUI.trailingIcon)} data-slot="trailing-icon">
114
+ <span class={twMerge(showTrailingIcon, trailingClasses)} aria-hidden="true" />
115
+ </span>
116
+ )}
117
+ </slot>
85
118
  </Tag>
@@ -1,97 +1,139 @@
1
- <script setup lang="ts">
2
- import { scv, cx } from "css-variants"
3
- import { twMerge } from "tailwind-merge"
4
- import defu from "defu"
5
- import { buttonTheme } from "../../themes/button.theme.ts"
6
- import { getUIConfig } from "virtual:rimelight-ui"
7
-
8
- const button = scv({
9
- slots: [...buttonTheme.slots],
10
- base: buttonTheme.base,
11
- variants: buttonTheme.variants,
12
- compoundVariants: [...buttonTheme.compoundVariants],
13
- defaultVariants: buttonTheme.defaultVariants,
14
- classNameResolver: (...args) => twMerge(cx(...args))
15
- })
16
-
17
- export interface RLVButtonProps {
18
- /**
19
- * Button variant.
20
- *
21
- * @default "solid"
22
- */
23
- variant?: keyof typeof buttonTheme.variants.variant
24
- /**
25
- * Button color.
26
- *
27
- * @default "primary"
28
- */
29
- color?: keyof typeof buttonTheme.variants.color
30
- /**
31
- * Button size.
32
- *
33
- * @default "md"
34
- */
35
- size?: keyof typeof buttonTheme.variants.size
36
- /**
37
- * When provided, renders as <a> instead of <button>.
38
- */
39
- href?: string
40
- /**
41
- * UI overrides for individual slots, derived from the button theme.
42
- */
43
- ui?: Partial<Record<keyof typeof buttonTheme.base, string>>
44
- /**
45
- * External class — applied to the root element.
46
- */
47
- class?: string
48
- /**
49
- * Standard HTML attributes for <button>
50
- */
51
- [key: string]: unknown
52
- }
53
-
54
- const {
55
- variant = "solid",
56
- color = "primary",
57
- size = "md",
58
- class: className,
59
- ui: uiProp,
60
- href
61
- } = defineProps<RLVButtonProps>()
62
-
63
- defineSlots<{
64
- /**
65
- * The default slot for the button content (e.g., text, icons).
66
- */
67
- default(props: {}): any
68
- }>()
69
-
70
- const globalConfig = getUIConfig()
71
-
72
- const mergedUI = defu(
73
- uiProp ?? {},
74
- (globalConfig.button as Record<string, unknown>) ?? {}
75
- ) as Record<keyof typeof buttonTheme.base, string | undefined>
76
-
77
- const { root } = button({
78
- variant,
79
- color,
80
- size
81
- })
82
-
83
- // Determine whether to render <a> or <button>
84
- const Tag = href ? "a" : "button"
85
- </script>
86
-
87
- <template>
88
- <component
89
- v-bind="$attrs"
90
- :is="Tag"
91
- :href="href"
92
- :class="twMerge(root, mergedUI.root, className)"
93
- data-slot="rlv-button"
94
- >
95
- <slot />
96
- </component>
97
- </template>
1
+ <script setup lang="ts">
2
+ import { computed, useSlots } from "vue"
3
+ import { scv, cx } from "css-variants"
4
+ import { twMerge } from "tailwind-merge"
5
+ import defu from "defu"
6
+ import { buttonTheme } from "../../themes/button.theme.ts"
7
+ import { getUIConfig } from "virtual:rimelight-ui"
8
+
9
+ const button = scv({
10
+ slots: [...buttonTheme.slots],
11
+ base: buttonTheme.base,
12
+ variants: buttonTheme.variants,
13
+ compoundVariants: [...buttonTheme.compoundVariants],
14
+ defaultVariants: buttonTheme.defaultVariants,
15
+ classNameResolver: (...args) => twMerge(cx(...args))
16
+ })
17
+
18
+ export interface RLVButtonProps {
19
+ variant?: keyof typeof buttonTheme.variants.variant
20
+ color?: keyof typeof buttonTheme.variants.color
21
+ size?: keyof typeof buttonTheme.variants.size
22
+ href?: string
23
+ label?: string
24
+ leadingIcon?: string
25
+ trailingIcon?: string
26
+ loading?: boolean
27
+ square?: boolean
28
+ block?: boolean
29
+ active?: boolean
30
+ activeColor?: keyof typeof buttonTheme.variants.color
31
+ activeVariant?: keyof typeof buttonTheme.variants.variant
32
+ ui?: Partial<Record<string, string>>
33
+ class?: string
34
+ [key: string]: unknown
35
+ }
36
+
37
+ const {
38
+ variant = "solid",
39
+ color = "primary",
40
+ size = "md",
41
+ class: className,
42
+ ui: uiProp,
43
+ href,
44
+ label,
45
+ leadingIcon,
46
+ trailingIcon,
47
+ loading = false,
48
+ square = false,
49
+ block = false,
50
+ active = false,
51
+ activeColor,
52
+ activeVariant
53
+ } = defineProps<RLVButtonProps>()
54
+
55
+ const slots = useSlots()
56
+
57
+ const isLeading = computed(() => !!(leadingIcon || slots.leading) || loading)
58
+ const isTrailing = computed(() => !!(trailingIcon || slots.trailing) || (loading && !isLeading.value))
59
+
60
+ const showLeadingIcon = computed(() => {
61
+ if (loading) return "i-lucide-loader-circle"
62
+ return leadingIcon
63
+ })
64
+
65
+ const showTrailingIcon = computed(() => {
66
+ if (loading) return "i-lucide-loader-circle"
67
+ return trailingIcon
68
+ })
69
+
70
+ const leadingIconClass = computed(() => {
71
+ return loading && isLeading.value ? "animate-spin" : ""
72
+ })
73
+
74
+ const trailingIconClass = computed(() => {
75
+ return loading && isTrailing.value ? "animate-spin" : ""
76
+ })
77
+
78
+ defineSlots<{
79
+ default(props: {}): any
80
+ leading(props: { ui: Record<string, string> }): any
81
+ trailing(props: { ui: Record<string, string> }): any
82
+ }>()
83
+
84
+ const globalConfig = getUIConfig()
85
+
86
+ const mergedUI = defu(
87
+ uiProp ?? {},
88
+ (globalConfig.button as Record<string, unknown>) ?? {}
89
+ ) as Record<string, string | undefined>
90
+
91
+ const resolved = computed(() => button({
92
+ variant: active && activeVariant ? activeVariant : variant,
93
+ color: active && activeColor ? activeColor : color,
94
+ size,
95
+ block,
96
+ square: square || (!label && !slots.default),
97
+ leading: isLeading.value,
98
+ trailing: isTrailing.value,
99
+ loading,
100
+ active
101
+ }))
102
+
103
+ const Tag = href ? "a" : "button"
104
+ </script>
105
+
106
+ <template>
107
+ <component
108
+ v-bind="$attrs"
109
+ :is="Tag"
110
+ :href="href"
111
+ :class="twMerge(resolved.root, mergedUI.root, className)"
112
+ data-slot="rlv-button"
113
+ >
114
+ <slot name="leading" :ui="resolved">
115
+ <span
116
+ v-if="isLeading"
117
+ :class="twMerge(resolved.leadingIcon, mergedUI.leadingIcon)"
118
+ data-slot="leading-icon"
119
+ >
120
+ <span :class="[showLeadingIcon, leadingIconClass]" aria-hidden="true" />
121
+ </span>
122
+ </slot>
123
+
124
+ <span v-if="label !== undefined && label !== null" :class="twMerge(resolved.label, mergedUI.label)" data-slot="label">
125
+ {{ label }}
126
+ </span>
127
+ <slot v-else />
128
+
129
+ <slot name="trailing" :ui="resolved">
130
+ <span
131
+ v-if="isTrailing"
132
+ :class="twMerge(resolved.trailingIcon, mergedUI.trailingIcon)"
133
+ data-slot="trailing-icon"
134
+ >
135
+ <span :class="[showTrailingIcon, trailingIconClass]" aria-hidden="true" />
136
+ </span>
137
+ </slot>
138
+ </component>
139
+ </template>
@@ -0,0 +1,3 @@
1
+ export type * from "@nuxt/ui/runtime/types"
2
+ export type * from "@nuxt/ui/runtime/composables"
3
+ export type * from "@nuxt/ui/runtime/utils"
@@ -3,7 +3,7 @@
3
3
  * set of variants including color logic.
4
4
  */
5
5
  export const buttonTheme = {
6
- slots: ["root"],
6
+ slots: ["root", "label", "leadingIcon", "trailingIcon"],
7
7
  base: {
8
8
  root: [
9
9
  "inline-flex items-center justify-center gap-4xs rounded-md font-medium ws-nowrap",
@@ -11,12 +11,16 @@ export const buttonTheme = {
11
11
  "transition-all outline-none focus-visible:ring-3",
12
12
  "disabled:pointer-events-none disabled:op-50",
13
13
  "aria-invalid:border-error-500 aria-invalid:ring-error-500/20"
14
- ]
14
+ ],
15
+ label: "truncate",
16
+ leadingIcon: "shrink-0",
17
+ trailingIcon: "shrink-0"
15
18
  },
16
19
  variants: {
17
20
  variant: {
18
21
  solid: { root: "b shadow-xs" },
19
- outlined: { root: "b shadow-xs border" },
22
+ outline: { root: "b shadow-xs border" },
23
+ soft: { root: "" },
20
24
  subtle: { root: "" },
21
25
  ghost: { root: "" },
22
26
  link: { root: "p-0 h-auto" }
@@ -33,11 +37,24 @@ export const buttonTheme = {
33
37
  source: { root: "" }
34
38
  },
35
39
  size: {
36
- xs: { root: "h-7 px-2xs text-xs [&_svg]:size-3.5" },
37
- sm: { root: "h-8 px-xs text-sm [&_svg]:size-4" },
38
- md: { root: "h-9 px-sm text-sm [&_svg]:size-4" },
39
- lg: { root: "h-10 px-md text-base [&_svg]:size-4.5" },
40
- xl: { root: "h-11 px-lg text-base [&_svg]:size-5" }
40
+ xs: { root: "h-7 px-2xs text-xs [&_svg]:size-3.5", leadingIcon: "[&_svg]:size-3.5", trailingIcon: "[&_svg]:size-3.5" },
41
+ sm: { root: "h-8 px-xs text-sm [&_svg]:size-4", leadingIcon: "[&_svg]:size-4", trailingIcon: "[&_svg]:size-4" },
42
+ md: { root: "h-9 px-sm text-sm [&_svg]:size-4", leadingIcon: "[&_svg]:size-4", trailingIcon: "[&_svg]:size-4" },
43
+ lg: { root: "h-10 px-md text-base [&_svg]:size-4.5", leadingIcon: "[&_svg]:size-4.5", trailingIcon: "[&_svg]:size-4.5" },
44
+ xl: { root: "h-11 px-lg text-base [&_svg]:size-5", leadingIcon: "[&_svg]:size-5", trailingIcon: "[&_svg]:size-5" }
45
+ },
46
+ block: {
47
+ true: { root: "w-full justify-center", trailingIcon: "ms-auto" }
48
+ },
49
+ square: {
50
+ true: { root: "" }
51
+ },
52
+ leading: { true: {} },
53
+ trailing: { true: {} },
54
+ loading: { true: {} },
55
+ active: {
56
+ true: { root: "" },
57
+ false: { root: "" }
41
58
  }
42
59
  },
43
60
  compoundVariants: [
@@ -105,63 +122,63 @@ export const buttonTheme = {
105
122
  }
106
123
  },
107
124
  {
108
- variant: "outlined",
125
+ variant: "outline",
109
126
  color: "primary",
110
127
  classNames: {
111
128
  root: "border-primary/20 text-primary-600 bg-primary/5 hover:bg-primary/10 hover:border-primary/30 focus-visible:ring-primary/40"
112
129
  }
113
130
  },
114
131
  {
115
- variant: "outlined",
132
+ variant: "outline",
116
133
  color: "secondary",
117
134
  classNames: {
118
135
  root: "border-secondary/20 text-secondary-600 bg-secondary/5 hover:bg-secondary/10 hover:border-secondary/30 focus-visible:ring-secondary/40"
119
136
  }
120
137
  },
121
138
  {
122
- variant: "outlined",
139
+ variant: "outline",
123
140
  color: "info",
124
141
  classNames: {
125
142
  root: "border-info/20 text-info-600 bg-info/5 hover:bg-info/10 hover:border-info/30 focus-visible:ring-info/40"
126
143
  }
127
144
  },
128
145
  {
129
- variant: "outlined",
146
+ variant: "outline",
130
147
  color: "success",
131
148
  classNames: {
132
149
  root: "border-success/20 text-success-600 bg-success/5 hover:bg-success/10 hover:border-success/30 focus-visible:ring-success/40"
133
150
  }
134
151
  },
135
152
  {
136
- variant: "outlined",
153
+ variant: "outline",
137
154
  color: "warning",
138
155
  classNames: {
139
156
  root: "border-warning/20 text-warning-600 bg-warning/5 hover:bg-warning/10 hover:border-warning/30 focus-visible:ring-warning/40"
140
157
  }
141
158
  },
142
159
  {
143
- variant: "outlined",
160
+ variant: "outline",
144
161
  color: "error",
145
162
  classNames: {
146
163
  root: "border-error/20 text-error-600 bg-error/5 hover:bg-error/10 hover:border-error/30 focus-visible:ring-error/40"
147
164
  }
148
165
  },
149
166
  {
150
- variant: "outlined",
167
+ variant: "outline",
151
168
  color: "commentary",
152
169
  classNames: {
153
170
  root: "border-commentary/20 text-commentary-600 bg-commentary/5 hover:bg-commentary/10 hover:border-commentary/30 focus-visible:ring-commentary/40"
154
171
  }
155
172
  },
156
173
  {
157
- variant: "outlined",
174
+ variant: "outline",
158
175
  color: "ideation",
159
176
  classNames: {
160
177
  root: "border-ideation/20 text-ideation-600 bg-ideation/5 hover:bg-ideation/10 hover:border-ideation/30 focus-visible:ring-ideation/40"
161
178
  }
162
179
  },
163
180
  {
164
- variant: "outlined",
181
+ variant: "outline",
165
182
  color: "source",
166
183
  classNames: {
167
184
  root: "border-source/20 text-source-600 bg-source/5 hover:bg-source/10 hover:border-source/30 focus-visible:ring-source/40"
@@ -355,6 +372,130 @@ export const buttonTheme = {
355
372
  classNames: {
356
373
  root: "text-source-600 hover:underline hover:decoration-source/30"
357
374
  }
375
+ },
376
+ // soft variant compound variants
377
+ {
378
+ variant: "soft",
379
+ color: "primary",
380
+ classNames: {
381
+ root: "text-primary-600 bg-primary/10 hover:bg-primary/20 focus-visible:ring-primary/40"
382
+ }
383
+ },
384
+ {
385
+ variant: "soft",
386
+ color: "secondary",
387
+ classNames: {
388
+ root: "text-secondary-600 bg-secondary/10 hover:bg-secondary/20 focus-visible:ring-secondary/40"
389
+ }
390
+ },
391
+ {
392
+ variant: "soft",
393
+ color: "info",
394
+ classNames: {
395
+ root: "text-info-600 bg-info/10 hover:bg-info/20 focus-visible:ring-info/40"
396
+ }
397
+ },
398
+ {
399
+ variant: "soft",
400
+ color: "success",
401
+ classNames: {
402
+ root: "text-success-600 bg-success/10 hover:bg-success/20 focus-visible:ring-success/40"
403
+ }
404
+ },
405
+ {
406
+ variant: "soft",
407
+ color: "warning",
408
+ classNames: {
409
+ root: "text-warning-600 bg-warning/10 hover:bg-warning/20 focus-visible:ring-warning/40"
410
+ }
411
+ },
412
+ {
413
+ variant: "soft",
414
+ color: "error",
415
+ classNames: {
416
+ root: "text-error-600 bg-error/10 hover:bg-error/20 focus-visible:ring-error/40"
417
+ }
418
+ },
419
+ {
420
+ variant: "soft",
421
+ color: "commentary",
422
+ classNames: {
423
+ root: "text-commentary-600 bg-commentary/10 hover:bg-commentary/20 focus-visible:ring-commentary/40"
424
+ }
425
+ },
426
+ {
427
+ variant: "soft",
428
+ color: "ideation",
429
+ classNames: {
430
+ root: "text-ideation-600 bg-ideation/10 hover:bg-ideation/20 focus-visible:ring-ideation/40"
431
+ }
432
+ },
433
+ {
434
+ variant: "soft",
435
+ color: "source",
436
+ classNames: {
437
+ root: "text-source-600 bg-source/10 hover:bg-source/20 focus-visible:ring-source/40"
438
+ }
439
+ },
440
+ // square + size compound variants (explicit width to match height)
441
+ {
442
+ square: true,
443
+ size: "xs",
444
+ classNames: {
445
+ root: "p-1 w-7"
446
+ }
447
+ },
448
+ {
449
+ square: true,
450
+ size: "sm",
451
+ classNames: {
452
+ root: "p-1.5 w-8"
453
+ }
454
+ },
455
+ {
456
+ square: true,
457
+ size: "md",
458
+ classNames: {
459
+ root: "p-1.5 w-9"
460
+ }
461
+ },
462
+ {
463
+ square: true,
464
+ size: "lg",
465
+ classNames: {
466
+ root: "p-2 w-10"
467
+ }
468
+ },
469
+ {
470
+ square: true,
471
+ size: "xl",
472
+ classNames: {
473
+ root: "p-2 w-11"
474
+ }
475
+ },
476
+ // loading compound variants
477
+ {
478
+ loading: true,
479
+ leading: true,
480
+ classNames: {
481
+ leadingIcon: "animate-spin"
482
+ }
483
+ },
484
+ {
485
+ loading: true,
486
+ leading: false,
487
+ trailing: true,
488
+ classNames: {
489
+ trailingIcon: "animate-spin"
490
+ }
491
+ },
492
+ {
493
+ loading: true,
494
+ leading: false,
495
+ trailing: false,
496
+ classNames: {
497
+ trailingIcon: "animate-spin"
498
+ }
358
499
  }
359
500
  ],
360
501
  defaultVariants: {