@rimelight/ui 0.0.22 → 0.0.23
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 +1 -2
- package/src/components/ThemeToggle.astro +2 -4
- package/src/components/astro/RLAIcon.astro +61 -0
- package/src/components/astro/RLALogo.astro +100 -0
- package/src/components/astro/RLAPlaceholder.astro +71 -0
- package/src/components/vue/RLVIcon.vue +64 -0
- package/src/components/vue/RLVLogo.vue +123 -0
- package/src/components/vue/RLVPlaceholder.vue +76 -0
- package/src/integrations/ui.ts +18 -6
- package/src/presets/index.ts +7 -0
- package/src/themes/icon.theme.ts +18 -0
- package/src/themes/index.ts +7 -1
- package/src/themes/logo.theme.ts +8 -0
- package/src/themes/placeholder.theme.ts +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimelight/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Rimelight Entertainment UI Library.",
|
|
6
6
|
"keywords": [
|
|
@@ -70,7 +70,6 @@
|
|
|
70
70
|
"tailwindcss": "^4.2.3",
|
|
71
71
|
"turndown": "^7.2.4",
|
|
72
72
|
"turndown-plugin-gfm": "^1.0.2",
|
|
73
|
-
"unplugin-icons": "23.0.1",
|
|
74
73
|
"vite-plugin-virtual": "^0.5.0"
|
|
75
74
|
},
|
|
76
75
|
"devDependencies": {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
import RLAButton from "./astro/RLAButton.astro";
|
|
3
|
-
import IconSun from "~icons/lucide/sun"
|
|
4
|
-
import IconMoon from "~icons/lucide/moon"
|
|
5
3
|
|
|
6
4
|
export interface ThemeToggleProps {
|
|
7
5
|
class?: string;
|
|
@@ -23,8 +21,8 @@ const { class: className, size = "md" } = Astro.props as Props
|
|
|
23
21
|
variant="ghost"
|
|
24
22
|
aria-label="Toggle theme"
|
|
25
23
|
>
|
|
26
|
-
<
|
|
27
|
-
<
|
|
24
|
+
<span class="sun-wrapper block dark:hidden i-lucide-sun" />
|
|
25
|
+
<span class="moon-wrapper hidden dark:block i-lucide-moon" />
|
|
28
26
|
</RLAButton>
|
|
29
27
|
|
|
30
28
|
<script>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { scv, cx } from "css-variants"
|
|
3
|
+
import { twMerge } from "tailwind-merge"
|
|
4
|
+
import defu from "defu"
|
|
5
|
+
import { iconTheme } from "../../themes/icon.theme"
|
|
6
|
+
import { getUIConfig } from "virtual:rimelight-ui"
|
|
7
|
+
|
|
8
|
+
const icon = scv({
|
|
9
|
+
slots: [...iconTheme.slots],
|
|
10
|
+
base: iconTheme.base,
|
|
11
|
+
variants: iconTheme.variants,
|
|
12
|
+
defaultVariants: iconTheme.defaultVariants,
|
|
13
|
+
classNameResolver: (...args) => twMerge(cx(...args))
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export interface RLAIconProps {
|
|
17
|
+
/**
|
|
18
|
+
* Icon name following the UnoCSS icons format.
|
|
19
|
+
* @example "i-lucide-home"
|
|
20
|
+
*/
|
|
21
|
+
name: string
|
|
22
|
+
/**
|
|
23
|
+
* Size variant for the icon.
|
|
24
|
+
*/
|
|
25
|
+
size?: keyof typeof iconTheme.variants.size
|
|
26
|
+
/**
|
|
27
|
+
* External class applied to the root element.
|
|
28
|
+
*/
|
|
29
|
+
class?: string
|
|
30
|
+
/**
|
|
31
|
+
* UI overrides for individual slots.
|
|
32
|
+
*/
|
|
33
|
+
ui?: Partial<Record<keyof typeof iconTheme.base, string>>
|
|
34
|
+
[key: string]: unknown
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
name,
|
|
39
|
+
size = "md",
|
|
40
|
+
class: className,
|
|
41
|
+
ui: uiProp,
|
|
42
|
+
...rest
|
|
43
|
+
} = Astro.props as RLAIconProps
|
|
44
|
+
|
|
45
|
+
const globalConfig = getUIConfig()
|
|
46
|
+
|
|
47
|
+
const mergedUI = defu(
|
|
48
|
+
uiProp ?? {},
|
|
49
|
+
(globalConfig.icon as Record<string, unknown>) ?? {}
|
|
50
|
+
) as Record<keyof typeof iconTheme.base, string | undefined>
|
|
51
|
+
|
|
52
|
+
const { root } = icon({ size })
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
<span
|
|
56
|
+
class={twMerge(root, mergedUI.root, className, name)}
|
|
57
|
+
data-slot="rla-icon"
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
{...rest}
|
|
60
|
+
>
|
|
61
|
+
</span>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { scv, cx } from "css-variants"
|
|
3
|
+
import { twMerge } from "tailwind-merge"
|
|
4
|
+
import defu from "defu"
|
|
5
|
+
import { logoTheme } from "../../themes/logo.theme.ts"
|
|
6
|
+
import { getUIConfig } from "virtual:rimelight-ui"
|
|
7
|
+
|
|
8
|
+
const logo = scv({
|
|
9
|
+
slots: [...logoTheme.slots],
|
|
10
|
+
base: logoTheme.base,
|
|
11
|
+
variants: logoTheme.variants,
|
|
12
|
+
defaultVariants: logoTheme.defaultVariants,
|
|
13
|
+
classNameResolver: (...args) => twMerge(cx(...args)),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export interface RLALogoProps {
|
|
17
|
+
/**
|
|
18
|
+
* The variant of the logo to display.
|
|
19
|
+
* @default "logomark"
|
|
20
|
+
*/
|
|
21
|
+
variant?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Override the color mode.
|
|
24
|
+
*/
|
|
25
|
+
mode?: "color" | "white" | "black";
|
|
26
|
+
/**
|
|
27
|
+
* The URL to link to.
|
|
28
|
+
* @default "/"
|
|
29
|
+
*/
|
|
30
|
+
href?: string;
|
|
31
|
+
/**
|
|
32
|
+
* UI overrides for individual slots, derived from the logo theme.
|
|
33
|
+
*/
|
|
34
|
+
ui?: Partial<Record<keyof typeof logoTheme.base, string>>;
|
|
35
|
+
/**
|
|
36
|
+
* External class — applied to the root element.
|
|
37
|
+
*/
|
|
38
|
+
class?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The alt text for the logo image.
|
|
41
|
+
*/
|
|
42
|
+
alt?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Standard HTML attributes for <a>
|
|
45
|
+
*/
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
variant = "logomark",
|
|
51
|
+
mode,
|
|
52
|
+
href = "/",
|
|
53
|
+
class: className,
|
|
54
|
+
ui: uiProp,
|
|
55
|
+
alt,
|
|
56
|
+
...rest
|
|
57
|
+
} = Astro.props as RLALogoProps;
|
|
58
|
+
|
|
59
|
+
const globalConfig = getUIConfig();
|
|
60
|
+
|
|
61
|
+
const mergedUI = defu(
|
|
62
|
+
uiProp ?? {},
|
|
63
|
+
(globalConfig.logo as Record<string, unknown>) ?? {},
|
|
64
|
+
) as Record<keyof typeof logoTheme.base, string | undefined>;
|
|
65
|
+
|
|
66
|
+
const { root } = logo();
|
|
67
|
+
|
|
68
|
+
const rcLogos = globalConfig.logos as Record<string, any>;
|
|
69
|
+
let logoSrc: string | null = null;
|
|
70
|
+
|
|
71
|
+
if (rcLogos && typeof rcLogos === "object") {
|
|
72
|
+
let src = rcLogos[variant];
|
|
73
|
+
if (src && typeof src === "object") {
|
|
74
|
+
logoSrc = src[mode || "color"] || src.black || src.color;
|
|
75
|
+
} else if (typeof src === "string") {
|
|
76
|
+
logoSrc = src;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Support for UnoCSS icons (e.g. `i-heroicons-home`)
|
|
81
|
+
const isIcon = logoSrc && (logoSrc.includes(":") || logoSrc.startsWith("i-"));
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
<a
|
|
85
|
+
class={twMerge(root, mergedUI.root, className)}
|
|
86
|
+
href={href}
|
|
87
|
+
aria-label={alt || variant}
|
|
88
|
+
data-slot="rla-logo"
|
|
89
|
+
{...rest}
|
|
90
|
+
>
|
|
91
|
+
{logoSrc ? (
|
|
92
|
+
isIcon ? (
|
|
93
|
+
<span class:list={[logoSrc, "size-full block shrink-0"]} aria-hidden="true" />
|
|
94
|
+
) : (
|
|
95
|
+
<img src={logoSrc} alt={alt || ""} class="size-full block object-contain shrink-0" />
|
|
96
|
+
)
|
|
97
|
+
) : (
|
|
98
|
+
<slot />
|
|
99
|
+
)}
|
|
100
|
+
</a>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { scv, cx } from "css-variants"
|
|
3
|
+
import { twMerge } from "tailwind-merge"
|
|
4
|
+
import defu from "defu"
|
|
5
|
+
import { placeholderTheme } from "../../themes/placeholder.theme.ts"
|
|
6
|
+
import { getUIConfig } from "virtual:rimelight-ui"
|
|
7
|
+
|
|
8
|
+
const placeholder = scv({
|
|
9
|
+
slots: [...placeholderTheme.slots],
|
|
10
|
+
base: placeholderTheme.base,
|
|
11
|
+
variants: placeholderTheme.variants,
|
|
12
|
+
compoundVariants: [...placeholderTheme.compoundVariants],
|
|
13
|
+
defaultVariants: placeholderTheme.defaultVariants,
|
|
14
|
+
classNameResolver: (...args) => twMerge(cx(...args))
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export interface RLAPlaceholderProps {
|
|
18
|
+
/**
|
|
19
|
+
* UI overrides for individual slots, derived from the placeholder theme.
|
|
20
|
+
*/
|
|
21
|
+
ui?: Partial<Record<keyof typeof placeholderTheme.base, string>>
|
|
22
|
+
/**
|
|
23
|
+
* External class — applied to the root element.
|
|
24
|
+
*/
|
|
25
|
+
class?: string
|
|
26
|
+
/**
|
|
27
|
+
* Standard HTML attributes.
|
|
28
|
+
*/
|
|
29
|
+
[key: string]: unknown
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
class: className,
|
|
34
|
+
ui: uiProp,
|
|
35
|
+
...rest
|
|
36
|
+
} = Astro.props as RLAPlaceholderProps
|
|
37
|
+
|
|
38
|
+
const globalConfig = getUIConfig()
|
|
39
|
+
|
|
40
|
+
const mergedUI = defu(
|
|
41
|
+
uiProp ?? {},
|
|
42
|
+
(globalConfig.placeholder as Record<string, unknown>) ?? {}
|
|
43
|
+
) as Record<keyof typeof placeholderTheme.base, string | undefined>
|
|
44
|
+
|
|
45
|
+
const { base, svg } = placeholder()
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
<div class={twMerge(base, mergedUI.base, className)} {...rest}>
|
|
49
|
+
<svg class={twMerge(svg, mergedUI.svg)}>
|
|
50
|
+
<defs>
|
|
51
|
+
<pattern
|
|
52
|
+
id="pattern-5c1e4f0e-62d5-498b-8ff0-cf77bb448c8e"
|
|
53
|
+
x="0"
|
|
54
|
+
y="0"
|
|
55
|
+
width="10"
|
|
56
|
+
height="10"
|
|
57
|
+
patternUnits="userSpaceOnUse"
|
|
58
|
+
>
|
|
59
|
+
<path d="M-3 13 15-5M-5 5l18-18M-1 21 17 3" />
|
|
60
|
+
</pattern>
|
|
61
|
+
</defs>
|
|
62
|
+
<rect
|
|
63
|
+
stroke="none"
|
|
64
|
+
fill="url(#pattern-5c1e4f0e-62d5-498b-8ff0-cf77bb448c8e)"
|
|
65
|
+
width="100%"
|
|
66
|
+
height="100%"
|
|
67
|
+
/>
|
|
68
|
+
</svg>
|
|
69
|
+
|
|
70
|
+
<slot />
|
|
71
|
+
</div>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from "vue"
|
|
3
|
+
import { scv, cx } from "css-variants"
|
|
4
|
+
import { twMerge } from "tailwind-merge"
|
|
5
|
+
import { useUi } from "../../composables"
|
|
6
|
+
import { iconTheme } from "../../themes/icon.theme"
|
|
7
|
+
|
|
8
|
+
const icon = scv({
|
|
9
|
+
slots: [...iconTheme.slots],
|
|
10
|
+
base: iconTheme.base,
|
|
11
|
+
variants: iconTheme.variants,
|
|
12
|
+
defaultVariants: iconTheme.defaultVariants,
|
|
13
|
+
classNameResolver: (...args) => twMerge(cx(...args))
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export interface RLVIconProps {
|
|
17
|
+
/**
|
|
18
|
+
* Icon name following the UnoCSS icons format. Can be a string like "i-lucide-home" or a Vue
|
|
19
|
+
* component.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* "i-lucide-home"
|
|
23
|
+
*/
|
|
24
|
+
name: string
|
|
25
|
+
/**
|
|
26
|
+
* Size variant for the icon.
|
|
27
|
+
*/
|
|
28
|
+
size?: keyof typeof iconTheme.variants.size
|
|
29
|
+
/**
|
|
30
|
+
* External class applied to the root element.
|
|
31
|
+
*/
|
|
32
|
+
class?: string
|
|
33
|
+
/**
|
|
34
|
+
* UI overrides for individual slots.
|
|
35
|
+
*/
|
|
36
|
+
ui?: Partial<Record<keyof typeof iconTheme.base, string>>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { name, size = "md", class: className, ui: uiProp } = defineProps<RLVIconProps>()
|
|
40
|
+
|
|
41
|
+
const mergedUI = useUi("icon", uiProp as Record<string, unknown> | undefined)
|
|
42
|
+
|
|
43
|
+
const resolvedClasses = computed(() => {
|
|
44
|
+
const { root } = icon({ size })
|
|
45
|
+
return {
|
|
46
|
+
root: twMerge(root, mergedUI.value.root, className)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
defineSlots<{
|
|
51
|
+
default(props: {}): any
|
|
52
|
+
}>()
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<span
|
|
57
|
+
v-bind="$attrs"
|
|
58
|
+
:class="[resolvedClasses.root, name]"
|
|
59
|
+
data-slot="rlv-icon"
|
|
60
|
+
aria-hidden="true"
|
|
61
|
+
>
|
|
62
|
+
<slot />
|
|
63
|
+
</span>
|
|
64
|
+
</template>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from "vue"
|
|
3
|
+
import { scv, cx } from "css-variants"
|
|
4
|
+
import { twMerge } from "tailwind-merge"
|
|
5
|
+
import defu from "defu"
|
|
6
|
+
import { logoTheme } from "../../themes/logo.theme.ts"
|
|
7
|
+
import { getUIConfig } from "virtual:rimelight-ui"
|
|
8
|
+
|
|
9
|
+
const logo = scv({
|
|
10
|
+
slots: [...logoTheme.slots],
|
|
11
|
+
base: logoTheme.base,
|
|
12
|
+
variants: logoTheme.variants,
|
|
13
|
+
defaultVariants: logoTheme.defaultVariants,
|
|
14
|
+
classNameResolver: (...args) => twMerge(cx(...args))
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export interface RLVLogoProps {
|
|
18
|
+
/**
|
|
19
|
+
* The variant of the logo to display.
|
|
20
|
+
*
|
|
21
|
+
* @default "logomark"
|
|
22
|
+
*/
|
|
23
|
+
variant?: string
|
|
24
|
+
/**
|
|
25
|
+
* Override the color mode.
|
|
26
|
+
*/
|
|
27
|
+
mode?: "color" | "white" | "black"
|
|
28
|
+
/**
|
|
29
|
+
* The URL to link to.
|
|
30
|
+
*
|
|
31
|
+
* @default "/"
|
|
32
|
+
*/
|
|
33
|
+
href?: string
|
|
34
|
+
/**
|
|
35
|
+
* UI overrides for individual slots, derived from the logo theme.
|
|
36
|
+
*/
|
|
37
|
+
ui?: Partial<Record<keyof typeof logoTheme.base, string>>
|
|
38
|
+
/**
|
|
39
|
+
* External class — applied to the root element.
|
|
40
|
+
*/
|
|
41
|
+
class?: string
|
|
42
|
+
/**
|
|
43
|
+
* The alt text for the logo image.
|
|
44
|
+
*/
|
|
45
|
+
alt?: string
|
|
46
|
+
/**
|
|
47
|
+
* Standard HTML attributes for <a>
|
|
48
|
+
*/
|
|
49
|
+
[key: string]: unknown
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const props = withDefaults(defineProps<RLVLogoProps>(), {
|
|
53
|
+
variant: "logomark",
|
|
54
|
+
href: "/"
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
defineSlots<{
|
|
58
|
+
/**
|
|
59
|
+
* The default slot for the logo content (e.g., text, custom elements).
|
|
60
|
+
*/
|
|
61
|
+
default(props: {}): any
|
|
62
|
+
}>()
|
|
63
|
+
|
|
64
|
+
const globalConfig = getUIConfig()
|
|
65
|
+
|
|
66
|
+
const mergedUI = computed(
|
|
67
|
+
() =>
|
|
68
|
+
defu(props.ui ?? {}, (globalConfig.logo as Record<string, unknown>) ?? {}) as Record<
|
|
69
|
+
keyof typeof logoTheme.base,
|
|
70
|
+
string | undefined
|
|
71
|
+
>
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const resolvedClasses = computed(() => {
|
|
75
|
+
const { root } = logo()
|
|
76
|
+
return {
|
|
77
|
+
root: twMerge(root, mergedUI.value.root, props.class)
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const logoSrc = computed<string | null>(() => {
|
|
82
|
+
const rcLogos = globalConfig.logos as Record<string, any>
|
|
83
|
+
let src: any = null
|
|
84
|
+
|
|
85
|
+
if (rcLogos && typeof rcLogos === "object") {
|
|
86
|
+
src = rcLogos[props.variant]
|
|
87
|
+
if (src && typeof src === "object") {
|
|
88
|
+
src = src[props.mode || "color"] || src.black || src.color
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (src && typeof src === "string" && src) return src
|
|
93
|
+
|
|
94
|
+
return null
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const isIcon = computed(() => {
|
|
98
|
+
const src = logoSrc.value
|
|
99
|
+
if (!src) return false
|
|
100
|
+
if (src.startsWith("http") || src.startsWith("/") || src.startsWith(".")) return false
|
|
101
|
+
return src.includes(":") || src.startsWith("i-")
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
const Tag = computed(() => (props.href ? "a" : "div"))
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<template>
|
|
108
|
+
<component
|
|
109
|
+
v-bind="$attrs"
|
|
110
|
+
:is="Tag"
|
|
111
|
+
:href="Tag === 'a' ? href : undefined"
|
|
112
|
+
:aria-label="alt || variant"
|
|
113
|
+
:class="resolvedClasses.root"
|
|
114
|
+
data-slot="rlv-logo"
|
|
115
|
+
>
|
|
116
|
+
<template v-if="logoSrc">
|
|
117
|
+
<!-- Using mode='svg' pattern is not strictly needed for UnoCSS icons -->
|
|
118
|
+
<span v-if="isIcon" :class="[logoSrc, 'size-full block shrink-0']" aria-hidden="true" />
|
|
119
|
+
<img v-else :src="logoSrc" :alt="alt || ''" class="size-full block object-contain shrink-0" />
|
|
120
|
+
</template>
|
|
121
|
+
<slot v-else />
|
|
122
|
+
</component>
|
|
123
|
+
</template>
|
|
@@ -0,0 +1,76 @@
|
|
|
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 { placeholderTheme } from "../../themes/placeholder.theme.ts"
|
|
6
|
+
import { getUIConfig } from "virtual:rimelight-ui"
|
|
7
|
+
|
|
8
|
+
const placeholder = scv({
|
|
9
|
+
slots: [...placeholderTheme.slots],
|
|
10
|
+
base: placeholderTheme.base,
|
|
11
|
+
variants: placeholderTheme.variants,
|
|
12
|
+
compoundVariants: [...placeholderTheme.compoundVariants],
|
|
13
|
+
defaultVariants: placeholderTheme.defaultVariants,
|
|
14
|
+
classNameResolver: (...args) => twMerge(cx(...args))
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export interface RLVPlaceholderProps {
|
|
18
|
+
/**
|
|
19
|
+
* UI overrides for individual slots, derived from the placeholder theme.
|
|
20
|
+
*/
|
|
21
|
+
ui?: Partial<Record<keyof typeof placeholderTheme.base, string>>
|
|
22
|
+
/**
|
|
23
|
+
* External class — applied to the root element.
|
|
24
|
+
*/
|
|
25
|
+
class?: string
|
|
26
|
+
/**
|
|
27
|
+
* Standard HTML attributes.
|
|
28
|
+
*/
|
|
29
|
+
[key: string]: unknown
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const { class: className, ui: uiProp } = defineProps<RLVPlaceholderProps>()
|
|
33
|
+
|
|
34
|
+
defineSlots<{
|
|
35
|
+
/**
|
|
36
|
+
* The default slot for placeholder content.
|
|
37
|
+
*/
|
|
38
|
+
default(props: {}): any
|
|
39
|
+
}>()
|
|
40
|
+
|
|
41
|
+
const globalConfig = getUIConfig()
|
|
42
|
+
|
|
43
|
+
const mergedUI = defu(
|
|
44
|
+
uiProp ?? {},
|
|
45
|
+
(globalConfig.placeholder as Record<string, unknown>) ?? {}
|
|
46
|
+
) as Record<keyof typeof placeholderTheme.base, string | undefined>
|
|
47
|
+
|
|
48
|
+
const { base, svg } = placeholder()
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<div :class="twMerge(base, mergedUI.base, className)" v-bind="$attrs">
|
|
53
|
+
<svg :class="twMerge(svg, mergedUI.svg)">
|
|
54
|
+
<defs>
|
|
55
|
+
<pattern
|
|
56
|
+
id="pattern-5c1e4f0e-62d5-498b-8ff0-cf77bb448c8e"
|
|
57
|
+
x="0"
|
|
58
|
+
y="0"
|
|
59
|
+
width="10"
|
|
60
|
+
height="10"
|
|
61
|
+
patternUnits="userSpaceOnUse"
|
|
62
|
+
>
|
|
63
|
+
<path d="M-3 13 15-5M-5 5l18-18M-1 21 17 3" />
|
|
64
|
+
</pattern>
|
|
65
|
+
</defs>
|
|
66
|
+
<rect
|
|
67
|
+
stroke="none"
|
|
68
|
+
fill="url(#pattern-5c1e4f0e-62d5-498b-8ff0-cf77bb448c8e)"
|
|
69
|
+
width="100%"
|
|
70
|
+
height="100%"
|
|
71
|
+
/>
|
|
72
|
+
</svg>
|
|
73
|
+
|
|
74
|
+
<slot />
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
package/src/integrations/ui.ts
CHANGED
|
@@ -3,7 +3,6 @@ import UnoCSS from "unocss/astro"
|
|
|
3
3
|
import vue from "@astrojs/vue"
|
|
4
4
|
import uiPlugin from "@nuxt/ui/vite"
|
|
5
5
|
import defu from "defu"
|
|
6
|
-
import Icons from "unplugin-icons/vite"
|
|
7
6
|
import tailwindcss from "@tailwindcss/vite"
|
|
8
7
|
import { defaultUIConfig } from "../themes"
|
|
9
8
|
|
|
@@ -14,9 +13,25 @@ export type UIConfigOverrides = {
|
|
|
14
13
|
"button"?: Partial<(typeof defaultUIConfig)["button"]>
|
|
15
14
|
"header"?: Partial<(typeof defaultUIConfig)["header"]>
|
|
16
15
|
"scroll-to-top"?: Partial<(typeof defaultUIConfig)["scroll-to-top"]>
|
|
16
|
+
"logo"?: Partial<(typeof defaultUIConfig)["logo"]>
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface UIOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for the Logo component variants.
|
|
22
|
+
*/
|
|
23
|
+
logos?: Record<
|
|
24
|
+
string,
|
|
25
|
+
| string
|
|
26
|
+
| {
|
|
27
|
+
light?: string
|
|
28
|
+
dark?: string
|
|
29
|
+
color?: string
|
|
30
|
+
white?: string
|
|
31
|
+
black?: string
|
|
32
|
+
[key: string]: string | undefined
|
|
33
|
+
}
|
|
34
|
+
>
|
|
20
35
|
/**
|
|
21
36
|
* Global UI overrides applied to all components. Merged with defaults via `defu` (first arg
|
|
22
37
|
* wins).
|
|
@@ -47,7 +62,8 @@ export interface UIOptions {
|
|
|
47
62
|
* })
|
|
48
63
|
*/
|
|
49
64
|
export function ui(options: UIOptions = {}): AstroIntegration[] {
|
|
50
|
-
const
|
|
65
|
+
const resolvedUI = defu(options.ui ?? {}, defaultUIConfig)
|
|
66
|
+
const resolvedConfig = { ...resolvedUI, logos: options.logos ?? {} }
|
|
51
67
|
|
|
52
68
|
const virtualModuleId = "virtual:rimelight-ui"
|
|
53
69
|
const resolvedVirtualModuleId = "\0" + virtualModuleId
|
|
@@ -74,10 +90,6 @@ export function ui(options: UIOptions = {}): AstroIntegration[] {
|
|
|
74
90
|
router: false,
|
|
75
91
|
scanPackages: ["@rimelight/ui"]
|
|
76
92
|
}),
|
|
77
|
-
Icons({
|
|
78
|
-
compiler: "astro",
|
|
79
|
-
autoInstall: true
|
|
80
|
-
}),
|
|
81
93
|
tailwindcss(),
|
|
82
94
|
{
|
|
83
95
|
name: "vite-plugin-rimelight-ui-config",
|
package/src/presets/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
definePreset,
|
|
3
3
|
presetTypography,
|
|
4
4
|
presetWind4,
|
|
5
|
+
presetIcons,
|
|
5
6
|
transformerDirectives,
|
|
6
7
|
transformerVariantGroup
|
|
7
8
|
} from "unocss"
|
|
@@ -23,6 +24,12 @@ export default definePreset(() => {
|
|
|
23
24
|
"font-family": "var(--font-mono), monospace"
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
}),
|
|
28
|
+
presetIcons({
|
|
29
|
+
extraProperties: {
|
|
30
|
+
"display": "inline-block",
|
|
31
|
+
"vertical-align": "middle"
|
|
32
|
+
}
|
|
26
33
|
})
|
|
27
34
|
],
|
|
28
35
|
transformers: [transformerDirectives(), transformerVariantGroup()],
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const iconTheme = {
|
|
2
|
+
slots: ["root"],
|
|
3
|
+
base: {
|
|
4
|
+
root: ["inline-block", "align-middle"]
|
|
5
|
+
},
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
xs: { root: ["h-3", "w-3"] },
|
|
9
|
+
sm: { root: ["h-4", "w-4"] },
|
|
10
|
+
md: { root: ["h-5", "w-5"] },
|
|
11
|
+
lg: { root: ["h-6", "w-6"] },
|
|
12
|
+
xl: { root: ["h-8", "w-8"] }
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
size: "md"
|
|
17
|
+
}
|
|
18
|
+
} as const
|
package/src/themes/index.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { headerTheme } from "./header.theme"
|
|
|
2
2
|
import { footerTheme } from "./footer.theme"
|
|
3
3
|
import { scrollToTopTheme } from "./scroll-to-top.theme"
|
|
4
4
|
import { buttonTheme } from "./button.theme"
|
|
5
|
+
import { logoTheme } from "./logo.theme"
|
|
6
|
+
import { iconTheme } from "./icon.theme"
|
|
7
|
+
import { placeholderTheme } from "./placeholder.theme"
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Default UI configuration for all components. This is the baseline that gets merged with
|
|
@@ -10,8 +13,11 @@ import { buttonTheme } from "./button.theme"
|
|
|
10
13
|
export const defaultUIConfig = {
|
|
11
14
|
"header": headerTheme,
|
|
12
15
|
"footer": footerTheme,
|
|
16
|
+
"logo": logoTheme,
|
|
13
17
|
"scroll-to-top": scrollToTopTheme,
|
|
14
|
-
"button": buttonTheme
|
|
18
|
+
"button": buttonTheme,
|
|
19
|
+
"icon": iconTheme,
|
|
20
|
+
"placeholder": placeholderTheme
|
|
15
21
|
} as const
|
|
16
22
|
|
|
17
23
|
export type DefaultUIConfig = typeof defaultUIConfig
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme configuration for the Placeholder component. Defines the slots, base styles for a
|
|
3
|
+
* placeholder container with a decorative SVG pattern overlay.
|
|
4
|
+
*/
|
|
5
|
+
export const placeholderTheme = {
|
|
6
|
+
slots: ["base", "svg"],
|
|
7
|
+
base: {
|
|
8
|
+
base: "relative flex items-center justify-center overflow-hidden rounded-sm border-1 border-dashed border-primary px-4 opacity-75",
|
|
9
|
+
svg: "absolute inset-0 h-full w-full stroke-primary/10"
|
|
10
|
+
},
|
|
11
|
+
variants: {},
|
|
12
|
+
compoundVariants: [],
|
|
13
|
+
defaultVariants: {}
|
|
14
|
+
} as const
|