@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
@@ -0,0 +1,104 @@
1
+ ---
2
+ export interface Props {
3
+ class?: string;
4
+ color?: string;
5
+ width?: number | string;
6
+ opacity?: number;
7
+ shadowRatio?: number;
8
+ angle?: number | string;
9
+ }
10
+
11
+ const {
12
+ class: className,
13
+ color = "255 255 255",
14
+ opacity = 0.6,
15
+ width = 1,
16
+ shadowRatio = 1,
17
+ angle,
18
+ } = Astro.props;
19
+
20
+ const num = (v: number | string) =>
21
+ typeof v === "number" ? v : parseFloat(v) || 0;
22
+
23
+ const gradientId = `hl-grad-${Math.random().toString(36).slice(2, 8)}`;
24
+ const rectId = `hl-rect-${Math.random().toString(36).slice(2, 8)}`;
25
+ const hlColorComma = color.trim().split(/\s+/).join(",");
26
+ const hlWidth = num(width);
27
+ const r = 0;
28
+ const a0 = Math.max(0, Math.min(1, opacity));
29
+ const a1 = a0 * (2 / 3);
30
+ const a2 = a0 * (1 / 20);
31
+
32
+ const ratio = (() => {
33
+ const n = typeof shadowRatio === "number" ? shadowRatio : parseFloat(String(shadowRatio));
34
+ if (!Number.isFinite(n)) return 1;
35
+ return Math.max(0, n);
36
+ })();
37
+
38
+ const stop42 = Math.max(0, Math.min(100, 50 - 8 * ratio));
39
+ const stop49 = Math.max(0, Math.min(100, 50 - 1 * ratio));
40
+ const stop54 = Math.max(0, Math.min(100, 50 + 4 * ratio));
41
+
42
+ const angleDeg = (() => {
43
+ if (angle === undefined || angle === null || angle === "") return undefined;
44
+ if (typeof angle === "number") return `${angle}`;
45
+ const s = String(angle).trim();
46
+ if (!s) return undefined;
47
+ const n = parseFloat(s);
48
+ if (!Number.isFinite(n)) return undefined;
49
+ return `${n}`;
50
+ })();
51
+ ---
52
+
53
+ <svg class={className} aria-hidden="true" style="overflow: visible;">
54
+ <defs>
55
+ <linearGradient
56
+ id={gradientId}
57
+ x1="0%"
58
+ y1="0%"
59
+ x2="100%"
60
+ y2="105%"
61
+ gradientTransform={angleDeg ? `rotate(${angleDeg} 0.5 0.5)` : undefined}
62
+ >
63
+ <stop offset="0%" stop-color={`rgba(${hlColorComma}, ${a0})`}></stop>
64
+ <stop offset={`${stop42}%`} stop-color={`rgba(${hlColorComma}, ${a1})`}></stop>
65
+ <stop offset={`${stop49}%`} stop-color={`rgba(${hlColorComma}, ${a2})`}></stop>
66
+ <stop offset="50%" stop-color={`rgba(${hlColorComma}, ${a2})`}></stop>
67
+ <stop offset={`${stop54}%`} stop-color={`rgba(${hlColorComma}, ${a1})`}></stop>
68
+ <stop offset="100%" stop-color={`rgba(${hlColorComma}, ${a0})`}></stop>
69
+ </linearGradient>
70
+ </defs>
71
+ <rect
72
+ id={rectId}
73
+ x={hlWidth / 2}
74
+ y={hlWidth / 2}
75
+ width={`calc(100% - ${hlWidth}px)`}
76
+ height={`calc(100% - ${hlWidth}px)`}
77
+ rx={r}
78
+ ry={r}
79
+ fill="none"
80
+ stroke={`url(#${gradientId})`}
81
+ stroke-width={hlWidth}></rect>
82
+ </svg>
83
+
84
+ <script is:inline define:vars={{ rectId }}>
85
+ const rect = document.getElementById(rectId);
86
+ if (!rect) {
87
+ // noop
88
+ } else {
89
+ const updateRadius = () => {
90
+ let host = rect.ownerSVGElement?.parentElement;
91
+ if (host?.hasAttribute("data-bg-group")) host = host.parentElement;
92
+ if (!host) return;
93
+ const cs = getComputedStyle(host);
94
+ const v = cs.borderTopLeftRadius || cs.borderRadius || "0px";
95
+ const n = parseFloat(v);
96
+ const r = Number.isFinite(n) ? n : 0;
97
+ rect.setAttribute("rx", String(r));
98
+ rect.setAttribute("ry", String(r));
99
+ };
100
+
101
+ updateRadius();
102
+ window.addEventListener("resize", updateRadius);
103
+ }
104
+ </script>
@@ -0,0 +1,85 @@
1
+ ---
2
+ interface Props {
3
+ class?: string;
4
+ className?: string;
5
+ }
6
+
7
+ const {
8
+ class: classAttr,
9
+ className,
10
+ } = Astro.props;
11
+
12
+ const filterId = `glass-refract-${Math.random().toString(36).slice(2)}`;
13
+ ---
14
+
15
+ <div
16
+ class:list={["bg-glass-refraction", classAttr, className]}
17
+ style={`--glass-filter: url(#${filterId});`}
18
+ >
19
+ </div>
20
+ <svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" style="position:absolute;overflow:hidden">
21
+ <defs>
22
+ <filter id={filterId} x="0%" y="0%" width="100%" height="100%">
23
+ <feTurbulence type="turbulence" baseFrequency="0.006 0.012" numOctaves="2" seed="92" result="noise" />
24
+ <feGaussianBlur in="noise" stdDeviation="4" result="smoothNoise" />
25
+ <feDisplacementMap in="SourceGraphic" in2="smoothNoise" scale="10" xChannelSelector="R" yChannelSelector="G" />
26
+ </filter>
27
+ </defs>
28
+ </svg>
29
+
30
+ <style is:global>
31
+ .bg-glass-refraction {
32
+ --glass-tint-color: 255, 255, 255;
33
+ --glass-tint-opacity: 0.04;
34
+ --glass-frost-blur: 1px;
35
+ --glass-shadow-blur: 20px;
36
+ --glass-shadow-spread: -5px;
37
+ --glass-shadow-color: rgba(255, 255, 255, 0.1);
38
+
39
+ overflow: hidden;
40
+ isolation: isolate;
41
+ contain: paint;
42
+ }
43
+
44
+ .bg-glass-refraction::before {
45
+ content: '';
46
+ position: absolute;
47
+ inset: 0;
48
+ z-index: 1;
49
+ border-radius: inherit;
50
+ box-shadow: inset 0 0 var(--glass-shadow-blur) var(--glass-shadow-spread) var(--glass-shadow-color);
51
+ background-color: rgba(var(--glass-tint-color), var(--glass-tint-opacity));
52
+ transition: none;
53
+ }
54
+
55
+ .bg-glass-refraction::after {
56
+ content: '';
57
+ position: absolute;
58
+ inset: 0;
59
+ z-index: 0;
60
+ border-radius: inherit;
61
+ backdrop-filter: blur(var(--glass-frost-blur));
62
+ -webkit-backdrop-filter: blur(var(--glass-frost-blur));
63
+ filter: var(--glass-filter);
64
+ -webkit-filter: var(--glass-filter);
65
+ isolation: isolate;
66
+ transition: none;
67
+ }
68
+
69
+
70
+ @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
71
+ .bg-glass-refraction::after {
72
+ backdrop-filter: none;
73
+ -webkit-backdrop-filter: none;
74
+ filter: none;
75
+ -webkit-filter: none;
76
+ }
77
+ }
78
+
79
+ @supports not (filter: url(#test)) {
80
+ .bg-glass-refraction::after {
81
+ filter: none;
82
+ -webkit-filter: none;
83
+ }
84
+ }
85
+ </style>
@@ -0,0 +1,80 @@
1
+ ---
2
+ import type {
3
+ GradientConfig,
4
+ GradientDirection,
5
+ } from "@rxdrag/website-lib-core";
6
+
7
+ export interface Props extends GradientConfig {
8
+ class?: string;
9
+ width?: number | string;
10
+ }
11
+
12
+ const {
13
+ class: className,
14
+ width = 2,
15
+ colors,
16
+ fromColor = "#1356da",
17
+ toColor = "#719fff",
18
+ viaColor,
19
+ angle,
20
+ direction = "to-r",
21
+ } = Astro.props;
22
+
23
+ const px = (v: number | string) => (typeof v === "number" ? `${v}px` : v);
24
+
25
+ const deg = (v: number | string) => {
26
+ if (typeof v === "number") return `${v}deg`;
27
+ const s = `${v}`.trim();
28
+ if (!s) return "0deg";
29
+ return /deg|rad|turn|grad$/i.test(s) ? s : `${s}deg`;
30
+ };
31
+
32
+ const directionMap: Record<GradientDirection, string> = {
33
+ "to-r": "to right",
34
+ "to-l": "to left",
35
+ "to-t": "to top",
36
+ "to-b": "to bottom",
37
+ "to-tr": "to top right",
38
+ "to-tl": "to top left",
39
+ "to-br": "to bottom right",
40
+ "to-bl": "to bottom left",
41
+ };
42
+
43
+ const gradientColors = (() => {
44
+ if (colors?.length) return colors.join(", ");
45
+ return viaColor
46
+ ? `${fromColor}, ${viaColor}, ${toColor}`
47
+ : `${fromColor}, ${toColor}`;
48
+ })();
49
+
50
+ const gradientDirection =
51
+ angle !== undefined ? deg(angle) : directionMap[direction];
52
+
53
+ const styleStr = [
54
+ `--gb-width:${px(width)}`,
55
+ `--gb-colors:${gradientColors}`,
56
+ `--gb-direction:${gradientDirection}`,
57
+ ].join(";");
58
+ ---
59
+
60
+ <span class:list={["gb-root", className]} style={styleStr} aria-hidden="true"
61
+ ></span>
62
+
63
+ <style>
64
+ .gb-root {
65
+ position: absolute;
66
+ inset: 0;
67
+ pointer-events: none;
68
+ border-radius: inherit;
69
+ padding: var(--gb-width);
70
+ background: linear-gradient(var(--gb-direction), var(--gb-colors));
71
+ -webkit-mask:
72
+ linear-gradient(#fff 0 0) content-box,
73
+ linear-gradient(#fff 0 0);
74
+ -webkit-mask-composite: xor;
75
+ mask:
76
+ linear-gradient(#fff 0 0) content-box,
77
+ linear-gradient(#fff 0 0);
78
+ mask-composite: exclude;
79
+ }
80
+ </style>
@@ -1,34 +1,32 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
- import BaseBlock from "./BaseBlock.astro";
5
-
6
- /**
7
- * 网格
8
- *
9
- * 规范:被冻结(Frozen)的设计器原子组件
10
- * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
11
- * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
12
- */
13
-
14
- interface Props extends HTMLAttributes<'div'> {
15
- // 布局方案名称(设计器用)
16
- patternName?: string;
17
- className?: string;
18
- backgrounds?: BackgroundConfig[];
19
- }
20
-
21
- const { className, class: originalClass, backgrounds, ...rest } = Astro.props;
22
-
23
- //布局容器
24
- ---
25
-
26
- <BaseBlock
27
- baseClass="relative grid gap-12"
28
- className={className}
29
- class={originalClass}
30
- backgrounds={backgrounds}
31
- {...rest}
32
- >
33
- <slot />
34
- </BaseBlock>
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
+ import Frame from "./Frame.astro";
5
+
6
+ /**
7
+ * 网格
8
+ *
9
+ * 规范:被冻结(Frozen)的设计器原子组件
10
+ * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
11
+ * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
12
+ */
13
+
14
+ interface Props extends HTMLAttributes<"div"> {
15
+ // 布局方案名称(设计器用)
16
+ patternName?: string;
17
+ className?: string;
18
+ backgrounds?: BackgroundConfig[];
19
+ }
20
+
21
+ const { className, class: originalClass, backgrounds, ...rest } = Astro.props;
22
+
23
+ //布局容器
24
+ ---
25
+
26
+ <Frame
27
+ class:list={["relative grid", className, originalClass]}
28
+ backgrounds={backgrounds}
29
+ {...rest}
30
+ >
31
+ <slot />
32
+ </Frame>
@@ -1,32 +1,28 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import type {
4
- BackgroundConfig,
5
- } from "@rxdrag/website-lib-core";
6
- import BaseBlock from "./BaseBlock.astro";
7
-
8
- /**
9
- * 网格单元
10
- *
11
- * 规范:被冻结(Frozen)的设计器原子组件
12
- * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
13
- * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
14
- */
15
-
16
- interface Props extends HTMLAttributes<'div'> {
17
- className?: string;
18
- backgrounds?: BackgroundConfig[];
19
- }
20
-
21
- const { className, class: originalClass, backgrounds, ...rest } = Astro.props;
22
- ---
23
-
24
- <BaseBlock
25
- baseClass={["w-full", "h-full", "flex", "flex-col"]}
26
- className={className}
27
- class={originalClass}
28
- backgrounds={backgrounds}
29
- {...rest}
30
- >
31
- <slot />
32
- </BaseBlock>
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
+ import Frame from "./Frame.astro";
5
+
6
+ /**
7
+ * 网格单元
8
+ *
9
+ * 规范:被冻结(Frozen)的设计器原子组件
10
+ * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
11
+ * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
12
+ */
13
+
14
+ interface Props extends HTMLAttributes<"div"> {
15
+ className?: string;
16
+ backgrounds?: BackgroundConfig[];
17
+ }
18
+
19
+ const { className, class: originalClass, backgrounds, ...rest } = Astro.props;
20
+ ---
21
+
22
+ <Frame
23
+ class:list={[className, originalClass]}
24
+ backgrounds={backgrounds}
25
+ {...rest}
26
+ >
27
+ <slot />
28
+ </Frame>
@@ -1,24 +1,24 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import { headingLevelToTypographyClassName } from "@rxdrag/website-lib-core";
4
-
5
- interface Props extends HTMLAttributes<"h1" | "h2" | "h3" | "h4" | "h5" | "h6"> {
6
- level: 1 | 2 | 3 | 4 | 5 | 6;
7
- customSize?: boolean;
8
- className?: string;
9
- }
10
-
11
- const { level, customSize = false, className, class: classAttr, ...rest } = Astro.props;
12
-
13
- if (typeof level !== "number" || level < 1 || level > 6) {
14
- console.log("[Heading] invalid level", level);
15
- throw new Error("Heading.astro: prop 'level' must be a number from 1 to 6");
16
- }
17
-
18
- const Tag = `h${level}`;
19
- const baseClassName = customSize ? undefined : headingLevelToTypographyClassName[level];
20
- ---
21
-
22
- <Tag class:list={[baseClassName, className, classAttr]} {...rest}>
23
- <slot />
24
- </Tag>
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import { headingLevelToTypographyClassName } from "@rxdrag/website-lib-core";
4
+
5
+ interface Props extends HTMLAttributes<"h1" | "h2" | "h3" | "h4" | "h5" | "h6"> {
6
+ level?: 1 | 2 | 3 | 4 | 5 | 6;
7
+ customSize?: boolean;
8
+ className?: string;
9
+ }
10
+
11
+ const { level =2, customSize = false, className, class: classAttr, ...rest } = Astro.props;
12
+
13
+ if (typeof level !== "number" || level < 1 || level > 6) {
14
+ console.log("[Heading] invalid level", level);
15
+ throw new Error("Heading.astro: prop 'level' must be a number from 1 to 6");
16
+ }
17
+
18
+ const Tag = `h${level}`;
19
+ const baseClassName = customSize ? undefined : headingLevelToTypographyClassName[level];
20
+ ---
21
+
22
+ <Tag class:list={[baseClassName, className, classAttr]} {...rest}>
23
+ <slot />
24
+ </Tag>
@@ -1,30 +1,30 @@
1
- ---
2
- import {
3
- Icon as CoreIcon,
4
- Entify,
5
- type Locals,
6
- } from "@rxdrag/website-lib-core";
7
-
8
- interface Props {
9
- className?: string;
10
- icon?: string;
11
- svg?: string;
12
- }
13
- const { env, imageSizes } = Astro.locals as Locals;
14
- const { className, icon, svg, ...rest } = Astro.props;
15
-
16
- const localIconName = icon?.startsWith("local:") ? icon?.split(":")[1] : null;
17
-
18
- const rx = Entify.getInstance(env, imageSizes);
19
-
20
- const svgIcon =
21
- !!rx && localIconName ? await rx.getIcon(localIconName) : undefined;
22
- ---
23
-
24
- <CoreIcon
25
- className={className}
26
- icon={localIconName ? undefined : icon}
27
- svg={svgIcon?.code || svg}
28
- {...rest}
29
- client:only="react"
1
+ ---
2
+ import {
3
+ Icon as CoreIcon,
4
+ Entify,
5
+ type Locals,
6
+ } from "@rxdrag/website-lib-core";
7
+
8
+ interface Props {
9
+ className?: string;
10
+ icon?: string;
11
+ svg?: string;
12
+ }
13
+ const { env, imageSizes } = Astro.locals as Locals;
14
+ const { className, icon, svg, ...rest } = Astro.props;
15
+
16
+ const localIconName = icon?.startsWith("local:") ? icon?.split(":")[1] : null;
17
+
18
+ const rx = Entify.getInstance(env, imageSizes);
19
+
20
+ const svgIcon =
21
+ !!rx && localIconName ? await rx.getIcon(localIconName) : undefined;
22
+ ---
23
+
24
+ <CoreIcon
25
+ className={className}
26
+ icon={localIconName ? undefined : icon}
27
+ svg={svgIcon?.code || svg}
28
+ {...rest}
29
+ client:only="react"
30
30
  />