fancy-ui-vue 0.4.0 → 0.5.0
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 +12 -12
- 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/frost-glass/FrostGlass.vue.d.ts +31 -0
- package/dist/components/frost-glass/FrostGlass.vue.js +90 -0
- package/dist/components/frost-glass/FrostGlass.vue2.js +4 -0
- package/dist/components/frost-glass/frost-glass-core.d.ts +155 -0
- package/dist/components/frost-glass/frost-glass-core.js +820 -0
- package/dist/components/frost-glass/index.d.ts +2 -0
- package/dist/components/gift-reveal/GiftReveal.vue.d.ts +50 -0
- package/dist/components/gift-reveal/GiftReveal.vue.js +7 -0
- package/dist/components/gift-reveal/GiftReveal.vue2.js +177 -0
- package/dist/components/gift-reveal/gift-reveal-core.d.ts +109 -0
- package/dist/components/gift-reveal/gift-reveal-core.js +116 -0
- package/dist/components/gift-reveal/index.d.ts +2 -0
- 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/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/ornament/Ornament.vue.d.ts +29 -0
- package/dist/components/ornament/Ornament.vue.js +112 -0
- package/dist/components/ornament/Ornament.vue2.js +4 -0
- package/dist/components/ornament/index.d.ts +2 -0
- package/dist/components/ornament/ornament-core.d.ts +177 -0
- package/dist/components/ornament/ornament-core.js +861 -0
- package/dist/components/ripple/Ripple.vue.js +1 -1
- package/dist/components/ripple/Ripple.vue2.js +6 -1
- package/dist/components/snowfall/Snowfall.vue.d.ts +29 -0
- package/dist/components/snowfall/Snowfall.vue.js +81 -0
- package/dist/components/snowfall/Snowfall.vue2.js +4 -0
- package/dist/components/snowfall/index.d.ts +2 -0
- package/dist/components/snowfall/snowfall-core.d.ts +119 -0
- package/dist/components/snowfall/snowfall-core.js +483 -0
- 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/string-lights/StringLights.vue.d.ts +35 -0
- package/dist/components/string-lights/StringLights.vue.js +7 -0
- package/dist/components/string-lights/StringLights.vue2.js +98 -0
- package/dist/components/string-lights/index.d.ts +2 -0
- package/dist/components/string-lights/string-lights-core.d.ts +157 -0
- package/dist/components/string-lights/string-lights-core.js +228 -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/index.d.ts +5 -0
- package/dist/index.js +393 -386
- package/dist/styles.css +1669 -185
- package/package.json +2 -2
- 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
|
@@ -1,40 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
props: {
|
|
7
|
-
words: {},
|
|
8
|
-
delay: { default: 0.05 },
|
|
9
|
-
class: { type: [Boolean, null, String, Object, Array] }
|
|
10
|
-
},
|
|
11
|
-
setup(__props) {
|
|
12
|
-
const attrs = useAttrs();
|
|
13
|
-
const letters = computed(() => __props.words.split(""));
|
|
14
|
-
return (_ctx, _cache) => {
|
|
15
|
-
return openBlock(), createElementBlock("div", mergeProps(unref(attrs), { class: "letter-pullup flex justify-center" }), [
|
|
16
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(letters.value, (letter, index) => {
|
|
17
|
-
return openBlock(), createElementBlock("span", {
|
|
18
|
-
key: index,
|
|
19
|
-
class: normalizeClass(
|
|
20
|
-
unref(cn)(
|
|
21
|
-
"letter-pullup-char inline-block text-center text-4xl font-bold tracking-[-0.02em] text-black drop-shadow-sm md:leading-[5rem] dark:text-white",
|
|
22
|
-
__props.class
|
|
23
|
-
)
|
|
24
|
-
),
|
|
25
|
-
style: normalizeStyle(`animation:letterPullUp 0.5s ease forwards;animation-delay:${index * __props.delay}s;opacity:0;transform:translateY(100px)`)
|
|
26
|
-
}, [
|
|
27
|
-
letter === " " ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
28
|
-
createTextVNode(" ")
|
|
29
|
-
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
30
|
-
createTextVNode(toDisplayString(letter), 1)
|
|
31
|
-
], 64))
|
|
32
|
-
], 6);
|
|
33
|
-
}), 128))
|
|
34
|
-
], 16);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
});
|
|
1
|
+
import _sfc_main from "./LetterPullup.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
/* empty css */
|
|
4
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
5
|
+
const LetterPullup = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-83f4fa7b"]]);
|
|
38
6
|
export {
|
|
39
|
-
|
|
7
|
+
LetterPullup as default
|
|
40
8
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineComponent, useAttrs, computed, createElementBlock, openBlock, mergeProps, unref, Fragment, renderList, normalizeStyle, normalizeClass, createTextVNode, toDisplayString } from "vue";
|
|
2
|
+
import { cn } from "../../utils.js";
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
...{ name: "LetterPullup", inheritAttrs: false },
|
|
5
|
+
__name: "LetterPullup",
|
|
6
|
+
props: {
|
|
7
|
+
words: {},
|
|
8
|
+
delay: { default: 0.05 },
|
|
9
|
+
class: { type: [Boolean, null, String, Object, Array] }
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const attrs = useAttrs();
|
|
13
|
+
const letters = computed(() => __props.words.split(""));
|
|
14
|
+
return (_ctx, _cache) => {
|
|
15
|
+
return openBlock(), createElementBlock("div", mergeProps(unref(attrs), { class: "letter-pullup flex justify-center" }), [
|
|
16
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(letters.value, (letter, index) => {
|
|
17
|
+
return openBlock(), createElementBlock("span", {
|
|
18
|
+
key: index,
|
|
19
|
+
class: normalizeClass(
|
|
20
|
+
unref(cn)(
|
|
21
|
+
"letter-pullup-char inline-block text-center text-4xl font-bold tracking-[-0.02em] text-black drop-shadow-sm md:leading-[5rem] dark:text-white",
|
|
22
|
+
__props.class
|
|
23
|
+
)
|
|
24
|
+
),
|
|
25
|
+
style: normalizeStyle({ "--letter-pullup-delay": `${index * __props.delay}s` })
|
|
26
|
+
}, [
|
|
27
|
+
letter === " " ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
28
|
+
createTextVNode(" ")
|
|
29
|
+
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
30
|
+
createTextVNode(toDisplayString(letter), 1)
|
|
31
|
+
], 64))
|
|
32
|
+
], 6);
|
|
33
|
+
}), 128))
|
|
34
|
+
], 16);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
_sfc_main as default
|
|
40
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./AnimatedLogoCloud.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const AnimatedLogoCloud = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const AnimatedLogoCloud = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3366d174"]]);
|
|
5
5
|
export {
|
|
6
6
|
AnimatedLogoCloud as default
|
|
7
7
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineComponent, useTemplateRef, onMounted, onBeforeUnmount, watch, createElementBlock, openBlock, normalizeClass, unref } from "vue";
|
|
2
2
|
import { cn } from "../../utils.js";
|
|
3
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
3
4
|
import { createMatrixRain } from "./matrix-rain-core.js";
|
|
4
5
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
6
|
...{ name: "MatrixRain", inheritAttrs: false },
|
|
@@ -16,10 +17,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
16
17
|
const canvasRef = useTemplateRef("canvas");
|
|
17
18
|
let engine = null;
|
|
18
19
|
let observer = null;
|
|
20
|
+
const reducedMotion = useReducedMotion();
|
|
19
21
|
onMounted(() => {
|
|
20
22
|
const canvas = canvasRef.value;
|
|
21
23
|
if (!canvas) return;
|
|
22
|
-
engine = createMatrixRain(
|
|
24
|
+
engine = createMatrixRain(
|
|
25
|
+
{ canvas },
|
|
26
|
+
{
|
|
27
|
+
color: __props.color,
|
|
28
|
+
speed: __props.speed,
|
|
29
|
+
density: __props.density,
|
|
30
|
+
glyphSize: __props.glyphSize,
|
|
31
|
+
fadeOpacity: __props.fadeOpacity,
|
|
32
|
+
reducedMotion: reducedMotion.value
|
|
33
|
+
}
|
|
34
|
+
);
|
|
23
35
|
if (!engine) return;
|
|
24
36
|
observer = new ResizeObserver(() => engine?.resize());
|
|
25
37
|
observer.observe(canvas);
|
|
@@ -44,6 +56,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
44
56
|
},
|
|
45
57
|
{ flush: "post" }
|
|
46
58
|
);
|
|
59
|
+
watch(
|
|
60
|
+
reducedMotion,
|
|
61
|
+
(next) => {
|
|
62
|
+
engine?.setOptions({ reducedMotion: next });
|
|
63
|
+
},
|
|
64
|
+
{ flush: "post" }
|
|
65
|
+
);
|
|
47
66
|
return (_ctx, _cache) => {
|
|
48
67
|
return openBlock(), createElementBlock("canvas", {
|
|
49
68
|
ref: "canvas",
|
|
@@ -18,6 +18,12 @@ export interface MatrixRainLiveOptions {
|
|
|
18
18
|
glyphSize?: number;
|
|
19
19
|
/** Alpha of the per-frame fade-trail rectangle. Per-frame. */
|
|
20
20
|
fadeOpacity?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Reduced-motion preference, owned by the wrapper (the core stays free of
|
|
23
|
+
* `matchMedia`). When true the engine paints one still frame and idles; a
|
|
24
|
+
* flip back to false resumes the loop.
|
|
25
|
+
*/
|
|
26
|
+
reducedMotion?: boolean;
|
|
21
27
|
}
|
|
22
28
|
export interface MatrixRainEngine {
|
|
23
29
|
setOptions(next: Partial<MatrixRainLiveOptions>): void;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const GLYPHS = "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%&";
|
|
2
|
+
const STILL_PRE_ROLL_STEPS = 80;
|
|
2
3
|
const DEFAULTS = {
|
|
3
4
|
color: "#00ff41",
|
|
4
5
|
speed: 1,
|
|
5
6
|
density: 1,
|
|
6
7
|
glyphSize: 16,
|
|
7
|
-
fadeOpacity: 0.05
|
|
8
|
+
fadeOpacity: 0.05,
|
|
9
|
+
reducedMotion: false
|
|
8
10
|
};
|
|
9
11
|
function merge(base, next) {
|
|
10
12
|
return {
|
|
@@ -12,7 +14,8 @@ function merge(base, next) {
|
|
|
12
14
|
speed: next.speed ?? base.speed,
|
|
13
15
|
density: next.density ?? base.density,
|
|
14
16
|
glyphSize: next.glyphSize ?? base.glyphSize,
|
|
15
|
-
fadeOpacity: next.fadeOpacity ?? base.fadeOpacity
|
|
17
|
+
fadeOpacity: next.fadeOpacity ?? base.fadeOpacity,
|
|
18
|
+
reducedMotion: next.reducedMotion ?? base.reducedMotion
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
function createMatrixRain(elements, options, random = Math.random) {
|
|
@@ -47,9 +50,12 @@ function createMatrixRain(elements, options, random = Math.random) {
|
|
|
47
50
|
ctx.fillStyle = "black";
|
|
48
51
|
ctx.fillRect(0, 0, canvasW, canvasH);
|
|
49
52
|
initColumns(canvasW, canvasH);
|
|
53
|
+
if (opts.reducedMotion && rafId === null) paintStill();
|
|
50
54
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
55
|
+
function paintStill() {
|
|
56
|
+
for (let i = 0; i < STILL_PRE_ROLL_STEPS; i++) step(true);
|
|
57
|
+
}
|
|
58
|
+
function step(advanceNow = false) {
|
|
53
59
|
const w = canvasW;
|
|
54
60
|
const h = canvasH;
|
|
55
61
|
ctx.fillStyle = `rgba(0, 0, 0, ${opts.fadeOpacity})`;
|
|
@@ -59,7 +65,7 @@ function createMatrixRain(elements, options, random = Math.random) {
|
|
|
59
65
|
ctx.shadowColor = opts.color;
|
|
60
66
|
const rowsPerFrame = Math.max(1, opts.speed);
|
|
61
67
|
frameCount++;
|
|
62
|
-
const shouldAdvance = opts.speed >= 1 || frameCount % Math.round(1 / opts.speed) === 0;
|
|
68
|
+
const shouldAdvance = advanceNow || opts.speed >= 1 || frameCount % Math.round(1 / opts.speed) === 0;
|
|
63
69
|
if (shouldAdvance) {
|
|
64
70
|
for (let i = 0; i < columns.length; i++) {
|
|
65
71
|
const column = columns[i];
|
|
@@ -79,10 +85,18 @@ function createMatrixRain(elements, options, random = Math.random) {
|
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
ctx.shadowBlur = 0;
|
|
88
|
+
}
|
|
89
|
+
function draw() {
|
|
90
|
+
if (destroyed) return;
|
|
91
|
+
step();
|
|
92
|
+
if (opts.reducedMotion) {
|
|
93
|
+
rafId = null;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
82
96
|
rafId = requestAnimationFrame(draw);
|
|
83
97
|
}
|
|
84
98
|
resize();
|
|
85
|
-
rafId = requestAnimationFrame(draw);
|
|
99
|
+
if (!opts.reducedMotion) rafId = requestAnimationFrame(draw);
|
|
86
100
|
return {
|
|
87
101
|
setOptions(next) {
|
|
88
102
|
if (destroyed) return;
|
|
@@ -90,6 +104,14 @@ function createMatrixRain(elements, options, random = Math.random) {
|
|
|
90
104
|
opts = merge(opts, next);
|
|
91
105
|
if (opts.glyphSize !== prev.glyphSize || opts.density !== prev.density) {
|
|
92
106
|
resize();
|
|
107
|
+
} else if (opts.reducedMotion && rafId === null && (opts.color !== prev.color || opts.fadeOpacity !== prev.fadeOpacity)) {
|
|
108
|
+
ctx.fillStyle = "black";
|
|
109
|
+
ctx.fillRect(0, 0, canvasW, canvasH);
|
|
110
|
+
initColumns(canvasW, canvasH);
|
|
111
|
+
paintStill();
|
|
112
|
+
}
|
|
113
|
+
if (prev.reducedMotion && !opts.reducedMotion && rafId === null) {
|
|
114
|
+
rafId = requestAnimationFrame(draw);
|
|
93
115
|
}
|
|
94
116
|
},
|
|
95
117
|
resize,
|
|
@@ -76,6 +76,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
76
76
|
},
|
|
77
77
|
{ flush: "post" }
|
|
78
78
|
);
|
|
79
|
+
watch(
|
|
80
|
+
[engine, reducedMotion],
|
|
81
|
+
([currentEngine, currentReduced]) => {
|
|
82
|
+
currentEngine?.setOptions({ reducedMotion: currentReduced });
|
|
83
|
+
},
|
|
84
|
+
{ flush: "post" }
|
|
85
|
+
);
|
|
79
86
|
watch(
|
|
80
87
|
[() => __props.trigger, engine, () => __props.revealed],
|
|
81
88
|
([currentTrigger, currentEngine, currentRevealed]) => {
|
|
@@ -196,6 +196,7 @@ function createNoiseReveal(el, options) {
|
|
|
196
196
|
uniforms.uTexture.value = loaded;
|
|
197
197
|
const image = loaded.image;
|
|
198
198
|
uniforms.uImageRes.value.set(image.naturalWidth || 1, image.naturalHeight || 1);
|
|
199
|
+
wake();
|
|
199
200
|
});
|
|
200
201
|
let destroyed = false;
|
|
201
202
|
let reducedMotion = options.reducedMotion ?? false;
|
|
@@ -207,11 +208,12 @@ function createNoiseReveal(el, options) {
|
|
|
207
208
|
if (reducedMotion) {
|
|
208
209
|
progress = value;
|
|
209
210
|
tween.active = false;
|
|
210
|
-
|
|
211
|
+
} else {
|
|
212
|
+
tween.from = progress;
|
|
213
|
+
tween.start = performance.now();
|
|
214
|
+
tween.active = true;
|
|
211
215
|
}
|
|
212
|
-
|
|
213
|
-
tween.start = performance.now();
|
|
214
|
-
tween.active = true;
|
|
216
|
+
wake();
|
|
215
217
|
};
|
|
216
218
|
const handleResize = () => {
|
|
217
219
|
if (destroyed) return;
|
|
@@ -221,27 +223,41 @@ function createNoiseReveal(el, options) {
|
|
|
221
223
|
camera.updateProjectionMatrix();
|
|
222
224
|
renderer.setSize(r.width, r.height, false);
|
|
223
225
|
fitPlane(r.width, r.height);
|
|
226
|
+
wake();
|
|
224
227
|
};
|
|
225
228
|
window.addEventListener("resize", handleResize);
|
|
226
229
|
const clock = new THREE.Clock();
|
|
227
230
|
let animationId = 0;
|
|
228
|
-
|
|
231
|
+
function wake() {
|
|
232
|
+
if (destroyed || animationId !== 0) return;
|
|
229
233
|
animationId = requestAnimationFrame(animate);
|
|
234
|
+
}
|
|
235
|
+
const animate = () => {
|
|
236
|
+
animationId = 0;
|
|
230
237
|
if (tween.active) {
|
|
231
238
|
const t = getProgress(performance.now() - tween.start, duration * 1e3);
|
|
232
239
|
progress = lerp(tween.from, tween.to, easeInOutCubic(t));
|
|
233
240
|
if (t >= 1) tween.active = false;
|
|
234
241
|
}
|
|
235
242
|
uniforms.uProgress.value = progress;
|
|
236
|
-
uniforms.uTime.value = clock.getElapsedTime();
|
|
243
|
+
if (!reducedMotion) uniforms.uTime.value = clock.getElapsedTime();
|
|
237
244
|
renderer.render(scene, camera);
|
|
245
|
+
if (reducedMotion && !tween.active) return;
|
|
246
|
+
animationId = requestAnimationFrame(animate);
|
|
238
247
|
};
|
|
239
248
|
animate();
|
|
240
249
|
if (options.target !== void 0) setTarget(options.target);
|
|
241
250
|
return {
|
|
242
251
|
setOptions(next) {
|
|
243
252
|
if (destroyed) return;
|
|
244
|
-
if (next.reducedMotion !== void 0
|
|
253
|
+
if (next.reducedMotion !== void 0 && next.reducedMotion !== reducedMotion) {
|
|
254
|
+
reducedMotion = next.reducedMotion;
|
|
255
|
+
if (reducedMotion && tween.active) {
|
|
256
|
+
progress = tween.to;
|
|
257
|
+
tween.active = false;
|
|
258
|
+
}
|
|
259
|
+
wake();
|
|
260
|
+
}
|
|
245
261
|
if (next.target !== void 0) setTarget(next.target);
|
|
246
262
|
},
|
|
247
263
|
resize: handleResize,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "vue";
|
|
2
|
+
import type { OrnamentBand, OrnamentFinish } from "./ornament-core.js";
|
|
3
|
+
export interface OrnamentProps {
|
|
4
|
+
/** Colour of the glass, `#rgb` or `#rrggbb`. */
|
|
5
|
+
color?: string;
|
|
6
|
+
/** Surface: clear glass, soft velvet or fine glitter. */
|
|
7
|
+
finish?: OrnamentFinish;
|
|
8
|
+
/** Metallic band around the equator. */
|
|
9
|
+
band?: OrnamentBand;
|
|
10
|
+
/** Diameter of the sphere in CSS pixels. The box is twice as wide. */
|
|
11
|
+
size?: number;
|
|
12
|
+
/** Length of the thread above the cap, in CSS pixels. */
|
|
13
|
+
threadLength?: number;
|
|
14
|
+
/** Idle sway, 0..1. 0 hangs perfectly still at rest. */
|
|
15
|
+
swing?: number;
|
|
16
|
+
/** Hover nudges, drag and arrow keys move it. Off: decorative and hidden from assistive tech. */
|
|
17
|
+
interactive?: boolean;
|
|
18
|
+
/** Strength of the soft halo behind the sphere, 0..1. */
|
|
19
|
+
glow?: number;
|
|
20
|
+
/** Seed for the glitter, the resting turn and the sway phase. Read once, on mount. */
|
|
21
|
+
seed?: number;
|
|
22
|
+
/** Accessible name while interactive. */
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Additional CSS classes */
|
|
25
|
+
class?: HTMLAttributes["class"];
|
|
26
|
+
}
|
|
27
|
+
declare const _default: typeof __VLS_export;
|
|
28
|
+
export default _default;
|
|
29
|
+
declare const __VLS_export: import("vue").DefineComponent<OrnamentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<OrnamentProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { defineComponent, useTemplateRef, shallowRef, computed, onMounted, onBeforeUnmount, watch, createElementBlock, openBlock, mergeProps, unref, createCommentVNode, createElementVNode, normalizeStyle } from "vue";
|
|
2
|
+
import { cn } from "../../utils.js";
|
|
3
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
4
|
+
import { ORNAMENT_DEFAULTS, ornamentGeometry, createOrnament, fallbackSphere } from "./ornament-core.js";
|
|
5
|
+
const _hoisted_1 = ["role", "aria-label", "aria-hidden", "tabindex", "data-ready"];
|
|
6
|
+
const _hoisted_2 = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "fancy-ornament-fallback pointer-events-none absolute inset-0"
|
|
9
|
+
};
|
|
10
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
|
+
...{ name: "Ornament", inheritAttrs: false },
|
|
12
|
+
__name: "Ornament",
|
|
13
|
+
props: {
|
|
14
|
+
color: { default: () => ORNAMENT_DEFAULTS.color },
|
|
15
|
+
finish: { default: () => ORNAMENT_DEFAULTS.finish },
|
|
16
|
+
band: { default: () => ORNAMENT_DEFAULTS.band },
|
|
17
|
+
size: { default: () => ORNAMENT_DEFAULTS.size },
|
|
18
|
+
threadLength: { default: () => ORNAMENT_DEFAULTS.threadLength },
|
|
19
|
+
swing: { default: () => ORNAMENT_DEFAULTS.swing },
|
|
20
|
+
interactive: { type: Boolean, default: true },
|
|
21
|
+
glow: { default: () => ORNAMENT_DEFAULTS.glow },
|
|
22
|
+
seed: { default: () => ORNAMENT_DEFAULTS.seed },
|
|
23
|
+
label: { default: "Swing the ornament" },
|
|
24
|
+
class: { type: [Boolean, null, String, Object, Array], default: "" }
|
|
25
|
+
},
|
|
26
|
+
setup(__props) {
|
|
27
|
+
const rootRef = useTemplateRef("root");
|
|
28
|
+
const canvasRef = useTemplateRef("canvas");
|
|
29
|
+
const engine = shallowRef(null);
|
|
30
|
+
const reducedMotion = useReducedMotion();
|
|
31
|
+
const box = computed(() => ornamentGeometry(__props.size, __props.threadLength));
|
|
32
|
+
const active = computed(() => __props.interactive && !reducedMotion.value);
|
|
33
|
+
function liveOptions() {
|
|
34
|
+
return {
|
|
35
|
+
color: __props.color,
|
|
36
|
+
finish: __props.finish,
|
|
37
|
+
band: __props.band,
|
|
38
|
+
size: __props.size,
|
|
39
|
+
threadLength: __props.threadLength,
|
|
40
|
+
swing: __props.swing,
|
|
41
|
+
interactive: __props.interactive,
|
|
42
|
+
glow: __props.glow,
|
|
43
|
+
reducedMotion: reducedMotion.value
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
onMounted(() => {
|
|
47
|
+
const canvas = canvasRef.value;
|
|
48
|
+
if (!canvas) return;
|
|
49
|
+
engine.value = createOrnament({ canvas, root: rootRef.value }, { ...liveOptions(), seed: __props.seed });
|
|
50
|
+
});
|
|
51
|
+
onBeforeUnmount(() => {
|
|
52
|
+
const instance = engine.value;
|
|
53
|
+
if (!instance) return;
|
|
54
|
+
engine.value = null;
|
|
55
|
+
instance.destroy();
|
|
56
|
+
});
|
|
57
|
+
watch(
|
|
58
|
+
[engine, liveOptions],
|
|
59
|
+
([currentEngine, options]) => {
|
|
60
|
+
currentEngine?.setOptions(options);
|
|
61
|
+
},
|
|
62
|
+
{ flush: "post" }
|
|
63
|
+
);
|
|
64
|
+
return (_ctx, _cache) => {
|
|
65
|
+
return openBlock(), createElementBlock("div", mergeProps({ ref: "root" }, _ctx.$attrs, {
|
|
66
|
+
class: unref(cn)(
|
|
67
|
+
"fancy-ornament focus-visible:ring-ring relative inline-block shrink-0 rounded-lg outline-none focus-visible:ring-2",
|
|
68
|
+
__props.class
|
|
69
|
+
),
|
|
70
|
+
style: { width: `${box.value.width}px`, height: `${box.value.height}px` },
|
|
71
|
+
role: active.value ? "button" : void 0,
|
|
72
|
+
"aria-label": active.value ? __props.label : void 0,
|
|
73
|
+
"aria-hidden": active.value ? void 0 : "true",
|
|
74
|
+
tabindex: active.value ? 0 : void 0,
|
|
75
|
+
"data-ready": engine.value ? "" : void 0
|
|
76
|
+
}), [
|
|
77
|
+
!engine.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
78
|
+
createElementVNode("div", {
|
|
79
|
+
class: "absolute top-0 left-1/2 w-px -translate-x-1/2 bg-neutral-400/80",
|
|
80
|
+
style: normalizeStyle({ height: `${box.value.capTop}px` })
|
|
81
|
+
}, null, 4),
|
|
82
|
+
createElementVNode("div", {
|
|
83
|
+
class: "absolute left-1/2 -translate-x-1/2 rounded-full",
|
|
84
|
+
style: normalizeStyle({
|
|
85
|
+
top: `${box.value.arm - box.value.radius}px`,
|
|
86
|
+
width: `${box.value.radius * 2}px`,
|
|
87
|
+
height: `${box.value.radius * 2}px`,
|
|
88
|
+
background: unref(fallbackSphere)(__props.color)
|
|
89
|
+
})
|
|
90
|
+
}, null, 4),
|
|
91
|
+
createElementVNode("div", {
|
|
92
|
+
class: "absolute left-1/2 -translate-x-1/2 rounded-[2px] bg-gradient-to-r from-amber-700 via-amber-200 to-amber-700",
|
|
93
|
+
style: normalizeStyle({
|
|
94
|
+
top: `${box.value.capTop}px`,
|
|
95
|
+
width: `${box.value.capWidth}px`,
|
|
96
|
+
height: `${box.value.capHeight}px`
|
|
97
|
+
})
|
|
98
|
+
}, null, 4)
|
|
99
|
+
])) : createCommentVNode("", true),
|
|
100
|
+
createElementVNode("canvas", {
|
|
101
|
+
ref: "canvas",
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
class: "absolute inset-0 block h-full w-full",
|
|
104
|
+
style: normalizeStyle(active.value ? { touchAction: "pan-y", cursor: "grab" } : void 0)
|
|
105
|
+
}, null, 4)
|
|
106
|
+
], 16, _hoisted_1);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
export {
|
|
111
|
+
_sfc_main as default
|
|
112
|
+
};
|