@rxdrag/website-lib 0.0.151 → 0.0.153

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.
Files changed (51) hide show
  1. package/README.md +2 -2
  2. package/components/AnimationNumber.astro +217 -217
  3. package/components/Background.astro +140 -114
  4. package/components/BackgroundGroup.astro +20 -26
  5. package/components/BaseFooter.astro +24 -39
  6. package/components/BaseHeader.astro +22 -25
  7. package/components/Box.astro +20 -22
  8. package/components/Button.astro +80 -0
  9. package/components/Carousel.astro +456 -315
  10. package/components/CarouselPagination.astro +97 -76
  11. package/components/CarouselSlide.astro +10 -16
  12. package/components/Collapse.astro +125 -125
  13. package/components/CollapseIndicator.astro +20 -20
  14. package/components/Container.astro +27 -32
  15. package/components/Content.astro +20 -0
  16. package/components/CookieConsent.astro +47 -47
  17. package/components/CookieConsent.css +52 -52
  18. package/components/CookieConsentConfig.ts +208 -208
  19. package/components/Dialog.astro +342 -338
  20. package/components/DialogTrigger.astro +32 -32
  21. package/components/Document.astro +240 -225
  22. package/components/Frame.astro +32 -0
  23. package/components/GlassBorder.astro +104 -0
  24. package/components/GlassRefraction.astro +85 -0
  25. package/components/GradientBorder.astro +80 -0
  26. package/components/Grid.astro +32 -34
  27. package/components/GridCell.astro +28 -32
  28. package/components/Heading.astro +24 -24
  29. package/components/Icon.astro +29 -29
  30. package/components/Image.astro +100 -100
  31. package/components/Image.md +14 -14
  32. package/components/Link.astro +89 -99
  33. package/components/Main.astro +17 -17
  34. package/components/Meta.astro +65 -65
  35. package/components/Popover.astro +189 -189
  36. package/components/RichTextView.astro +28 -28
  37. package/components/Section.astro +26 -44
  38. package/components/TabButton.astro +32 -16
  39. package/components/TabPanel.astro +20 -19
  40. package/components/Tabs.astro +220 -147
  41. package/components/Video.astro +6 -4
  42. package/components/YearsSince.astro +20 -20
  43. package/components//344/270/211/345/261/202/346/250/241/345/236/213.md +5 -5
  44. package/components//344/270/273/351/242/230Token.md +198 -198
  45. package/components//345/216/237/345/255/220/345/206/273/347/273/223/346/270/205/345/215/225.md +270 -260
  46. package/components//347/211/251/346/226/231/346/270/205/345/215/225.md +599 -567
  47. package/index.ts +5 -5
  48. package/package.json +7 -7
  49. package/components/BaseBlock.astro +0 -34
  50. package/components/Motion.astro +0 -77
  51. package/components/Stack.astro +0 -31
