@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.
- package/README.md +2 -2
- package/components/AnimationNumber.astro +217 -217
- package/components/Background.astro +140 -114
- package/components/BackgroundGroup.astro +20 -26
- package/components/BaseFooter.astro +24 -39
- package/components/BaseHeader.astro +22 -25
- package/components/Box.astro +20 -22
- package/components/Button.astro +80 -0
- package/components/Carousel.astro +456 -315
- package/components/CarouselPagination.astro +97 -76
- package/components/CarouselSlide.astro +10 -16
- package/components/Collapse.astro +125 -125
- package/components/CollapseIndicator.astro +20 -20
- package/components/Container.astro +27 -32
- package/components/Content.astro +20 -0
- package/components/CookieConsent.astro +47 -47
- package/components/CookieConsent.css +52 -52
- package/components/CookieConsentConfig.ts +208 -208
- package/components/Dialog.astro +342 -338
- package/components/DialogTrigger.astro +32 -32
- package/components/Document.astro +240 -225
- package/components/Frame.astro +32 -0
- package/components/GlassBorder.astro +104 -0
- package/components/GlassRefraction.astro +85 -0
- package/components/GradientBorder.astro +80 -0
- package/components/Grid.astro +32 -34
- package/components/GridCell.astro +28 -32
- package/components/Heading.astro +24 -24
- package/components/Icon.astro +29 -29
- package/components/Image.astro +100 -100
- package/components/Image.md +14 -14
- package/components/Link.astro +89 -82
- package/components/Main.astro +17 -17
- package/components/Meta.astro +65 -65
- package/components/Popover.astro +189 -189
- package/components/RichTextView.astro +28 -28
- package/components/Section.astro +26 -44
- package/components/TabButton.astro +32 -16
- package/components/TabPanel.astro +20 -19
- package/components/Tabs.astro +220 -147
- package/components/Video.astro +6 -4
- package/components/YearsSince.astro +20 -20
- package/components//344/270/211/345/261/202/346/250/241/345/236/213.md +5 -5
- package/components//344/270/273/351/242/230Token.md +198 -198
- package/components//345/216/237/345/255/220/345/206/273/347/273/223/346/270/205/345/215/225.md +270 -260
- package/components//347/211/251/346/226/231/346/270/205/345/215/225.md +599 -567
- package/index.ts +5 -5
- package/package.json +5 -5
- package/components/BaseBlock.astro +0 -34
- package/components/Motion.astro +0 -77
- package/components/Stack.astro +0 -31
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@rxdrag/website-lib
|
|
2
|
-
含 astro 组件,不能在 React 中使用
|
|
1
|
+
@rxdrag/website-lib
|
|
2
|
+
含 astro 组件,不能在 React 中使用
|
|
@@ -1,218 +1,218 @@
|
|
|
1
|
-
---
|
|
2
|
-
interface Props {
|
|
3
|
-
start?: number;
|
|
4
|
-
end: number;
|
|
5
|
-
duration?: number;
|
|
6
|
-
class?: string;
|
|
7
|
-
sign?: string;
|
|
8
|
-
once?: boolean;
|
|
9
|
-
type?: "int" | "float";
|
|
10
|
-
fractionDigits?: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
start = 0,
|
|
15
|
-
end,
|
|
16
|
-
duration = 1200,
|
|
17
|
-
class: className,
|
|
18
|
-
sign = "+",
|
|
19
|
-
once = false,
|
|
20
|
-
type = "int",
|
|
21
|
-
fractionDigits = 1,
|
|
22
|
-
} = Astro.props;
|
|
23
|
-
|
|
24
|
-
const id = crypto.randomUUID();
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
<span
|
|
28
|
-
class={className}
|
|
29
|
-
data-light-number
|
|
30
|
-
data-id={id}
|
|
31
|
-
data-start={start}
|
|
32
|
-
data-end={end}
|
|
33
|
-
data-duration={duration}
|
|
34
|
-
data-once={once ? "1" : "0"}
|
|
35
|
-
data-type={type}
|
|
36
|
-
data-fraction-digits={fractionDigits}
|
|
37
|
-
>
|
|
38
|
-
<span data-light-number-value>{start}</span>
|
|
39
|
-
{
|
|
40
|
-
sign && (
|
|
41
|
-
<span data-light-number-sign style="display:none">
|
|
42
|
-
{sign}
|
|
43
|
-
</span>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
</span>
|
|
47
|
-
|
|
48
|
-
<script is:inline>
|
|
49
|
-
(() => {
|
|
50
|
-
const bindAstroLifecycle = (key, fn) => {
|
|
51
|
-
const w = window;
|
|
52
|
-
const bound = (w.__astro_lifecycle_bound__ ||= Object.create(null));
|
|
53
|
-
if (bound[key]) return;
|
|
54
|
-
bound[key] = true;
|
|
55
|
-
|
|
56
|
-
const boot = () => fn();
|
|
57
|
-
|
|
58
|
-
if (document.readyState === "loading") {
|
|
59
|
-
document.addEventListener("DOMContentLoaded", boot, { once: true });
|
|
60
|
-
} else {
|
|
61
|
-
boot();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
document.addEventListener("astro:page-load", boot);
|
|
65
|
-
document.addEventListener("astro:after-swap", boot);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const globalKey = "__light_number_state__";
|
|
69
|
-
const w = window;
|
|
70
|
-
const state = (w[globalKey] ||= {
|
|
71
|
-
docBound: false,
|
|
72
|
-
moBound: false,
|
|
73
|
-
scheduled: false,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const scheduleInit = () => {
|
|
77
|
-
if (state.scheduled) return;
|
|
78
|
-
state.scheduled = true;
|
|
79
|
-
requestAnimationFrame(() => {
|
|
80
|
-
state.scheduled = false;
|
|
81
|
-
init();
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const init = () => {
|
|
86
|
-
const nodes = document.querySelectorAll("[data-light-number]");
|
|
87
|
-
nodes.forEach((root) => {
|
|
88
|
-
if (!(root instanceof HTMLElement)) return;
|
|
89
|
-
if (root.dataset.bound === "1") return;
|
|
90
|
-
root.dataset.bound = "1";
|
|
91
|
-
|
|
92
|
-
const valueEl = root.querySelector("[data-light-number-value]");
|
|
93
|
-
const signEl = root.querySelector("[data-light-number-sign]");
|
|
94
|
-
if (!(valueEl instanceof HTMLElement)) return;
|
|
95
|
-
|
|
96
|
-
const start = Number(root.dataset.start ?? "0");
|
|
97
|
-
const end = Number(root.dataset.end ?? "0");
|
|
98
|
-
const duration = Number(root.dataset.duration ?? "1200");
|
|
99
|
-
const once = root.dataset.once === "1";
|
|
100
|
-
const type = root.dataset.type === "float" ? "float" : "int";
|
|
101
|
-
const fractionDigits = Number(root.dataset.fractionDigits ?? "1");
|
|
102
|
-
|
|
103
|
-
let running = false;
|
|
104
|
-
let played = false;
|
|
105
|
-
let rafId = 0;
|
|
106
|
-
|
|
107
|
-
const format = (n) => {
|
|
108
|
-
if (type === "float") {
|
|
109
|
-
return n.toFixed(
|
|
110
|
-
Number.isFinite(fractionDigits) ? fractionDigits : 1
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
return String(Math.round(n));
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const setValue = (n) => {
|
|
117
|
-
valueEl.textContent = format(n);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const showSign = () => {
|
|
121
|
-
if (signEl instanceof HTMLElement) {
|
|
122
|
-
signEl.style.display = "";
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const animate = () => {
|
|
127
|
-
if (running) return;
|
|
128
|
-
if (once && played) return;
|
|
129
|
-
|
|
130
|
-
running = true;
|
|
131
|
-
played = true;
|
|
132
|
-
showSign();
|
|
133
|
-
|
|
134
|
-
const from = start;
|
|
135
|
-
const to = end;
|
|
136
|
-
const t0 = performance.now();
|
|
137
|
-
|
|
138
|
-
const step = (t) => {
|
|
139
|
-
const p = Math.min(1, (t - t0) / Math.max(16, duration));
|
|
140
|
-
const eased = 1 - Math.pow(1 - p, 3);
|
|
141
|
-
const v = from + (to - from) * eased;
|
|
142
|
-
setValue(v);
|
|
143
|
-
if (p < 1) {
|
|
144
|
-
rafId = requestAnimationFrame(step);
|
|
145
|
-
} else {
|
|
146
|
-
running = false;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
cancelAnimationFrame(rafId);
|
|
151
|
-
rafId = requestAnimationFrame(step);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const isInViewport = () => {
|
|
155
|
-
const rect = root.getBoundingClientRect();
|
|
156
|
-
const vh = window.innerHeight || document.documentElement.clientHeight;
|
|
157
|
-
return rect.bottom > 0 && rect.top < vh;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
if (typeof IntersectionObserver === "undefined") {
|
|
161
|
-
if (isInViewport()) animate();
|
|
162
|
-
else window.addEventListener("scroll", animate, { passive: true, once: true });
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const io = new IntersectionObserver(
|
|
167
|
-
(entries) => {
|
|
168
|
-
entries.forEach((entry) => {
|
|
169
|
-
if (!entry.isIntersecting) return;
|
|
170
|
-
animate();
|
|
171
|
-
if (once) io.disconnect();
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
{ threshold: 0.25 }
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
io.observe(root);
|
|
178
|
-
|
|
179
|
-
if (isInViewport()) animate();
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const boot = () => {
|
|
184
|
-
init();
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
bindAstroLifecycle("light-number:boot", boot);
|
|
188
|
-
|
|
189
|
-
if (!state.moBound) {
|
|
190
|
-
state.moBound = true;
|
|
191
|
-
const mo = new MutationObserver((mutations) => {
|
|
192
|
-
for (const m of mutations) {
|
|
193
|
-
if (!m.addedNodes || m.addedNodes.length === 0) continue;
|
|
194
|
-
for (const n of m.addedNodes) {
|
|
195
|
-
if (!(n instanceof Element)) continue;
|
|
196
|
-
if (n.matches && n.matches("[data-light-number]")) {
|
|
197
|
-
scheduleInit();
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
if (n.querySelector && n.querySelector("[data-light-number]")) {
|
|
201
|
-
scheduleInit();
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
if (document.body) {
|
|
208
|
-
mo.observe(document.body, { childList: true, subtree: true });
|
|
209
|
-
} else {
|
|
210
|
-
document.addEventListener(
|
|
211
|
-
"DOMContentLoaded",
|
|
212
|
-
() => mo.observe(document.body, { childList: true, subtree: true }),
|
|
213
|
-
{ once: true }
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
})();
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
start?: number;
|
|
4
|
+
end: number;
|
|
5
|
+
duration?: number;
|
|
6
|
+
class?: string;
|
|
7
|
+
sign?: string;
|
|
8
|
+
once?: boolean;
|
|
9
|
+
type?: "int" | "float";
|
|
10
|
+
fractionDigits?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
start = 0,
|
|
15
|
+
end,
|
|
16
|
+
duration = 1200,
|
|
17
|
+
class: className,
|
|
18
|
+
sign = "+",
|
|
19
|
+
once = false,
|
|
20
|
+
type = "int",
|
|
21
|
+
fractionDigits = 1,
|
|
22
|
+
} = Astro.props;
|
|
23
|
+
|
|
24
|
+
const id = crypto.randomUUID();
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<span
|
|
28
|
+
class={className}
|
|
29
|
+
data-light-number
|
|
30
|
+
data-id={id}
|
|
31
|
+
data-start={start}
|
|
32
|
+
data-end={end}
|
|
33
|
+
data-duration={duration}
|
|
34
|
+
data-once={once ? "1" : "0"}
|
|
35
|
+
data-type={type}
|
|
36
|
+
data-fraction-digits={fractionDigits}
|
|
37
|
+
>
|
|
38
|
+
<span data-light-number-value>{start}</span>
|
|
39
|
+
{
|
|
40
|
+
sign && (
|
|
41
|
+
<span data-light-number-sign style="display:none">
|
|
42
|
+
{sign}
|
|
43
|
+
</span>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
</span>
|
|
47
|
+
|
|
48
|
+
<script is:inline>
|
|
49
|
+
(() => {
|
|
50
|
+
const bindAstroLifecycle = (key, fn) => {
|
|
51
|
+
const w = window;
|
|
52
|
+
const bound = (w.__astro_lifecycle_bound__ ||= Object.create(null));
|
|
53
|
+
if (bound[key]) return;
|
|
54
|
+
bound[key] = true;
|
|
55
|
+
|
|
56
|
+
const boot = () => fn();
|
|
57
|
+
|
|
58
|
+
if (document.readyState === "loading") {
|
|
59
|
+
document.addEventListener("DOMContentLoaded", boot, { once: true });
|
|
60
|
+
} else {
|
|
61
|
+
boot();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
document.addEventListener("astro:page-load", boot);
|
|
65
|
+
document.addEventListener("astro:after-swap", boot);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const globalKey = "__light_number_state__";
|
|
69
|
+
const w = window;
|
|
70
|
+
const state = (w[globalKey] ||= {
|
|
71
|
+
docBound: false,
|
|
72
|
+
moBound: false,
|
|
73
|
+
scheduled: false,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const scheduleInit = () => {
|
|
77
|
+
if (state.scheduled) return;
|
|
78
|
+
state.scheduled = true;
|
|
79
|
+
requestAnimationFrame(() => {
|
|
80
|
+
state.scheduled = false;
|
|
81
|
+
init();
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const init = () => {
|
|
86
|
+
const nodes = document.querySelectorAll("[data-light-number]");
|
|
87
|
+
nodes.forEach((root) => {
|
|
88
|
+
if (!(root instanceof HTMLElement)) return;
|
|
89
|
+
if (root.dataset.bound === "1") return;
|
|
90
|
+
root.dataset.bound = "1";
|
|
91
|
+
|
|
92
|
+
const valueEl = root.querySelector("[data-light-number-value]");
|
|
93
|
+
const signEl = root.querySelector("[data-light-number-sign]");
|
|
94
|
+
if (!(valueEl instanceof HTMLElement)) return;
|
|
95
|
+
|
|
96
|
+
const start = Number(root.dataset.start ?? "0");
|
|
97
|
+
const end = Number(root.dataset.end ?? "0");
|
|
98
|
+
const duration = Number(root.dataset.duration ?? "1200");
|
|
99
|
+
const once = root.dataset.once === "1";
|
|
100
|
+
const type = root.dataset.type === "float" ? "float" : "int";
|
|
101
|
+
const fractionDigits = Number(root.dataset.fractionDigits ?? "1");
|
|
102
|
+
|
|
103
|
+
let running = false;
|
|
104
|
+
let played = false;
|
|
105
|
+
let rafId = 0;
|
|
106
|
+
|
|
107
|
+
const format = (n) => {
|
|
108
|
+
if (type === "float") {
|
|
109
|
+
return n.toFixed(
|
|
110
|
+
Number.isFinite(fractionDigits) ? fractionDigits : 1
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return String(Math.round(n));
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const setValue = (n) => {
|
|
117
|
+
valueEl.textContent = format(n);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const showSign = () => {
|
|
121
|
+
if (signEl instanceof HTMLElement) {
|
|
122
|
+
signEl.style.display = "";
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const animate = () => {
|
|
127
|
+
if (running) return;
|
|
128
|
+
if (once && played) return;
|
|
129
|
+
|
|
130
|
+
running = true;
|
|
131
|
+
played = true;
|
|
132
|
+
showSign();
|
|
133
|
+
|
|
134
|
+
const from = start;
|
|
135
|
+
const to = end;
|
|
136
|
+
const t0 = performance.now();
|
|
137
|
+
|
|
138
|
+
const step = (t) => {
|
|
139
|
+
const p = Math.min(1, (t - t0) / Math.max(16, duration));
|
|
140
|
+
const eased = 1 - Math.pow(1 - p, 3);
|
|
141
|
+
const v = from + (to - from) * eased;
|
|
142
|
+
setValue(v);
|
|
143
|
+
if (p < 1) {
|
|
144
|
+
rafId = requestAnimationFrame(step);
|
|
145
|
+
} else {
|
|
146
|
+
running = false;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
cancelAnimationFrame(rafId);
|
|
151
|
+
rafId = requestAnimationFrame(step);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const isInViewport = () => {
|
|
155
|
+
const rect = root.getBoundingClientRect();
|
|
156
|
+
const vh = window.innerHeight || document.documentElement.clientHeight;
|
|
157
|
+
return rect.bottom > 0 && rect.top < vh;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
161
|
+
if (isInViewport()) animate();
|
|
162
|
+
else window.addEventListener("scroll", animate, { passive: true, once: true });
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const io = new IntersectionObserver(
|
|
167
|
+
(entries) => {
|
|
168
|
+
entries.forEach((entry) => {
|
|
169
|
+
if (!entry.isIntersecting) return;
|
|
170
|
+
animate();
|
|
171
|
+
if (once) io.disconnect();
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
{ threshold: 0.25 }
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
io.observe(root);
|
|
178
|
+
|
|
179
|
+
if (isInViewport()) animate();
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const boot = () => {
|
|
184
|
+
init();
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
bindAstroLifecycle("light-number:boot", boot);
|
|
188
|
+
|
|
189
|
+
if (!state.moBound) {
|
|
190
|
+
state.moBound = true;
|
|
191
|
+
const mo = new MutationObserver((mutations) => {
|
|
192
|
+
for (const m of mutations) {
|
|
193
|
+
if (!m.addedNodes || m.addedNodes.length === 0) continue;
|
|
194
|
+
for (const n of m.addedNodes) {
|
|
195
|
+
if (!(n instanceof Element)) continue;
|
|
196
|
+
if (n.matches && n.matches("[data-light-number]")) {
|
|
197
|
+
scheduleInit();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (n.querySelector && n.querySelector("[data-light-number]")) {
|
|
201
|
+
scheduleInit();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
if (document.body) {
|
|
208
|
+
mo.observe(document.body, { childList: true, subtree: true });
|
|
209
|
+
} else {
|
|
210
|
+
document.addEventListener(
|
|
211
|
+
"DOMContentLoaded",
|
|
212
|
+
() => mo.observe(document.body, { childList: true, subtree: true }),
|
|
213
|
+
{ once: true }
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
})();
|
|
218
218
|
</script>
|