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.
- package/README.md +12 -12
- 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/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/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/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/index.d.ts +5 -0
- package/dist/index.js +326 -316
- package/dist/styles.css +1341 -0
- package/package.json +2 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "vue";
|
|
2
|
+
export type GiftRevealTrigger = "click" | "manual";
|
|
3
|
+
export interface GiftRevealProps {
|
|
4
|
+
/**
|
|
5
|
+
* What opens the box. `click` (default): the box is a button (click, tap,
|
|
6
|
+
* Enter or Space). `manual`: only the `open` model does.
|
|
7
|
+
*/
|
|
8
|
+
trigger?: GiftRevealTrigger;
|
|
9
|
+
/** Once opened, a press cannot close it again (`v-model:open` still can). */
|
|
10
|
+
once?: boolean;
|
|
11
|
+
/** Wrapping paper colour, `#rgb` or `#rrggbb` */
|
|
12
|
+
color?: string;
|
|
13
|
+
/** Ribbon and bow colour, `#rgb` or `#rrggbb` */
|
|
14
|
+
ribbonColor?: string;
|
|
15
|
+
/** Colour of the light that rises out of the box, `#rgb` or `#rrggbb` */
|
|
16
|
+
glowColor?: string;
|
|
17
|
+
/** Box width in pixels. The component is 1.8 × this wide and 2.1 × tall. */
|
|
18
|
+
size?: number;
|
|
19
|
+
/** Playback speed multiplier: 2 plays twice as fast */
|
|
20
|
+
speed?: number;
|
|
21
|
+
/** Accessible name of the box button */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Called when the box starts to open, whatever opened it (`@open`) */
|
|
24
|
+
onOpen?: (() => void) | (() => void)[];
|
|
25
|
+
/** Called when the box starts to close, whatever closed it (`@close`) */
|
|
26
|
+
onClose?: (() => void) | (() => void)[];
|
|
27
|
+
/** Additional CSS classes on the root */
|
|
28
|
+
class?: HTMLAttributes["class"];
|
|
29
|
+
}
|
|
30
|
+
declare const _default: typeof __VLS_export;
|
|
31
|
+
export default _default;
|
|
32
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<GiftRevealProps & {
|
|
33
|
+
/** Whether the box is open (`v-model:open`). */
|
|
34
|
+
open?: boolean;
|
|
35
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
36
|
+
"update:open": (value: boolean) => any;
|
|
37
|
+
}, string, import("vue").PublicProps, Readonly<GiftRevealProps & {
|
|
38
|
+
/** Whether the box is open (`v-model:open`). */
|
|
39
|
+
open?: boolean;
|
|
40
|
+
}> & Readonly<{
|
|
41
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
42
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
43
|
+
/** The revealed content */
|
|
44
|
+
default?(): unknown;
|
|
45
|
+
}>;
|
|
46
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
47
|
+
new (): {
|
|
48
|
+
$slots: S;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _sfc_main from "./GiftReveal.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const GiftReveal = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f28780c3"]]);
|
|
5
|
+
export {
|
|
6
|
+
GiftReveal as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { defineComponent, mergeModels, useModel, computed, ref, watch, createElementBlock, openBlock, mergeProps, unref, createElementVNode, createStaticVNode, Fragment, renderList, normalizeClass, renderSlot } from "vue";
|
|
2
|
+
import { cn } from "../../utils.js";
|
|
3
|
+
import { callListener } from "../../internals/call-listener.js";
|
|
4
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
5
|
+
import { useFancyId } from "../../internals/use-id.js";
|
|
6
|
+
import { giftRevealVars, GIFT_REVEAL_DEFAULTS, nextOpenOnPress } from "./gift-reveal-core.js";
|
|
7
|
+
const _hoisted_1 = ["data-open", "data-animate", "data-motion", "data-trigger"];
|
|
8
|
+
const _hoisted_2 = ["aria-expanded", "aria-label", "aria-disabled"];
|
|
9
|
+
const _hoisted_3 = { class: "gr-box" };
|
|
10
|
+
const _hoisted_4 = { class: "gr-camera" };
|
|
11
|
+
const _hoisted_5 = { class: "gr-sinker" };
|
|
12
|
+
const _hoisted_6 = { class: "gr-wiggle" };
|
|
13
|
+
const _hoisted_7 = { class: "gr-body" };
|
|
14
|
+
const _hoisted_8 = {
|
|
15
|
+
key: 0,
|
|
16
|
+
class: "gr-face gr-floor"
|
|
17
|
+
};
|
|
18
|
+
const _hoisted_9 = { class: "gr-lid-hint" };
|
|
19
|
+
const _hoisted_10 = { class: "gr-lid-lift" };
|
|
20
|
+
const _hoisted_11 = { class: "gr-lid" };
|
|
21
|
+
const _hoisted_12 = { class: "gr-face gr-face--out gr-lid-top" };
|
|
22
|
+
const _hoisted_13 = {
|
|
23
|
+
class: "gr-burst",
|
|
24
|
+
"aria-hidden": "true"
|
|
25
|
+
};
|
|
26
|
+
const _hoisted_14 = { class: "gr-motes" };
|
|
27
|
+
const _hoisted_15 = { class: "gr-emerge" };
|
|
28
|
+
const _hoisted_16 = ["aria-hidden", "inert"];
|
|
29
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
30
|
+
...{ name: "GiftReveal", inheritAttrs: false },
|
|
31
|
+
__name: "GiftReveal",
|
|
32
|
+
props: /* @__PURE__ */ mergeModels({
|
|
33
|
+
trigger: { default: () => GIFT_REVEAL_DEFAULTS.trigger },
|
|
34
|
+
once: { type: Boolean, default: () => GIFT_REVEAL_DEFAULTS.once },
|
|
35
|
+
color: { default: () => GIFT_REVEAL_DEFAULTS.color },
|
|
36
|
+
ribbonColor: { default: () => GIFT_REVEAL_DEFAULTS.ribbonColor },
|
|
37
|
+
glowColor: { default: () => GIFT_REVEAL_DEFAULTS.glowColor },
|
|
38
|
+
size: { default: () => GIFT_REVEAL_DEFAULTS.size },
|
|
39
|
+
speed: { default: () => GIFT_REVEAL_DEFAULTS.speed },
|
|
40
|
+
label: { default: () => GIFT_REVEAL_DEFAULTS.label },
|
|
41
|
+
onOpen: { type: [Function, Array] },
|
|
42
|
+
onClose: { type: [Function, Array] },
|
|
43
|
+
class: { type: [Boolean, null, String, Object, Array], default: "" }
|
|
44
|
+
}, {
|
|
45
|
+
"open": { type: Boolean, ...{ default: false } },
|
|
46
|
+
"openModifiers": {}
|
|
47
|
+
}),
|
|
48
|
+
emits: ["update:open"],
|
|
49
|
+
setup(__props) {
|
|
50
|
+
const open = useModel(__props, "open");
|
|
51
|
+
const reduced = useReducedMotion();
|
|
52
|
+
const contentId = `gift-reveal-${useFancyId()}`;
|
|
53
|
+
const style = computed(
|
|
54
|
+
() => giftRevealVars({ color: __props.color, ribbonColor: __props.ribbonColor, glowColor: __props.glowColor, size: __props.size, speed: __props.speed, reducedMotion: reduced.value })
|
|
55
|
+
);
|
|
56
|
+
const animate = ref(false);
|
|
57
|
+
const shown = ref(open.value);
|
|
58
|
+
watch(open, (want) => {
|
|
59
|
+
if (want === shown.value) return;
|
|
60
|
+
shown.value = want;
|
|
61
|
+
animate.value = true;
|
|
62
|
+
if (want) callListener(__props.onOpen);
|
|
63
|
+
else callListener(__props.onClose);
|
|
64
|
+
});
|
|
65
|
+
function press() {
|
|
66
|
+
const next = nextOpenOnPress(open.value, { trigger: __props.trigger, once: __props.once });
|
|
67
|
+
if (next !== null) open.value = next;
|
|
68
|
+
}
|
|
69
|
+
const locked = computed(() => __props.trigger === "manual" || __props.once && shown.value);
|
|
70
|
+
const BODY = ["back", "left", "floor", "right", "front"];
|
|
71
|
+
const LID_SIDES = ["back", "left", "right", "front"];
|
|
72
|
+
const ARMS = ["n", "s", "w", "e"];
|
|
73
|
+
const MOTES = [0, 1, 2, 3, 4, 5, 6, 7];
|
|
74
|
+
return (_ctx, _cache) => {
|
|
75
|
+
return openBlock(), createElementBlock("div", mergeProps({
|
|
76
|
+
class: unref(cn)("ft-gift-reveal", __props.class),
|
|
77
|
+
"data-open": shown.value ? "" : void 0,
|
|
78
|
+
"data-animate": animate.value ? "" : void 0,
|
|
79
|
+
"data-motion": unref(reduced) ? "reduced" : void 0,
|
|
80
|
+
"data-trigger": __props.trigger,
|
|
81
|
+
style: style.value
|
|
82
|
+
}, _ctx.$attrs), [
|
|
83
|
+
_cache[11] || (_cache[11] = createElementVNode("span", {
|
|
84
|
+
class: "gr-spill",
|
|
85
|
+
"aria-hidden": "true"
|
|
86
|
+
}, null, -1)),
|
|
87
|
+
createElementVNode("button", {
|
|
88
|
+
type: "button",
|
|
89
|
+
class: "gr-button",
|
|
90
|
+
"aria-expanded": shown.value,
|
|
91
|
+
"aria-controls": contentId,
|
|
92
|
+
"aria-label": __props.label,
|
|
93
|
+
"aria-disabled": locked.value ? "true" : void 0,
|
|
94
|
+
onClick: press
|
|
95
|
+
}, [
|
|
96
|
+
_cache[5] || (_cache[5] = createElementVNode("span", { class: "gr-groundglow" }, null, -1)),
|
|
97
|
+
_cache[6] || (_cache[6] = createElementVNode("span", { class: "gr-shadow" }, null, -1)),
|
|
98
|
+
createElementVNode("span", _hoisted_3, [
|
|
99
|
+
createElementVNode("span", _hoisted_4, [
|
|
100
|
+
createElementVNode("span", _hoisted_5, [
|
|
101
|
+
createElementVNode("span", _hoisted_6, [
|
|
102
|
+
createElementVNode("span", _hoisted_7, [
|
|
103
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(BODY, (side) => {
|
|
104
|
+
return openBlock(), createElementBlock(Fragment, { key: side }, [
|
|
105
|
+
side === "floor" ? (openBlock(), createElementBlock("span", _hoisted_8, [..._cache[0] || (_cache[0] = [
|
|
106
|
+
createElementVNode("span", { class: "gr-inlight" }, null, -1)
|
|
107
|
+
])])) : (openBlock(), createElementBlock("span", {
|
|
108
|
+
key: 1,
|
|
109
|
+
class: normalizeClass(`gr-wall gr-wall--${side}`)
|
|
110
|
+
}, [..._cache[1] || (_cache[1] = [
|
|
111
|
+
createStaticVNode('<span class="gr-face gr-face--out" data-v-f28780c3><span class="gr-band gr-band--v" data-v-f28780c3></span><span class="gr-shade" data-v-f28780c3></span><span class="gr-sheen" data-v-f28780c3></span></span><span class="gr-face gr-face--in" data-v-f28780c3><span class="gr-shade" data-v-f28780c3></span><span class="gr-inlight" data-v-f28780c3></span></span>', 2)
|
|
112
|
+
])], 2))
|
|
113
|
+
], 64);
|
|
114
|
+
}), 64))
|
|
115
|
+
]),
|
|
116
|
+
createElementVNode("span", _hoisted_9, [
|
|
117
|
+
createElementVNode("span", _hoisted_10, [
|
|
118
|
+
createElementVNode("span", _hoisted_11, [
|
|
119
|
+
_cache[4] || (_cache[4] = createElementVNode("span", { class: "gr-face gr-lid-under" }, null, -1)),
|
|
120
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(LID_SIDES, (side) => {
|
|
121
|
+
return createElementVNode("span", {
|
|
122
|
+
key: side,
|
|
123
|
+
class: normalizeClass(`gr-face gr-face--out gr-lid-side gr-lid-side--${side}`)
|
|
124
|
+
}, [..._cache[2] || (_cache[2] = [
|
|
125
|
+
createElementVNode("span", { class: "gr-band gr-band--v" }, null, -1),
|
|
126
|
+
createElementVNode("span", { class: "gr-shade" }, null, -1),
|
|
127
|
+
createElementVNode("span", { class: "gr-sheen" }, null, -1)
|
|
128
|
+
])], 2);
|
|
129
|
+
}), 64)),
|
|
130
|
+
createElementVNode("span", _hoisted_12, [
|
|
131
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(ARMS, (arm) => {
|
|
132
|
+
return createElementVNode("span", {
|
|
133
|
+
key: arm,
|
|
134
|
+
class: normalizeClass(`gr-band gr-band--${arm}`)
|
|
135
|
+
}, null, 2);
|
|
136
|
+
}), 64)),
|
|
137
|
+
_cache[3] || (_cache[3] = createElementVNode("span", { class: "gr-sheen" }, null, -1))
|
|
138
|
+
])
|
|
139
|
+
])
|
|
140
|
+
])
|
|
141
|
+
])
|
|
142
|
+
])
|
|
143
|
+
])
|
|
144
|
+
])
|
|
145
|
+
]),
|
|
146
|
+
_cache[7] || (_cache[7] = createStaticVNode('<span class="gr-bow" data-v-f28780c3><span class="gr-bow-wiggle" data-v-f28780c3><span class="gr-bow-hint" data-v-f28780c3><span class="gr-bow-shadow" data-v-f28780c3></span><span class="gr-tail gr-tail--l" data-v-f28780c3></span><span class="gr-tail gr-tail--r" data-v-f28780c3></span><span class="gr-loop gr-loop--l" data-v-f28780c3></span><span class="gr-loop gr-loop--r" data-v-f28780c3></span><span class="gr-knot" data-v-f28780c3></span></span></span></span>', 1))
|
|
147
|
+
], 8, _hoisted_2),
|
|
148
|
+
createElementVNode("span", _hoisted_13, [
|
|
149
|
+
_cache[8] || (_cache[8] = createElementVNode("span", { class: "gr-column" }, null, -1)),
|
|
150
|
+
_cache[9] || (_cache[9] = createElementVNode("span", { class: "gr-bloom" }, null, -1)),
|
|
151
|
+
_cache[10] || (_cache[10] = createElementVNode("span", { class: "gr-flash" }, null, -1)),
|
|
152
|
+
createElementVNode("span", _hoisted_14, [
|
|
153
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(MOTES, (i) => {
|
|
154
|
+
return createElementVNode("span", {
|
|
155
|
+
key: i,
|
|
156
|
+
class: "gr-mote"
|
|
157
|
+
});
|
|
158
|
+
}), 64))
|
|
159
|
+
])
|
|
160
|
+
]),
|
|
161
|
+
createElementVNode("div", _hoisted_15, [
|
|
162
|
+
createElementVNode("div", {
|
|
163
|
+
id: contentId,
|
|
164
|
+
class: "gr-content",
|
|
165
|
+
"aria-hidden": shown.value ? void 0 : "true",
|
|
166
|
+
inert: !shown.value || void 0
|
|
167
|
+
}, [
|
|
168
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
169
|
+
], 8, _hoisted_16)
|
|
170
|
+
])
|
|
171
|
+
], 16, _hoisted_1);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
export {
|
|
176
|
+
_sfc_main as default
|
|
177
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GiftReveal core: the opening and closing timeline of a wrapped box, and the
|
|
3
|
+
* CSS custom properties the wrappers write on the root so the stylesheet can
|
|
4
|
+
* play it.
|
|
5
|
+
*
|
|
6
|
+
* Framework-free and shared byte-for-byte by the Svelte, React and Vue
|
|
7
|
+
* wrappers (see shared-cores.json). It has no imports and never touches the
|
|
8
|
+
* DOM: every export is a pure function or a constant, safe during SSR.
|
|
9
|
+
*
|
|
10
|
+
* The box is drawn and moved by CSS only (3D transforms, transitions and
|
|
11
|
+
* keyframes). What this file decides is WHEN each part moves. The opening is
|
|
12
|
+
* five overlapping phases:
|
|
13
|
+
*
|
|
14
|
+
* anticipate the box squashes and wiggles, as if something inside stirs
|
|
15
|
+
* untie the bow loosens and the ribbon slides off
|
|
16
|
+
* lid the lid lifts, tilts back and drifts away
|
|
17
|
+
* burst warm light rises out of the box and spills around it
|
|
18
|
+
* reveal the content rises out and settles; the box sinks back
|
|
19
|
+
*
|
|
20
|
+
* Closing plays a shorter reverse. Each phase becomes a pair of custom
|
|
21
|
+
* properties per direction (`--gr-o-lid-delay`, `--gr-o-lid-dur` for opening,
|
|
22
|
+
* `--gr-c-lid-delay`, `--gr-c-lid-dur` for closing). Both directions are
|
|
23
|
+
* written at once, because a CSS transition takes its timing from the state
|
|
24
|
+
* it is heading TO: the open rule reads the `-o-` set, the closed rule the
|
|
25
|
+
* `-c-` set.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The motion tokens this timeline is built from, in milliseconds. Copied from
|
|
29
|
+
* `_internals/motion/tokens.ts` (DURATIONS) because a shared core may not
|
|
30
|
+
* import outside its folder; keep the two in sync by hand.
|
|
31
|
+
*/
|
|
32
|
+
export declare const GIFT_REVEAL_TOKENS: {
|
|
33
|
+
readonly micro: 80;
|
|
34
|
+
readonly fast: 150;
|
|
35
|
+
readonly base: 300;
|
|
36
|
+
readonly exit: 200;
|
|
37
|
+
readonly entrance: 600;
|
|
38
|
+
};
|
|
39
|
+
export type GiftRevealPhaseName = "anticipate" | "untie" | "lid" | "burst" | "reveal";
|
|
40
|
+
/** Every phase, in the order it starts when the box opens. */
|
|
41
|
+
export declare const GIFT_REVEAL_PHASE_NAMES: readonly GiftRevealPhaseName[];
|
|
42
|
+
export interface GiftRevealPhase {
|
|
43
|
+
name: GiftRevealPhaseName;
|
|
44
|
+
/** Milliseconds from the start of the sequence. */
|
|
45
|
+
start: number;
|
|
46
|
+
/** Milliseconds. */
|
|
47
|
+
duration: number;
|
|
48
|
+
}
|
|
49
|
+
export interface GiftRevealTimeline {
|
|
50
|
+
direction: "open" | "close";
|
|
51
|
+
phases: readonly GiftRevealPhase[];
|
|
52
|
+
/** Milliseconds until the last phase ends. */
|
|
53
|
+
total: number;
|
|
54
|
+
}
|
|
55
|
+
export declare const GIFT_REVEAL_DEFAULTS: {
|
|
56
|
+
readonly open: false;
|
|
57
|
+
readonly trigger: "click" | "manual";
|
|
58
|
+
readonly once: false;
|
|
59
|
+
/** Wrapping paper. A deep ink blue: reads as premium, not seasonal. */
|
|
60
|
+
readonly color: "#26324d";
|
|
61
|
+
/** Ribbon. Champagne, so it catches the light against the dark paper. */
|
|
62
|
+
readonly ribbonColor: "#e9d6ad";
|
|
63
|
+
/** The light that rises out of the box. */
|
|
64
|
+
readonly glowColor: "#ffd28a";
|
|
65
|
+
/** Box width in pixels. */
|
|
66
|
+
readonly size: 160;
|
|
67
|
+
/** Playback speed multiplier. 2 is twice as fast. */
|
|
68
|
+
readonly speed: 1;
|
|
69
|
+
/** Accessible name of the closed box. */
|
|
70
|
+
readonly label: "Open";
|
|
71
|
+
};
|
|
72
|
+
/** Slowest and fastest speed accepted, so a stray 0 never freezes the box. */
|
|
73
|
+
export declare const GIFT_REVEAL_SPEED_RANGE: {
|
|
74
|
+
readonly min: 0.1;
|
|
75
|
+
readonly max: 10;
|
|
76
|
+
};
|
|
77
|
+
/** Clamp a speed multiplier; anything not finite falls back to 1. */
|
|
78
|
+
export declare function clampSpeed(speed: number | undefined): number;
|
|
79
|
+
/** The timeline for one direction, scaled by `speed` (phases are rounded to whole ms). */
|
|
80
|
+
export declare function giftRevealTimeline(direction: "open" | "close", options?: {
|
|
81
|
+
speed?: number;
|
|
82
|
+
reducedMotion?: boolean;
|
|
83
|
+
}): GiftRevealTimeline;
|
|
84
|
+
/** `#rgb` or `#rrggbb`, lower-cased and expanded; anything else gives `fallback`. */
|
|
85
|
+
export declare function normalizeHex(value: string | undefined, fallback: string): string;
|
|
86
|
+
export interface GiftRevealStyleOptions {
|
|
87
|
+
color?: string;
|
|
88
|
+
ribbonColor?: string;
|
|
89
|
+
glowColor?: string;
|
|
90
|
+
size?: number;
|
|
91
|
+
speed?: number;
|
|
92
|
+
reducedMotion?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Every custom property the wrappers set on the root: colours, size and both
|
|
96
|
+
* timelines. The stylesheet derives lighter and darker shades of each colour
|
|
97
|
+
* itself with `color-mix()`.
|
|
98
|
+
*/
|
|
99
|
+
export declare function giftRevealVars(options?: GiftRevealStyleOptions): Record<string, string>;
|
|
100
|
+
/** The same properties as one inline `style` string, for wrappers that template it. */
|
|
101
|
+
export declare function giftRevealStyle(options?: GiftRevealStyleOptions): string;
|
|
102
|
+
/**
|
|
103
|
+
* What a press of the box does. `null` means nothing changes: the trigger is
|
|
104
|
+
* manual, or the box was opened with `once` and stays open.
|
|
105
|
+
*/
|
|
106
|
+
export declare function nextOpenOnPress(open: boolean, options?: {
|
|
107
|
+
trigger?: "click" | "manual";
|
|
108
|
+
once?: boolean;
|
|
109
|
+
}): boolean | null;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const GIFT_REVEAL_TOKENS = {
|
|
2
|
+
fast: 150,
|
|
3
|
+
base: 300,
|
|
4
|
+
exit: 200,
|
|
5
|
+
entrance: 600
|
|
6
|
+
};
|
|
7
|
+
const T = GIFT_REVEAL_TOKENS;
|
|
8
|
+
const GIFT_REVEAL_PHASE_NAMES = [
|
|
9
|
+
"anticipate",
|
|
10
|
+
"untie",
|
|
11
|
+
"lid",
|
|
12
|
+
"burst",
|
|
13
|
+
"reveal"
|
|
14
|
+
];
|
|
15
|
+
const OPEN = [
|
|
16
|
+
{ name: "anticipate", start: 0, duration: T.base + T.fast },
|
|
17
|
+
// the ribbon gives as the wiggle settles: bow, then the arms on the lid,
|
|
18
|
+
// then the bands down the sides
|
|
19
|
+
{ name: "untie", start: T.base, duration: T.entrance },
|
|
20
|
+
// the lid goes once the ribbon is off
|
|
21
|
+
{ name: "lid", start: T.base * 3, duration: T.entrance + T.base },
|
|
22
|
+
// light follows the lid out
|
|
23
|
+
{ name: "burst", start: T.base * 3 + T.fast, duration: T.entrance + T.base },
|
|
24
|
+
// the content rides the light up
|
|
25
|
+
{ name: "reveal", start: T.base * 4, duration: T.entrance + T.base }
|
|
26
|
+
];
|
|
27
|
+
const CLOSE = [
|
|
28
|
+
{ name: "reveal", start: 0, duration: T.exit },
|
|
29
|
+
{ name: "burst", start: 0, duration: T.exit },
|
|
30
|
+
{ name: "lid", start: T.fast, duration: T.base + T.fast },
|
|
31
|
+
{ name: "untie", start: T.base + T.fast, duration: T.base },
|
|
32
|
+
{ name: "anticipate", start: 0, duration: 0 }
|
|
33
|
+
];
|
|
34
|
+
const REDUCED = GIFT_REVEAL_PHASE_NAMES.map((name) => ({
|
|
35
|
+
name,
|
|
36
|
+
start: 0,
|
|
37
|
+
duration: T.base
|
|
38
|
+
}));
|
|
39
|
+
const GIFT_REVEAL_DEFAULTS = {
|
|
40
|
+
trigger: "click",
|
|
41
|
+
once: false,
|
|
42
|
+
/** Wrapping paper. A deep ink blue: reads as premium, not seasonal. */
|
|
43
|
+
color: "#26324d",
|
|
44
|
+
/** Ribbon. Champagne, so it catches the light against the dark paper. */
|
|
45
|
+
ribbonColor: "#e9d6ad",
|
|
46
|
+
/** The light that rises out of the box. */
|
|
47
|
+
glowColor: "#ffd28a",
|
|
48
|
+
/** Box width in pixels. */
|
|
49
|
+
size: 160,
|
|
50
|
+
/** Playback speed multiplier. 2 is twice as fast. */
|
|
51
|
+
speed: 1,
|
|
52
|
+
/** Accessible name of the closed box. */
|
|
53
|
+
label: "Open"
|
|
54
|
+
};
|
|
55
|
+
const GIFT_REVEAL_SPEED_RANGE = { min: 0.1, max: 10 };
|
|
56
|
+
function clampSpeed(speed) {
|
|
57
|
+
if (speed === void 0 || !Number.isFinite(speed)) return GIFT_REVEAL_DEFAULTS.speed;
|
|
58
|
+
return Math.min(GIFT_REVEAL_SPEED_RANGE.max, Math.max(GIFT_REVEAL_SPEED_RANGE.min, speed));
|
|
59
|
+
}
|
|
60
|
+
function giftRevealTimeline(direction, options = {}) {
|
|
61
|
+
const speed = clampSpeed(options.speed);
|
|
62
|
+
const source = options.reducedMotion ? REDUCED : direction === "open" ? OPEN : CLOSE;
|
|
63
|
+
const phases = source.map((p) => ({
|
|
64
|
+
name: p.name,
|
|
65
|
+
start: Math.round(p.start / speed),
|
|
66
|
+
duration: Math.round(p.duration / speed)
|
|
67
|
+
}));
|
|
68
|
+
const total = phases.reduce((end, p) => Math.max(end, p.start + p.duration), 0);
|
|
69
|
+
return { direction, phases, total };
|
|
70
|
+
}
|
|
71
|
+
function normalizeHex(value, fallback) {
|
|
72
|
+
if (typeof value !== "string") return fallback;
|
|
73
|
+
const v = value.trim().toLowerCase();
|
|
74
|
+
if (/^#[0-9a-f]{6}$/.test(v)) return v;
|
|
75
|
+
if (/^#[0-9a-f]{3}$/.test(v)) {
|
|
76
|
+
const [, r = "0", g = "0", b = "0"] = v;
|
|
77
|
+
return `#${r}${r}${g}${g}${b}${b}`;
|
|
78
|
+
}
|
|
79
|
+
return fallback;
|
|
80
|
+
}
|
|
81
|
+
function giftRevealVars(options = {}) {
|
|
82
|
+
const d = GIFT_REVEAL_DEFAULTS;
|
|
83
|
+
const size = typeof options.size === "number" && Number.isFinite(options.size) && options.size > 0 ? options.size : d.size;
|
|
84
|
+
const vars = {
|
|
85
|
+
"--gr-color": normalizeHex(options.color, d.color),
|
|
86
|
+
"--gr-ribbon": normalizeHex(options.ribbonColor, d.ribbonColor),
|
|
87
|
+
"--gr-glow": normalizeHex(options.glowColor, d.glowColor),
|
|
88
|
+
"--gr-size": `${size}px`
|
|
89
|
+
};
|
|
90
|
+
for (const direction of ["open", "close"]) {
|
|
91
|
+
const key = direction === "open" ? "o" : "c";
|
|
92
|
+
const timeline = giftRevealTimeline(direction, options);
|
|
93
|
+
for (const p of timeline.phases) {
|
|
94
|
+
vars[`--gr-${key}-${p.name}-delay`] = `${p.start}ms`;
|
|
95
|
+
vars[`--gr-${key}-${p.name}-dur`] = `${p.duration}ms`;
|
|
96
|
+
}
|
|
97
|
+
vars[`--gr-${key}-total`] = `${timeline.total}ms`;
|
|
98
|
+
}
|
|
99
|
+
return vars;
|
|
100
|
+
}
|
|
101
|
+
function nextOpenOnPress(open, options = {}) {
|
|
102
|
+
if ((options.trigger ?? GIFT_REVEAL_DEFAULTS.trigger) === "manual") return null;
|
|
103
|
+
if (open && options.once) return null;
|
|
104
|
+
return !open;
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
GIFT_REVEAL_DEFAULTS,
|
|
108
|
+
GIFT_REVEAL_PHASE_NAMES,
|
|
109
|
+
GIFT_REVEAL_SPEED_RANGE,
|
|
110
|
+
GIFT_REVEAL_TOKENS,
|
|
111
|
+
clampSpeed,
|
|
112
|
+
giftRevealTimeline,
|
|
113
|
+
giftRevealVars,
|
|
114
|
+
nextOpenOnPress,
|
|
115
|
+
normalizeHex
|
|
116
|
+
};
|
|
@@ -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
|
+
};
|