fancy-ui-vue 0.3.0 → 0.4.1
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 +9 -6
- package/dist/components/animated-testimonials/AnimatedTestimonials.vue.js +23 -12
- package/dist/components/bg-falling-stars/FallingStarsBg.vue.js +10 -1
- package/dist/components/bg-falling-stars/bg-falling-stars-core.d.ts +6 -0
- package/dist/components/bg-falling-stars/bg-falling-stars-core.js +24 -2
- package/dist/components/bg-stars/StarsBackground.vue.js +1 -1
- package/dist/components/bg-stars/StarsBackground.vue2.js +13 -1
- package/dist/components/bg-stars/bg-stars-core.d.ts +6 -0
- package/dist/components/bg-stars/bg-stars-core.js +21 -1
- package/dist/components/book/Book.vue.js +5 -83
- package/dist/components/book/Book.vue2.js +82 -1
- package/dist/components/box-reveal/BoxReveal.vue.js +5 -47
- package/dist/components/box-reveal/BoxReveal.vue2.js +48 -1
- package/dist/components/compare/StarField.vue.js +1 -1
- package/dist/components/container-text-flip/ContainerTextFlip.vue.js +1 -1
- package/dist/components/container-text-flip/ContainerTextFlip.vue2.js +14 -5
- package/dist/components/flickering-grid/FlickeringGrid.vue.js +19 -1
- package/dist/components/flickering-grid/flickering-grid-core.d.ts +6 -0
- package/dist/components/flickering-grid/flickering-grid-core.js +30 -1
- package/dist/components/flip-words/FlipWords.vue.js +1 -1
- package/dist/components/flip-words/FlipWords.vue2.js +14 -7
- package/dist/components/hyper-text/HyperText.vue.js +6 -97
- package/dist/components/hyper-text/HyperText.vue2.js +101 -0
- package/dist/components/letter-pullup/LetterPullup.vue.js +6 -38
- package/dist/components/letter-pullup/LetterPullup.vue2.js +40 -0
- package/dist/components/logo-cloud/AnimatedLogoCloud.vue.js +1 -1
- package/dist/components/magnetic-field/MagnetPuck.vue.d.ts +51 -0
- package/dist/components/magnetic-field/MagnetPuck.vue.js +7 -0
- package/dist/components/magnetic-field/MagnetPuck.vue2.js +191 -0
- package/dist/components/magnetic-field/MagneticField.vue.d.ts +39 -0
- package/dist/components/magnetic-field/MagneticField.vue.js +7 -0
- package/dist/components/magnetic-field/MagneticField.vue2.js +157 -0
- package/dist/components/magnetic-field/MagneticItem.vue.d.ts +28 -0
- package/dist/components/magnetic-field/MagneticItem.vue.js +7 -0
- package/dist/components/magnetic-field/MagneticItem.vue2.js +72 -0
- package/dist/components/magnetic-field/index.d.ts +10 -0
- package/dist/components/magnetic-field/magnetic-field-core.d.ts +163 -0
- package/dist/components/magnetic-field/magnetic-field-core.js +534 -0
- package/dist/components/magnetic-field/magnetic-field-source.d.ts +58 -0
- package/dist/components/magnetic-field/magnetic-field-source.js +58 -0
- package/dist/components/magnetic-field/types.d.ts +14 -0
- package/dist/components/magnetic-field/types.js +5 -0
- package/dist/components/matrix-rain/MatrixRain.vue.js +20 -1
- package/dist/components/matrix-rain/matrix-rain-core.d.ts +6 -0
- package/dist/components/matrix-rain/matrix-rain-core.js +28 -6
- package/dist/components/noise-reveal/NoiseReveal.vue.js +7 -0
- package/dist/components/noise-reveal/noise-reveal-core.js +23 -7
- package/dist/components/pixel-scene/PixelScene.vue.d.ts +60 -0
- package/dist/components/pixel-scene/PixelScene.vue.js +184 -0
- package/dist/components/pixel-scene/PixelScene.vue2.js +4 -0
- package/dist/components/pixel-scene/index.d.ts +4 -0
- package/dist/components/pixel-scene/pixel-scene-core.d.ts +256 -0
- package/dist/components/pixel-scene/pixel-scene-core.js +878 -0
- package/dist/components/pixel-scene/pixel-scene-hdr.d.ts +68 -0
- package/dist/components/pixel-scene/pixel-scene-hdr.js +312 -0
- package/dist/components/pixel-scene/pixel-scene-scenes.d.ts +31 -0
- package/dist/components/pixel-scene/pixel-scene-scenes.js +1074 -0
- package/dist/components/ripple/Ripple.vue.js +1 -1
- package/dist/components/ripple/Ripple.vue2.js +6 -1
- package/dist/components/sparkles/Sparkles.vue.js +10 -1
- package/dist/components/sparkles/sparkles-core.d.ts +6 -0
- package/dist/components/sparkles/sparkles-core.js +26 -2
- package/dist/components/sparkles-text/SparklesText.vue.js +6 -88
- package/dist/components/sparkles-text/SparklesText.vue2.js +100 -0
- package/dist/components/story-thread/StoryNode.vue.d.ts +11 -0
- package/dist/components/story-thread/StoryNode.vue.js +7 -0
- package/dist/components/story-thread/StoryNode.vue2.js +23 -0
- package/dist/components/story-thread/StoryThread.vue.d.ts +56 -0
- package/dist/components/story-thread/StoryThread.vue.js +7 -0
- package/dist/components/story-thread/StoryThread.vue2.js +103 -0
- package/dist/components/story-thread/index.d.ts +5 -0
- package/dist/components/story-thread/story-thread-core.d.ts +119 -0
- package/dist/components/story-thread/story-thread-core.js +491 -0
- package/dist/components/story-thread/types.d.ts +1 -0
- package/dist/components/sun-switch/SunSwitch.vue.d.ts +61 -0
- package/dist/components/sun-switch/SunSwitch.vue.js +7 -0
- package/dist/components/sun-switch/SunSwitch.vue2.js +559 -0
- package/dist/components/sun-switch/index.d.ts +4 -0
- package/dist/components/sun-switch/pixel-wave-core.d.ts +82 -0
- package/dist/components/sun-switch/pixel-wave-core.js +508 -0
- package/dist/components/sun-switch/sun-switch-core.d.ts +251 -0
- package/dist/components/sun-switch/sun-switch-core.js +546 -0
- package/dist/components/sun-switch/sun-switch-hdr.d.ts +70 -0
- package/dist/components/sun-switch/sun-switch-hdr.js +311 -0
- package/dist/components/terminal-text/TerminalText.vue.js +1 -1
- package/dist/components/terminal-text/TerminalText.vue2.js +36 -4
- package/dist/components/text-generate-effect/TextGenerateEffect.vue.js +5 -72
- package/dist/components/text-generate-effect/TextGenerateEffect.vue2.js +74 -1
- package/dist/components/text-reveal-card/TextRevealCard.vue.js +5 -101
- package/dist/components/text-reveal-card/TextRevealCard.vue2.js +98 -1
- package/dist/components/text-reveal-card/TextRevealStars.vue.js +1 -1
- package/dist/components/text-reveal-card/TextRevealStars.vue2.js +29 -12
- package/dist/components/tracing-beam/TracingBeam.vue.d.ts +20 -1
- package/dist/components/tracing-beam/TracingBeam.vue.js +5 -164
- package/dist/components/tracing-beam/TracingBeam.vue2.js +168 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +361 -338
- package/dist/styles.css +731 -89
- package/package.json +1 -1
- package/dist/components/hyper-text/HyperText.vue3.js +0 -5
- package/dist/components/letter-pullup/LetterPullup.vue3.js +0 -5
- package/dist/components/sparkles-text/SparklesText.vue3.js +0 -5
|
@@ -2,7 +2,7 @@ import _sfc_main from "./Ripple.vue2.js";
|
|
|
2
2
|
/* empty css */
|
|
3
3
|
/* empty css */
|
|
4
4
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
5
|
-
const Ripple = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
5
|
+
const Ripple = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-cf5b782d"]]);
|
|
6
6
|
export {
|
|
7
7
|
Ripple as default
|
|
8
8
|
};
|
|
@@ -30,7 +30,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
30
30
|
(openBlock(true), createElementBlock(Fragment, null, renderList(circles.value, (circle, i) => {
|
|
31
31
|
return openBlock(), createElementBlock("div", {
|
|
32
32
|
key: i,
|
|
33
|
-
class: normalizeClass(
|
|
33
|
+
class: normalizeClass(
|
|
34
|
+
unref(cn)(
|
|
35
|
+
"animate-ripple-circle absolute rounded-full shadow-xl motion-reduce:animate-none",
|
|
36
|
+
__props.circleClass
|
|
37
|
+
)
|
|
38
|
+
),
|
|
34
39
|
style: normalizeStyle(`width: ${circle.size}px; height: ${circle.size}px; opacity: ${circle.opacity}; animation-delay: ${circle.delay}ms; border-style: ${circle.borderStyle}; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(1); border-width: 1px;`)
|
|
35
40
|
}, null, 6);
|
|
36
41
|
}), 128))
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineComponent, useTemplateRef, onMounted, onBeforeUnmount, watch, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createElementVNode } from "vue";
|
|
2
2
|
import { cn } from "../../utils.js";
|
|
3
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
3
4
|
import { createSparkles } from "./sparkles-core.js";
|
|
4
5
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
6
|
...{ name: "Sparkles", inheritAttrs: false },
|
|
@@ -18,11 +19,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
18
19
|
const canvasRef = useTemplateRef("canvasRef");
|
|
19
20
|
let engine = null;
|
|
20
21
|
let resizeObserver = null;
|
|
22
|
+
const reducedMotion = useReducedMotion();
|
|
21
23
|
onMounted(() => {
|
|
22
24
|
if (!canvasRef.value || !containerRef.value) return;
|
|
23
25
|
engine = createSparkles(
|
|
24
26
|
{ canvas: canvasRef.value, container: containerRef.value },
|
|
25
|
-
{ minSize: __props.minSize, maxSize: __props.maxSize, speed: __props.speed, particleDensity: __props.particleDensity, particleColor: __props.particleColor }
|
|
27
|
+
{ minSize: __props.minSize, maxSize: __props.maxSize, speed: __props.speed, particleDensity: __props.particleDensity, particleColor: __props.particleColor, reducedMotion: reducedMotion.value }
|
|
26
28
|
);
|
|
27
29
|
resizeObserver = new ResizeObserver(() => engine?.resize());
|
|
28
30
|
resizeObserver.observe(containerRef.value);
|
|
@@ -38,6 +40,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
38
40
|
(color) => engine?.setOptions({ particleColor: color }),
|
|
39
41
|
{ flush: "post" }
|
|
40
42
|
);
|
|
43
|
+
watch(
|
|
44
|
+
reducedMotion,
|
|
45
|
+
(next) => {
|
|
46
|
+
engine?.setOptions({ reducedMotion: next });
|
|
47
|
+
},
|
|
48
|
+
{ flush: "post" }
|
|
49
|
+
);
|
|
41
50
|
return (_ctx, _cache) => {
|
|
42
51
|
return openBlock(), createElementBlock("div", {
|
|
43
52
|
ref_key: "containerRef",
|
|
@@ -17,6 +17,12 @@ export interface SparklesInitOptions {
|
|
|
17
17
|
export interface SparklesLiveOptions {
|
|
18
18
|
/** Hex color (e.g. "#ffffff") or `currentColor` particles are filled with; re-read every frame. */
|
|
19
19
|
particleColor?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Reduced-motion preference, owned by the wrapper (the core never reads
|
|
22
|
+
* `matchMedia`). When true the engine paints one still frame and idles; a
|
|
23
|
+
* flip back to false resumes the drift.
|
|
24
|
+
*/
|
|
25
|
+
reducedMotion?: boolean;
|
|
20
26
|
}
|
|
21
27
|
export interface SparklesEngine {
|
|
22
28
|
setOptions(next: Partial<SparklesLiveOptions>): void;
|
|
@@ -42,6 +42,7 @@ function createSparkles(elements, options, random = Math.random) {
|
|
|
42
42
|
let particles = [];
|
|
43
43
|
let dpr = 1;
|
|
44
44
|
let rafId = 0;
|
|
45
|
+
let reducedMotion = options.reducedMotion ?? false;
|
|
45
46
|
let destroyed = false;
|
|
46
47
|
function resize() {
|
|
47
48
|
if (destroyed) return;
|
|
@@ -51,6 +52,7 @@ function createSparkles(elements, options, random = Math.random) {
|
|
|
51
52
|
canvas.height = rect.height * dpr;
|
|
52
53
|
ctx = canvas.getContext("2d");
|
|
53
54
|
if (ctx) ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
55
|
+
if (reducedMotion && rafId === 0 && particles.length > 0) updateAndDraw();
|
|
54
56
|
}
|
|
55
57
|
function generateParticles() {
|
|
56
58
|
particles = [];
|
|
@@ -93,19 +95,41 @@ function createSparkles(elements, options, random = Math.random) {
|
|
|
93
95
|
ctx.fillStyle = `${fill}${Math.floor(opacity * 255).toString(16).padStart(2, "0")}`;
|
|
94
96
|
ctx.fill();
|
|
95
97
|
}
|
|
98
|
+
if (reducedMotion) {
|
|
99
|
+
rafId = 0;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
96
102
|
rafId = requestAnimationFrame(updateAndDraw);
|
|
97
103
|
}
|
|
98
104
|
resize();
|
|
99
105
|
generateParticles();
|
|
100
|
-
|
|
106
|
+
if (reducedMotion) updateAndDraw();
|
|
107
|
+
else rafId = requestAnimationFrame(updateAndDraw);
|
|
108
|
+
const themeObserver = typeof MutationObserver !== "undefined" ? new MutationObserver(() => {
|
|
109
|
+
if (reducedMotion && rafId === 0 && CURRENT_COLOR.test(particleColor)) updateAndDraw();
|
|
110
|
+
}) : null;
|
|
111
|
+
themeObserver?.observe(document.documentElement, {
|
|
112
|
+
attributes: true,
|
|
113
|
+
attributeFilter: ["class"]
|
|
114
|
+
});
|
|
101
115
|
return {
|
|
102
116
|
setOptions(next) {
|
|
103
|
-
if (
|
|
117
|
+
if (destroyed) return;
|
|
118
|
+
const wasReduced = reducedMotion;
|
|
119
|
+
if (next.reducedMotion !== void 0) reducedMotion = next.reducedMotion;
|
|
120
|
+
if (next.particleColor !== void 0 && next.particleColor !== particleColor) {
|
|
121
|
+
particleColor = next.particleColor;
|
|
122
|
+
if (reducedMotion && rafId === 0) updateAndDraw();
|
|
123
|
+
}
|
|
124
|
+
if (wasReduced && !reducedMotion && rafId === 0) {
|
|
125
|
+
rafId = requestAnimationFrame(updateAndDraw);
|
|
126
|
+
}
|
|
104
127
|
},
|
|
105
128
|
resize,
|
|
106
129
|
destroy() {
|
|
107
130
|
if (destroyed) return;
|
|
108
131
|
destroyed = true;
|
|
132
|
+
themeObserver?.disconnect();
|
|
109
133
|
cancelAnimationFrame(rafId);
|
|
110
134
|
}
|
|
111
135
|
};
|
|
@@ -1,90 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let state = seed >>> 0;
|
|
7
|
-
return () => {
|
|
8
|
-
state = state + 1831565813 >>> 0;
|
|
9
|
-
let t = state;
|
|
10
|
-
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
11
|
-
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
12
|
-
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function generateStar(random, colors) {
|
|
16
|
-
const x = `${random() * 100}%`;
|
|
17
|
-
const y = `${random() * 100}%`;
|
|
18
|
-
const color = random() > 0.5 ? colors.first : colors.second;
|
|
19
|
-
const delay = random() * 2;
|
|
20
|
-
const scale = random() * 1 + 0.3;
|
|
21
|
-
const lifespan = random() * 10 + 5;
|
|
22
|
-
const id = `${x}-${y}-${random()}`;
|
|
23
|
-
return { id, x, y, color, delay, scale, lifespan };
|
|
24
|
-
}
|
|
25
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
26
|
-
...{ name: "SparklesText", inheritAttrs: false },
|
|
27
|
-
__name: "SparklesText",
|
|
28
|
-
props: {
|
|
29
|
-
text: {},
|
|
30
|
-
sparklesCount: { default: 10 },
|
|
31
|
-
colors: { default: () => ({ first: "#9E7AFF", second: "#FE8BBB" }) },
|
|
32
|
-
class: { type: [Boolean, null, String, Object, Array] },
|
|
33
|
-
seed: { default: 1 }
|
|
34
|
-
},
|
|
35
|
-
setup(__props) {
|
|
36
|
-
const initialRandom = mulberry32(__props.seed);
|
|
37
|
-
const sparkles = ref(
|
|
38
|
-
Array.from({ length: __props.sparklesCount }, () => generateStar(initialRandom, __props.colors))
|
|
39
|
-
);
|
|
40
|
-
let intervalId;
|
|
41
|
-
onMounted(() => {
|
|
42
|
-
const random = mulberry32(__props.seed + 1);
|
|
43
|
-
intervalId = setInterval(() => {
|
|
44
|
-
sparkles.value = sparkles.value.map((star) => {
|
|
45
|
-
if (star.lifespan <= 0) {
|
|
46
|
-
return generateStar(random, __props.colors);
|
|
47
|
-
}
|
|
48
|
-
return { ...star, lifespan: star.lifespan - 0.1 };
|
|
49
|
-
});
|
|
50
|
-
}, 100);
|
|
51
|
-
});
|
|
52
|
-
onBeforeUnmount(() => {
|
|
53
|
-
if (intervalId !== void 0) clearInterval(intervalId);
|
|
54
|
-
});
|
|
55
|
-
return (_ctx, _cache) => {
|
|
56
|
-
return openBlock(), createElementBlock("div", {
|
|
57
|
-
class: normalizeClass(unref(cn)("sparkles-text text-6xl font-bold", __props.class))
|
|
58
|
-
}, [
|
|
59
|
-
createElementVNode("span", _hoisted_1, [
|
|
60
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(sparkles.value, (sparkle) => {
|
|
61
|
-
return openBlock(), createElementBlock("svg", {
|
|
62
|
-
key: sparkle.id,
|
|
63
|
-
class: "sparkles-star pointer-events-none absolute z-20",
|
|
64
|
-
style: normalizeStyle({
|
|
65
|
-
left: sparkle.x,
|
|
66
|
-
top: sparkle.y,
|
|
67
|
-
"--sparkle-scale": `${sparkle.scale}`,
|
|
68
|
-
animation: `sparkleAnim 0.8s ease-in-out ${sparkle.delay}s infinite`,
|
|
69
|
-
transform: "scale(0) rotate(75deg)",
|
|
70
|
-
opacity: 0
|
|
71
|
-
}),
|
|
72
|
-
width: "21",
|
|
73
|
-
height: "21",
|
|
74
|
-
viewBox: "0 0 21 21"
|
|
75
|
-
}, [
|
|
76
|
-
createElementVNode("path", {
|
|
77
|
-
d: "M9.82531 0.843845C10.0553 0.215178 10.9446 0.215178 11.1746 0.843845L11.8618 2.72026C12.4006 4.19229 12.3916 6.39157 13.5 7.5C14.6084 8.60843 16.8077 8.59935 18.2797 9.13822L20.1561 9.82534C20.7858 10.0553 20.7858 10.9447 20.1561 11.1747L18.2797 11.8618C16.8077 12.4007 14.6084 12.3916 13.5 13.5C12.3916 14.6084 12.4006 16.8077 11.8618 18.2798L11.1746 20.1562C10.9446 20.7858 10.0553 20.7858 9.82531 20.1562L9.13819 18.2798C8.59932 16.8077 8.60843 14.6084 7.5 13.5C6.39157 12.3916 4.19225 12.4007 2.72023 11.8618L0.843814 11.1747C0.215148 10.9447 0.215148 10.0553 0.843814 9.82534L2.72023 9.13822C4.19225 8.59935 6.39157 8.60843 7.5 7.5C8.60843 6.39157 8.59932 4.19229 9.13819 2.72026L9.82531 0.843845Z",
|
|
78
|
-
fill: sparkle.color
|
|
79
|
-
}, null, 8, _hoisted_2)
|
|
80
|
-
], 4);
|
|
81
|
-
}), 128)),
|
|
82
|
-
createTextVNode(" " + toDisplayString(__props.text), 1)
|
|
83
|
-
])
|
|
84
|
-
], 2);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
});
|
|
1
|
+
import _sfc_main from "./SparklesText.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
/* empty css */
|
|
4
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
5
|
+
const SparklesText = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f06a1c48"]]);
|
|
88
6
|
export {
|
|
89
|
-
|
|
7
|
+
SparklesText as default
|
|
90
8
|
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { defineComponent, ref, onMounted, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, createTextVNode, Fragment, renderList, normalizeStyle, toDisplayString } from "vue";
|
|
2
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
3
|
+
import { cn } from "../../utils.js";
|
|
4
|
+
const _hoisted_1 = { class: "relative inline-block" };
|
|
5
|
+
const _hoisted_2 = ["fill"];
|
|
6
|
+
function mulberry32(seed) {
|
|
7
|
+
let state = seed >>> 0;
|
|
8
|
+
return () => {
|
|
9
|
+
state = state + 1831565813 >>> 0;
|
|
10
|
+
let t = state;
|
|
11
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
12
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
13
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function generateStar(random, colors) {
|
|
17
|
+
const x = `${random() * 100}%`;
|
|
18
|
+
const y = `${random() * 100}%`;
|
|
19
|
+
const color = random() > 0.5 ? colors.first : colors.second;
|
|
20
|
+
const delay = random() * 2;
|
|
21
|
+
const scale = random() * 1 + 0.3;
|
|
22
|
+
const lifespan = random() * 10 + 5;
|
|
23
|
+
const id = `${x}-${y}-${random()}`;
|
|
24
|
+
return { id, x, y, color, delay, scale, lifespan };
|
|
25
|
+
}
|
|
26
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
27
|
+
...{ name: "SparklesText", inheritAttrs: false },
|
|
28
|
+
__name: "SparklesText",
|
|
29
|
+
props: {
|
|
30
|
+
text: {},
|
|
31
|
+
sparklesCount: { default: 10 },
|
|
32
|
+
colors: { default: () => ({ first: "#9E7AFF", second: "#FE8BBB" }) },
|
|
33
|
+
class: { type: [Boolean, null, String, Object, Array] },
|
|
34
|
+
seed: { default: 1 }
|
|
35
|
+
},
|
|
36
|
+
setup(__props) {
|
|
37
|
+
const initialRandom = mulberry32(__props.seed);
|
|
38
|
+
const sparkles = ref(
|
|
39
|
+
Array.from({ length: __props.sparklesCount }, () => generateStar(initialRandom, __props.colors))
|
|
40
|
+
);
|
|
41
|
+
let intervalId;
|
|
42
|
+
function stop() {
|
|
43
|
+
if (intervalId !== void 0) clearInterval(intervalId);
|
|
44
|
+
intervalId = void 0;
|
|
45
|
+
}
|
|
46
|
+
const reducedMotion = useReducedMotion();
|
|
47
|
+
onMounted(() => {
|
|
48
|
+
const random = mulberry32(__props.seed + 1);
|
|
49
|
+
watch(
|
|
50
|
+
reducedMotion,
|
|
51
|
+
(reduced) => {
|
|
52
|
+
stop();
|
|
53
|
+
if (reduced) return;
|
|
54
|
+
intervalId = setInterval(() => {
|
|
55
|
+
sparkles.value = sparkles.value.map((star) => {
|
|
56
|
+
if (star.lifespan <= 0) {
|
|
57
|
+
return generateStar(random, __props.colors);
|
|
58
|
+
}
|
|
59
|
+
return { ...star, lifespan: star.lifespan - 0.1 };
|
|
60
|
+
});
|
|
61
|
+
}, 100);
|
|
62
|
+
},
|
|
63
|
+
{ flush: "post", immediate: true }
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
onBeforeUnmount(stop);
|
|
67
|
+
return (_ctx, _cache) => {
|
|
68
|
+
return openBlock(), createElementBlock("div", {
|
|
69
|
+
class: normalizeClass(unref(cn)("sparkles-text text-6xl font-bold", __props.class))
|
|
70
|
+
}, [
|
|
71
|
+
createElementVNode("span", _hoisted_1, [
|
|
72
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(sparkles.value, (sparkle) => {
|
|
73
|
+
return openBlock(), createElementBlock("svg", {
|
|
74
|
+
key: sparkle.id,
|
|
75
|
+
class: "sparkles-star pointer-events-none absolute z-20",
|
|
76
|
+
style: normalizeStyle({
|
|
77
|
+
left: sparkle.x,
|
|
78
|
+
top: sparkle.y,
|
|
79
|
+
"--sparkle-scale": `${sparkle.scale}`,
|
|
80
|
+
"--sparkles-text-delay": `${sparkle.delay}s`
|
|
81
|
+
}),
|
|
82
|
+
width: "21",
|
|
83
|
+
height: "21",
|
|
84
|
+
viewBox: "0 0 21 21"
|
|
85
|
+
}, [
|
|
86
|
+
createElementVNode("path", {
|
|
87
|
+
d: "M9.82531 0.843845C10.0553 0.215178 10.9446 0.215178 11.1746 0.843845L11.8618 2.72026C12.4006 4.19229 12.3916 6.39157 13.5 7.5C14.6084 8.60843 16.8077 8.59935 18.2797 9.13822L20.1561 9.82534C20.7858 10.0553 20.7858 10.9447 20.1561 11.1747L18.2797 11.8618C16.8077 12.4007 14.6084 12.3916 13.5 13.5C12.3916 14.6084 12.4006 16.8077 11.8618 18.2798L11.1746 20.1562C10.9446 20.7858 10.0553 20.7858 9.82531 20.1562L9.13819 18.2798C8.59932 16.8077 8.60843 14.6084 7.5 13.5C6.39157 12.3916 4.19225 12.4007 2.72023 11.8618L0.843814 11.1747C0.215148 10.9447 0.215148 10.0553 0.843814 9.82534L2.72023 9.13822C4.19225 8.59935 6.39157 8.60843 7.5 7.5C8.60843 6.39157 8.59932 4.19229 9.13819 2.72026L9.82531 0.843845Z",
|
|
88
|
+
fill: sparkle.color
|
|
89
|
+
}, null, 8, _hoisted_2)
|
|
90
|
+
], 4);
|
|
91
|
+
}), 128)),
|
|
92
|
+
createTextVNode(" " + toDisplayString(__props.text), 1)
|
|
93
|
+
])
|
|
94
|
+
], 2);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
export {
|
|
99
|
+
_sfc_main as default
|
|
100
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface StoryNodeProps {
|
|
2
|
+
/** Id the thread runs through; referenced by StoryThread's `segments`. */
|
|
3
|
+
id: string;
|
|
4
|
+
/** `"dot"` is a filled dot; `"ring"` a hollow ring, for a fork or a destination. */
|
|
5
|
+
variant?: "dot" | "ring";
|
|
6
|
+
}
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<StoryNodeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<StoryNodeProps> & Readonly<{}>, {
|
|
10
|
+
variant: "dot" | "ring";
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _sfc_main from "./StoryNode.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const StoryNode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c134385b"]]);
|
|
5
|
+
export {
|
|
6
|
+
StoryNode as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineComponent, createElementBlock, openBlock, mergeProps } from "vue";
|
|
2
|
+
const _hoisted_1 = ["data-story-node", "data-variant"];
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
...{ name: "StoryNode", inheritAttrs: false },
|
|
5
|
+
__name: "StoryNode",
|
|
6
|
+
props: {
|
|
7
|
+
id: {},
|
|
8
|
+
variant: { default: "dot" }
|
|
9
|
+
},
|
|
10
|
+
setup(__props) {
|
|
11
|
+
return (_ctx, _cache) => {
|
|
12
|
+
return openBlock(), createElementBlock("span", mergeProps(_ctx.$attrs, {
|
|
13
|
+
class: "st-node",
|
|
14
|
+
"data-story-node": __props.id,
|
|
15
|
+
"data-variant": __props.variant,
|
|
16
|
+
"aria-hidden": "true"
|
|
17
|
+
}), null, 16, _hoisted_1);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
export {
|
|
22
|
+
_sfc_main as default
|
|
23
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "vue";
|
|
2
|
+
import type { StoryThreadDash, StoryThreadLayout, StoryThreadSegment } from "./types.js";
|
|
3
|
+
export interface StoryThreadProps {
|
|
4
|
+
/**
|
|
5
|
+
* `"horizontal"` pins a full-height viewport and pans the content sideways
|
|
6
|
+
* as the page scrolls; `"vertical"` keeps a plain stack. `"auto"` is
|
|
7
|
+
* horizontal from 900 × 520 px up, vertical below.
|
|
8
|
+
*/
|
|
9
|
+
layout?: StoryThreadLayout;
|
|
10
|
+
/**
|
|
11
|
+
* The thread's segments, each through a list of StoryNode ids. Leave it
|
|
12
|
+
* out for one segment through every node in document order. Several
|
|
13
|
+
* segments that leave the same node and meet again draw a fork whose
|
|
14
|
+
* branches advance together.
|
|
15
|
+
*/
|
|
16
|
+
segments?: StoryThreadSegment[];
|
|
17
|
+
/** Where the tip of the thread sits in the viewport, 0..1 along the reading axis. */
|
|
18
|
+
lead?: number;
|
|
19
|
+
/** Curve tension between nodes: 0 draws straight lines, 1 long flat tangents. */
|
|
20
|
+
tension?: number;
|
|
21
|
+
/** Stroke pattern of the thread. */
|
|
22
|
+
dash?: StoryThreadDash;
|
|
23
|
+
/** Draw a glowing dot at the tip of every segment while it is drawing. */
|
|
24
|
+
head?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Plays a soft `tick` each time the thread reaches a node going forward.
|
|
27
|
+
* Off by default; only audible once the user has enabled sound.
|
|
28
|
+
*/
|
|
29
|
+
sound?: boolean;
|
|
30
|
+
/** Called with a node's id each time the thread reaches it going forward. */
|
|
31
|
+
onReach?: (id: string) => void;
|
|
32
|
+
/** Accessible name of the region. */
|
|
33
|
+
ariaLabel?: string;
|
|
34
|
+
/** Additional CSS classes on the root. */
|
|
35
|
+
class?: HTMLAttributes["class"];
|
|
36
|
+
}
|
|
37
|
+
declare const _default: typeof __VLS_export;
|
|
38
|
+
export default _default;
|
|
39
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<StoryThreadProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<StoryThreadProps> & Readonly<{}>, {
|
|
40
|
+
head: boolean;
|
|
41
|
+
sound: boolean;
|
|
42
|
+
ariaLabel: string;
|
|
43
|
+
layout: StoryThreadLayout;
|
|
44
|
+
segments: StoryThreadSegment[];
|
|
45
|
+
lead: number;
|
|
46
|
+
tension: number;
|
|
47
|
+
dash: StoryThreadDash;
|
|
48
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
49
|
+
/** The story: sections holding StoryNode anchors. */
|
|
50
|
+
default?(): unknown;
|
|
51
|
+
}>;
|
|
52
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
53
|
+
new (): {
|
|
54
|
+
$slots: S;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _sfc_main from "./StoryThread.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const StoryThread = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-dc205dfd"]]);
|
|
5
|
+
export {
|
|
6
|
+
StoryThread as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { defineComponent, useTemplateRef, shallowRef, onMounted, onBeforeUnmount, watch, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, renderSlot } from "vue";
|
|
2
|
+
import { cn } from "../../utils.js";
|
|
3
|
+
import { sound } from "../../sound/sound.js";
|
|
4
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
5
|
+
import { STORY_THREAD_DEFAULTS, createStoryThread } from "./story-thread-core.js";
|
|
6
|
+
const _hoisted_1 = ["aria-label"];
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
...{ name: "StoryThread", inheritAttrs: false },
|
|
9
|
+
__name: "StoryThread",
|
|
10
|
+
props: {
|
|
11
|
+
layout: { default: STORY_THREAD_DEFAULTS.layout },
|
|
12
|
+
segments: { default: () => [] },
|
|
13
|
+
lead: { default: STORY_THREAD_DEFAULTS.lead },
|
|
14
|
+
tension: { default: STORY_THREAD_DEFAULTS.tension },
|
|
15
|
+
dash: { default: STORY_THREAD_DEFAULTS.dash },
|
|
16
|
+
head: { type: Boolean, default: STORY_THREAD_DEFAULTS.head },
|
|
17
|
+
sound: { type: Boolean, default: false },
|
|
18
|
+
onReach: {},
|
|
19
|
+
ariaLabel: { default: "Story" },
|
|
20
|
+
class: { type: [Boolean, null, String, Object, Array] }
|
|
21
|
+
},
|
|
22
|
+
setup(__props) {
|
|
23
|
+
const props = __props;
|
|
24
|
+
const root = useTemplateRef("root");
|
|
25
|
+
const viewport = useTemplateRef("viewport");
|
|
26
|
+
const track = useTemplateRef("track");
|
|
27
|
+
const svg = useTemplateRef("svg");
|
|
28
|
+
const core = shallowRef(null);
|
|
29
|
+
const reduced = useReducedMotion();
|
|
30
|
+
function options() {
|
|
31
|
+
return {
|
|
32
|
+
layout: props.layout,
|
|
33
|
+
segments: props.segments,
|
|
34
|
+
lead: props.lead,
|
|
35
|
+
tension: props.tension,
|
|
36
|
+
dash: props.dash,
|
|
37
|
+
head: props.head,
|
|
38
|
+
reducedMotion: reduced.value
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
onMounted(() => {
|
|
42
|
+
if (!root.value || !viewport.value || !track.value || !svg.value) return;
|
|
43
|
+
core.value = createStoryThread(root.value, viewport.value, track.value, svg.value, {
|
|
44
|
+
...options(),
|
|
45
|
+
onReach(id) {
|
|
46
|
+
if (props.sound) sound.play("tick", { volume: 0.5 });
|
|
47
|
+
props.onReach?.(id);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
onBeforeUnmount(() => {
|
|
52
|
+
core.value?.destroy();
|
|
53
|
+
core.value = null;
|
|
54
|
+
});
|
|
55
|
+
watch(
|
|
56
|
+
[
|
|
57
|
+
() => props.layout,
|
|
58
|
+
() => props.segments,
|
|
59
|
+
() => props.lead,
|
|
60
|
+
() => props.tension,
|
|
61
|
+
() => props.dash,
|
|
62
|
+
() => props.head,
|
|
63
|
+
reduced
|
|
64
|
+
],
|
|
65
|
+
() => core.value?.update(options()),
|
|
66
|
+
{ flush: "post" }
|
|
67
|
+
);
|
|
68
|
+
return (_ctx, _cache) => {
|
|
69
|
+
return openBlock(), createElementBlock("div", {
|
|
70
|
+
ref_key: "root",
|
|
71
|
+
ref: root,
|
|
72
|
+
class: normalizeClass(unref(cn)("st-root", props.class)),
|
|
73
|
+
role: "region",
|
|
74
|
+
"aria-label": __props.ariaLabel,
|
|
75
|
+
tabindex: "0"
|
|
76
|
+
}, [
|
|
77
|
+
createElementVNode("div", {
|
|
78
|
+
ref_key: "viewport",
|
|
79
|
+
ref: viewport,
|
|
80
|
+
class: "st-viewport"
|
|
81
|
+
}, [
|
|
82
|
+
createElementVNode("div", {
|
|
83
|
+
ref_key: "track",
|
|
84
|
+
ref: track,
|
|
85
|
+
class: "st-track"
|
|
86
|
+
}, [
|
|
87
|
+
(openBlock(), createElementBlock("svg", {
|
|
88
|
+
ref_key: "svg",
|
|
89
|
+
ref: svg,
|
|
90
|
+
class: "st-svg",
|
|
91
|
+
"aria-hidden": "true",
|
|
92
|
+
focusable: "false"
|
|
93
|
+
}, null, 512)),
|
|
94
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
95
|
+
], 512)
|
|
96
|
+
], 512)
|
|
97
|
+
], 10, _hoisted_1);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
export {
|
|
102
|
+
_sfc_main as default
|
|
103
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as StoryThread } from "./StoryThread.vue";
|
|
2
|
+
export { default as StoryNode } from "./StoryNode.vue";
|
|
3
|
+
export type { StoryThreadProps } from "./StoryThread.vue";
|
|
4
|
+
export type { StoryNodeProps } from "./StoryNode.vue";
|
|
5
|
+
export type { StoryThreadSegment, StoryThreadLayout, StoryThreadDash } from "./types.js";
|