@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,76 +1,97 @@
1
- ---
2
- export interface ClassNames {
3
- /** bullet 按钮 class */
4
- bullet?: string;
5
- /** 激活态 bullet 追加的 class */
6
- bulletActive?: string;
7
- }
8
-
9
- export interface Props {
10
- class?: string;
11
- /** 分页类型 */
12
- type?: "bullets" | "fraction" | "progressbar";
13
- /** 主体形式 */
14
- variant?: "dots" | "numbers" | "lines";
15
- /** 样式类名配置 */
16
- classNames?: ClassNames;
17
- }
18
-
19
- const variantDefaults: Record<string, ClassNames> = {
20
- dots: {
21
- bullet: "w-2.5 h-2.5 rounded-full bg-white/40 hover:bg-white/60",
22
- bulletActive: "bg-white",
23
- },
24
- lines: {
25
- bullet: "w-6 h-1 rounded-sm bg-white/40 hover:bg-white/60",
26
- bulletActive: "w-8 bg-white",
27
- },
28
- numbers: {
29
- bullet: "min-w-8 h-8 px-2 rounded-full bg-white/10 text-white/50 text-xs font-medium tracking-wider hover:bg-white/20",
30
- bulletActive: "bg-white/10 text-white",
31
- },
32
- };
33
-
34
- const {
35
- class: className,
36
- type = "bullets",
37
- variant = "dots",
38
- classNames = {},
39
- } = Astro.props;
40
-
41
- const defaults = variantDefaults[variant] || variantDefaults.dots;
42
- const mergedClassNames = {
43
- bullet: classNames.bullet || defaults.bullet,
44
- bulletActive: classNames.bulletActive || defaults.bulletActive,
45
- };
46
- ---
47
-
48
- <div
49
- class:list={["carousel-pagination-wrapper flex items-center gap-2 pointer-events-auto", className]}
50
- data-carousel-pagination
51
- data-bullet-class={mergedClassNames.bullet}
52
- data-bullet-active-class={mergedClassNames.bulletActive}
53
- >
54
- {type === "bullets" && (
55
- <div class="carousel-pagination flex items-center gap-2" role="tablist" aria-label="Slide navigation"></div>
56
- )}
57
-
58
- {type === "fraction" && (
59
- <div class="carousel-fraction flex items-center gap-1 text-sm font-medium text-white">
60
- <span class="carousel-fraction-current">1</span>
61
- <span class="carousel-fraction-separator opacity-50">/</span>
62
- <span class="carousel-fraction-total">1</span>
63
- </div>
64
- )}
65
-
66
- {type === "progressbar" && (
67
- <div class="carousel-progressbar w-[100px] h-1 bg-white/20 rounded overflow-hidden">
68
- <div class="carousel-progress-bar h-full bg-white transition-[width] duration-300 w-0"></div>
69
- </div>
70
- )}
71
- </div>
72
-
73
- <style>
74
- .carousel-pagination { counter-reset: carouselPage; }
75
- .carousel-pagination :global(.carousel-bullet) { counter-increment: carouselPage; }
76
- </style>
1
+ ---
2
+ export interface ClassNames {
3
+ /** bullet 按钮 class */
4
+ bullet?: string;
5
+ /** 激活态 bullet 追加的 class */
6
+ bulletActive?: string;
7
+ }
8
+
9
+ export interface Props {
10
+ class?: string;
11
+ /** 分页类型 */
12
+ type?: "bullets" | "fraction" | "progressbar";
13
+ /** 主体形式 */
14
+ variant?: "dots" | "numbers" | "lines";
15
+ /** bullets 数量(提供则 SSR 直接渲染,避免客户端初始化延时) */
16
+ count?: number;
17
+ /** 样式类名配置 */
18
+ classNames?: ClassNames;
19
+ }
20
+
21
+ const variantDefaults: Record<string, ClassNames> = {
22
+ dots: {
23
+ bullet: "w-2.5 h-2.5 rounded-full bg-white/40 hover:bg-white/60",
24
+ bulletActive: "bg-white",
25
+ },
26
+ lines: {
27
+ bullet: "w-6 h-1 rounded-sm bg-white/40 hover:bg-white/60",
28
+ bulletActive: "w-8 bg-white",
29
+ },
30
+ numbers: {
31
+ bullet: "min-w-8 h-8 px-2 rounded-full bg-white/10 text-white/50 text-xs font-medium tracking-wider hover:bg-white/20",
32
+ bulletActive: "bg-white/10 text-white",
33
+ },
34
+ };
35
+
36
+ const {
37
+ class: className,
38
+ type = "bullets",
39
+ variant = "dots",
40
+ count,
41
+ classNames = {},
42
+ } = Astro.props;
43
+
44
+ const defaults = variantDefaults[variant] || variantDefaults.dots;
45
+ const mergedClassNames = {
46
+ bullet: classNames.bullet || defaults.bullet,
47
+ bulletActive: classNames.bulletActive || defaults.bulletActive,
48
+ };
49
+ ---
50
+
51
+ <div
52
+ class:list={["carousel-pagination-wrapper flex items-center gap-2 pointer-events-auto", className]}
53
+ data-carousel-pagination
54
+ data-bullet-class={mergedClassNames.bullet}
55
+ data-bullet-active-class={mergedClassNames.bulletActive}
56
+ >
57
+ {type === "bullets" && (
58
+ <div class="carousel-pagination flex items-center gap-2" role="tablist" aria-label="Slide navigation">
59
+ {typeof count === "number" && count > 0 && (
60
+ Array.from({ length: count }, (_, i) => (
61
+ <button
62
+ class:list={[
63
+ "carousel-bullet",
64
+ mergedClassNames.bullet,
65
+ i === 0 && "carousel-bullet-active",
66
+ i === 0 && mergedClassNames.bulletActive,
67
+ ]}
68
+ type="button"
69
+ role="tab"
70
+ aria-current={i === 0 ? "true" : "false"}
71
+ aria-selected={i === 0 ? "true" : "false"}
72
+ aria-label={`Go to slide ${i + 1}`}
73
+ />
74
+ ))
75
+ )}
76
+ </div>
77
+ )}
78
+
79
+ {type === "fraction" && (
80
+ <div class="carousel-fraction flex items-center gap-1 text-sm font-medium text-white">
81
+ <span class="carousel-fraction-current">1</span>
82
+ <span class="carousel-fraction-separator opacity-50">/</span>
83
+ <span class="carousel-fraction-total">1</span>
84
+ </div>
85
+ )}
86
+
87
+ {type === "progressbar" && (
88
+ <div class="carousel-progressbar w-[100px] h-1 bg-white/20 rounded overflow-hidden">
89
+ <div class="carousel-progress-bar h-full bg-white transition-[width] duration-300 w-0"></div>
90
+ </div>
91
+ )}
92
+ </div>
93
+
94
+ <style>
95
+ .carousel-pagination { counter-reset: carouselPage; }
96
+ .carousel-pagination :global(.carousel-bullet) { counter-increment: carouselPage; }
97
+ </style>
@@ -1,15 +1,12 @@
1
1
  ---
