fancy-ui-vue 0.4.1 → 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.
Files changed (35) hide show
  1. package/README.md +12 -12
  2. package/dist/components/frost-glass/FrostGlass.vue.d.ts +31 -0
  3. package/dist/components/frost-glass/FrostGlass.vue.js +90 -0
  4. package/dist/components/frost-glass/FrostGlass.vue2.js +4 -0
  5. package/dist/components/frost-glass/frost-glass-core.d.ts +155 -0
  6. package/dist/components/frost-glass/frost-glass-core.js +820 -0
  7. package/dist/components/frost-glass/index.d.ts +2 -0
  8. package/dist/components/gift-reveal/GiftReveal.vue.d.ts +50 -0
  9. package/dist/components/gift-reveal/GiftReveal.vue.js +7 -0
  10. package/dist/components/gift-reveal/GiftReveal.vue2.js +177 -0
  11. package/dist/components/gift-reveal/gift-reveal-core.d.ts +109 -0
  12. package/dist/components/gift-reveal/gift-reveal-core.js +116 -0
  13. package/dist/components/gift-reveal/index.d.ts +2 -0
  14. package/dist/components/ornament/Ornament.vue.d.ts +29 -0
  15. package/dist/components/ornament/Ornament.vue.js +112 -0
  16. package/dist/components/ornament/Ornament.vue2.js +4 -0
  17. package/dist/components/ornament/index.d.ts +2 -0
  18. package/dist/components/ornament/ornament-core.d.ts +177 -0
  19. package/dist/components/ornament/ornament-core.js +861 -0
  20. package/dist/components/snowfall/Snowfall.vue.d.ts +29 -0
  21. package/dist/components/snowfall/Snowfall.vue.js +81 -0
  22. package/dist/components/snowfall/Snowfall.vue2.js +4 -0
  23. package/dist/components/snowfall/index.d.ts +2 -0
  24. package/dist/components/snowfall/snowfall-core.d.ts +119 -0
  25. package/dist/components/snowfall/snowfall-core.js +483 -0
  26. package/dist/components/string-lights/StringLights.vue.d.ts +35 -0
  27. package/dist/components/string-lights/StringLights.vue.js +7 -0
  28. package/dist/components/string-lights/StringLights.vue2.js +98 -0
  29. package/dist/components/string-lights/index.d.ts +2 -0
  30. package/dist/components/string-lights/string-lights-core.d.ts +157 -0
  31. package/dist/components/string-lights/string-lights-core.js +228 -0
  32. package/dist/index.d.ts +5 -0
  33. package/dist/index.js +326 -316
  34. package/dist/styles.css +1341 -0
  35. package/package.json +2 -2
