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
|
@@ -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,35 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "vue";
|
|
2
|
+
import { type StringLightsPattern } from "./string-lights-core.js";
|
|
3
|
+
export type { StringLightsPattern };
|
|
4
|
+
/**
|
|
5
|
+
* StringLights - a string of glowing bulbs hanging on a sagging wire.
|
|
6
|
+
*
|
|
7
|
+
* The geometry and timing live in `string-lights-core.ts`, shared with the
|
|
8
|
+
* Svelte and React packages; this file measures the width, renders the bulbs
|
|
9
|
+
* and lets CSS keyframes run the patterns.
|
|
10
|
+
*/
|
|
11
|
+
export interface StringLightsProps {
|
|
12
|
+
/** Number of bulbs on the whole string. */
|
|
13
|
+
count?: number;
|
|
14
|
+
/** Number of drapes across the width. 2 adds one anchor in the middle. */
|
|
15
|
+
swags?: number;
|
|
16
|
+
/** Depth of each drape below its two anchors, in px. */
|
|
17
|
+
sag?: number;
|
|
18
|
+
/** Bulb colours, given out in turn along the string. */
|
|
19
|
+
colors?: string[];
|
|
20
|
+
/** How the bulbs light up over time. */
|
|
21
|
+
pattern?: StringLightsPattern;
|
|
22
|
+
/** Speed multiplier for the pattern. 0 holds every bulb lit. */
|
|
23
|
+
speed?: number;
|
|
24
|
+
/** Diameter of the glass, in px. */
|
|
25
|
+
size?: number;
|
|
26
|
+
/** Strength and reach of the light around each bulb, 0 to 1. */
|
|
27
|
+
glow?: number;
|
|
28
|
+
/** Seed for the twinkle pattern. Same seed, same flicker. */
|
|
29
|
+
seed?: number;
|
|
30
|
+
/** Additional CSS classes */
|
|
31
|
+
class?: HTMLAttributes["class"];
|
|
32
|
+
}
|
|
33
|
+
declare const _default: typeof __VLS_export;
|
|
34
|
+
export default _default;
|
|
35
|
+
declare const __VLS_export: import("vue").DefineComponent<StringLightsProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<StringLightsProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _sfc_main from "./StringLights.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const StringLights = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-12f37b6d"]]);
|
|
5
|
+
export {
|
|
6
|
+
StringLights as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { defineComponent, useTemplateRef, ref, computed, onMounted, onBeforeUnmount, createElementBlock, openBlock, mergeProps, unref, createElementVNode, Fragment, renderList, normalizeStyle } from "vue";
|
|
2
|
+
import { cn } from "../../utils.js";
|
|
3
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
4
|
+
import { STRING_LIGHTS_DEFAULTS, FALLBACK_WIDTH, effectivePattern, stringLightsLayout, createStringLights, haloStyle, bulbStyle } from "./string-lights-core.js";
|
|
5
|
+
const _hoisted_1 = ["data-pattern"];
|
|
6
|
+
const _hoisted_2 = ["viewBox"];
|
|
7
|
+
const _hoisted_3 = ["d"];
|
|
8
|
+
const DEFAULT_COLORS = [...STRING_LIGHTS_DEFAULTS.colors];
|
|
9
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
|
+
...{ name: "StringLights", inheritAttrs: false },
|
|
11
|
+
__name: "StringLights",
|
|
12
|
+
props: {
|
|
13
|
+
count: { default: () => STRING_LIGHTS_DEFAULTS.count },
|
|
14
|
+
swags: { default: () => STRING_LIGHTS_DEFAULTS.swags },
|
|
15
|
+
sag: { default: () => STRING_LIGHTS_DEFAULTS.sag },
|
|
16
|
+
colors: { default: () => DEFAULT_COLORS },
|
|
17
|
+
pattern: { default: () => STRING_LIGHTS_DEFAULTS.pattern },
|
|
18
|
+
speed: { default: () => STRING_LIGHTS_DEFAULTS.speed },
|
|
19
|
+
size: { default: () => STRING_LIGHTS_DEFAULTS.size },
|
|
20
|
+
glow: { default: () => STRING_LIGHTS_DEFAULTS.glow },
|
|
21
|
+
seed: { default: () => STRING_LIGHTS_DEFAULTS.seed },
|
|
22
|
+
class: { type: [Boolean, null, String, Object, Array], default: "" }
|
|
23
|
+
},
|
|
24
|
+
setup(__props) {
|
|
25
|
+
const rootRef = useTemplateRef("root");
|
|
26
|
+
const width = ref(FALLBACK_WIDTH);
|
|
27
|
+
const reducedMotion = useReducedMotion();
|
|
28
|
+
const active = computed(() => effectivePattern(__props.pattern, __props.speed, reducedMotion.value));
|
|
29
|
+
const layout = computed(
|
|
30
|
+
() => stringLightsLayout(width.value, {
|
|
31
|
+
count: __props.count,
|
|
32
|
+
swags: __props.swags,
|
|
33
|
+
sag: __props.sag,
|
|
34
|
+
colors: __props.colors,
|
|
35
|
+
pattern: active.value,
|
|
36
|
+
speed: __props.speed,
|
|
37
|
+
size: __props.size,
|
|
38
|
+
glow: __props.glow,
|
|
39
|
+
seed: __props.seed
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
const rootStyle = computed(() => ({
|
|
43
|
+
height: `${layout.value.height}px`,
|
|
44
|
+
"--sl-size": `${Math.max(2, Number.isFinite(__props.size) ? __props.size : STRING_LIGHTS_DEFAULTS.size)}px`,
|
|
45
|
+
"--sl-glow": String(Math.max(0, Math.min(1, Number.isFinite(__props.glow) ? __props.glow : 0)))
|
|
46
|
+
}));
|
|
47
|
+
let engine = null;
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
const root = rootRef.value;
|
|
50
|
+
if (!root) return;
|
|
51
|
+
engine = createStringLights({ root }, { onResize: (w) => width.value = w });
|
|
52
|
+
});
|
|
53
|
+
onBeforeUnmount(() => {
|
|
54
|
+
engine?.destroy();
|
|
55
|
+
engine = null;
|
|
56
|
+
});
|
|
57
|
+
return (_ctx, _cache) => {
|
|
58
|
+
return openBlock(), createElementBlock("div", mergeProps({ ref: "root" }, _ctx.$attrs, {
|
|
59
|
+
class: unref(cn)("fancy-string-lights", __props.class),
|
|
60
|
+
style: rootStyle.value,
|
|
61
|
+
"data-pattern": active.value,
|
|
62
|
+
"aria-hidden": "true"
|
|
63
|
+
}), [
|
|
64
|
+
(openBlock(), createElementBlock("svg", {
|
|
65
|
+
class: "fancy-string-lights-wire",
|
|
66
|
+
viewBox: `0 0 ${layout.value.width} ${layout.value.height}`,
|
|
67
|
+
preserveAspectRatio: "none"
|
|
68
|
+
}, [
|
|
69
|
+
createElementVNode("path", {
|
|
70
|
+
d: layout.value.wire
|
|
71
|
+
}, null, 8, _hoisted_3)
|
|
72
|
+
], 8, _hoisted_2)),
|
|
73
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(layout.value.bulbs, (bulb, i) => {
|
|
74
|
+
return openBlock(), createElementBlock("span", {
|
|
75
|
+
key: `h${i}`,
|
|
76
|
+
class: "fancy-string-lights-halo",
|
|
77
|
+
style: normalizeStyle(unref(haloStyle)(bulb))
|
|
78
|
+
}, null, 4);
|
|
79
|
+
}), 128)),
|
|
80
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(layout.value.bulbs, (bulb, i) => {
|
|
81
|
+
return openBlock(), createElementBlock("span", {
|
|
82
|
+
key: `b${i}`,
|
|
83
|
+
class: "fancy-string-lights-bulb",
|
|
84
|
+
style: normalizeStyle(unref(bulbStyle)(bulb))
|
|
85
|
+
}, [..._cache[0] || (_cache[0] = [
|
|
86
|
+
createElementVNode("span", { class: "fancy-string-lights-glass" }, [
|
|
87
|
+
createElementVNode("span", { class: "fancy-string-lights-lit" })
|
|
88
|
+
], -1),
|
|
89
|
+
createElementVNode("span", { class: "fancy-string-lights-socket" }, null, -1)
|
|
90
|
+
])], 4);
|
|
91
|
+
}), 128))
|
|
92
|
+
], 16, _hoisted_1);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
export {
|
|
97
|
+
_sfc_main as default
|
|
98
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StringLights engine: the geometry and timing of a string of bulbs hanging on
|
|
3
|
+
* a sagging wire.
|
|
4
|
+
*
|
|
5
|
+
* Framework-free and shared byte-for-byte by the Svelte, React and Vue
|
|
6
|
+
* wrappers (see shared-cores.json). Nothing here touches the DOM at import
|
|
7
|
+
* time; `createStringLights` is the only entry that needs a browser, and all it
|
|
8
|
+
* does is measure the root's width.
|
|
9
|
+
*
|
|
10
|
+
* Everything else is pure:
|
|
11
|
+
*
|
|
12
|
+
* - `stringLightsLayout(width, options)` returns the wire's SVG path, the
|
|
13
|
+
* reserved height and, per bulb, where it clips onto the wire, how far it
|
|
14
|
+
* swings with the slope, its colour and its animation delay and duration.
|
|
15
|
+
* - Each drape between two anchors is a parabola. For a sag that is small
|
|
16
|
+
* next to the span (any string that reads as "hanging") it cannot be told
|
|
17
|
+
* apart from the true catenary, and a parabola is exactly one quadratic
|
|
18
|
+
* Bézier: control point at twice the sag, so the path is the curve itself.
|
|
19
|
+
* - Bulbs are spaced by arc length, not by x, so they stay evenly spread along
|
|
20
|
+
* the wire where it runs steep near the anchors.
|
|
21
|
+
*
|
|
22
|
+
* Horizontal positions are fractions of the width, so a layout computed for
|
|
23
|
+
* the wrong width (on the server, before the first measurement) still puts
|
|
24
|
+
* every bulb on the wire; only the arc spacing and the tilt are refined when
|
|
25
|
+
* the real width arrives. Vertical positions are pixels and depend only on
|
|
26
|
+
* `sag` and `size`, so the reserved height never changes after measurement.
|
|
27
|
+
*
|
|
28
|
+
* Twinkle patterns are CSS keyframes; this module only hands out per-bulb
|
|
29
|
+
* delays and durations, seeded so the server and the browser agree.
|
|
30
|
+
*/
|
|
31
|
+
export type StringLightsPattern = "wave" | "alternate" | "breathe" | "twinkle" | "steady";
|
|
32
|
+
export declare const STRING_LIGHTS_PATTERNS: readonly StringLightsPattern[];
|
|
33
|
+
export interface StringLightsOptions {
|
|
34
|
+
/** Number of bulbs on the whole string. */
|
|
35
|
+
count: number;
|
|
36
|
+
/** Number of drapes across the width. 2 adds one anchor in the middle. */
|
|
37
|
+
swags: number;
|
|
38
|
+
/** Depth of each drape below its anchors, in px. */
|
|
39
|
+
sag: number;
|
|
40
|
+
/** Bulb colours, assigned in turn along the string. */
|
|
41
|
+
colors: readonly string[];
|
|
42
|
+
/** How the bulbs light up over time. */
|
|
43
|
+
pattern: StringLightsPattern;
|
|
44
|
+
/** Speed multiplier for the pattern. 0 or less holds every bulb lit. */
|
|
45
|
+
speed: number;
|
|
46
|
+
/** Bulb glass diameter, in px. */
|
|
47
|
+
size: number;
|
|
48
|
+
/** Strength and reach of the light around each bulb, 0..1. */
|
|
49
|
+
glow: number;
|
|
50
|
+
/** Seed for the twinkle pattern. Same seed, same flicker. */
|
|
51
|
+
seed: number;
|
|
52
|
+
}
|
|
53
|
+
export declare const STRING_LIGHTS_DEFAULTS: {
|
|
54
|
+
readonly count: 14;
|
|
55
|
+
readonly swags: 1;
|
|
56
|
+
readonly sag: 40;
|
|
57
|
+
readonly colors: readonly string[];
|
|
58
|
+
readonly pattern: StringLightsPattern;
|
|
59
|
+
readonly speed: 1;
|
|
60
|
+
readonly size: 12;
|
|
61
|
+
readonly glow: 0.7;
|
|
62
|
+
readonly seed: 1;
|
|
63
|
+
};
|
|
64
|
+
/** Width assumed before the root has been measured (server render, first paint). */
|
|
65
|
+
export declare const FALLBACK_WIDTH = 640;
|
|
66
|
+
/** Room above the anchors, px, so the wire's stroke is not cut. */
|
|
67
|
+
export declare const WIRE_TOP = 2;
|
|
68
|
+
/** Socket height as a share of the bulb size. */
|
|
69
|
+
export declare const SOCKET_RATIO = 0.75;
|
|
70
|
+
/** The glass tucks this far (share of the bulb size) into the socket. */
|
|
71
|
+
export declare const SOCKET_OVERLAP = 0.12;
|
|
72
|
+
/** How much of the wire's slope a bulb follows: 0 hangs plumb, 1 stands square to the wire. */
|
|
73
|
+
export declare const TILT_FOLLOW = 0.55;
|
|
74
|
+
/** Seconds per cycle at speed 1. */
|
|
75
|
+
export declare const PATTERN_PERIODS: Record<Exclude<StringLightsPattern, "steady">, number>;
|
|
76
|
+
export interface StringLightsBulb {
|
|
77
|
+
/** Where the socket clips onto the wire: share of the width, 0..1. */
|
|
78
|
+
x: number;
|
|
79
|
+
/** Where the socket clips onto the wire: px from the top. */
|
|
80
|
+
y: number;
|
|
81
|
+
/** Swing away from plumb, degrees, clockwise. */
|
|
82
|
+
angle: number;
|
|
83
|
+
/** Centre of the glass: share of the width, 0..1. */
|
|
84
|
+
cx: number;
|
|
85
|
+
/** Centre of the glass: px from the top. */
|
|
86
|
+
cy: number;
|
|
87
|
+
color: string;
|
|
88
|
+
/** Animation delay, seconds (negative: the cycle is already under way). */
|
|
89
|
+
delay: number;
|
|
90
|
+
/** Animation duration, seconds. 0 when the bulb does not animate. */
|
|
91
|
+
duration: number;
|
|
92
|
+
}
|
|
93
|
+
export interface StringLightsLayout {
|
|
94
|
+
/** Width the layout was computed for, px. */
|
|
95
|
+
width: number;
|
|
96
|
+
/** Height the component reserves, px. Depends only on `sag` and `size`. */
|
|
97
|
+
height: number;
|
|
98
|
+
/** The wire, as an SVG path in a `0 0 width height` box. */
|
|
99
|
+
wire: string;
|
|
100
|
+
bulbs: StringLightsBulb[];
|
|
101
|
+
}
|
|
102
|
+
/** Small seedable PRNG. Same seed, same sequence, on the server and in the browser. */
|
|
103
|
+
export declare function mulberry32(seed: number): () => number;
|
|
104
|
+
/** Options with every value checked and clamped, so the layout never sees NaN. */
|
|
105
|
+
export declare function resolveOptions(options?: Partial<StringLightsOptions>): StringLightsOptions;
|
|
106
|
+
/**
|
|
107
|
+
* The pattern the bulbs actually run. Reduced motion and a speed of 0 or less
|
|
108
|
+
* both mean every bulb holds steady and fully lit.
|
|
109
|
+
*/
|
|
110
|
+
export declare function effectivePattern(pattern: StringLightsPattern, speed: number, reducedMotion: boolean): StringLightsPattern;
|
|
111
|
+
/** Height the component reserves: anchors, sag, socket, glass and a little air. */
|
|
112
|
+
export declare function reservedHeight(sag: number, size: number): number;
|
|
113
|
+
/** The wire: one quadratic Bézier per drape, control point at twice the sag. */
|
|
114
|
+
export declare function wirePath(width: number, swags: number, sag: number): string;
|
|
115
|
+
/**
|
|
116
|
+
* Where the bulbs clip onto the wire: `count` points spread evenly by arc
|
|
117
|
+
* length, half a step in from each end so no bulb sits on an end anchor.
|
|
118
|
+
* Returns x in px and the slope angle in radians.
|
|
119
|
+
*/
|
|
120
|
+
export declare function bulbPoints(width: number, swags: number, sag: number, count: number): {
|
|
121
|
+
x: number;
|
|
122
|
+
y: number;
|
|
123
|
+
slope: number;
|
|
124
|
+
}[];
|
|
125
|
+
/** Delay and duration of one bulb's cycle, in seconds. */
|
|
126
|
+
export declare function bulbTiming(pattern: StringLightsPattern, index: number, count: number, speed: number, rand: () => number): {
|
|
127
|
+
delay: number;
|
|
128
|
+
duration: number;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The whole string for a given width. `options.pattern` should already be the
|
|
132
|
+
* effective one (see `effectivePattern`).
|
|
133
|
+
*/
|
|
134
|
+
export declare function stringLightsLayout(width: number, options?: Partial<StringLightsOptions>): StringLightsLayout;
|
|
135
|
+
/** Inline style of a bulb (socket and glass), as CSS property → value. */
|
|
136
|
+
export declare function bulbStyle(bulb: StringLightsBulb): Record<string, string>;
|
|
137
|
+
/** Inline style of a bulb's light spill, centred on the glass. */
|
|
138
|
+
export declare function haloStyle(bulb: StringLightsBulb): Record<string, string>;
|
|
139
|
+
/** Inline style string, for frameworks that bind `style` as text. */
|
|
140
|
+
export declare function styleText(style: Record<string, string>): string;
|
|
141
|
+
export interface StringLightsElements {
|
|
142
|
+
root: HTMLElement;
|
|
143
|
+
}
|
|
144
|
+
export interface StringLightsEngineOptions {
|
|
145
|
+
/** Called with the root's width in whole px, now and on every change. */
|
|
146
|
+
onResize?: (width: number) => void;
|
|
147
|
+
}
|
|
148
|
+
export interface StringLightsEngine {
|
|
149
|
+
setOptions(options: StringLightsEngineOptions): void;
|
|
150
|
+
destroy(): void;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Watches the root's width. Returns null when ResizeObserver is missing; the
|
|
154
|
+
* wrapper then keeps the layout computed for `FALLBACK_WIDTH`, which is still
|
|
155
|
+
* correct apart from the exact tilt and spacing.
|
|
156
|
+
*/
|
|
157
|
+
export declare function createStringLights(elements: StringLightsElements, options?: StringLightsEngineOptions): StringLightsEngine | null;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
const STRING_LIGHTS_PATTERNS = [
|
|
2
|
+
"wave",
|
|
3
|
+
"alternate",
|
|
4
|
+
"breathe",
|
|
5
|
+
"twinkle",
|
|
6
|
+
"steady"
|
|
7
|
+
];
|
|
8
|
+
const STRING_LIGHTS_DEFAULTS = {
|
|
9
|
+
count: 14,
|
|
10
|
+
swags: 1,
|
|
11
|
+
sag: 40,
|
|
12
|
+
colors: ["#ffd59a"],
|
|
13
|
+
pattern: "wave",
|
|
14
|
+
speed: 1,
|
|
15
|
+
size: 12,
|
|
16
|
+
glow: 0.7,
|
|
17
|
+
seed: 1
|
|
18
|
+
};
|
|
19
|
+
const FALLBACK_WIDTH = 640;
|
|
20
|
+
const WIRE_TOP = 2;
|
|
21
|
+
const SOCKET_RATIO = 0.75;
|
|
22
|
+
const SOCKET_OVERLAP = 0.12;
|
|
23
|
+
const TILT_FOLLOW = 0.55;
|
|
24
|
+
const ARC_SAMPLES = 48;
|
|
25
|
+
const PATTERN_PERIODS = {
|
|
26
|
+
wave: 3.6,
|
|
27
|
+
alternate: 2.8,
|
|
28
|
+
breathe: 5,
|
|
29
|
+
twinkle: 2.4
|
|
30
|
+
};
|
|
31
|
+
function mulberry32(seed) {
|
|
32
|
+
let a = seed >>> 0;
|
|
33
|
+
return () => {
|
|
34
|
+
a = a + 1831565813 >>> 0;
|
|
35
|
+
let t = a;
|
|
36
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
37
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
38
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function finite(value, fallback) {
|
|
42
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
43
|
+
}
|
|
44
|
+
function round(value, digits = 3) {
|
|
45
|
+
const f = 10 ** digits;
|
|
46
|
+
return Math.round(value * f) / f;
|
|
47
|
+
}
|
|
48
|
+
function resolveOptions(options = {}) {
|
|
49
|
+
const d = STRING_LIGHTS_DEFAULTS;
|
|
50
|
+
const colors = Array.isArray(options.colors) ? options.colors.filter((c) => typeof c === "string" && c.trim() !== "") : [];
|
|
51
|
+
const pattern = STRING_LIGHTS_PATTERNS.includes(options.pattern) ? options.pattern : d.pattern;
|
|
52
|
+
return {
|
|
53
|
+
count: Math.max(0, Math.min(500, Math.floor(finite(options.count, d.count)))),
|
|
54
|
+
swags: Math.max(1, Math.min(50, Math.floor(finite(options.swags, d.swags)))),
|
|
55
|
+
sag: Math.max(0, finite(options.sag, d.sag)),
|
|
56
|
+
colors: colors.length > 0 ? colors : d.colors,
|
|
57
|
+
pattern,
|
|
58
|
+
speed: finite(options.speed, d.speed),
|
|
59
|
+
size: Math.max(2, finite(options.size, d.size)),
|
|
60
|
+
glow: Math.max(0, Math.min(1, finite(options.glow, d.glow))),
|
|
61
|
+
seed: Math.floor(finite(options.seed, d.seed))
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function effectivePattern(pattern, speed, reducedMotion) {
|
|
65
|
+
if (reducedMotion || !(speed > 0)) return "steady";
|
|
66
|
+
return STRING_LIGHTS_PATTERNS.includes(pattern) ? pattern : STRING_LIGHTS_DEFAULTS.pattern;
|
|
67
|
+
}
|
|
68
|
+
function reservedHeight(sag, size) {
|
|
69
|
+
return Math.ceil(WIRE_TOP + sag + size * (SOCKET_RATIO - SOCKET_OVERLAP + 1) + size * 0.25);
|
|
70
|
+
}
|
|
71
|
+
function wirePath(width, swags, sag) {
|
|
72
|
+
const span = width / swags;
|
|
73
|
+
const top = WIRE_TOP;
|
|
74
|
+
const parts = [`M0 ${top}`];
|
|
75
|
+
for (let k = 0; k < swags; k++) {
|
|
76
|
+
const x0 = k * span;
|
|
77
|
+
const x1 = (k + 1) * span;
|
|
78
|
+
parts.push(`Q${round((x0 + x1) / 2, 2)} ${round(top + 2 * sag, 2)} ${round(x1, 2)} ${top}`);
|
|
79
|
+
}
|
|
80
|
+
return parts.join(" ");
|
|
81
|
+
}
|
|
82
|
+
function drape(t, span, sag) {
|
|
83
|
+
return {
|
|
84
|
+
y: WIRE_TOP + 4 * sag * t * (1 - t),
|
|
85
|
+
slope: span > 0 ? 4 * sag * (1 - 2 * t) / span : 0
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function bulbPoints(width, swags, sag, count) {
|
|
89
|
+
if (count <= 0 || width <= 0) return [];
|
|
90
|
+
const span = width / swags;
|
|
91
|
+
const lengths = [0];
|
|
92
|
+
let prev = drape(0, span, sag);
|
|
93
|
+
let total = 0;
|
|
94
|
+
for (let i = 1; i <= ARC_SAMPLES; i++) {
|
|
95
|
+
const t = i / ARC_SAMPLES;
|
|
96
|
+
const cur = drape(t, span, sag);
|
|
97
|
+
total += Math.hypot(span / ARC_SAMPLES, cur.y - prev.y);
|
|
98
|
+
lengths.push(total);
|
|
99
|
+
prev = cur;
|
|
100
|
+
}
|
|
101
|
+
const whole = total * swags;
|
|
102
|
+
const points = [];
|
|
103
|
+
for (let b = 0; b < count; b++) {
|
|
104
|
+
const s = (b + 0.5) / count * whole;
|
|
105
|
+
const k = Math.min(swags - 1, Math.floor(s / total));
|
|
106
|
+
const local = s - k * total;
|
|
107
|
+
let i = 1;
|
|
108
|
+
while (i < ARC_SAMPLES && (lengths[i] ?? total) < local) i++;
|
|
109
|
+
const a = lengths[i - 1] ?? 0;
|
|
110
|
+
const z = lengths[i] ?? total;
|
|
111
|
+
const t = (i - 1 + (z > a ? (local - a) / (z - a) : 0)) / ARC_SAMPLES;
|
|
112
|
+
const at = drape(t, span, sag);
|
|
113
|
+
points.push({ x: k * span + t * span, y: at.y, slope: Math.atan(at.slope) });
|
|
114
|
+
}
|
|
115
|
+
return points;
|
|
116
|
+
}
|
|
117
|
+
function bulbTiming(pattern, index, count, speed, rand) {
|
|
118
|
+
if (pattern === "steady" || !(speed > 0)) return { delay: 0, duration: 0 };
|
|
119
|
+
const period = PATTERN_PERIODS[pattern] / speed;
|
|
120
|
+
switch (pattern) {
|
|
121
|
+
case "wave":
|
|
122
|
+
return {
|
|
123
|
+
delay: round(index / Math.max(1, count) * period - period),
|
|
124
|
+
duration: round(period)
|
|
125
|
+
};
|
|
126
|
+
case "alternate":
|
|
127
|
+
return { delay: index % 2 === 0 ? 0 : round(-period / 2), duration: round(period) };
|
|
128
|
+
case "breathe":
|
|
129
|
+
return { delay: 0, duration: round(period) };
|
|
130
|
+
case "twinkle": {
|
|
131
|
+
const own = period * (0.6 + rand() * 1.1);
|
|
132
|
+
return { delay: round(-rand() * own), duration: round(own) };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function stringLightsLayout(width, options = {}) {
|
|
137
|
+
const o = resolveOptions(options);
|
|
138
|
+
const w = width > 0 && Number.isFinite(width) ? width : FALLBACK_WIDTH;
|
|
139
|
+
const rand = mulberry32(o.seed);
|
|
140
|
+
const reach = o.size * (SOCKET_RATIO - SOCKET_OVERLAP + 0.5);
|
|
141
|
+
const bulbs = bulbPoints(w, o.swags, o.sag, o.count).map((p, i) => {
|
|
142
|
+
const tilt = p.slope * TILT_FOLLOW;
|
|
143
|
+
const timing = bulbTiming(o.pattern, i, o.count, o.speed, rand);
|
|
144
|
+
return {
|
|
145
|
+
x: round(p.x / w, 5),
|
|
146
|
+
y: round(p.y, 2),
|
|
147
|
+
angle: round(tilt * 180 / Math.PI, 2),
|
|
148
|
+
cx: round((p.x - Math.sin(tilt) * reach) / w, 5),
|
|
149
|
+
cy: round(p.y + Math.cos(tilt) * reach, 2),
|
|
150
|
+
color: o.colors[i % o.colors.length] ?? STRING_LIGHTS_DEFAULTS.colors[0] ?? "#ffd59a",
|
|
151
|
+
...timing
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
width: w,
|
|
156
|
+
height: reservedHeight(o.sag, o.size),
|
|
157
|
+
wire: wirePath(w, o.swags, o.sag),
|
|
158
|
+
bulbs
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function bulbStyle(bulb) {
|
|
162
|
+
return {
|
|
163
|
+
left: `${round(bulb.x * 100, 3)}%`,
|
|
164
|
+
top: `${bulb.y}px`,
|
|
165
|
+
"--sl-angle": `${bulb.angle}deg`,
|
|
166
|
+
"--sl-color": bulb.color,
|
|
167
|
+
"--sl-delay": `${bulb.delay}s`,
|
|
168
|
+
"--sl-duration": `${bulb.duration}s`
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function haloStyle(bulb) {
|
|
172
|
+
return {
|
|
173
|
+
left: `${round(bulb.cx * 100, 3)}%`,
|
|
174
|
+
top: `${bulb.cy}px`,
|
|
175
|
+
"--sl-color": bulb.color,
|
|
176
|
+
"--sl-delay": `${bulb.delay}s`,
|
|
177
|
+
"--sl-duration": `${bulb.duration}s`
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function createStringLights(elements, options = {}) {
|
|
181
|
+
const { root } = elements;
|
|
182
|
+
if (!root || typeof ResizeObserver === "undefined") return null;
|
|
183
|
+
let onResize = options.onResize;
|
|
184
|
+
let last = -1;
|
|
185
|
+
let destroyed = false;
|
|
186
|
+
const report = (width) => {
|
|
187
|
+
const w = Math.round(width);
|
|
188
|
+
if (destroyed || w <= 0 || w === last) return;
|
|
189
|
+
last = w;
|
|
190
|
+
onResize?.(w);
|
|
191
|
+
};
|
|
192
|
+
const observer = new ResizeObserver((entries) => {
|
|
193
|
+
const entry = entries[entries.length - 1];
|
|
194
|
+
if (entry) report(entry.contentRect.width);
|
|
195
|
+
});
|
|
196
|
+
observer.observe(root);
|
|
197
|
+
report(root.getBoundingClientRect().width);
|
|
198
|
+
return {
|
|
199
|
+
setOptions(next) {
|
|
200
|
+
if ("onResize" in next) onResize = next.onResize;
|
|
201
|
+
},
|
|
202
|
+
destroy() {
|
|
203
|
+
destroyed = true;
|
|
204
|
+
observer.disconnect();
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
export {
|
|
209
|
+
FALLBACK_WIDTH,
|
|
210
|
+
PATTERN_PERIODS,
|
|
211
|
+
SOCKET_OVERLAP,
|
|
212
|
+
SOCKET_RATIO,
|
|
213
|
+
STRING_LIGHTS_DEFAULTS,
|
|
214
|
+
STRING_LIGHTS_PATTERNS,
|
|
215
|
+
TILT_FOLLOW,
|
|
216
|
+
WIRE_TOP,
|
|
217
|
+
bulbPoints,
|
|
218
|
+
bulbStyle,
|
|
219
|
+
bulbTiming,
|
|
220
|
+
createStringLights,
|
|
221
|
+
effectivePattern,
|
|
222
|
+
haloStyle,
|
|
223
|
+
mulberry32,
|
|
224
|
+
reservedHeight,
|
|
225
|
+
resolveOptions,
|
|
226
|
+
stringLightsLayout,
|
|
227
|
+
wirePath
|
|
228
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./TerminalText.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const TerminalText = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const TerminalText = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4e11cdd8"]]);
|
|
5
5
|
export {
|
|
6
6
|
TerminalText as default
|
|
7
7
|
};
|