2
2
  import type { BackgroundConfig } from "@rxdrag/website-lib-core";
3
3
  import Box from "@rxdrag/website-lib/components/Box.astro";
4
- import Container from "@rxdrag/website-lib/components/Container.astro";
5
4
 
6
5
  export interface Props {
7
6
  class?: string;
8
7
  className?: string;
9
8
  /** 背景配置 */
10
9
  backgrounds?: BackgroundConfig[];
11
- /** 是否使用 Container 包裹内容 */
12
- useContainer?: boolean;
13
10
  /** 内容垂直对齐:start | center | end */
14
11
  align?: "start" | "center" | "end";
15
12
  /** 内容水平对齐:start | center | end */
@@ -20,7 +17,6 @@ const {
20
17
  class: className,
21
18
  className: className2,
22
19
  backgrounds,
23
- useContainer = true,
24
20
  align = "center",
25
21
  justify = "start",
26
22
  } = Astro.props;
@@ -41,23 +37,21 @@ const justifyClasses = {
41
37
  <div class="carousel-slide h-full" data-carousel-slide>
42
38
  <Box
43
39
  class:list={[
44
- "w-full h-full flex flex-col",
40
+ "w-full h-full flex flex-col relative overflow-hidden",
45
41
  justifyClasses[justify],
46
42
  alignClasses[align],
47
43
  ]}
48
44
  backgrounds={backgrounds}
49
45
  >
50
- {
51
- useContainer ? (
52
- <Container class:list={["h-full w-full slider-container relative overflow-hidden", className, className2]}>
53
- <slot />
54
- </Container>
55
- ) : (
56
- <div class:list={["w-full h-full slider-div relative overflow-hidden", className, className2]}>
57
- <slot />
58
- </div>
59
- )
60
- }
46
+ <div
47
+ class:list={[
48
+ "w-full h-full relative overflow-hidden",
49
+ className,
50
+ className2,
51
+ ]}
52
+ >
53
+ <slot />
54
+ </div>
61
55
  </Box>
62
56
  </div>
63
57
 
@@ -1,125 +1,125 @@
1
- ---
2
- interface Props {
3
- class?: string;
4
- triggerClass?: string;
5
- panelClass?: string;
6
- initialOpen?: boolean;
7
- }
8
-
9
- const {
10
- class: className,
11
- triggerClass,
12
- panelClass,
13
- initialOpen = false,
14
- } = Astro.props;
15
-
16
- const collapseId = crypto.randomUUID();
17
- const panelId = `collapse-panel-${collapseId}`;
18
- const rootId = `collapse-${collapseId}`;
19
- ---
20
-
21
- <div
22
- class:list={["n-collapse", className]}
23
- id={rootId}
24
- data-open={initialOpen ? "true" : "false"}
25
- >
26
- <button
27
- type="button"
28
- class:list={["n-collapse__trigger", triggerClass]}
29
- aria-expanded={initialOpen ? "true" : "false"}
30
- aria-controls={panelId}
31
- >
32
- <slot name="trigger" />
33
- </button>
34
-
35
- <div
36
- id={panelId}
37
- class:list={["n-collapse__panel", panelClass]}
38
- style={`height: ${initialOpen ? "auto" : "0px"};`}
39
- aria-hidden={initialOpen ? "false" : "true"}
40
- >
41
- <slot />
42
- </div>
43
- </div>
44
-
45
- <style>
46
- .n-collapse__panel {
47
- transition: height 0.35s ease;
48
- }
49
-
50
- .n-collapse__indicator {
51
- transition: transform 0.25s ease;
52
- }
53
-
54
- .n-collapse[data-open="true"] .n-collapse__indicator {
55
- transform: rotate(180deg);
56
- }
57
- </style>
58
-
59
- <script is:inline>
60
- // This component can appear multiple times per page.
61
- // We install a single global initializer so it keeps working after Astro SPA navigation.
62
- if (!window.__nCollapse) {
63
- window.__nCollapse = {
64
- initCollapseRoot(root) {
65
- if (!root || root.dataset.nCollapseBound === "true") return;
66
- root.dataset.nCollapseBound = "true";
67
-
68
- const trigger = root.querySelector(":scope > .n-collapse__trigger");
69
- const panel = root.querySelector(":scope > .n-collapse__panel");
70
- if (!trigger || !panel) {
71
- console.log("Collapse: trigger/panel not found", root);
72
- return;
73
- }
74
-
75
- let open = root.dataset.open === "true";
76
- if (open) {
77
- panel.style.height = "auto";
78
- trigger.setAttribute("aria-expanded", "true");
79
- panel.setAttribute("aria-hidden", "false");
80
- }
81
-
82
- const setOpen = (next) => {
83
- open = next;
84
- root.dataset.open = open ? "true" : "false";
85
- trigger.setAttribute("aria-expanded", open ? "true" : "false");
86
- panel.setAttribute("aria-hidden", open ? "false" : "true");
87
-
88
- if (open) {
89
- panel.style.height = "auto";
90
- const h = panel.scrollHeight;
91
- panel.style.height = "0px";
92
- panel.offsetHeight;
93
- panel.style.height = h + "px";
94
- } else {
95
- const h = panel.scrollHeight;
96
- panel.style.height = h + "px";
97
- panel.offsetHeight;
98
- panel.style.height = "0px";
99
- }
100
- };
101
-
102
- const onTransitionEnd = (e) => {
103
- if (e.target !== panel || e.propertyName !== "height") return;
104
- if (open) panel.style.height = "auto";
105
- };
106
-
107
- trigger.addEventListener("click", () => setOpen(!open));
108
- panel.addEventListener("transitionend", onTransitionEnd);
109
- },
110
- initAll() {
111
- document.querySelectorAll(".n-collapse").forEach((el) => window.__nCollapse.initCollapseRoot(el));
112
- },
113
- listenersBound: false,
114
- };
115
- }
116
-
117
- // Bind listeners once to support ClientRouter/ViewTransitions.
118
- if (!window.__nCollapse.listenersBound) {
119
- window.__nCollapse.listenersBound = true;
120
- document.addEventListener("astro:page-load", () => window.__nCollapse.initAll());
121
- document.addEventListener("astro:after-swap", () => window.__nCollapse.initAll());
122
- }
123
-
124
- window.__nCollapse.initAll();
125
- </script>
1
+ ---
2
+ interface Props {
3
+ class?: string;
4
+ triggerClass?: string;
5
+ panelClass?: string;
6
+ initialOpen?: boolean;
7
+ }
8
+
9
+ const {
10
+ class: className,
11
+ triggerClass,
12
+ panelClass,
13
+ initialOpen = false,
14
+ } = Astro.props;
15
+
16
+ const collapseId = crypto.randomUUID();
17
+ const panelId = `collapse-panel-${collapseId}`;
18
+ const rootId = `collapse-${collapseId}`;
19
+ ---
20
+
21
+ <div
22
+ class:list={["n-collapse", className]}
23
+ id={rootId}
24
+ data-open={initialOpen ? "true" : "false"}
25
+ >
26
+ <button
27
+ type="button"
28
+ class:list={["n-collapse__trigger", triggerClass]}
29
+ aria-expanded={initialOpen ? "true" : "false"}
30
+ aria-controls={panelId}
31
+ >
32
+ <slot name="trigger" />
33
+ </button>
34
+
35
+ <div
36
+ id={panelId}
37
+ class:list={["n-collapse__panel", panelClass]}
38
+ style={`height: ${initialOpen ? "auto" : "0px"};`}
39
+ aria-hidden={initialOpen ? "false" : "true"}
40
+ >
41
+ <slot />
42
+ </div>
43
+ </div>
44
+
45
+ <style>
46
+ .n-collapse__panel {
47
+ transition: height 0.35s ease;
48
+ }
49
+
50
+ .n-collapse__indicator {
51
+ transition: transform 0.25s ease;
52
+ }
53
+
54
+ .n-collapse[data-open="true"] .n-collapse__indicator {
55
+ transform: rotate(180deg);
56
+ }
57
+ </style>
58
+
59
+ <script is:inline>
60
+ // This component can appear multiple times per page.
61
+ // We install a single global initializer so it keeps working after Astro SPA navigation.
62
+ if (!window.__nCollapse) {
63
+ window.__nCollapse = {
64
+ initCollapseRoot(root) {
65
+ if (!root || root.dataset.nCollapseBound === "true") return;
66
+ root.dataset.nCollapseBound = "true";
67
+
68
+ const trigger = root.querySelector(":scope > .n-collapse__trigger");
69
+ const panel = root.querySelector(":scope > .n-collapse__panel");
70
+ if (!trigger || !panel) {
71
+ console.log("Collapse: trigger/panel not found", root);
72
+ return;
73
+ }
74
+
75
+ let open = root.dataset.open === "true";
76
+ if (open) {
77
+ panel.style.height = "auto";
78
+ trigger.setAttribute("aria-expanded", "true");
79
+ panel.setAttribute("aria-hidden", "false");
80
+ }
81
+
82
+ const setOpen = (next) => {
83
+ open = next;
84
+ root.dataset.open = open ? "true" : "false";
85
+ trigger.setAttribute("aria-expanded", open ? "true" : "false");
86
+ panel.setAttribute("aria-hidden", open ? "false" : "true");
87
+
88
+ if (open) {
89
+ panel.style.height = "auto";
90
+ const h = panel.scrollHeight;
91
+ panel.style.height = "0px";
92
+ panel.offsetHeight;
93
+ panel.style.height = h + "px";
94
+ } else {
95
+ const h = panel.scrollHeight;
96
+ panel.style.height = h + "px";
97
+ panel.offsetHeight;
98
+ panel.style.height = "0px";
99
+ }
100
+ };
101
+
102
+ const onTransitionEnd = (e) => {
103
+ if (e.target !== panel || e.propertyName !== "height") return;
104
+ if (open) panel.style.height = "auto";
105
+ };
106
+
107
+ trigger.addEventListener("click", () => setOpen(!open));
108
+ panel.addEventListener("transitionend", onTransitionEnd);
109
+ },
110
+ initAll() {
111
+ document.querySelectorAll(".n-collapse").forEach((el) => window.__nCollapse.initCollapseRoot(el));
112
+ },
113
+ listenersBound: false,
114
+ };
115
+ }
116
+
117
+ // Bind listeners once to support ClientRouter/ViewTransitions.
118
+ if (!window.__nCollapse.listenersBound) {
119
+ window.__nCollapse.listenersBound = true;
120
+ document.addEventListener("astro:page-load", () => window.__nCollapse.initAll());
121
+ document.addEventListener("astro:after-swap", () => window.__nCollapse.initAll());
122
+ }
123
+
124
+ window.__nCollapse.initAll();
125
+ </script>
@@ -1,20 +1,20 @@
1
- ---
2
- interface Props {
3
- class?: string;
4
- }
5
-
6
- const { class: className } = Astro.props;
7
- ---
8
-
9
- <span class:list={["n-collapse__indicator", "h-5", "w-5", "flex-none", "text-foreground", className]} aria-hidden="true">
10
- <svg
11
- aria-hidden="true"
12
- fill="currentColor"
13
- focusable="false"
14
- height="1.25rem"
15
- viewBox="0 0 24 24"
16
- width="1.25rem"
17
- >
18
- <path d="M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"></path>
19
- </svg>
20
- </span>
1
+ ---
2
+ interface Props {
3
+ class?: string;
4
+ }
5
+
6
+ const { class: className } = Astro.props;
7
+ ---
8
+
9
+ <span class:list={["n-collapse__indicator", "h-5", "w-5", "flex-none", "text-foreground", className]} aria-hidden="true">
10
+ <svg
11
+ aria-hidden="true"
12
+ fill="currentColor"
13
+ focusable="false"
14
+ height="1.25rem"
15
+ viewBox="0 0 24 24"
16
+ width="1.25rem"
17
+ >
18
+ <path d="M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"></path>
19
+ </svg>
20
+ </span>
@@ -1,32 +1,27 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import BaseBlock from "./BaseBlock.astro";
4
- import type { BackgroundConfig } from "@rxdrag/website-lib-core";
5
- import BackgroundGroup from "./BackgroundGroup.astro";
6
-
7
- /**
8
- * 容器
9
- *
10
- * 规范:被冻结(Frozen)的设计器原子组件
11
- * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
12
- * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
13
- */
14
-
15
- interface Props extends HTMLAttributes<"div"> {
16
- //布局
17
- className?: string;
18
- backgrounds?: BackgroundConfig[];
19
- }
20
-
21
- const { className, class: classAttr, backgrounds, ...rest } = Astro.props;
22
- ---
23
-
24
- <BaseBlock
25
- baseClass="section-container"
26
- className={className}
27
- class={classAttr}
28
- {...rest}
29
- >
30
- <BackgroundGroup backgrounds={backgrounds} />
31
- <slot />
32
- </BaseBlock>
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import Frame from "./Frame.astro";
4
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
5
+ import BackgroundGroup from "./BackgroundGroup.astro";
6
+
7
+ /**
8
+ * 容器
9
+ *
10
+ * 规范:被冻结(Frozen)的设计器原子组件
11
+ * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
12
+ * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
13
+ */
14
+
15
+ interface Props extends HTMLAttributes<"div"> {
16
+ //布局
17
+ className?: string;
18
+ backgrounds?: BackgroundConfig[];
19
+ }
20
+
21
+ const { className, class: classAttr, backgrounds, ...rest } = Astro.props;
22
+ ---
23
+
24
+ <Frame class:list={["section-container w-full h-full", className, classAttr]} {...rest}>
25
+ <BackgroundGroup backgrounds={backgrounds} />
26
+ <slot />
27
+ </Frame>
@@ -0,0 +1,20 @@
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={["text-content", className, originalClass]}
16
+ backgrounds={backgrounds}
17
+ {...rest}
18
+ >
19
+ <slot />
20
+ </Frame>