@rimelight/ui 0.0.27 → 0.0.29
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 +14 -13
- package/src/components/astro/RLAAccordion.astro +2 -6
- package/src/components/astro/RLAButton.astro +7 -23
- package/src/components/astro/RLAEmbedYoutube.astro +34 -25
- package/src/components/astro/RLAFooter.astro +2 -10
- package/src/components/astro/RLAHeader.astro +2 -14
- package/src/components/astro/RLAIcon.astro +2 -11
- package/src/components/astro/RLALogo.astro +2 -12
- package/src/components/astro/RLAPlaceholder.astro +2 -8
- package/src/components/astro/RLAScrollToTop.astro +2 -14
- package/src/components/astro/RLASection.astro +24 -82
- package/src/components/vue/RLVButton.vue +2 -64
- package/src/components/vue/RLVFooter.vue +2 -9
- package/src/components/vue/RLVHeader.vue +2 -13
- package/src/components/vue/RLVIcon.vue +2 -10
- package/src/components/vue/RLVLogo.vue +13 -21
- package/src/components/vue/RLVPlaceholder.vue +2 -8
- package/src/components/vue/RLVScrollToTop.vue +2 -13
- package/src/components/vue/RLVSection.vue +2 -19
- package/src/env.d.ts +1 -1
- package/src/integrations/ui.ts +17 -1
- package/src/presets/index.ts +63 -193
- package/src/themes/button.theme.ts +180 -511
- package/src/themes/embedYoutube.theme.ts +14 -0
- package/src/types/components/accordion.ts +15 -0
- package/src/types/components/button.ts +71 -0
- package/src/types/components/embed-youtube.ts +27 -0
- package/src/types/components/footer.ts +15 -0
- package/src/types/components/header.ts +31 -0
- package/src/types/components/icon.ts +19 -0
- package/src/types/components/index.ts +12 -0
- package/src/types/components/link.ts +23 -0
- package/src/types/components/logo.ts +27 -0
- package/src/types/components/navigation.ts +34 -0
- package/src/types/components/placeholder.ts +11 -0
- package/src/types/components/scroll-to-top.ts +31 -0
- package/src/types/components/section.ts +63 -0
- package/src/types/index.ts +1 -0
- package/src/nuxt-types.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimelight/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Rimelight Entertainment UI Library.",
|
|
6
6
|
"keywords": [
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"./middleware": "./src/middleware/index.ts",
|
|
49
49
|
"./middleware/*": "./src/middleware/*",
|
|
50
50
|
"./nuxt": "./src/nuxt.ts",
|
|
51
|
-
"./
|
|
51
|
+
"./types": "./src/types/index.ts",
|
|
52
|
+
"./types/*": "./src/types/*",
|
|
52
53
|
"./presets": "./src/presets/index.ts",
|
|
53
54
|
"./presets/*": "./src/presets/*",
|
|
54
55
|
"./*": "./src/*"
|
|
@@ -63,14 +64,14 @@
|
|
|
63
64
|
"docs:meta": "tsx scripts/extract-meta.ts"
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
66
|
-
"@astrojs/prism": "^4.0.
|
|
67
|
+
"@astrojs/prism": "^4.0.2",
|
|
67
68
|
"@astrojs/vue": "6.0.1",
|
|
68
|
-
"@iconify-json/lucide": "^1.2.
|
|
69
|
-
"@nuxt/ui": "4.
|
|
70
|
-
"@tailwindcss/vite": "^4.
|
|
69
|
+
"@iconify-json/lucide": "^1.2.108",
|
|
70
|
+
"@nuxt/ui": "4.7.1",
|
|
71
|
+
"@tailwindcss/vite": "^4.3.0",
|
|
71
72
|
"@unocss/astro": "^66.6.8",
|
|
72
73
|
"css-variants": "2.3.5",
|
|
73
|
-
"defu": "6.1.
|
|
74
|
+
"defu": "6.1.7",
|
|
74
75
|
"embla-carousel": "8.6.0",
|
|
75
76
|
"picomatch": "^4.0.4",
|
|
76
77
|
"tailwindcss": "^4.2.3",
|
|
@@ -80,18 +81,18 @@
|
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
83
|
"@astrojs/check": "0.9.8",
|
|
83
|
-
"@astrojs/ts-plugin": "1.10.
|
|
84
|
+
"@astrojs/ts-plugin": "1.10.8",
|
|
84
85
|
"@e18e/eslint-plugin": "0.3.0",
|
|
85
|
-
"@types/node": "25.
|
|
86
|
+
"@types/node": "25.8.0",
|
|
86
87
|
"@types/picomatch": "^4.0.3",
|
|
87
88
|
"@unocss/eslint-plugin": "66.6.8",
|
|
88
|
-
"astro": "6.
|
|
89
|
+
"astro": "6.3.6",
|
|
89
90
|
"eslint-plugin-regexp": "3.1.0",
|
|
90
|
-
"knip": "6.
|
|
91
|
-
"tsx": "4.
|
|
91
|
+
"knip": "6.14.1",
|
|
92
|
+
"tsx": "4.22.1",
|
|
92
93
|
"typescript": "6.0.3",
|
|
93
94
|
"unocss": "66.6.8",
|
|
94
|
-
"vite-plus": "0.1.
|
|
95
|
+
"vite-plus": "0.1.21"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"@astrojs/starlight": ">=0.5.0",
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
import type {
|
|
2
|
+
import type { AccordionProps } from "../../types";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
summary: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const { summary, class: className, ...attrs } = Astro.props;
|
|
4
|
+
const { summary, class: className, ...attrs } = Astro.props as AccordionProps;
|
|
9
5
|
---
|
|
10
6
|
|
|
11
7
|
<details class:list={['group', className]} {...attrs}>
|
|
@@ -1,30 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { scv, cx } from "css-variants"
|
|
3
3
|
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
-
import type {
|
|
5
|
-
import
|
|
4
|
+
import type { ButtonProps } from "../../types"
|
|
5
|
+
import buttonThemeDefault, { createButtonTheme } from "../../themes/button.theme"
|
|
6
|
+
import { getUIConfig } from "virtual:rimelight-ui"
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const uiConfig = getUIConfig()
|
|
9
|
+
const buttonTheme = uiConfig.colors ? createButtonTheme(uiConfig.colors) : buttonThemeDefault
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
variant?: ButtonVariants['variant'];
|
|
12
|
-
color?: ButtonVariants['color'];
|
|
13
|
-
size?: ButtonVariants['size'];
|
|
14
|
-
href?: string;
|
|
15
|
-
label?: string;
|
|
16
|
-
leadingIcon?: string;
|
|
17
|
-
trailingIcon?: string;
|
|
18
|
-
loading?: boolean;
|
|
19
|
-
square?: boolean;
|
|
20
|
-
block?: boolean;
|
|
21
|
-
active?: boolean;
|
|
22
|
-
activeColor?: ButtonVariants['color'];
|
|
23
|
-
activeVariant?: ButtonVariants['variant'];
|
|
24
|
-
ui?: ComponentSlots<typeof buttonTheme>;
|
|
25
|
-
class?: any;
|
|
26
|
-
[key: string]: unknown;
|
|
27
|
-
}
|
|
11
|
+
const button = scv(buttonTheme)
|
|
28
12
|
|
|
29
13
|
const {
|
|
30
14
|
variant = "solid",
|
|
@@ -43,7 +27,7 @@ const {
|
|
|
43
27
|
ui: uiProp,
|
|
44
28
|
class: className,
|
|
45
29
|
...rest
|
|
46
|
-
} = Astro.props as
|
|
30
|
+
} = Astro.props as ButtonProps
|
|
47
31
|
|
|
48
32
|
const isLeading = !!(leadingIcon || Astro.slots.has("leading")) || loading
|
|
49
33
|
const isTrailing = !!(trailingIcon || Astro.slots.has("trailing")) || (loading && !isLeading)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
import { scv } from "css-variants"
|
|
3
|
+
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
+
import type { EmbedYoutubeProps } from "../../types"
|
|
5
|
+
import embedYoutubeTheme from "../../themes/embedYoutube.theme"
|
|
6
|
+
import { Image } from "astro:assets"
|
|
3
7
|
|
|
8
|
+
const PLACEHOLDER_THUMBNAIL = "/assets/placeholder.webp";
|
|
4
9
|
const YOUTUBE_EMBED_BASE = "https://www.youtube.com/embed/";
|
|
5
|
-
|
|
6
10
|
const VALID_ID_PATTERN = /^[\w-]{11}$/;
|
|
7
|
-
|
|
8
11
|
const KNOWN_PREFIXES = ["www.", "m.", "music.", "gaming."];
|
|
9
|
-
|
|
10
12
|
const YOUTUBE_THUMB_BASE = "https://i3.ytimg.com/vi/";
|
|
11
|
-
|
|
12
13
|
const MAXRES_THUMBNAIL = "maxresdefault.jpg";
|
|
13
|
-
|
|
14
14
|
const DEFAULT_THUMBNAIL = "hqdefault.jpg";
|
|
15
15
|
|
|
16
16
|
const thumbnailAvailabilityCache = new Map<string, boolean>();
|
|
@@ -109,44 +109,54 @@ function getYoutubeEmbedUrl(rawUrl: string): string | null {
|
|
|
109
109
|
return id ? `${YOUTUBE_EMBED_BASE}${id}?autoplay=1` : null;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
const embedYoutube = scv(embedYoutubeTheme)
|
|
113
|
+
|
|
114
|
+
const {
|
|
115
|
+
src,
|
|
116
|
+
title = "YouTube Video Player",
|
|
117
|
+
icon = "i-lucide-play",
|
|
118
|
+
ui: uiProp,
|
|
119
|
+
class: className,
|
|
120
|
+
...rest
|
|
121
|
+
} = Astro.props as EmbedYoutubeProps
|
|
117
122
|
|
|
118
|
-
const
|
|
123
|
+
const classes = resolveClasses(embedYoutube, {
|
|
124
|
+
title: !!(Astro.slots.has("title") || title),
|
|
125
|
+
icon: !!(Astro.slots.has("icon") || icon),
|
|
126
|
+
}, useUi("embedYoutube", uiProp), className);
|
|
119
127
|
|
|
120
128
|
const embedUrl = getYoutubeEmbedUrl(src);
|
|
121
129
|
const thumbnail = await getYoutubeThumbnail(src);
|
|
122
130
|
const isPlayable = Boolean(embedUrl);
|
|
123
|
-
const ariaLabel = isPlayable ? "Play YouTube
|
|
131
|
+
const ariaLabel = isPlayable ? "Play YouTube Video" : "YouTube Video Unavailable";
|
|
124
132
|
---
|
|
125
133
|
|
|
126
|
-
<div
|
|
134
|
+
<div
|
|
135
|
+
class:list={[classes.root]}
|
|
136
|
+
{...rest}
|
|
137
|
+
>
|
|
127
138
|
<button
|
|
128
139
|
type="button"
|
|
129
|
-
class="absolute inset-0 aspect-video h-full w-full overflow-hidden group"
|
|
130
140
|
data-youtube-trigger
|
|
131
141
|
aria-label={ariaLabel}
|
|
132
142
|
data-embed-url={isPlayable ? embedUrl : undefined}
|
|
133
143
|
disabled={!isPlayable}
|
|
134
144
|
data-video-title={title}
|
|
145
|
+
class:list={[classes.trigger]}
|
|
135
146
|
>
|
|
136
|
-
<
|
|
147
|
+
<Image
|
|
148
|
+
layout="full-width"
|
|
137
149
|
src={thumbnail}
|
|
138
|
-
class="h-full w-full object-cover"
|
|
139
150
|
alt={title}
|
|
140
151
|
width="1280"
|
|
141
152
|
height="720"
|
|
142
153
|
loading="lazy"
|
|
154
|
+
class:list={[classes.image]}
|
|
143
155
|
/>
|
|
144
156
|
|
|
145
|
-
<
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
</svg>
|
|
149
|
-
</span>
|
|
157
|
+
<slot name="icon">
|
|
158
|
+
<span class:list={[classes.icon, icon]} aria-hidden="true" />
|
|
159
|
+
</slot>
|
|
150
160
|
</button>
|
|
151
161
|
</div>
|
|
152
162
|
|
|
@@ -167,7 +177,7 @@ const ariaLabel = isPlayable ? "Play YouTube video" : "YouTube video unavailable
|
|
|
167
177
|
iframe.src = embedUrl;
|
|
168
178
|
iframe.title = title;
|
|
169
179
|
iframe.allow =
|
|
170
|
-
|
|
180
|
+
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";
|
|
171
181
|
iframe.allowFullscreen = true;
|
|
172
182
|
iframe.loading = "lazy";
|
|
173
183
|
iframe.referrerPolicy = "strict-origin-when-cross-origin";
|
|
@@ -176,7 +186,6 @@ const ariaLabel = isPlayable ? "Play YouTube video" : "YouTube video unavailable
|
|
|
176
186
|
root.replaceChildren(iframe);
|
|
177
187
|
};
|
|
178
188
|
|
|
179
|
-
// click and accessibility activation
|
|
180
189
|
trigger.addEventListener("click", activate, { once: true });
|
|
181
190
|
trigger.addEventListener("keydown", (event) => {
|
|
182
191
|
if (event.key === "Enter" || event.key === " ") {
|
|
@@ -185,4 +194,4 @@ const ariaLabel = isPlayable ? "Play YouTube video" : "YouTube video unavailable
|
|
|
185
194
|
}
|
|
186
195
|
}, { once: true });
|
|
187
196
|
})();
|
|
188
|
-
</script>
|
|
197
|
+
</script>
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { scv } from "css-variants"
|
|
3
3
|
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
-
import type {
|
|
4
|
+
import type { FooterProps } from "../../types"
|
|
5
5
|
import footerTheme from "../../themes/footer.theme"
|
|
6
6
|
|
|
7
7
|
const footer = scv(footerTheme)
|
|
8
|
-
type FooterVariants = ComponentVariants<typeof footerTheme>
|
|
9
|
-
|
|
10
|
-
export interface RLAFooterProps {
|
|
11
|
-
contain?: FooterVariants['contain'];
|
|
12
|
-
ui?: ComponentSlots<typeof footerTheme>;
|
|
13
|
-
class?: any;
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
}
|
|
16
8
|
|
|
17
9
|
const {
|
|
18
10
|
contain = false,
|
|
19
11
|
ui: uiProp,
|
|
20
12
|
class: className,
|
|
21
13
|
...rest
|
|
22
|
-
} = Astro.props as
|
|
14
|
+
} = Astro.props as FooterProps
|
|
23
15
|
|
|
24
16
|
const classes = resolveClasses(footer, { contain }, useUi("footer", uiProp), className)
|
|
25
17
|
---
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { scv } from "css-variants"
|
|
3
3
|
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
-
import type {
|
|
4
|
+
import type { HeaderProps } from "../../types"
|
|
5
5
|
import headerTheme from "../../themes/header.theme"
|
|
6
6
|
|
|
7
7
|
const header = scv(headerTheme)
|
|
8
|
-
type HeaderVariants = ComponentVariants<typeof headerTheme>
|
|
9
|
-
|
|
10
|
-
export interface RLAHeaderProps {
|
|
11
|
-
contain?: HeaderVariants['contain'];
|
|
12
|
-
sticky?: HeaderVariants['sticky'];
|
|
13
|
-
fixed?: HeaderVariants['fixed'];
|
|
14
|
-
stackIndex?: number;
|
|
15
|
-
hideOnScroll?: boolean;
|
|
16
|
-
ui?: ComponentSlots<typeof headerTheme>;
|
|
17
|
-
class?: any;
|
|
18
|
-
[key: string]: unknown;
|
|
19
|
-
}
|
|
20
8
|
|
|
21
9
|
const {
|
|
22
10
|
contain = true,
|
|
@@ -27,7 +15,7 @@ const {
|
|
|
27
15
|
ui: uiProp,
|
|
28
16
|
class: className,
|
|
29
17
|
...rest
|
|
30
|
-
} = Astro.props as
|
|
18
|
+
} = Astro.props as HeaderProps;
|
|
31
19
|
|
|
32
20
|
const classes = resolveClasses(header, {
|
|
33
21
|
contain,
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { scv } from "css-variants"
|
|
3
3
|
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
-
import type {
|
|
4
|
+
import type { IconProps } from "../../types"
|
|
5
5
|
import iconTheme from "../../themes/icon.theme"
|
|
6
6
|
|
|
7
7
|
const icon = scv(iconTheme)
|
|
8
|
-
type IconVariants = ComponentVariants<typeof iconTheme>
|
|
9
|
-
|
|
10
|
-
export interface RLAIconProps {
|
|
11
|
-
name: string
|
|
12
|
-
size?: IconVariants['size']
|
|
13
|
-
ui?: ComponentSlots<typeof iconTheme>
|
|
14
|
-
class?: any
|
|
15
|
-
[key: string]: unknown
|
|
16
|
-
}
|
|
17
8
|
|
|
18
9
|
const {
|
|
19
10
|
name,
|
|
@@ -21,7 +12,7 @@ const {
|
|
|
21
12
|
ui: uiProp,
|
|
22
13
|
class: className,
|
|
23
14
|
...rest
|
|
24
|
-
} = Astro.props as
|
|
15
|
+
} = Astro.props as IconProps
|
|
25
16
|
|
|
26
17
|
const classes = resolveClasses(icon, { size }, useUi("icon", uiProp), className)
|
|
27
18
|
---
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { scv } from "css-variants"
|
|
3
3
|
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
-
import type {
|
|
4
|
+
import type { LogoProps } from "../../types"
|
|
5
5
|
import logoTheme from "../../themes/logo.theme"
|
|
6
6
|
import { getUIConfig } from "virtual:rimelight-ui"
|
|
7
7
|
|
|
8
8
|
const logo = scv(logoTheme)
|
|
9
9
|
|
|
10
|
-
export interface RLALogoProps {
|
|
11
|
-
variant?: string;
|
|
12
|
-
mode?: "color" | "white" | "black";
|
|
13
|
-
href?: string;
|
|
14
|
-
alt?: string;
|
|
15
|
-
ui?: ComponentSlots<typeof logoTheme>;
|
|
16
|
-
class?: any;
|
|
17
|
-
[key: string]: unknown;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
10
|
const {
|
|
21
11
|
variant = "logomark",
|
|
22
12
|
mode,
|
|
@@ -25,7 +15,7 @@ const {
|
|
|
25
15
|
ui: uiProp,
|
|
26
16
|
class: className,
|
|
27
17
|
...rest
|
|
28
|
-
} = Astro.props as
|
|
18
|
+
} = Astro.props as LogoProps;
|
|
29
19
|
|
|
30
20
|
const classes = resolveClasses(logo, {}, useUi("logo", uiProp), className);
|
|
31
21
|
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { scv } from "css-variants"
|
|
3
3
|
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
-
import type {
|
|
4
|
+
import type { PlaceholderProps } from "../../types"
|
|
5
5
|
import placeholderTheme from "../../themes/placeholder.theme"
|
|
6
6
|
|
|
7
7
|
const placeholder = scv(placeholderTheme)
|
|
8
8
|
|
|
9
|
-
export interface RLAPlaceholderProps {
|
|
10
|
-
ui?: ComponentSlots<typeof placeholderTheme>
|
|
11
|
-
class?: any
|
|
12
|
-
[key: string]: unknown
|
|
13
|
-
}
|
|
14
|
-
|
|
15
9
|
const {
|
|
16
10
|
ui: uiProp,
|
|
17
11
|
class: className,
|
|
18
12
|
...rest
|
|
19
|
-
} = Astro.props as
|
|
13
|
+
} = Astro.props as PlaceholderProps
|
|
20
14
|
|
|
21
15
|
const classes = resolveClasses(placeholder, {}, useUi("placeholder", uiProp), className)
|
|
22
16
|
---
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { scv } from "css-variants"
|
|
3
3
|
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
-
import type {
|
|
4
|
+
import type { ScrollToTopProps } from "../../types"
|
|
5
5
|
import scrollToTopTheme from "../../themes/scroll-to-top.theme"
|
|
6
6
|
|
|
7
7
|
const scrollToTop = scv(scrollToTopTheme)
|
|
8
|
-
type ScrollToTopVariants = ComponentVariants<typeof scrollToTopTheme>
|
|
9
|
-
|
|
10
|
-
export interface RLAScrollToTopProps {
|
|
11
|
-
color?: ScrollToTopVariants['color'];
|
|
12
|
-
progressWidth?: number;
|
|
13
|
-
duration?: number;
|
|
14
|
-
threshold?: number;
|
|
15
|
-
showProgress?: boolean;
|
|
16
|
-
ui?: ComponentSlots<typeof scrollToTopTheme>;
|
|
17
|
-
class?: any;
|
|
18
|
-
[key: string]: unknown;
|
|
19
|
-
}
|
|
20
8
|
|
|
21
9
|
const {
|
|
22
10
|
color = "primary",
|
|
@@ -27,7 +15,7 @@ const {
|
|
|
27
15
|
ui: uiProp,
|
|
28
16
|
class: className,
|
|
29
17
|
...rest
|
|
30
|
-
} = Astro.props as
|
|
18
|
+
} = Astro.props as ScrollToTopProps
|
|
31
19
|
|
|
32
20
|
const classes = resolveClasses(scrollToTop, { color }, useUi("scrollToTop", uiProp), className)
|
|
33
21
|
|
|
@@ -1,65 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { scv } from "css-variants"
|
|
3
3
|
import { useUi, resolveClasses } from "../../utils"
|
|
4
|
-
import type {
|
|
4
|
+
import type { SectionProps } from "../../types"
|
|
5
5
|
import sectionTheme from "../../themes/section.theme"
|
|
6
|
-
import type { RLAIconProps } from "./RLAIcon.astro"
|
|
7
|
-
import type { RLAButtonProps } from "./RLAButton.astro"
|
|
8
6
|
import RLAIcon from "./RLAIcon.astro"
|
|
9
7
|
import RLAButton from "./RLAButton.astro"
|
|
10
8
|
|
|
11
9
|
const section = scv(sectionTheme)
|
|
12
|
-
type SectionVariants = ComponentVariants<typeof sectionTheme>
|
|
13
|
-
|
|
14
|
-
export interface RLASectionProps {
|
|
15
|
-
/**
|
|
16
|
-
* The element or component this component should render as.
|
|
17
|
-
* @default 'section'
|
|
18
|
-
*/
|
|
19
|
-
as?: any;
|
|
20
|
-
/**
|
|
21
|
-
* The variant of the section.
|
|
22
|
-
* @default 'default'
|
|
23
|
-
*/
|
|
24
|
-
variant?: SectionVariants['variant'];
|
|
25
|
-
/** The variant of the section when it's a CTA.
|
|
26
|
-
* @default 'solid'
|
|
27
|
-
*/
|
|
28
|
-
ctaVariant?: SectionVariants['ctaVariant'];
|
|
29
|
-
/**
|
|
30
|
-
* The headline displayed above the title.
|
|
31
|
-
*/
|
|
32
|
-
headline?: string;
|
|
33
|
-
/**
|
|
34
|
-
* The icon displayed above the title.
|
|
35
|
-
*/
|
|
36
|
-
icon?: RLAIconProps["name"];
|
|
37
|
-
/**
|
|
38
|
-
* The section's title, displayed as a <h1> for the hero variant or <h2> otherwise.
|
|
39
|
-
*/
|
|
40
|
-
title?: string;
|
|
41
|
-
/**
|
|
42
|
-
* The section's description, displayed under the title.
|
|
43
|
-
*/
|
|
44
|
-
description?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Display a list of buttons under the description.
|
|
47
|
-
*/
|
|
48
|
-
links?: RLAButtonProps[]
|
|
49
|
-
/**
|
|
50
|
-
* The orientation of the section.
|
|
51
|
-
* @default 'vertical'
|
|
52
|
-
*/
|
|
53
|
-
orientation?: SectionVariants['orientation'];
|
|
54
|
-
/**
|
|
55
|
-
* Reverse the order of the default slot.
|
|
56
|
-
* @default false
|
|
57
|
-
*/
|
|
58
|
-
reverse?: boolean;
|
|
59
|
-
ui?: ComponentSlots<typeof sectionTheme>;
|
|
60
|
-
class?: any;
|
|
61
|
-
[key: string]: unknown;
|
|
62
|
-
}
|
|
63
10
|
|
|
64
11
|
const {
|
|
65
12
|
as = "section",
|
|
@@ -67,19 +14,24 @@ const {
|
|
|
67
14
|
orientation = "vertical",
|
|
68
15
|
reverse = false,
|
|
69
16
|
ctaVariant = "solid",
|
|
17
|
+
headline,
|
|
18
|
+
title,
|
|
19
|
+
description,
|
|
20
|
+
icon,
|
|
21
|
+
links,
|
|
70
22
|
ui: uiProp,
|
|
71
23
|
class: className,
|
|
72
24
|
...rest
|
|
73
|
-
} = Astro.props as
|
|
25
|
+
} = Astro.props as SectionProps;
|
|
74
26
|
|
|
75
27
|
const classes = resolveClasses(section, {
|
|
76
28
|
variant,
|
|
77
29
|
orientation,
|
|
78
30
|
reverse,
|
|
79
31
|
...(variant === "cta" && { ctaVariant }),
|
|
80
|
-
headline: !!(Astro.slots.has("headline") ||
|
|
81
|
-
title: !!(Astro.slots.has("title") ||
|
|
82
|
-
description: !!(Astro.slots.has("description") ||
|
|
32
|
+
headline: !!(Astro.slots.has("headline") || headline),
|
|
33
|
+
title: !!(Astro.slots.has("title") || title),
|
|
34
|
+
description: !!(Astro.slots.has("description") || description),
|
|
83
35
|
body: Astro.slots.has("body")
|
|
84
36
|
}, useUi("section", uiProp), className);
|
|
85
37
|
|
|
@@ -104,62 +56,55 @@ const TitleTag = variant === "hero" ? "h1" : "h2";
|
|
|
104
56
|
<slot name="top" />
|
|
105
57
|
|
|
106
58
|
<div
|
|
107
|
-
data-slot="container"
|
|
108
59
|
class:list={[classes.container]}
|
|
109
60
|
>
|
|
110
|
-
{(Astro.slots.has("header") ||
|
|
61
|
+
{(Astro.slots.has("header") || icon || headline || title || description || Astro.slots.has("body") || Astro.slots.has("footer") || Astro.slots.has("links") || links?.length) && (
|
|
111
62
|
<div
|
|
112
|
-
data-slot="wrapper"
|
|
113
63
|
class:list={[classes.wrapper]}
|
|
114
64
|
>
|
|
115
|
-
{(Astro.slots.has("header") ||
|
|
65
|
+
{(Astro.slots.has("header") || icon || headline || title || description) && (
|
|
116
66
|
<div
|
|
117
|
-
data-slot="header"
|
|
118
67
|
class:list={[classes.header]}
|
|
119
68
|
>
|
|
120
69
|
<slot name="header">
|
|
121
|
-
{(
|
|
70
|
+
{(icon || Astro.slots.has("leading")) && (
|
|
122
71
|
<div
|
|
123
|
-
data-slot="leading"
|
|
124
72
|
class:list={[classes.leading]}
|
|
125
73
|
>
|
|
126
74
|
<slot name="leading" {...{ ui: classes }}>
|
|
127
|
-
{
|
|
128
|
-
<RLAIcon name={
|
|
75
|
+
{icon && (
|
|
76
|
+
<RLAIcon name={icon} size="md" ui={{ root: classes.leadingIcon }} />
|
|
129
77
|
)}
|
|
130
78
|
</slot>
|
|
131
79
|
</div>
|
|
132
80
|
)}
|
|
133
81
|
|
|
134
|
-
{(
|
|
82
|
+
{(headline || Astro.slots.has("headline")) && (
|
|
135
83
|
<div
|
|
136
|
-
data-slot="headline"
|
|
137
84
|
class:list={[classes.headline]}
|
|
138
85
|
>
|
|
139
86
|
<slot name="headline">
|
|
140
|
-
{
|
|
87
|
+
{headline}
|
|
141
88
|
</slot>
|
|
142
89
|
</div>
|
|
143
90
|
)}
|
|
144
91
|
|
|
145
|
-
{(
|
|
92
|
+
{(title || Astro.slots.has("title")) && (
|
|
146
93
|
<TitleTag
|
|
147
|
-
data-slot="title"
|
|
148
94
|
class:list={[classes.title]}
|
|
149
95
|
>
|
|
150
96
|
<slot name="title">
|
|
151
|
-
{
|
|
97
|
+
{title}
|
|
152
98
|
</slot>
|
|
153
99
|
</TitleTag>
|
|
154
100
|
)}
|
|
155
101
|
|
|
156
|
-
{(
|
|
102
|
+
{(description || Astro.slots.has("description")) && (
|
|
157
103
|
<div
|
|
158
|
-
data-slot="description"
|
|
159
104
|
class:list={[classes.description]}
|
|
160
105
|
>
|
|
161
106
|
<slot name="description">
|
|
162
|
-
{
|
|
107
|
+
{description}
|
|
163
108
|
</slot>
|
|
164
109
|
</div>
|
|
165
110
|
)}
|
|
@@ -169,25 +114,22 @@ const TitleTag = variant === "hero" ? "h1" : "h2";
|
|
|
169
114
|
|
|
170
115
|
{Astro.slots.has("body") && (
|
|
171
116
|
<div
|
|
172
|
-
data-slot="body"
|
|
173
117
|
class:list={[classes.body]}
|
|
174
118
|
>
|
|
175
119
|
<slot name="body" />
|
|
176
120
|
</div>
|
|
177
121
|
)}
|
|
178
122
|
|
|
179
|
-
{(Astro.slots.has("footer") || Astro.slots.has("links") ||
|
|
123
|
+
{(Astro.slots.has("footer") || Astro.slots.has("links") || links?.length) && (
|
|
180
124
|
<div
|
|
181
|
-
data-slot="footer"
|
|
182
125
|
class:list={[classes.footer]}
|
|
183
126
|
>
|
|
184
127
|
<slot name="footer">
|
|
185
|
-
{(
|
|
128
|
+
{(links?.length || Astro.slots.has("links")) && (
|
|
186
129
|
<div
|
|
187
|
-
data-slot="links"
|
|
188
130
|
class:list={[classes.links]}
|
|
189
131
|
>
|
|
190
|
-
{
|
|
132
|
+
{links?.map((link) => (
|
|
191
133
|
<RLAButton size="lg" {...link} />
|
|
192
134
|
))}
|
|
193
135
|
<slot name="links" />
|