@rxdrag/website-lib 0.0.152 → 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 -82
  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 +5 -5
  49. package/components/BaseBlock.astro +0 -34
  50. package/components/Motion.astro +0 -77
  51. package/components/Stack.astro +0 -31
@@ -1,32 +1,32 @@
1
- ---
2
- interface Props {
3
- dialogId: string;
4
- openableKey?: string;
5
- as?: string;
6
- callToAction?: string;
7
- class?: string;
8
- className?: string;
9
- }
10
-
11
- const {
12
- dialogId,
13
- openableKey,
14
- as: _as,
15
- callToAction,
16
- class: _class,
17
- className,
18
- ...rest
19
- } = Astro.props;
20
-
21
- const resolvedDialogId = dialogId || openableKey;
22
- ---
23
-
24
- <button
25
- type="button"
26
- data-modal-open={resolvedDialogId}
27
- data-call-to-action={callToAction}
28
- class:list={[className, _class]}
29
- {...rest}
30
- >
31
- <slot />
32
- </button>
1
+ ---
2
+ interface Props {
3
+ dialogId: string;
4
+ openableKey?: string;
5
+ as?: string;
6
+ callToAction?: string;
7
+ class?: string;
8
+ className?: string;
9
+ }
10
+
11
+ const {
12
+ dialogId,
13
+ openableKey,
14
+ as: _as,
15
+ callToAction,
16
+ class: _class,
17
+ className,
18
+ ...rest
19
+ } = Astro.props;
20
+
21
+ const resolvedDialogId = dialogId || openableKey;
22
+ ---
23
+
24
+ <button
25
+ type="button"
26
+ data-modal-open={resolvedDialogId}
27
+ data-call-to-action={callToAction}
28
+ class:list={[className, _class]}
29
+ {...rest}
30
+ >
31
+ <slot />
32
+ </button>
@@ -1,225 +1,240 @@
1
- ---
2
- import "aos/dist/aos.css";
3
- import { PageType, type PageMeta } from "@rxdrag/rxcms-models";
4
- import type { Locals } from "@rxdrag/website-lib-core";
5
- import Meta from "@rxdrag/website-lib/components/Meta.astro";
6
- import { Entify } from "@rxdrag/website-lib-core";
7
- import { ClientRouter } from "astro:transitions";
8
-
9
- const { env, imageSizes } = Astro.locals as Locals;
10
-
11
- const rx = Entify.getInstance(env, imageSizes);
12
-
13
- // 文档壳:只负责 <html>/<head>/<body> 结构,不包含 Header/Footer 等站点布局。
14
- interface Props {
15
- // html 的 lang 属性
16
- lang?: string;
17
- // SEO Meta(由上层 Layout/页面传入)
18
- meta?: PageMeta;
19
- // 页面标题(由 Meta 组件消费)
20
- title?: string;
21
- // 兼容 class / className 两种写法,最终合并到 body 上
22
- class?: string;
23
- className?: string;
24
- }
25
-
26
- const {
27
- lang = "en",
28
- meta,
29
- title,
30
- class: className = "scroll-smooth",
31
- className: className2,
32
- // 其余 props 透传到 body(例如 data-* 属性等)
33
- ...rest
34
- } = Astro.props;
35
-
36
- const bodyAttrs = {
37
- "data-aos-easing": "ease-out-cubic",
38
- "data-aos-duration": "800",
39
- "data-aos-delay": "0",
40
- "data-aos-offset": "50",
41
- "data-aos-once": "true",
42
- ...rest,
43
- };
44
-
45
- //TODO: 添加meta获取逻辑,有可能需要重构后端数据结构,现在看来,只有动态内容需要获取meta,其它页面可以传入
46
-
47
- let resolvedMeta: PageMeta | undefined = meta;
48
- let resolvedTitle: string | undefined = title;
49
-
50
- // 仅在未传入 meta/title 时,针对动态详情页兜底拉取
51
- if (!resolvedMeta || !resolvedTitle) {
52
- try {
53
- const pathname = Astro.url?.pathname || "";
54
- const slug =
55
- typeof Astro.params?.slug === "string" ? Astro.params.slug : undefined;
56
- const id =
57
- typeof Astro.params?.id === "string" ? Astro.params.id : undefined;
58
-
59
- if (slug && pathname.startsWith("/posts/categories/")) {
60
- const category = await rx.getPostCategoryBySlug(slug);
61
- const page = await rx.getPageByType(PageType.PostList);
62
- resolvedTitle = resolvedTitle ?? category?.name ?? "Blog";
63
- resolvedMeta = resolvedMeta ?? page?.meta;
64
- } else if (slug && pathname.startsWith("/products/categories/")) {
65
- const category = await rx.getProductCategoryBySlug(slug);
66
- const page = await rx.getPageByType(PageType.ProductList);
67
- resolvedTitle = resolvedTitle ?? category?.name ?? "Products";
68
- resolvedMeta = resolvedMeta ?? page?.meta;
69
- } else if (id && pathname.startsWith("/profiles/")) {
70
- const user = await rx.getOneUser(id);
71
- const page = await rx.getPageByType(PageType.Profile);
72
- resolvedTitle = resolvedTitle ?? user?.name ?? "Profile";
73
- resolvedMeta = resolvedMeta ?? page?.meta;
74
- } else if (slug && pathname.startsWith("/posts/")) {
75
- const post = await rx.getPostBySlug(slug, { width: 1200, height: 600 });
76
- resolvedTitle = resolvedTitle ?? post?.title;
77
- resolvedMeta = resolvedMeta ?? post?.meta;
78
- } else if (slug && pathname.startsWith("/products/")) {
79
- const product = await rx.getProductBySlug(slug, {
80
- width: 800,
81
- height: 800,
82
- });
83
- resolvedTitle = resolvedTitle ?? product?.title;
84
- resolvedMeta = resolvedMeta ?? product?.meta;
85
- }
86
- } catch (e) {
87
- console.log("[Document] resolve meta failed:", e);
88
- }
89
- }
90
- ---
91
-
92
- <!doctype html>
93
- <html lang={lang} class="aos-preload">
94
- <head>
95
- <meta charset="UTF-8" />
96
- <meta
97
- name="viewport"
98
- content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=0.5, user-scalable=yes"
99
- />
100
-
101
- <meta name="generator" content={Astro.generator} />
102
- <link rel="sitemap" href="/sitemap-index.xml" />
103
- <link rel="icon" type="image/png" href="/favicon.png" />
104
- <!-- 给上层 Layout/页面注入自定义 head 内容(预加载、脚本、样式等) -->
105
- <!-- 预连接 -->
106
- <link
107
- rel="preconnect"
108
- href="https://customer-amj1dt4tnge8w6ji.cloudflarestream.com"
109
- crossorigin
110
- />
111
- <script>
112
- const w = window as any;
113
- const state =
114
- w.__aos_state__ ||
115
- (w.__aos_state__ = { inited: false, loading: null, aos: null });
116
-
117
- const el = document.documentElement;
118
- const raf = () =>
119
- new Promise((resolve) =>
120
- requestAnimationFrame(() => resolve(undefined)),
121
- );
122
-
123
- const ensureAos = async () => {
124
- if (state.aos) return state.aos;
125
- if (!state.loading) {
126
- state.loading = import("aos").then((m) => {
127
- state.aos = m.default;
128
- return state.aos;
129
- });
130
- }
131
- return state.loading;
132
- };
133
-
134
- const bootOrRefresh = async () => {
135
- if (
136
- window.matchMedia &&
137
- window.matchMedia("(prefers-reduced-motion: reduce)").matches
138
- ) {
139
- el.classList.add("aos-ready");
140
- el.classList.remove("aos-preload");
141
- return;
142
- }
143
-
144
- if (!document.querySelector("[data-aos]")) {
145
- el.classList.add("aos-ready");
146
- el.classList.remove("aos-preload");
147
- return;
148
- }
149
-
150
- el.classList.add("aos-preload");
151
- el.classList.remove("aos-ready");
152
-
153
- const AOS = await ensureAos();
154
- if (!state.inited) {
155
- state.inited = true;
156
- AOS.init({
157
- duration: 800,
158
- easing: "ease-out-cubic",
159
- once: true,
160
- offset: 50,
161
- });
162
- }
163
-
164
- await raf();
165
- await raf();
166
- AOS.refresh();
167
-
168
- el.classList.add("aos-ready");
169
- el.classList.remove("aos-preload");
170
- };
171
-
172
- const boot = () => {
173
- bootOrRefresh();
174
- };
175
-
176
- if (document.readyState === "loading") {
177
- document.addEventListener("DOMContentLoaded", boot, { once: true });
178
- } else {
179
- boot();
180
- }
181
-
182
- document.addEventListener("astro:page-load", boot);
183
- document.addEventListener("astro:after-swap", boot);
184
- </script>
185
- <ClientRouter />
186
- <!-- Consent default (Google) -->
187
- <script is:inline>
188
- window.dataLayer = window.dataLayer || [];
189
- function gtag() {
190
- dataLayer.push(arguments);
191
- }
192
- gtag("js", new Date());
193
- gtag("consent", "default", {
194
- ad_storage: "denied",
195
- analytics_storage: "denied",
196
- });
197
- </script>
198
- <slot name="head" />
199
- <Meta title={resolvedTitle} content={resolvedMeta} />
200
- <style>
201
- html.aos-preload [data-aos] {
202
- opacity: 1 !important;
203
- transform: none !important;
204
- transition: none !important;
205
- }
206
- </style>
207
- </head>
208
- <!-- rest 会被展开到 body 上,方便上层控制 data-* 等属性 -->
209
- <body class:list={[className, className2]} {...bodyAttrs}>
210
- <slot />
211
- </body>
212
- </html>
213
-
214
- <style>
215
- html,
216
- body {
217
- margin: 0;
218
- width: 100%;
219
- height: 100%;
220
- }
221
-
222
- html {
223
- scroll-behavior: smooth;
224
- }
225
- </style>
1
+ ---
2
+ import "aos/dist/aos.css";
3
+ import { PageType, type PageMeta } from "@rxdrag/rxcms-models";
4
+ import type { Locals } from "@rxdrag/website-lib-core";
5
+ import Meta from "@rxdrag/website-lib/components/Meta.astro";
6
+ import { Entify } from "@rxdrag/website-lib-core";
7
+ import { ClientRouter } from "astro:transitions";
8
+
9
+ const { env, imageSizes } = Astro.locals as Locals;
10
+
11
+ const rx = Entify.getInstance(env, imageSizes);
12
+
13
+ // 文档壳:只负责 <html>/<head>/<body> 结构,不包含 Header/Footer 等站点布局。
14
+ interface Props {
15
+ // html 的 lang 属性
16
+ lang?: string;
17
+ // SEO Meta(由上层 Layout/页面传入)
18
+ meta?: PageMeta;
19
+ // 页面标题(由 Meta 组件消费)
20
+ title?: string;
21
+ // JSON-LD 结构化数据,支持单个或数组
22
+ jsonLd?: Record<string, unknown> | Record<string, unknown>[];
23
+ // 兼容 class / className 两种写法,最终合并到 body 上
24
+ class?: string;
25
+ className?: string;
26
+ }
27
+
28
+ const {
29
+ lang = "en",
30
+ meta,
31
+ title,
32
+ jsonLd,
33
+ class: className = "scroll-smooth",
34
+ className: className2,
35
+ // 其余 props 透传到 body(例如 data-* 属性等)
36
+ ...rest
37
+ } = Astro.props;
38
+
39
+ const jsonLdItems = jsonLd
40
+ ? Array.isArray(jsonLd) ? jsonLd : [jsonLd]
41
+ : [];
42
+
43
+ const bodyAttrs = {
44
+ "data-aos-easing": "ease-out-cubic",
45
+ "data-aos-duration": "800",
46
+ "data-aos-delay": "0",
47
+ "data-aos-offset": "50",
48
+ "data-aos-once": "true",
49
+ ...rest,
50
+ };
51
+
52
+ //TODO: 添加meta获取逻辑,有可能需要重构后端数据结构,现在看来,只有动态内容需要获取meta,其它页面可以传入
53
+
54
+ let resolvedMeta: PageMeta | undefined = meta;
55
+ let resolvedTitle: string | undefined = title;
56
+
57
+ // 仅在未传入 meta/title 时,针对动态详情页兜底拉取
58
+ if (!resolvedMeta || !resolvedTitle) {
59
+ try {
60
+ const pathname = Astro.url?.pathname || "";
61
+ const slug =
62
+ typeof Astro.params?.slug === "string" ? Astro.params.slug : undefined;
63
+ const id =
64
+ typeof Astro.params?.id === "string" ? Astro.params.id : undefined;
65
+
66
+ if (slug && pathname.startsWith("/posts/categories/")) {
67
+ const category = await rx.getPostCategoryBySlug(slug);
68
+ const page = await rx.getPageByType(PageType.PostList);
69
+ resolvedTitle = resolvedTitle ?? category?.name ?? "Blog";
70
+ resolvedMeta = resolvedMeta ?? page?.meta;
71
+ } else if (slug && pathname.startsWith("/products/categories/")) {
72
+ const category = await rx.getProductCategoryBySlug(slug);
73
+ const page = await rx.getPageByType(PageType.ProductList);
74
+ resolvedTitle = resolvedTitle ?? category?.name ?? "Products";
75
+ resolvedMeta = resolvedMeta ?? page?.meta;
76
+ } else if (id && pathname.startsWith("/profiles/")) {
77
+ const user = await rx.getOneUser(id);
78
+ const page = await rx.getPageByType(PageType.Profile);
79
+ resolvedTitle = resolvedTitle ?? user?.name ?? "Profile";
80
+ resolvedMeta = resolvedMeta ?? page?.meta;
81
+ } else if (slug && pathname.startsWith("/posts/")) {
82
+ const post = await rx.getPostBySlug(slug, { width: 1200, height: 600 });
83
+ resolvedTitle = resolvedTitle ?? post?.title;
84
+ resolvedMeta = resolvedMeta ?? post?.meta;
85
+ } else if (slug && pathname.startsWith("/products/")) {
86
+ const product = await rx.getProductBySlug(slug, {
87
+ width: 800,
88
+ height: 800,
89
+ });
90
+ resolvedTitle = resolvedTitle ?? product?.title;
91
+ resolvedMeta = resolvedMeta ?? product?.meta;
92
+ }
93
+ } catch (e) {
94
+ console.log("[Document] resolve meta failed:", e);
95
+ }
96
+ }
97
+ ---
98
+
99
+ <!doctype html>
100
+ <html lang={lang} class="aos-preload">
101
+ <head>
102
+ <meta charset="UTF-8" />
103
+ <meta
104
+ name="viewport"
105
+ content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=0.5, user-scalable=yes"
106
+ />
107
+
108
+ <meta name="generator" content={Astro.generator} />
109
+ <link rel="sitemap" href="/sitemap-index.xml" />
110
+ <link rel="icon" type="image/png" href="/favicon.png" />
111
+ <!-- 给上层 Layout/页面注入自定义 head 内容(预加载、脚本、样式等) -->
112
+ <!-- 预连接 -->
113
+ <link
114
+ rel="preconnect"
115
+ href="https://customer-amj1dt4tnge8w6ji.cloudflarestream.com"
116
+ crossorigin
117
+ />
118
+ <script>
119
+ const w = window as any;
120
+ const state =
121
+ w.__aos_state__ ||
122
+ (w.__aos_state__ = { inited: false, loading: null, aos: null });
123
+
124
+ const el = document.documentElement;
125
+ const raf = () =>
126
+ new Promise((resolve) =>
127
+ requestAnimationFrame(() => resolve(undefined)),
128
+ );
129
+
130
+ const ensureAos = async () => {
131
+ if (state.aos) return state.aos;
132
+ if (!state.loading) {
133
+ state.loading = import("aos").then((m) => {
134
+ state.aos = m.default;
135
+ return state.aos;
136
+ });
137
+ }
138
+ return state.loading;
139
+ };
140
+
141
+ const bootOrRefresh = async () => {
142
+ if (
143
+ window.matchMedia &&
144
+ window.matchMedia("(prefers-reduced-motion: reduce)").matches
145
+ ) {
146
+ el.classList.add("aos-ready");
147
+ el.classList.remove("aos-preload");
148
+ return;
149
+ }
150
+
151
+ if (!document.querySelector("[data-aos]")) {
152
+ el.classList.add("aos-ready");
153
+ el.classList.remove("aos-preload");
154
+ return;
155
+ }
156
+
157
+ el.classList.add("aos-preload");
158
+ el.classList.remove("aos-ready");
159
+
160
+ const AOS = await ensureAos();
161
+ if (!state.inited) {
162
+ state.inited = true;
163
+ AOS.init({
164
+ duration: 800,
165
+ easing: "ease-out-cubic",
166
+ once: true,
167
+ offset: 50,
168
+ });
169
+ }
170
+
171
+ await raf();
172
+ await raf();
173
+ AOS.refresh();
174
+
175
+ el.classList.add("aos-ready");
176
+ el.classList.remove("aos-preload");
177
+ };
178
+
179
+ const boot = () => {
180
+ bootOrRefresh();
181
+ };
182
+
183
+ if (document.readyState === "loading") {
184
+ document.addEventListener("DOMContentLoaded", boot, { once: true });
185
+ } else {
186
+ boot();
187
+ }
188
+
189
+ document.addEventListener("astro:page-load", boot);
190
+ document.addEventListener("astro:after-swap", boot);
191
+ </script>
192
+ <ClientRouter />
193
+ <!-- Consent default (Google) -->
194
+ <script is:inline>
195
+ window.dataLayer = window.dataLayer || [];
196
+ function gtag() {
197
+ dataLayer.push(arguments);
198
+ }
199
+ gtag("js", new Date());
200
+ gtag("consent", "default", {
201
+ ad_storage: "denied",
202
+ analytics_storage: "denied",
203
+ });
204
+ </script>
205
+ <slot name="head" />
206
+ <Meta title={resolvedTitle} content={resolvedMeta} />
207
+ {jsonLdItems.map((item) => (
208
+ <script type="application/ld+json" set:html={JSON.stringify(item)} />
209
+ ))}
210
+ <style>
211
+ html.aos-preload [data-aos] {
212
+ opacity: 1 !important;
213
+ transform: none !important;
214
+ transition: none !important;
215
+ }
216
+ </style>
217
+ </head>
218
+ <!-- rest 会被展开到 body 上,方便上层控制 data-* 等属性 -->
219
+ <body class:list={[className, className2]} {...bodyAttrs}>
220
+ <slot />
221
+ </body>
222
+ </html>
223
+
224
+ <style>
225
+ html,
226
+ body {
227
+ margin: 0;
228
+ width: 100%;
229
+ height: 100%;
230
+ }
231
+
232
+ html {
233
+ scroll-behavior: smooth;
234
+ scrollbar-gutter: stable;
235
+ }
236
+
237
+ body {
238
+ scrollbar-gutter: stable;
239
+ }
240
+ </style>
@@ -0,0 +1,32 @@
1
+ ---
2
+ import BackgroundGroup from "./BackgroundGroup.astro";
3
+ import type { FrameProps } from "@rxdrag/website-lib-core";
4
+
5
+ /**
6
+ * Frame — 设计系统基础原子组件
7
+ *
8
+ * 规范:被冻结(Frozen)的设计器原子组件
9
+ * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
10
+ * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
11
+ * - class 用于提供组件的默认类名;class/className 由使用方叠加
12
+ * - backgrounds 用于渲染 BackgroundGroup
13
+ * Frame裁剪用 如果是虚化背景,需要单独裁剪
14
+ */
15
+
16
+ export interface Props extends FrameProps {
17
+ tag?: string;
18
+ }
19
+
20
+ const {
21
+ tag: Tag = "div",
22
+ class: classAttr,
23
+ className,
24
+ backgrounds,
25
+ ...rest
26
+ } = Astro.props;
27
+ ---
28
+
29
+ <Tag class:list={["relative isolate",className, classAttr]} {...rest}>
30
+ <BackgroundGroup backgrounds={backgrounds} />
31
+ <slot />
32
+ </Tag>