@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,100 +1,100 @@
1
- ---
2
- import { Image as AstroImage, Picture as AstroPicture } from "astro:assets";
3
- import { type ImageProps, type ImageSizePreset } from "@rxdrag/website-lib-core";
4
-
5
- interface Props extends ImageProps {}
6
-
7
- /**
8
- * 布局预设 → sizes 属性映射
9
- */
10
- export const SIZES_MAP: Record<ImageSizePreset, string | undefined> = {
11
- auto: undefined,
12
- full: "100vw",
13
- half: "(max-width: 768px) 100vw, 50vw",
14
- third: "(max-width: 768px) 100vw, 33vw",
15
- quarter: "(max-width: 768px) 100vw, 25vw",
16
- sidebar: "(max-width: 768px) 100vw, 300px",
17
- };
18
-
19
-
20
- const {
21
- src,
22
- alt = "",
23
- width,
24
- height,
25
- layout,
26
- formats,
27
- loading,
28
- priority,
29
- quality,
30
- widths,
31
- sizes,
32
- sizeHint = "auto",
33
- class: className,
34
- ...restProps
35
- } = Astro.props as Props;
36
-
37
- // 优先使用原生 sizes,否则用 sizeHint 映射
38
- const actualSizes = sizes ?? SIZES_MAP[sizeHint];
39
-
40
- // 判断是否使用 Picture(有 formats 时使用)
41
- const usePicture = formats && formats.length > 0;
42
-
43
- // 判断是否为字符串路径(远程/CMS/public)
44
- const isStringSrc = typeof src === "string";
45
-
46
- // 检测本地资产路径错误用法
47
- if (isStringSrc && (src.startsWith("/src/") || src.startsWith("src/"))) {
48
- throw new Error(
49
- `Image src="${src}" 是本地资产路径,必须使用 import 导入。\n` +
50
- `正确用法:\n` +
51
- ` import myImage from "${src}";\n` +
52
- ` <Image src={myImage} />`
53
- );
54
- }
55
-
56
- ---
57
- {
58
- isStringSrc ? (
59
- <img
60
- src={src}
61
- alt={alt}
62
- width={width}
63
- height={height}
64
- loading={priority ? "eager" : loading}
65
- fetchpriority={priority ? "high" : undefined}
66
- class={className}
67
- {...restProps}
68
- />
69
- ) : usePicture ? (
70
- <AstroPicture
71
- src={src}
72
- alt={alt}
73
- width={width}
74
- height={height}
75
- formats={formats}
76
- quality={quality}
77
- loading={priority ? "eager" : loading}
78
- sizes={layout === "none" ? undefined : actualSizes}
79
- widths={layout === "none" ? undefined : widths}
80
- class={className}
81
- {...(layout && layout !== "none" ? { layout } : {})}
82
- {...restProps}
83
- />
84
- ) : (
85
- <AstroImage
86
- src={src}
87
- alt={alt}
88
- width={width}
89
- height={height}
90
- quality={quality}
91
- loading={priority ? "eager" : loading}
92
- sizes={layout === "none" ? undefined : actualSizes}
93
- widths={layout === "none" ? undefined : widths}
94
- class={className}
95
- {...(priority ? { priority } : {})}
96
- {...(layout && layout !== "none" ? { layout } : {})}
97
- {...restProps}
98
- />
99
- )
100
- }
1
+ ---
2
+ import { Image as AstroImage, Picture as AstroPicture } from "astro:assets";
3
+ import { type ImageProps, type ImageSizePreset } from "@rxdrag/website-lib-core";
4
+
5
+ interface Props extends ImageProps {}
6
+
7
+ /**
8
+ * 布局预设 → sizes 属性映射
9
+ */
10
+ export const SIZES_MAP: Record<ImageSizePreset, string | undefined> = {
11
+ auto: undefined,
12
+ full: "100vw",
13
+ half: "(max-width: 768px) 100vw, 50vw",
14
+ third: "(max-width: 768px) 100vw, 33vw",
15
+ quarter: "(max-width: 768px) 100vw, 25vw",
16
+ sidebar: "(max-width: 768px) 100vw, 300px",
17
+ };
18
+
19
+
20
+ const {
21
+ src,
22
+ alt = "",
23
+ width,
24
+ height,
25
+ layout,
26
+ formats,
27
+ loading,
28
+ priority,
29
+ quality,
30
+ widths,
31
+ sizes,
32
+ sizeHint = "auto",
33
+ class: className,
34
+ ...restProps
35
+ } = Astro.props as Props;
36
+
37
+ // 优先使用原生 sizes,否则用 sizeHint 映射
38
+ const actualSizes = sizes ?? SIZES_MAP[sizeHint];
39
+
40
+ // 判断是否使用 Picture(有 formats 时使用)
41
+ const usePicture = formats && formats.length > 0;
42
+
43
+ // 判断是否为字符串路径(远程/CMS/public)
44
+ const isStringSrc = typeof src === "string";
45
+
46
+ // 检测本地资产路径错误用法
47
+ if (isStringSrc && (src.startsWith("/src/") || src.startsWith("src/"))) {
48
+ throw new Error(
49
+ `Image src="${src}" 是本地资产路径,必须使用 import 导入。\n` +
50
+ `正确用法:\n` +
51
+ ` import myImage from "${src}";\n` +
52
+ ` <Image src={myImage} />`
53
+ );
54
+ }
55
+
56
+ ---
57
+ {
58
+ isStringSrc ? (
59
+ <img
60
+ src={src}
61
+ alt={alt}
62
+ width={width}
63
+ height={height}
64
+ loading={priority ? "eager" : loading}
65
+ fetchpriority={priority ? "high" : undefined}
66
+ class={className}
67
+ {...restProps}
68
+ />
69
+ ) : usePicture ? (
70
+ <AstroPicture
71
+ src={src}
72
+ alt={alt}
73
+ width={width}
74
+ height={height}
75
+ formats={formats}
76
+ quality={quality}
77
+ loading={priority ? "eager" : loading}
78
+ sizes={layout === "none" ? undefined : actualSizes}
79
+ widths={layout === "none" ? undefined : widths}
80
+ class={className}
81
+ {...(layout && layout !== "none" ? { layout } : {})}
82
+ {...restProps}
83
+ />
84
+ ) : (
85
+ <AstroImage
86
+ src={src}
87
+ alt={alt}
88
+ width={width}
89
+ height={height}
90
+ quality={quality}
91
+ loading={priority ? "eager" : loading}
92
+ sizes={layout === "none" ? undefined : actualSizes}
93
+ widths={layout === "none" ? undefined : widths}
94
+ class={className}
95
+ {...(priority ? { priority } : {})}
96
+ {...(layout && layout !== "none" ? { layout } : {})}
97
+ {...restProps}
98
+ />
99
+ )
100
+ }
@@ -1,15 +1,15 @@
1
- | 中文名 | key | 说明 |
2
- | ---- | ---------- | --------- |
3
- | 图片 | src | 必填 |
4
- | 替代文本 | alt | SEO / 无障碍 |
5
- | 使用场景 | scene | 下拉 |
6
- | 响应式 | responsive | 下拉 |
7
- | 优先加载 | priority | LCP |
8
- | 懒加载 | loading | 默认 lazy |
9
- | 装饰图片 | decorative | 自动 aria |
10
-
11
- ## 最后一句总结(你可以记下来)
12
-
13
- Tailwind 决定“看起来多大”
14
- sizes 决定“下载多大”
1
+ | 中文名 | key | 说明 |
2
+ | ---- | ---------- | --------- |
3
+ | 图片 | src | 必填 |
4
+ | 替代文本 | alt | SEO / 无障碍 |
5
+ | 使用场景 | scene | 下拉 |
6
+ | 响应式 | responsive | 下拉 |
7
+ | 优先加载 | priority | LCP |
8
+ | 懒加载 | loading | 默认 lazy |
9
+ | 装饰图片 | decorative | 自动 aria |
10
+
11
+ ## 最后一句总结(你可以记下来)
12
+
13
+ Tailwind 决定“看起来多大”
14
+ sizes 决定“下载多大”
15
15
  这两件事发生在不同时间、不同层级