@@ -1,114 +1,140 @@
1
- ---
2
- import type { BackgroundConfig, Locals } from "@rxdrag/website-lib-core";
3
- import {
4
- BackgroundVideoPlayer,
5
- BackgroundHlsVideoPlayer,
6
- Entify,
7
- } from "@rxdrag/website-lib-core";
8
- import Image from "./Image.astro";
9
-
10
- export interface Props {
11
- background: BackgroundConfig;
12
- index?: number;
13
- defaultClass?: string;
14
- }
15
-
16
- const { env, imageSizes } = Astro.locals as Locals;
17
-
18
- const {
19
- background,
20
- defaultClass = "absolute top-0 left-0 w-full h-full object-cover",
21
- } = Astro.props;
22
-
23
- // 安全地提取 mediaRef posterRef(只有部分背景类型有这些属性)
24
- const mediaRef = background.type === "video" ? background.mediaRef : undefined;
25
-
26
- const rx = Entify.getInstance(env, imageSizes);
27
-
28
- // 获取媒体数据
29
- const media = rx ? await rx.getMedia(mediaRef) : undefined;
30
-
31
- // 构建 className(同时支持 class 和 className)
32
- const className = [defaultClass, background.class].filter(Boolean).join(" ");
33
-
34
- // 预计算视频相关数据
35
- const videoUrl =
36
- background.type === "video" ? media?.file?.original : undefined;
37
-
38
- // 处理视频封面
39
- let posterUrl: string | undefined;
40
- if (background.type === "video" && background.poster) {
41
- if (typeof background.poster === "string") {
42
- posterUrl = background.poster;
43
- } else if (typeof background.poster === "object") {
44
- const poster = background.poster as Partial<ImageMetadata>;
45
- if (
46
- typeof poster.src === "string" &&
47
- typeof poster.width === "number" &&
48
- typeof poster.height === "number"
49
- ) {
50
- posterUrl = poster.src;
51
- } else {
52
- console.log(
53
- "[Background] invalid video poster, expect ImageMetadata:",
54
- background.poster,
55
- );
56
- }
57
- }
58
- }
59
-
60
- const isHls =
61
- background.type === "video" &&
62
- (media?.storageType === "cloudflare_stream" ||
63
- videoUrl?.endsWith(".m3u8") ||
64
- videoUrl?.includes("cloudflarestream.com"));
65
-
66
- // 预计算 Spline URL
67
- const splineUrl = background.type === "spline" ? background.url : undefined;
68
- ---
69
-
70
- {background.type === "color" && <div class={className} />}
71
-
72
- {background.type === "blur" && <div class={className} />}
73
-
74
- {
75
- background.type === "image" && background.src && (
76
- <Image
77
- class={className}
78
- src={background.src}
79
- layout={background.layout || "full-width"}
80
- alt=""
81
- />
82
- )
83
- }
84
-
85
- {
86
- background.type === "svg" && background.code && (
87
- <div class={className} set:html={background.code} />
88
- )
89
- }
90
-
91
- {
92
- background.type === "video" &&
93
- (isHls ? (
94
- <BackgroundHlsVideoPlayer
95
- className={className}
96
- src={videoUrl}
97
- poster={posterUrl}
98
- client:load
99
- />
100
- ) : (
101
- <BackgroundVideoPlayer
102
- className={className}
103
- src={videoUrl}
104
- poster={posterUrl}
105
- client:load
106
- />
107
- ))
108
- }
109
-
110
- {
111
- background.type === "spline" && (
112
- <iframe class={className} src={splineUrl} title="Spline 3D Scene" />
113
- )
114
- }
1
+ ---
2
+ import type { BackgroundConfig, Locals } from "@rxdrag/website-lib-core";
3
+ import {
4
+ BackgroundVideoPlayer,
5
+ BackgroundHlsVideoPlayer,
6
+ Entify,
7
+ } from "@rxdrag/website-lib-core";
8
+ import Image from "./Image.astro";
9
+ import GlassBorder from "./GlassBorder.astro";
10
+ import GradientBorder from "./GradientBorder.astro";
11
+ import GlassRefraction from "./GlassRefraction.astro";
12
+
13
+ export interface Props {
14
+ background: BackgroundConfig;
15
+ index?: number;
16
+ }
17
+
18
+ const { env, imageSizes } = Astro.locals as Locals;
19
+
20
+ const { background } = Astro.props;
21
+
22
+ const baseFill = "absolute inset-0 w-full h-full";
23
+ const defaultFill = `${baseFill} object-cover`;
24
+ const rawClass = (background.class || "").trim();
25
+ const hasLayoutOverride = /(?:^|\s)(?:inset(?:-[xy])?-|top-|bottom-|left-|right-|w-|h-)/.test(
26
+ rawClass,
27
+ );
28
+ const className = rawClass
29
+ ? `${hasLayoutOverride ? "absolute" : defaultFill} ${rawClass}`
30
+ : defaultFill;
31
+
32
+ // 安全地提取 mediaRef posterRef(只有部分背景类型有这些属性)
33
+ const mediaRef = background.type === "video" ? background.mediaRef : undefined;
34
+
35
+ const rx = Entify.getInstance(env, imageSizes);
36
+
37
+ // 获取媒体数据
38
+ const media = rx ? await rx.getMedia(mediaRef) : undefined;
39
+
40
+ // 预计算视频相关数据
41
+ const videoUrl =
42
+ background.type === "video" ? media?.file?.original : undefined;
43
+
44
+ // 处理视频封面
45
+ let posterUrl: string | undefined;
46
+ if (background.type === "video" && background.poster) {
47
+ if (typeof background.poster === "string") {
48
+ posterUrl = background.poster;
49
+ } else if (typeof background.poster === "object") {
50
+ const poster = background.poster as Partial<ImageMetadata>;
51
+ if (
52
+ typeof poster.src === "string" &&
53
+ typeof poster.width === "number" &&
54
+ typeof poster.height === "number"
55
+ ) {
56
+ posterUrl = poster.src;
57
+ } else {
58
+ console.log(
59
+ "[Background] invalid video poster, expect ImageMetadata:",
60
+ background.poster,
61
+ );
62
+ }
63
+ }
64
+ }
65
+
66
+ const isHls =
67
+ background.type === "video" &&
68
+ (media?.storageType === "cloudflare_stream" ||
69
+ videoUrl?.endsWith(".m3u8") ||
70
+ videoUrl?.includes("cloudflarestream.com"));
71
+
72
+ // 预计算 Spline URL
73
+ const splineUrl = background.type === "spline" ? background.url : undefined;
74
+
75
+ ---
76
+
77
+ {background.type === "color" && <div class={className} />}
78
+
79
+ {background.type === "blur" && <div class={className} />}
80
+
81
+ {
82
+ background.type === "glass" && (
83
+ <GlassRefraction class={className} />
84
+ )
85
+ }
86
+
87
+ {
88
+ background.type === "glass-border" && (
89
+ <GlassBorder {...background} class={className} />
90
+ )
91
+ }
92
+
93
+ {
94
+ background.type === "gradient-border" && (
95
+ <GradientBorder {...background} class={className} />
96
+ )
97
+ }
98
+
99
+ {
100
+ background.type === "image" && background.src && (
101
+ <Image
102
+ class={className}
103
+ src={background.src}
104
+ layout={background.layout || "full-width"}
105
+ alt=""
106
+ />
107
+ )
108
+ }
109
+
110
+ {
111
+ background.type === "svg" && background.code && (
112
+ <div class={className} set:html={background.code} />
113
+ )
114
+ }
115
+
116
+ {
117
+ background.type === "video" &&
118
+ (isHls ? (
119
+ <BackgroundHlsVideoPlayer
120
+ className={className}
121
+ src={videoUrl}
122
+ poster={posterUrl}
123
+ client:load
124
+ />
125
+ ) : (
126
+ <BackgroundVideoPlayer
127
+ className={className}
128
+ src={videoUrl}
129
+ poster={posterUrl}
130
+ client:load
131
+ />
132
+ ))
133
+ }
134
+
135
+ {
136
+ background.type === "spline" && (
137
+ <iframe class={className} src={splineUrl} title="Spline 3D Scene" />
138
+ )
139
+ }
140
+
@@ -1,26 +1,20 @@
1
- ---
2
- import type { BackgroundConfig } from "@rxdrag/website-lib-core";
3
- import Background from "./Background.astro";
4
-
5
- interface Props {
6
- backgrounds?: BackgroundConfig[];
7
- }
8
-
9
- const { backgrounds } = Astro.props;
10
-
11
- const defaultClass =
12
- "absolute w-full h-full inset-0 object-cover";
13
- ---
14
-
15
- <Fragment>
16
- {
17
- backgrounds?.length
18
- ? backgrounds.map((background) => (
19
- <Background
20
- background={background}
21
- defaultClass={defaultClass}
22
- />
23
- ))
24
- : null
25
- }
26
- </Fragment>
1
+ ---
2
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
3
+ import Background from "./Background.astro";
4
+
5
+ interface Props {
6
+ backgrounds?: BackgroundConfig[];
7
+ }
8
+
9
+ const { backgrounds } = Astro.props;
10
+ ---
11
+
12
+ {
13
+ backgrounds?.length ? (
14
+ <div class="absolute inset-0 w-full h-full -z-10 pointer-events-none" data-bg-group>
15
+ {backgrounds.map((background) => (
16
+ <Background background={background} />
17
+ ))}
18
+ </div>
19
+ ) : null
20
+ }
@@ -1,39 +1,24 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
- import BackgroundGroup from "./BackgroundGroup.astro";
5
- import Container from "./Container.astro";
6
-
7
- /**
8
- * 区块
9
- */
10
-
11
- interface Props extends HTMLAttributes<'footer'> {
12
- className?: string;
13
- containerClassName?: string;
14
- backgrounds?: BackgroundConfig[];
15
- disableContainer?: boolean;
16
- }
17
-
18
- const {
19
- className,
20
- containerClassName,
21
- backgrounds,
22
- disableContainer,
23
- class: originalClass,
24
- ...rest
25
- } = Astro.props;
26
- ---
27
-
28
- <footer class:list={["footer-block relative", className, originalClass]} {...rest}>
29
- <BackgroundGroup backgrounds={backgrounds} />
30
- {
31
- disableContainer ? (
32
- <slot />
33
- ) : (
34
- <Container class:list={["w-full h-full", containerClassName]}>
35
- <slot />
36
- </Container>
37
- )
38
- }
39
- </footer>
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
+ import BackgroundGroup from "./BackgroundGroup.astro";
5
+
6
+ /**
7
+ * 区块
8
+ */
9
+
10
+ interface Props extends HTMLAttributes<"footer"> {
11
+ className?: string;
12
+ backgrounds?: BackgroundConfig[];
13
+ }
14
+
15
+ const { className, backgrounds, class: originalClass, ...rest } = Astro.props;
16
+ ---
17
+
18
+ <footer
19
+ class:list={["footer-block relative", className, originalClass]}
20
+ {...rest}
21
+ >
22
+ <BackgroundGroup backgrounds={backgrounds} />
23
+ <slot />
24
+ </footer>
@@ -1,25 +1,22 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
- import BackgroundGroup from "./BackgroundGroup.astro";
5
- import Container from "./Container.astro";
6
-
7
- /**
8
- * 区块
9
- */
10
-
11
- interface Props extends HTMLAttributes<"header"> {
12
- className?: string;
13
- containerClassName?: string;
14
- backgrounds?: BackgroundConfig[];
15
- //动效
16
- disableContainer?: boolean;
17
- }
18
-
19
- const { className, backgrounds, class: originalClass, ...rest } = Astro.props;
20
- ---
21
-
22
- <header class:list={["header", className, originalClass]} {...rest}>
23
- <BackgroundGroup backgrounds={backgrounds} />
24
- <slot />
25
- </header>
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
+ import BackgroundGroup from "./BackgroundGroup.astro";
5
+
6
+ /**
7
+ * 区块
8
+ */
9
+
10
+ interface Props extends HTMLAttributes<"header"> {
11
+ class?: string;
12
+ className?: string;
13
+ backgrounds?: BackgroundConfig[];
14
+ }
15
+
16
+ const { className, backgrounds, class: originalClass, ...rest } = Astro.props;
17
+ ---
18
+
19
+ <header class:list={["header", className, originalClass]} {...rest}>
20
+ <BackgroundGroup backgrounds={backgrounds} />
21
+ <slot />
22
+ </header>
@@ -1,22 +1,20 @@
1
- ---
2
- import type { BackgroundConfig } from "@rxdrag/website-lib-core";
3
- import BaseBlock from "./BaseBlock.astro";
4
-
5
- interface Props {
6
- class?: string;
7
- className?: string;
8
- backgrounds?: BackgroundConfig[];
9
- }
10
-
11
- const { className, class: originalClass, backgrounds, ...rest } = Astro.props;
12
- ---
13
-
14
- <BaseBlock
15
- baseClass={["w-full", "h-full", "flex", "flex-col"]}
16
- className={className}
17
- class={originalClass}
18
- backgrounds={backgrounds}
19
- {...rest}
20
- >
21
- <slot />
22
- </BaseBlock>
1
+ ---
2
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
3
+ import Frame from "./Frame.astro";
4
+
5
+ interface Props {
6
+ class?: string;
7
+ className?: string;
8
+ backgrounds?: BackgroundConfig[];
9
+ }
10
+
11
+ const { className, class: originalClass, backgrounds, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <Frame
15
+ class:list={["flex relative", className, originalClass]}
16
+ backgrounds={backgrounds}
17
+ {...rest}
18
+ >
19
+ <slot />
20
+ </Frame>
@@ -0,0 +1,80 @@
1
+ ---
2
+ import Link from "@rxdrag/website-lib/components/Link.astro";
3
+ import type { LinkProps } from "@rxdrag/website-lib-core";
4
+ import type { FrameProps } from "@rxdrag/website-lib-core";
5
+ import BackgroundGroup from "./BackgroundGroup.astro";
6
+
7
+ interface Props extends FrameProps {
8
+ class?: string;
9
+ className?: string;
10
+ link?: LinkProps;
11
+ disabled?: boolean;
12
+ loading?: boolean;
13
+ fullWidth?: boolean;
14
+ size?: "sm" | "md" | "lg" | "none";
15
+ type?: "button" | "submit" | "reset";
16
+ }
17
+
18
+ const {
19
+ class: className,
20
+ className: className2,
21
+ link,
22
+ disabled,
23
+ loading = false,
24
+ fullWidth = false,
25
+ type = "button",
26
+ backgrounds,
27
+ size = "md",
28
+ ...rest
29
+ } = Astro.props;
30
+
31
+ const isDisabled = disabled || loading;
32
+ const isLink = !!(link?.type || link?.to);
33
+
34
+ const sizeClass: Record<"sm" | "md" | "lg", string> = {
35
+ sm: "btn-sm",
36
+ md: "btn-md",
37
+ lg: "btn-lg",
38
+ };
39
+
40
+ const sizeClassName = size === "none" ? undefined : sizeClass[size];
41
+
42
+ const composedClass = [
43
+ fullWidth && "w-full",
44
+ isDisabled && "opacity-60 cursor-not-allowed",
45
+ loading && "pointer-events-none",
46
+ className,
47
+ className2,
48
+ backgrounds ? "relative" : undefined,
49
+ sizeClassName,
50
+ ];
51
+
52
+ ---
53
+
54
+ {
55
+ isLink ? (
56
+ <Link
57
+ type={link!.type}
58
+ to={link!.to}
59
+ href={link!.href}
60
+ options={link!.options}
61
+ activeWhen={link!.activeWhen}
62
+ aria-disabled={isDisabled ? "true" : undefined}
63
+ class:list={composedClass}
64
+ backgrounds={backgrounds}
65
+ {...rest}
66
+ >
67
+ <slot />
68
+ </Link>
69
+ ) : (
70
+ <button
71
+ type={type}
72
+ disabled={isDisabled}
73
+ class:list={composedClass}
74
+ {...rest}
75
+ >
76
+ <BackgroundGroup backgrounds={backgrounds} />
77
+ <slot />
78
+ </button>
79
+ )
80
+ }