@@ -0,0 +1,29 @@
1
+ import type { HTMLAttributes } from "vue";
2
+ import type { SnowfallBlend } from "./snowfall-core.js";
3
+ export interface SnowfallProps {
4
+ /** Flakes per 100 000 CSS px² of the area. The total is capped at 1600. */
5
+ density?: number;
6
+ /** Time multiplier for every motion. 0 holds the flakes in place. */
7
+ speed?: number;
8
+ /** Horizontal drift, -1 (to the left) to 1 (to the right). */
9
+ wind?: number;
10
+ /** 0 puts every flake at the same distance; 1 spreads them from far and sharp to near and soft. */
11
+ depth?: number;
12
+ /** Multiplier on every flake's size. */
13
+ size?: number;
14
+ /** Flake colour, `#rgb` or `#rrggbb`. */
15
+ color?: string;
16
+ /** Soft halo around the sharp flakes, 0 to 1. */
17
+ glow?: number;
18
+ /** `glow` lightens the page, `normal` paints over it, `auto` picks from the brightness of `color`. */
19
+ blend?: SnowfallBlend;
20
+ /** Same seed, same flakes. */
21
+ seed?: number;
22
+ /** Hold the snow still without tearing it down. */
23
+ paused?: boolean;
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<SnowfallProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<SnowfallProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -0,0 +1,81 @@
1
+ import { defineComponent, useTemplateRef, shallowRef, 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 { SNOWFALL_DEFAULTS, createSnowfall, fallbackBackground } from "./snowfall-core.js";
5
+ const _hoisted_1 = ["data-ready"];
6
+ const _hoisted_2 = {
7
+ ref: "canvas",
8
+ class: "absolute inset-0 block h-full w-full"
9
+ };
10
+ const _sfc_main = /* @__PURE__ */ defineComponent({
11
+ ...{ name: "Snowfall", inheritAttrs: false },
12
+ __name: "Snowfall",
13
+ props: {
14
+ density: { default: () => SNOWFALL_DEFAULTS.density },
15
+ speed: { default: () => SNOWFALL_DEFAULTS.speed },
16
+ wind: { default: () => SNOWFALL_DEFAULTS.wind },
17
+ depth: { default: () => SNOWFALL_DEFAULTS.depth },
18
+ size: { default: () => SNOWFALL_DEFAULTS.size },
19
+ color: { default: () => SNOWFALL_DEFAULTS.color },
20
+ glow: { default: () => SNOWFALL_DEFAULTS.glow },
21
+ blend: { default: () => SNOWFALL_DEFAULTS.blend },
22
+ seed: { default: () => SNOWFALL_DEFAULTS.seed },
23
+ paused: { type: Boolean, default: false },
24
+ class: { type: [Boolean, null, String, Object, Array], default: "" }
25
+ },
26
+ setup(__props) {
27
+ const canvasRef = useTemplateRef("canvas");
28
+ const engine = shallowRef(null);
29
+ const reducedMotion = useReducedMotion();
30
+ function liveOptions() {
31
+ return {
32
+ density: __props.density,
33
+ speed: __props.speed,
34
+ wind: __props.wind,
35
+ depth: __props.depth,
36
+ size: __props.size,
37
+ color: __props.color,
38
+ glow: __props.glow,
39
+ blend: __props.blend,
40
+ seed: __props.seed,
41
+ paused: __props.paused,
42
+ reducedMotion: reducedMotion.value
43
+ };
44
+ }
45
+ onMounted(() => {
46
+ const canvas = canvasRef.value;
47
+ if (!canvas) return;
48
+ engine.value = createSnowfall({ canvas }, liveOptions());
49
+ });
50
+ onBeforeUnmount(() => {
51
+ const instance = engine.value;
52
+ if (!instance) return;
53
+ engine.value = null;
54
+ instance.destroy();
55
+ });
56
+ watch(
57
+ [engine, liveOptions],
58
+ ([currentEngine, options]) => {
59
+ currentEngine?.setOptions(options);
60
+ },
61
+ { flush: "post" }
62
+ );
63
+ return (_ctx, _cache) => {
64
+ return openBlock(), createElementBlock("div", mergeProps(_ctx.$attrs, {
65
+ class: unref(cn)("fancy-snowfall pointer-events-none absolute inset-0 overflow-hidden", __props.class),
66
+ "aria-hidden": "true",
67
+ "data-ready": engine.value ? "" : void 0
68
+ }), [
69
+ !engine.value ? (openBlock(), createElementBlock("div", {
70
+ key: 0,
71
+ class: "fancy-snowfall-fallback absolute inset-0 opacity-60",
72
+ style: normalizeStyle({ backgroundImage: unref(fallbackBackground)(__props.color) })
73
+ }, null, 4)) : createCommentVNode("", true),
74
+ createElementVNode("canvas", _hoisted_2, null, 512)
75
+ ], 16, _hoisted_1);
76
+ };
77
+ }
78
+ });
79
+ export {
80
+ _sfc_main as default
81
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./Snowfall.vue.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,2 @@
1
+ export { default as Snowfall } from "./Snowfall.vue";
2
+ export type { SnowfallProps } from "./Snowfall.vue";
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Snowfall engine: falling flakes spread in depth, drawn by WebGL as point
3
+ * sprites in a single draw call.
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; `createSnowfall` is the only entry that needs a browser.
8
+ *
9
+ * Every flake is one point. Its starting place, depth and personality (sway,
10
+ * twinkle, size) are written into one vertex buffer when the engine starts or
11
+ * the seed changes, and never again. All motion is a closed-form function of
12
+ * time evaluated in the vertex shader, so a frame costs the CPU a handful of
13
+ * uniforms and one `drawArrays`.
14
+ *
15
+ * Depth works like a camera with a shallow focus set far away. Far flakes are
16
+ * small, sharp, slow and dim; near flakes are large and fall fast, and being
17
+ * out of focus they spread into soft discs whose edge is a little brighter than
18
+ * their middle, as a real lens draws them. A disc that spreads its light over a
19
+ * larger area is fainter per pixel, so near flakes stay quiet.
20
+ */
21
+ export interface SnowfallElements {
22
+ canvas: HTMLCanvasElement;
23
+ }
24
+ /**
25
+ * How the flakes meet the page. `glow` lightens what is behind (right for pale
26
+ * flakes on a dark page); `normal` lays the flake over it like paint (right for
27
+ * dark flakes on a light page); `auto` picks from the brightness of `color`.
28
+ */
29
+ export type SnowfallBlend = "auto" | "glow" | "normal";
30
+ export interface SnowfallLiveOptions {
31
+ /** Flakes per 100 000 CSS px² of canvas. Capped at `MAX_FLAKES` in total. */
32
+ density?: number;
33
+ /** Time multiplier for every motion. 0 holds the flakes in place. */
34
+ speed?: number;
35
+ /** Horizontal drift, -1 (to the left) to 1 (to the right). */
36
+ wind?: number;
37
+ /** 0 puts every flake at the same distance; 1 spreads them from far to near. */
38
+ depth?: number;
39
+ /** Multiplier on every flake's size. */
40
+ size?: number;
41
+ /** Flake colour, `#rgb` or `#rrggbb`. */
42
+ color?: string;
43
+ /** Soft halo around the sharp flakes, 0 to 1. */
44
+ glow?: number;
45
+ /** How the flakes meet the page. */
46
+ blend?: SnowfallBlend;
47
+ /** Same seed, same flakes. */
48
+ seed?: number;
49
+ /** Hold time still without tearing anything down. */
50
+ paused?: boolean;
51
+ /** Draw one still frame and run no loop. */
52
+ reducedMotion?: boolean;
53
+ }
54
+ export interface SnowfallInitOptions extends SnowfallLiveOptions {
55
+ /**
56
+ * Lose the WebGL context on destroy. Leave on unless the same canvas element
57
+ * is handed to a second engine afterwards (a context cannot be un-lost).
58
+ */
59
+ releaseContext?: boolean;
60
+ }
61
+ export interface SnowfallEngine {
62
+ setOptions(options: SnowfallLiveOptions): void;
63
+ /** Seconds of snow time elapsed, for tests and for wrappers that persist it. */
64
+ getTime(): number;
65
+ destroy(): void;
66
+ }
67
+ export declare const SNOWFALL_DEFAULTS: {
68
+ readonly density: 45;
69
+ readonly speed: 1;
70
+ readonly wind: 0.15;
71
+ readonly depth: 0.8;
72
+ readonly size: 1;
73
+ readonly color: "#f4f7ff";
74
+ readonly glow: 0.5;
75
+ readonly blend: "auto";
76
+ readonly seed: 1;
77
+ };
78
+ /** Hard ceiling on flakes, whatever the density and the canvas size. */
79
+ export declare const MAX_FLAKES = 1600;
80
+ /** Device pixel ratio above this is not worth its fill cost for a soft effect. */
81
+ export declare const MAX_PIXEL_RATIO = 2;
82
+ /** Longest step the clock takes, so a background tab does not teleport the snow. */
83
+ export declare const MAX_STEP: number;
84
+ /** Sideways speed at `wind: 1`, in CSS px per second, for a flake at middle depth. */
85
+ export declare const WIND_SPEED = 70;
86
+ /** Floats per flake in the vertex buffer. */
87
+ export declare const FLOATS_PER_FLAKE = 8;
88
+ /** Local PRNG so the same seed gives the same flakes in every framework. */
89
+ export declare function mulberry32(seed: number): () => number;
90
+ /** Parse `#rgb` / `#rrggbb` to 0..1 components; anything else gives the fallback. */
91
+ export declare function parseHexColor(value: string | undefined, fallback: readonly [number, number, number]): [number, number, number];
92
+ /**
93
+ * `glow` or `normal` for a requested blend and a flake colour. Lightening only
94
+ * shows on something darker than the flake, so a dark flake under `auto` is
95
+ * painted over the page instead.
96
+ */
97
+ export declare function resolveBlend(blend: SnowfallBlend | undefined, rgb: readonly [number, number, number]): "glow" | "normal";
98
+ /** Flakes to draw for a canvas of `width` × `height` CSS px. */
99
+ export declare function flakeCount(density: number, width: number, height: number): number;
100
+ /**
101
+ * The vertex buffer for `MAX_FLAKES` flakes, `FLOATS_PER_FLAKE` floats each:
102
+ * x, y (0..1 of the wrapped field), depth (0 far, 1 near), rank, then phase,
103
+ * sway rate, sway reach (0..1) and twinkle rate.
104
+ *
105
+ * Sorted far to near so `normal` blending paints near flakes over far ones.
106
+ * `rank` is a shuffled 0..MAX_FLAKES-1: the shader keeps a flake only when its
107
+ * rank is below the wanted count, so any count is an even sample across depth
108
+ * and a density change never needs a new buffer.
109
+ */
110
+ export declare function buildFlakes(seed: number): Float32Array;
111
+ /** Static CSS stand-in: a few soft dots, shown on the server and without WebGL. */
112
+ export declare function fallbackBackground(color: string): string;
113
+ export declare const VERTEX_SHADER = "\nprecision highp float;\n\nattribute vec4 aPlace;\nattribute vec4 aTraits;\n\nuniform vec2 uView;\nuniform float uPixelRatio;\nuniform float uMaxPoint;\nuniform float uTime;\nuniform float uDrift;\nuniform float uGust;\nuniform float uCount;\nuniform float uDepth;\nuniform float uSize;\nuniform float uGlow;\n\nvarying float vAlpha;\nvarying float vBlur;\nvarying float vCore;\n\nconst float TAU = 6.2831853;\n\n// Gusts as a displacement, never a speed, so the wind can never snap: three\n// slow incommensurate waves, felt a moment later lower down the screen.\nfloat gust(float t) {\n\treturn sin(t * 0.13) * 1.3 + sin(t * 0.29 + 1.7) * 0.7 + sin(t * 0.071 + 4.1) * 1.6;\n}\n\nvoid main() {\n\tif (aPlace.w >= uCount) {\n\t\t// Not part of this density: park it outside the clip volume.\n\t\tgl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n\t\tgl_PointSize = 1.0;\n\t\tvAlpha = 0.0;\n\t\tvBlur = 0.0;\n\t\tvCore = 1.0;\n\t\treturn;\n\t}\n\tfloat z = mix(0.42, aPlace.z, uDepth);\n\tfloat near = pow(z, 3.0);\n\tfloat phase = aTraits.x * TAU;\n\tfloat jitter = 0.7 + 0.6 * fract(aTraits.x * 7.13);\n\n\tfloat core = mix(1.7, 58.0, near) * uSize * jitter;\n\t// Out of focus from a little past the middle; the far field stays sharp.\n\tfloat blur = smoothstep(0.4, 0.92, z);\n\t// The halo only belongs to sharp flakes; a disc is already soft.\n\tfloat pad = 1.0 + uGlow * 4.0 * (1.0 - blur);\n\tfloat sprite = core * pad;\n\n\t// The field wraps with a margin wider than the largest sprite, so a flake\n\t// leaves the canvas entirely before it comes back on the other side.\n\tfloat margin = 24.0 + 44.0 * uSize;\n\tvec2 field = uView + 2.0 * margin;\n\n\tfloat fall = mix(13.0, 64.0, z) * (0.85 + 0.3 * fract(aTraits.x * 3.7));\n\tfloat y = mod(aPlace.y * field.y + uTime * fall, field.y) - margin;\n\n\tfloat parallax = mix(0.35, 1.35, z);\n\tfloat sway = sin(uTime * aTraits.y + phase) * mix(3.0, 26.0, near) * aTraits.z;\n\tfloat wind = (uDrift + gust(uTime - y / 500.0) * uGust) * parallax;\n\tfloat x = mod(aPlace.x * field.x + wind + sway, field.x) - margin;\n\n\tgl_Position = vec4(x / uView.x * 2.0 - 1.0, 1.0 - y / uView.y * 2.0, 0.0, 1.0);\n\t// The hardware caps point size; the shape is drawn in sprite units, so a\n\t// capped sprite only shrinks, it never clips.\n\tgl_PointSize = min(sprite * uPixelRatio, uMaxPoint);\n\n\tfloat twinkle = 1.0 + (1.0 - blur) * 0.32 * sin(uTime * aTraits.w * 2.0 + phase * 3.0);\n\t// Light per pixel falls as the disc spreads; the far field fades into the distance.\n\tfloat bright = mix(0.95, 0.15, blur) * mix(0.5, 1.0, smoothstep(0.0, 0.3, z));\n\tvAlpha = bright * twinkle;\n\tvBlur = blur;\n\tvCore = 1.0 / pad;\n}\n";
114
+ export declare const FRAGMENT_SHADER = "\nprecision highp float;\n\nuniform vec3 uColor;\nuniform float uGlow;\n\nvarying float vAlpha;\nvarying float vBlur;\nvarying float vCore;\n\nvoid main() {\n\tvec2 p = gl_PointCoord * 2.0 - 1.0;\n\tfloat r = length(p);\n\tif (r > 1.0) discard;\n\tfloat rc = r / vCore;\n\n\t// In focus a small bright dot; drifting out of focus it widens into a soft\n\t// blob before it settles into a disc.\n\tfloat sharp = exp(-rc * rc * mix(3.0, 1.4, smoothstep(0.0, 0.5, vBlur)));\n\t// Out of focus: a flat disc, soft at the edge, its rim a touch brighter.\n\tfloat edge = mix(0.4, 0.2, vBlur);\n\tfloat disc = 1.0 - smoothstep(1.0 - edge, 1.0, rc);\n\tfloat rim = smoothstep(0.55, 0.9, rc) * disc;\n\tfloat bokeh = disc * (0.78 + 0.32 * rim);\n\tfloat shape = mix(sharp, bokeh, smoothstep(0.35, 0.85, vBlur));\n\n\tfloat halo = exp(-r * r * 5.0) * (1.0 - smoothstep(0.7, 1.0, r)) * uGlow * 0.32 * (1.0 - vBlur);\n\n\tfloat a = clamp((shape + halo) * vAlpha, 0.0, 1.0);\n\tgl_FragColor = vec4(uColor * a, a);\n}\n";
115
+ /**
116
+ * Start the snow on `canvas`. Returns `null` when WebGL is unavailable or the
117
+ * shaders do not compile, so a wrapper can leave its fallback showing.
118
+ */
119
+ export declare function createSnowfall(elements: SnowfallElements, options?: SnowfallInitOptions): SnowfallEngine | null;