@@ -1,99 +1,89 @@
1
- ---
2
- import { toHref, type LinkType } from "@rxdrag/website-lib-core";
3
-
4
- import type { HTMLAttributes } from "astro/types";
5
-
6
- /**
7
- * 链接
8
- *
9
- * 规范:被冻结(Frozen)的设计器原子组件
10
- * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
11
- * - 允许通过原生属性透传(...rest)注入 id/style/data-* 等通用能力
12
- * - 支持 className(自定义组件统一约定)
13
- * - href type/to/options 计算得出;不允许外部通过 props 覆盖(避免行为不稳定)
14
- */
15
-
16
- interface Props extends HTMLAttributes<"a"> {
17
- type?: LinkType | string;
18
- to?: string;
19
- className?: string;
20
- //用于active类名的传递
21
- activeWhen?: string | true;
22
-
23
- // 链接生成配置:用于 toHref 计算最终 href 的路径前缀
24
- // - productsSlug:产品详情页路径前缀(如 "products")
25
- // - postsSlug:文章详情页路径前缀(如 "posts")
26
- options?: {
27
- productsSlug?: string;
28
- postsSlug?: string;
29
- };
30
-
31
- // 允许外部传入以便兼容旧用法,但运行时会被忽略(href 统一由 type/to/options 生成)
32
- href?: string;
33
- }
34
-
35
- const {
36
- type,
37
- to,
38
- class: cls,
39
- className,
40
- activeWhen,
41
- options,
42
- href: hrefFromProps,
43
- "class:list": classListFromProps,
44
- ...props
45
- } = Astro.props;
46
-
47
- if (hrefFromProps) {
48
- console.log(
49
- `[Link] prop "href" is ignored. Use type/to/options to generate href. href=${hrefFromProps}`
50
- );
51
- }
52
- if (classListFromProps) {
53
- console.log(
54
- '[Link] prop "class:list" is ignored. Use class/className instead.'
55
- );
56
- }
57
-
58
- const href = toHref(type || "", to || "", options);
59
- const hrefObj = href ? { href } : {};
60
- ---
61
-
62
- <a
63
- {...props}
64
- {...hrefObj}
65
- data-actived-path={activeWhen}
66
- class:list={[cls, className]}
67
- >
68
- <slot />
69
- </a>
70
-
71
- <script>
72
- import { initLinks } from "@rxdrag/website-lib-core";
73
-
74
- (() => {
75
- const bindAstroLifecycle = (key: string, fn: () => void) => {
76
- const w = window as typeof window & {
77
- __astro_lifecycle_bound__?: Record<string, boolean>;
78
- };
79
- const bound = (w.__astro_lifecycle_bound__ ||= Object.create(null));
80
- if (bound[key]) return;
81
- bound[key] = true;
82
-
83
- const boot = () => fn();
84
-
85
- if (document.readyState === "loading") {
86
- document.addEventListener("DOMContentLoaded", boot, { once: true });
87
- } else {
88
- boot();
89
- }
90
-
91
- document.addEventListener("astro:page-load", boot);
92
- document.addEventListener("astro:after-swap", boot);
93
- };
94
-
95
- bindAstroLifecycle("website-lib:init-links", () => {
96
- initLinks();
97
- });
98
- })();
99
- </script>
1
+ ---
2
+ import {
3
+ toHref,
4
+ type BackgroundConfig,
5
+ type LinkProps,
6
+ } from "@rxdrag/website-lib-core";
7
+ import BackgroundGroup from "./BackgroundGroup.astro";
8
+
9
+ /**
10
+ * 链接
11
+ *
12
+ * 规范:被冻结(Frozen)的设计器原子组件
13
+ * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
14
+ * - 允许通过原生属性透传(...rest)注入 id/style/data-* 等通用能力
15
+ * - 支持 className(自定义组件统一约定)
16
+ * - href 由 type/to/options 计算得出;不允许外部通过 props 覆盖(避免行为不稳定)
17
+ */
18
+
19
+ interface Props extends LinkProps {
20
+ backgrounds?: BackgroundConfig[];
21
+ }
22
+
23
+ const {
24
+ type,
25
+ to,
26
+ class: cls,
27
+ className,
28
+ activeWhen,
29
+ options,
30
+ href: hrefFromProps,
31
+ "class:list": classListFromProps,
32
+ backgrounds,
33
+ ...props
34
+ } = Astro.props;
35
+
36
+ if (hrefFromProps) {
37
+ console.log(
38
+ `[Link] prop "href" is ignored. Use type/to/options to generate href. href=${hrefFromProps}`,
39
+ );
40
+ }
41
+ if (classListFromProps) {
42
+ console.log(
43
+ '[Link] prop "class:list" is ignored. Use class/className instead.',
44
+ );
45
+ }
46
+
47
+ const href = toHref(type || "", to || "", options);
48
+ const hrefObj = href ? { href } : {};
49
+ ---
50
+
51
+ <a
52
+ {...props}
53
+ {...hrefObj}
54
+ data-actived-path={activeWhen}
55
+ class:list={[cls, className, backgrounds ? "relative" : undefined]}
56
+ >
57
+ <BackgroundGroup backgrounds={backgrounds} />
58
+ <slot />
59
+ </a>
60
+
61
+ <script>
62
+ import { initLinks } from "@rxdrag/website-lib-core";
63
+
64
+ (() => {
65
+ const bindAstroLifecycle = (key: string, fn: () => void) => {
66
+ const w = window as typeof window & {
67
+ __astro_lifecycle_bound__?: Record<string, boolean>;
68
+ };
69
+ const bound = (w.__astro_lifecycle_bound__ ||= Object.create(null));
70
+ if (bound[key]) return;
71
+ bound[key] = true;
72
+
73
+ const boot = () => fn();
74
+
75
+ if (document.readyState === "loading") {
76
+ document.addEventListener("DOMContentLoaded", boot, { once: true });
77
+ } else {
78
+ boot();
79
+ }
80
+
81
+ document.addEventListener("astro:page-load", boot);
82
+ document.addEventListener("astro:after-swap", boot);
83
+ };
84
+
85
+ bindAstroLifecycle("website-lib:init-links", () => {
86
+ initLinks();
87
+ });
88
+ })();
89
+ </script>
@@ -1,17 +1,17 @@
1
- ---
2
- import type { BackgroundConfig } from "@rxdrag/website-lib-core";
3
- import BackgroundGroup from "./BackgroundGroup.astro";
4
-
5
- interface Props {
6
- class?: string;
7
- className?: string;
8
- backgrounds?: BackgroundConfig[];
9
- }
10
-
11
- const { className, class: className2, backgrounds, ...rest } = Astro.props;
12
- ---
13
-
14
- <main class:list={[className, className2]} {...rest}>
15
- {backgrounds?.length ? <BackgroundGroup backgrounds={backgrounds} /> : null}
16
- <slot />
17
- </main>
1
+ ---
2
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
3
+ import BackgroundGroup from "./BackgroundGroup.astro";
4
+
5
+ interface Props {
6
+ class?: string;
7
+ className?: string;
8
+ backgrounds?: BackgroundConfig[];
9
+ }
10
+
11
+ const { className, class: className2, backgrounds, ...rest } = Astro.props;
12
+ ---
13
+
14
+ <main class:list={[className, className2]} {...rest}>
15
+ {backgrounds?.length ? <BackgroundGroup backgrounds={backgrounds} /> : null}
16
+ <slot />
17
+ </main>
@@ -1,65 +1,65 @@
1
- ---
2
- import type { PageMeta } from "@rxdrag/rxcms-models";
3
-
4
- interface Props {
5
- content?: PageMeta;
6
- title?: string;
7
- }
8
-
9
- const { content, title: propTitle } = Astro.props;
10
-
11
- // 从content中提取SEO相关属性
12
- const {
13
- // SeoMeta属性
14
- seoTitle,
15
- seoKeywords,
16
- seoDescription,
17
- seoAuthor,
18
- publisher,
19
- seoRobots,
20
- // OgMeta属性
21
- ogTitle,
22
- ogDescription,
23
- ogUrl,
24
- ogSiteName,
25
- ogType,
26
- xCard,
27
- xSite,
28
- xUrl,
29
- // 其他属性
30
- ogImage,
31
- } = content || {};
32
-
33
- const title = propTitle || seoTitle || "YiZhanFei";
34
-
35
- //暂时不输出canonicalUrl非必须
36
- const canonicalURL = Astro.url.href;
37
- const imageUrl = ogImage?.file?.url || "";
38
- ---
39
-
40
- <title>{seoTitle || title}</title>
41
- <meta name="description" content={seoDescription} />
42
- <meta name="keywords" content={seoKeywords} />
43
- <meta name="author" content={seoAuthor} />
44
- <meta name="publisher" content={publisher} />
45
- <meta name="robots" content={seoRobots || "index, follow"} />
46
- <!-- <link rel="canonical" href={canonicalURL} /> -->
47
-
48
- <!-- Open Graph / Facebook -->
49
- <meta property="og:type" content={ogType || "website"} />
50
- <meta property="og:url" content={ogUrl || canonicalURL} />
51
- <meta property="og:title" content={ogTitle || title} />
52
- <meta property="og:description" content={ogDescription || seoDescription} />
53
- <meta property="og:image" content={imageUrl} />
54
- {ogSiteName && <meta property="og:site_name" content={ogSiteName} />}
55
-
56
- <!-- Twitter -->
57
- <meta property="twitter:card" content={xCard || "summary_large_image"} />
58
- <meta property="twitter:url" content={xUrl || ogUrl || canonicalURL} />
59
- <meta property="twitter:title" content={ogTitle || title} />
60
- <meta
61
- property="twitter:description"
62
- content={ogDescription || seoDescription}
63
- />
64
- <meta property="twitter:image" content={imageUrl} />
65
- {xSite && <meta property="twitter:site" content={xSite} />}
1
+ ---
2
+ import type { PageMeta } from "@rxdrag/rxcms-models";
3
+
4
+ interface Props {
5
+ content?: PageMeta;
6
+ title?: string;
7
+ }
8
+
9
+ const { content, title: propTitle } = Astro.props;
10
+
11
+ // 从content中提取SEO相关属性
12
+ const {
13
+ // SeoMeta属性
14
+ seoTitle,
15
+ seoKeywords,
16
+ seoDescription,
17
+ seoAuthor,
18
+ publisher,
19
+ seoRobots,
20
+ // OgMeta属性
21
+ ogTitle,
22
+ ogDescription,
23
+ ogUrl,
24
+ ogSiteName,
25
+ ogType,
26
+ xCard,
27
+ xSite,
28
+ xUrl,
29
+ // 其他属性
30
+ ogImage,
31
+ } = content || {};
32
+
33
+ const title = propTitle || seoTitle || "YiZhanFei";
34
+
35
+ //暂时不输出canonicalUrl非必须
36
+ const canonicalURL = Astro.url.href;
37
+ const imageUrl = ogImage?.file?.url || "";
38
+ ---
39
+
40
+ <title>{seoTitle || title}</title>
41
+ <meta name="description" content={seoDescription} />
42
+ <meta name="keywords" content={seoKeywords} />
43
+ <meta name="author" content={seoAuthor} />
44
+ <meta name="publisher" content={publisher} />
45
+ <meta name="robots" content={seoRobots || "index, follow"} />
46
+ <!-- <link rel="canonical" href={canonicalURL} /> -->
47
+
48
+ <!-- Open Graph / Facebook -->
49
+ <meta property="og:type" content={ogType || "website"} />
50
+ <meta property="og:url" content={ogUrl || canonicalURL} />
51
+ <meta property="og:title" content={ogTitle || title} />
52
+ <meta property="og:description" content={ogDescription || seoDescription} />
53
+ <meta property="og:image" content={imageUrl} />
54
+ {ogSiteName && <meta property="og:site_name" content={ogSiteName} />}
55
+
56
+ <!-- Twitter -->
57
+ <meta property="twitter:card" content={xCard || "summary_large_image"} />
58
+ <meta property="twitter:url" content={xUrl || ogUrl || canonicalURL} />
59
+ <meta property="twitter:title" content={ogTitle || title} />
60
+ <meta
61
+ property="twitter:description"
62
+ content={ogDescription || seoDescription}
63
+ />
64
+ <meta property="twitter:image" content={imageUrl} />
65
+ {xSite && <meta property="twitter:site" content={xSite} />}