@alea-design/motion 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +336 -0
- package/dist/react.d.ts +211 -0
- package/package.json +57 -4
- package/src/motion.css +285 -0
- package/src/patterns.css +144 -0
- package/src/utilities.css +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alejandro Vasquez (https://alevasquez.dev)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @alea-design/motion
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Alea Motion**: a motion system for interfaces. 33 named patterns built from motion tokens, 13 enter/exit presets, utilities for your own elements, and small React helpers (Reveal, TextSwap, NumberRoll, Presence, AutoHeight, StreamingText, ScrollProgress). Reduced motion built in.
|
|
4
|
+
|
|
5
|
+
```css
|
|
6
|
+
@import '@alea-design/motion/motion.css';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { Reveal, NumberRoll, motionStyle } from '@alea-design/motion';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Docs: https://alea.alevasquez.dev/motion · MIT license
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './react';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as w, jsxs as A } from "react/jsx-runtime";
|
|
3
|
+
import { useState as b, useEffect as v, useRef as g, useCallback as T, createElement as E, isValidElement as S, cloneElement as R, Children as I, useLayoutEffect as z } from "react";
|
|
4
|
+
const B = typeof window > "u" ? v : z, V = ["out", "in", "in-out", "standard", "emphasized", "spring"], D = (t) => V.includes(t) ? `var(--alea-motion-${t === "spring" ? "spring" : "ease-" + t})` : t, L = (t, e) => t === "none" ? "none" : `alea-m-${t}-${e}`;
|
|
5
|
+
function O(t) {
|
|
6
|
+
if (t === void 0) return;
|
|
7
|
+
const e = t === !1 ? { enter: "none" } : typeof t == "string" ? { enter: t } : t, n = {};
|
|
8
|
+
return e.enter ? (n["--alea-enter"] = L(e.enter, "in"), n["--alea-exit"] = L(e.exit || e.enter, "out")) : e.exit && (n["--alea-exit"] = L(e.exit, "out")), e.duration != null ? (n["--alea-enter-duration"] = `${e.duration}ms`, n["--alea-exit-duration"] = `${e.exitDuration ?? Math.round(e.duration * 0.6)}ms`) : e.exitDuration != null && (n["--alea-exit-duration"] = `${e.exitDuration}ms`), e.easing && (n["--alea-enter-ease"] = D(e.easing)), e.delay != null && (n["--alea-enter-delay"] = `${e.delay}ms`), n;
|
|
9
|
+
}
|
|
10
|
+
function Q(t, e) {
|
|
11
|
+
const n = O(e);
|
|
12
|
+
return n ? typeof t == "function" ? ((o) => ({ ...n, ...t(o) })) : { ...n, ...t } : t;
|
|
13
|
+
}
|
|
14
|
+
const Y = {
|
|
15
|
+
popover: ".alea-popover",
|
|
16
|
+
select: ".alea-select-popover",
|
|
17
|
+
menu: ".alea-menu-popover",
|
|
18
|
+
tooltip: ".alea-tooltip",
|
|
19
|
+
dialog: ".alea-modal",
|
|
20
|
+
drawer: ".alea-drawer",
|
|
21
|
+
toast: ".alea-toast",
|
|
22
|
+
command: ".alea-command",
|
|
23
|
+
hovercard: ".alea-hovercard",
|
|
24
|
+
datepicker: ".alea-cal-popover",
|
|
25
|
+
tour: ".alea-tour-card"
|
|
26
|
+
}, k = { instant: 120, fast: 200, base: 320, slow: 480, slower: 720 }, H = { sm: 8, md: 12, lg: 24 }, X = { sm: 4, md: 8, lg: 16 };
|
|
27
|
+
function Z(t = {}) {
|
|
28
|
+
const e = {}, n = t.speed, o = t.intensity;
|
|
29
|
+
if (n != null && n !== 1) for (const [a, r] of Object.entries(k)) e[`--alea-motion-duration-${a}`] = `${Math.round(r * n)}ms`;
|
|
30
|
+
if (o != null && o !== 1) {
|
|
31
|
+
for (const [a, r] of Object.entries(H)) e[`--alea-motion-distance-${a}`] = `${+(r * o).toFixed(2)}px`;
|
|
32
|
+
for (const [a, r] of Object.entries(X)) e[`--alea-motion-blur-${a}`] = `${+(r * o).toFixed(2)}px`;
|
|
33
|
+
e["--alea-motion-scale-from"] = String(+(1 - 0.08 * o).toFixed(3)), e["--alea-motion-scale-press"] = String(+(1 - 0.04 * o).toFixed(3)), e["--alea-motion-lift"] = `${+(-4 * o).toFixed(2)}px`;
|
|
34
|
+
}
|
|
35
|
+
return e;
|
|
36
|
+
}
|
|
37
|
+
function q(t = {}) {
|
|
38
|
+
const e = {};
|
|
39
|
+
return t.mode && t.mode !== "expressive" && (e["data-alea-motion"] = t.mode), t.reduced && t.reduced !== "system" && (e["data-alea-reduced"] = t.reduced), e;
|
|
40
|
+
}
|
|
41
|
+
function ee(t = {}, e = ":root") {
|
|
42
|
+
return Object.entries(t).map(([n, o]) => {
|
|
43
|
+
const a = O(o), r = Y[n];
|
|
44
|
+
return !a || !r ? "" : `${e} ${r} { ${Object.entries(a).map(([i, c]) => `${i}: ${c};`).join(" ")} }`;
|
|
45
|
+
}).filter(Boolean).join(`
|
|
46
|
+
`);
|
|
47
|
+
}
|
|
48
|
+
function C() {
|
|
49
|
+
const [t, e] = b(!1);
|
|
50
|
+
return v(() => {
|
|
51
|
+
var r, i;
|
|
52
|
+
if (typeof window > "u") return;
|
|
53
|
+
const n = (r = window.matchMedia) == null ? void 0 : r.call(window, "(prefers-reduced-motion: reduce)"), o = () => {
|
|
54
|
+
const c = document.documentElement, d = c.getAttribute("data-alea-reduced"), u = c.getAttribute("data-alea-motion");
|
|
55
|
+
e(u === "off" || u === "reduced" || d === "always" || d !== "never" && !!(n != null && n.matches));
|
|
56
|
+
};
|
|
57
|
+
o(), (i = n == null ? void 0 : n.addEventListener) == null || i.call(n, "change", o);
|
|
58
|
+
const a = new MutationObserver(o);
|
|
59
|
+
return a.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-alea-motion", "data-alea-reduced"] }), () => {
|
|
60
|
+
var c;
|
|
61
|
+
(c = n == null ? void 0 : n.removeEventListener) == null || c.call(n, "change", o), a.disconnect();
|
|
62
|
+
};
|
|
63
|
+
}, []), t;
|
|
64
|
+
}
|
|
65
|
+
function U(t = {}) {
|
|
66
|
+
const { once: e = !0, margin: n = "0px 0px -10% 0px", threshold: o = 0.1 } = t, a = g(null), [r, i] = b(!1);
|
|
67
|
+
return v(() => {
|
|
68
|
+
const c = a.current;
|
|
69
|
+
if (!c || typeof IntersectionObserver > "u") {
|
|
70
|
+
i(!0);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const d = new IntersectionObserver(([u]) => {
|
|
74
|
+
u.isIntersecting ? (i(!0), e && d.disconnect()) : e || i(!1);
|
|
75
|
+
}, { rootMargin: n, threshold: o });
|
|
76
|
+
return d.observe(c), () => d.disconnect();
|
|
77
|
+
}, [e, n, o]), [a, r];
|
|
78
|
+
}
|
|
79
|
+
let N = null;
|
|
80
|
+
function W(t) {
|
|
81
|
+
return typeof IntersectionObserver > "u" ? () => {
|
|
82
|
+
} : (N ?? (N = new IntersectionObserver((e) => {
|
|
83
|
+
for (const n of e) n.target.toggleAttribute("data-alea-offscreen", !n.isIntersecting);
|
|
84
|
+
}, { rootMargin: "64px" })), N.observe(t), () => {
|
|
85
|
+
N == null || N.unobserve(t), t.removeAttribute("data-alea-offscreen");
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function te() {
|
|
89
|
+
const t = g(null);
|
|
90
|
+
return v(() => t.current ? W(t.current) : void 0, []), t;
|
|
91
|
+
}
|
|
92
|
+
function ne(t = 8) {
|
|
93
|
+
const [e, n] = b("up");
|
|
94
|
+
return v(() => {
|
|
95
|
+
let o = window.scrollY;
|
|
96
|
+
const a = () => {
|
|
97
|
+
const r = window.scrollY;
|
|
98
|
+
Math.abs(r - o) < t || (n(r > o && r > 64 ? "down" : "up"), o = r);
|
|
99
|
+
};
|
|
100
|
+
return window.addEventListener("scroll", a, { passive: !0 }), () => window.removeEventListener("scroll", a);
|
|
101
|
+
}, [t]), e;
|
|
102
|
+
}
|
|
103
|
+
function re() {
|
|
104
|
+
return { onPointerDown: T((e) => {
|
|
105
|
+
const n = e.currentTarget, o = n.getBoundingClientRect(), a = Math.hypot(Math.max(e.clientX - o.left, o.right - e.clientX), Math.max(e.clientY - o.top, o.bottom - e.clientY)) * 2, r = document.createElement("span");
|
|
106
|
+
r.className = "alea-ripple", r.setAttribute("aria-hidden", "true"), r.style.setProperty("--alea-ripple-x", `${e.clientX - o.left}px`), r.style.setProperty("--alea-ripple-y", `${e.clientY - o.top}px`), r.style.setProperty("--alea-ripple-size", `${a}px`), n.appendChild(r), r.addEventListener("animationend", () => r.remove()), window.setTimeout(() => r.remove(), 1200);
|
|
107
|
+
}, []), className: "alea-ripple-host" };
|
|
108
|
+
}
|
|
109
|
+
function oe(t) {
|
|
110
|
+
const e = typeof document < "u" ? document : null;
|
|
111
|
+
e != null && e.startViewTransition ? e.startViewTransition(t) : t();
|
|
112
|
+
}
|
|
113
|
+
function ae({ as: t = "div", motion: e = "rise", delay: n, once: o = !0, stagger: a, className: r, style: i, children: c, ...d }) {
|
|
114
|
+
const [u, s] = U({ once: o }), [l, f] = b(!1);
|
|
115
|
+
B(() => {
|
|
116
|
+
const m = u.current;
|
|
117
|
+
m && m.getBoundingClientRect().top > window.innerHeight && f(!0);
|
|
118
|
+
}, []);
|
|
119
|
+
const p = typeof e == "string" ? { enter: e } : e;
|
|
120
|
+
return E(t, {
|
|
121
|
+
...d,
|
|
122
|
+
ref: u,
|
|
123
|
+
className: r,
|
|
124
|
+
"data-reveal": l && !s ? "pending" : l ? "in" : void 0,
|
|
125
|
+
"data-stagger": a ? "reveal" : void 0,
|
|
126
|
+
style: { ...a ? {} : O({ ...p, delay: n ?? p.delay }), ...i }
|
|
127
|
+
}, c);
|
|
128
|
+
}
|
|
129
|
+
function ie({ show: t, exitClassName: e = "alea-dissolve-out", children: n }) {
|
|
130
|
+
const [o, a] = b(t), [r, i] = b(!1), c = g(null);
|
|
131
|
+
return v(() => {
|
|
132
|
+
var l;
|
|
133
|
+
if (t) {
|
|
134
|
+
a(!0), i(!1);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (!o) return;
|
|
138
|
+
i(!0);
|
|
139
|
+
const d = c.current, u = () => {
|
|
140
|
+
a(!1), i(!1);
|
|
141
|
+
}, s = ((l = d == null ? void 0 : d.getAnimations) == null ? void 0 : l.call(d)) || [];
|
|
142
|
+
if (!d || !s.length) {
|
|
143
|
+
const f = window.setTimeout(u, 0);
|
|
144
|
+
return () => window.clearTimeout(f);
|
|
145
|
+
}
|
|
146
|
+
Promise.all(s.map((f) => f.finished.catch(() => {
|
|
147
|
+
}))).then(u);
|
|
148
|
+
}, [t]), v(() => {
|
|
149
|
+
var d, u;
|
|
150
|
+
r && c.current && !((u = (d = c.current).getAnimations) != null && u.call(d).length) && (a(!1), i(!1));
|
|
151
|
+
}, [r]), !o || !S(n) ? null : R(n, { ref: c, className: [n.props.className, r && e].filter(Boolean).join(" ") });
|
|
152
|
+
}
|
|
153
|
+
function se({ children: t, as: e = "span", className: n, direction: o = "up", variant: a = "blur" }) {
|
|
154
|
+
const [r, i] = b([{ id: 0, node: t }]), c = g(t), d = g(0), u = (s) => {
|
|
155
|
+
var l;
|
|
156
|
+
return typeof s == "string" || typeof s == "number" ? String(s) : S(s) ? String(s.key ?? "") + JSON.stringify(((l = s.props) == null ? void 0 : l.children) ?? "") : "";
|
|
157
|
+
};
|
|
158
|
+
return v(() => {
|
|
159
|
+
if (u(t) === u(c.current)) {
|
|
160
|
+
i((s) => s.map((l) => l.out ? l : { ...l, node: t }));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
c.current = t, d.current += 1, i((s) => [...s.filter((l) => !l.out).map((l) => ({ ...l, out: !0 })), { id: d.current, node: t }]);
|
|
164
|
+
}, [t]), E(
|
|
165
|
+
e,
|
|
166
|
+
{ className: ["alea-swap", n].filter(Boolean).join(" "), "data-variant": a === "scale" ? "scale" : void 0, style: { "--alea-swap-dir": o === "up" ? 1 : -1 }, "aria-live": "polite" },
|
|
167
|
+
r.map((s) => /* @__PURE__ */ w("span", { className: s.id === 0 && !s.out ? void 0 : s.out ? "alea-swap-out" : "alea-swap-in", "aria-hidden": s.out || void 0, onAnimationEnd: s.out ? () => i((l) => l.filter((f) => f.id !== s.id)) : void 0, children: s.node }, s.id))
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function le({ value: t, format: e, locale: n, className: o }) {
|
|
171
|
+
const a = new Intl.NumberFormat(n, e).format(t);
|
|
172
|
+
return /* @__PURE__ */ A("span", { className: ["alea-roll", o].filter(Boolean).join(" "), children: [
|
|
173
|
+
/* @__PURE__ */ w("span", { className: "alea-visually-hidden", "aria-live": "polite", children: a }),
|
|
174
|
+
/* @__PURE__ */ w("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: [...a].map((r, i) => /\d/.test(r) ? /* @__PURE__ */ w("span", { className: "alea-roll-digit", children: /* @__PURE__ */ w("span", { className: "alea-roll-strip", style: { "--alea-roll-n": r }, children: "0123456789".split("").map((c) => /* @__PURE__ */ w("span", { children: c }, c)) }) }, a.length - i) : /* @__PURE__ */ w("span", { children: r }, `s${a.length - i}`)) })
|
|
175
|
+
] });
|
|
176
|
+
}
|
|
177
|
+
function ce({ children: t, className: e, as: n = "div" }) {
|
|
178
|
+
const o = g(null), [a, r] = b(void 0);
|
|
179
|
+
return v(() => {
|
|
180
|
+
const i = o.current;
|
|
181
|
+
if (!i || typeof ResizeObserver > "u") return;
|
|
182
|
+
const c = new ResizeObserver(() => r(i.offsetHeight));
|
|
183
|
+
return c.observe(i), () => c.disconnect();
|
|
184
|
+
}, []), E(n, { className: ["alea-autoheight", e].filter(Boolean).join(" "), style: a != null ? { height: a } : void 0 }, /* @__PURE__ */ w("div", { ref: o, children: t }));
|
|
185
|
+
}
|
|
186
|
+
function ue({ className: t }) {
|
|
187
|
+
const e = g(null), [n, o] = b(!1);
|
|
188
|
+
return v(() => {
|
|
189
|
+
var r;
|
|
190
|
+
if (typeof CSS < "u" && ((r = CSS.supports) != null && r.call(CSS, "animation-timeline: scroll()"))) {
|
|
191
|
+
o(!0);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const a = () => {
|
|
195
|
+
var c;
|
|
196
|
+
const i = document.documentElement.scrollHeight - window.innerHeight;
|
|
197
|
+
(c = e.current) == null || c.style.setProperty("--alea-scroll", String(i > 0 ? Math.min(1, window.scrollY / i) : 0));
|
|
198
|
+
};
|
|
199
|
+
return a(), window.addEventListener("scroll", a, { passive: !0 }), window.addEventListener("resize", a), () => {
|
|
200
|
+
window.removeEventListener("scroll", a), window.removeEventListener("resize", a);
|
|
201
|
+
};
|
|
202
|
+
}, []), /* @__PURE__ */ w("div", { ref: e, className: ["alea-scroll-progress", t].filter(Boolean).join(" "), "data-css": n || void 0, "aria-hidden": "true" });
|
|
203
|
+
}
|
|
204
|
+
function de({ chunks: t, streaming: e = !1, className: n, as: o = "p" }) {
|
|
205
|
+
return E(
|
|
206
|
+
o,
|
|
207
|
+
{ className: ["alea-stream", n].filter(Boolean).join(" "), "data-streaming": e || void 0, "aria-busy": e || void 0 },
|
|
208
|
+
I.toArray(t.map((a, r) => /* @__PURE__ */ w("span", { className: "alea-stream-chunk", children: a }, r)))
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
const M = /* @__PURE__ */ new Map(), j = (t) => {
|
|
212
|
+
const e = t.getBoundingClientRect();
|
|
213
|
+
return { x: e.left + window.scrollX, y: e.top + window.scrollY, w: e.width, h: e.height, radius: getComputedStyle(t).borderRadius, time: performance.now() };
|
|
214
|
+
};
|
|
215
|
+
function fe({ id: t, as: e = "div", duration: n, easing: o, fadeContent: a = !0, className: r, style: i, children: c, ...d }) {
|
|
216
|
+
const u = g(null), s = C();
|
|
217
|
+
return B(() => {
|
|
218
|
+
const l = u.current;
|
|
219
|
+
if (!l) return;
|
|
220
|
+
const f = M.get(t), p = j(l);
|
|
221
|
+
if (f && !s && performance.now() - f.time < 1500 && (f.w !== p.w || f.h !== p.h || f.x !== p.x || f.y !== p.y) && typeof l.animate == "function") {
|
|
222
|
+
const $ = n ?? (parseFloat(getComputedStyle(l).getPropertyValue("--alea-motion-duration-slow")) || 480), x = o ?? "cubic-bezier(0.2, 0, 0, 1)", h = f.w / Math.max(1, p.w), P = f.h / Math.max(1, p.h);
|
|
223
|
+
if (l.animate([
|
|
224
|
+
{ transformOrigin: "0 0", transform: `translate(${f.x - p.x}px, ${f.y - p.y}px) scale(${h}, ${P})`, borderRadius: f.radius },
|
|
225
|
+
{ transformOrigin: "0 0", transform: "none", borderRadius: p.radius }
|
|
226
|
+
], { duration: $, easing: x }), a) for (const F of Array.from(l.children)) F.animate([{ opacity: 0 }, { opacity: 0, offset: 0.35 }, { opacity: 1 }], { duration: $, easing: "ease-out" });
|
|
227
|
+
}
|
|
228
|
+
M.set(t, p);
|
|
229
|
+
const y = () => {
|
|
230
|
+
l.isConnected && M.set(t, j(l));
|
|
231
|
+
};
|
|
232
|
+
window.addEventListener("scroll", y, { passive: !0 });
|
|
233
|
+
const m = typeof ResizeObserver < "u" ? new ResizeObserver(y) : null;
|
|
234
|
+
return m == null || m.observe(l), () => {
|
|
235
|
+
y(), M.set(t, { ...M.get(t) || p, time: performance.now() }), window.removeEventListener("scroll", y), m == null || m.disconnect();
|
|
236
|
+
};
|
|
237
|
+
}, [t]), E(e, { ...d, ref: u, className: r, style: i, "data-morph": t }, c);
|
|
238
|
+
}
|
|
239
|
+
function pe({ from: t, to: e, active: n, className: o }) {
|
|
240
|
+
return /* @__PURE__ */ A("span", { className: ["alea-morph-icon", o].filter(Boolean).join(" "), "data-active": n || void 0, "aria-hidden": "true", children: [
|
|
241
|
+
/* @__PURE__ */ w("span", { className: "alea-morph-icon-a", children: t }),
|
|
242
|
+
/* @__PURE__ */ w("span", { className: "alea-morph-icon-b", children: e })
|
|
243
|
+
] });
|
|
244
|
+
}
|
|
245
|
+
const _ = { lift: "alea-hover-lift", press: "alea-press", tint: "alea-hover-tint", glow: "alea-hover-glow", hint: "alea-hint" };
|
|
246
|
+
function G(t, { on: e = "mount", value: n, delay: o, duration: a, once: r = !0 } = {}) {
|
|
247
|
+
const i = g(null);
|
|
248
|
+
v(() => {
|
|
249
|
+
const s = i.current;
|
|
250
|
+
if (e !== "visible" || !s) return;
|
|
251
|
+
if (typeof IntersectionObserver > "u") {
|
|
252
|
+
s.setAttribute("data-m-in", "");
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const l = new IntersectionObserver((f) => {
|
|
256
|
+
for (const p of f)
|
|
257
|
+
p.isIntersecting ? (s.setAttribute("data-m-in", ""), r && l.disconnect()) : r || s.removeAttribute("data-m-in");
|
|
258
|
+
}, { rootMargin: "0px 0px -8% 0px" });
|
|
259
|
+
return l.observe(s), () => l.disconnect();
|
|
260
|
+
}, [e, r]);
|
|
261
|
+
const c = g(n);
|
|
262
|
+
v(() => {
|
|
263
|
+
if (e !== "change" || Object.is(c.current, n)) return;
|
|
264
|
+
c.current = n;
|
|
265
|
+
const s = i.current;
|
|
266
|
+
s && (s.removeAttribute("data-m-run"), s.offsetWidth, s.setAttribute("data-m-run", ""));
|
|
267
|
+
}, [e, n]);
|
|
268
|
+
const d = {};
|
|
269
|
+
if (o != null && (d["--alea-m-delay"] = `${o}ms`), a != null && (d["--alea-m-duration"] = `${a}ms`), t === "stagger") return { ref: i, "data-stagger": "", style: d };
|
|
270
|
+
const u = _[t];
|
|
271
|
+
return u ? { ref: i, className: u, style: d } : { ref: i, className: "alea-m", "data-m": t, "data-m-on": e, ...e === "loop" ? { "data-alea-loop": "" } : {}, style: d };
|
|
272
|
+
}
|
|
273
|
+
function me({ pattern: t, children: e, ...n }) {
|
|
274
|
+
const o = G(t, n), a = I.only(e);
|
|
275
|
+
if (!S(a)) return e;
|
|
276
|
+
const r = a.props.ref, i = (l) => {
|
|
277
|
+
o.ref.current = l, typeof r == "function" ? r(l) : r && typeof r == "object" && (r.current = l);
|
|
278
|
+
}, { ref: c, className: d, style: u, ...s } = o;
|
|
279
|
+
return R(a, { ...s, ref: i, className: [a.props.className, d].filter(Boolean).join(" ") || void 0, style: { ...a.props.style, ...u } });
|
|
280
|
+
}
|
|
281
|
+
function ve({ as: t = "div", strength: e = 16, scroll: n = !1, className: o, style: a, children: r, ...i }) {
|
|
282
|
+
const c = g(null), d = C();
|
|
283
|
+
return v(() => {
|
|
284
|
+
var $;
|
|
285
|
+
const u = c.current;
|
|
286
|
+
if (!u || d || typeof window > "u") return;
|
|
287
|
+
const s = ($ = window.matchMedia) == null ? void 0 : $.call(window, "(pointer: fine)").matches, l = (x, h) => {
|
|
288
|
+
u.style.setProperty("--alea-par-x", x.toFixed(3)), u.style.setProperty("--alea-par-y", h.toFixed(3));
|
|
289
|
+
}, f = (x) => {
|
|
290
|
+
const h = u.getBoundingClientRect();
|
|
291
|
+
l(((x.clientX - h.left) / h.width - 0.5) * 2, ((x.clientY - h.top) / h.height - 0.5) * 2);
|
|
292
|
+
}, p = () => l(0, 0);
|
|
293
|
+
let y = 0;
|
|
294
|
+
const m = () => {
|
|
295
|
+
cancelAnimationFrame(y), y = requestAnimationFrame(() => {
|
|
296
|
+
const x = u.getBoundingClientRect(), h = x.top + x.height / 2 - window.innerHeight / 2;
|
|
297
|
+
u.style.setProperty("--alea-par-s", Math.max(-1, Math.min(1, h / window.innerHeight)).toFixed(3));
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
return s && (u.addEventListener("pointermove", f), u.addEventListener("pointerleave", p)), n && (window.addEventListener("scroll", m, { passive: !0 }), m()), () => {
|
|
301
|
+
u.removeEventListener("pointermove", f), u.removeEventListener("pointerleave", p), window.removeEventListener("scroll", m), cancelAnimationFrame(y);
|
|
302
|
+
};
|
|
303
|
+
}, [d, n]), E(t, { ...i, ref: c, className: ["alea-parallax", o].filter(Boolean).join(" "), style: { "--alea-par-strength": `${e}px`, ...a } }, r);
|
|
304
|
+
}
|
|
305
|
+
function we({ as: t = "div", depth: e = 0.5, className: n, style: o, children: a, ...r }) {
|
|
306
|
+
return E(t, { ...r, className: ["alea-parallax-layer", n].filter(Boolean).join(" "), style: { "--alea-depth": e, ...o } }, a);
|
|
307
|
+
}
|
|
308
|
+
export {
|
|
309
|
+
ce as AutoHeight,
|
|
310
|
+
Y as MOTION_SELECTORS,
|
|
311
|
+
fe as Morph,
|
|
312
|
+
pe as MorphIcon,
|
|
313
|
+
me as Motion,
|
|
314
|
+
le as NumberRoll,
|
|
315
|
+
ve as Parallax,
|
|
316
|
+
we as ParallaxLayer,
|
|
317
|
+
ie as Presence,
|
|
318
|
+
ae as Reveal,
|
|
319
|
+
ue as ScrollProgress,
|
|
320
|
+
de as StreamingText,
|
|
321
|
+
se as TextSwap,
|
|
322
|
+
q as motionAttributes,
|
|
323
|
+
ee as motionComponentCss,
|
|
324
|
+
O as motionStyle,
|
|
325
|
+
Z as motionVariables,
|
|
326
|
+
W as pauseWhenOffscreen,
|
|
327
|
+
oe as startViewTransition,
|
|
328
|
+
U as useInView,
|
|
329
|
+
G as useMotion,
|
|
330
|
+
te as useOffscreenPause,
|
|
331
|
+
C as useReducedMotion,
|
|
332
|
+
re as useRipple,
|
|
333
|
+
ne as useScrollDirection,
|
|
334
|
+
Q as withMotionStyle
|
|
335
|
+
};
|
|
336
|
+
//# sourceMappingURL=index.js.map
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { type CSSProperties, type ElementType, type PointerEvent as ReactPointerEvent, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
/** The enter/exit presets. Each maps to the keyframes alea-m-<preset>-in and -out in motion.css. */
|
|
3
|
+
export type MotionPreset = 'fade' | 'scale' | 'pop' | 'rise' | 'drop' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'blur' | 'zoom' | 'flip' | 'morph' | 'none';
|
|
4
|
+
/** The easing tokens, or any CSS easing. */
|
|
5
|
+
export type MotionEasing = 'out' | 'in' | 'in-out' | 'standard' | 'emphasized' | 'spring' | (string & {});
|
|
6
|
+
export interface MotionOptions {
|
|
7
|
+
/** How it comes in. */
|
|
8
|
+
enter?: MotionPreset;
|
|
9
|
+
/** How it goes out. Default: the same preset as enter. */
|
|
10
|
+
exit?: MotionPreset;
|
|
11
|
+
/** Enter duration in ms. */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** Exit duration in ms. Default 60% of duration. */
|
|
14
|
+
exitDuration?: number;
|
|
15
|
+
easing?: MotionEasing;
|
|
16
|
+
/** Delay before entering, in ms. */
|
|
17
|
+
delay?: number;
|
|
18
|
+
}
|
|
19
|
+
/** What a component's motion prop takes: a preset name, false for none, or options. Leave it out for the component's default. */
|
|
20
|
+
export type MotionProp = MotionPreset | false | MotionOptions;
|
|
21
|
+
/** The inline style for a motion prop: sets --alea-enter, --alea-exit and their timing on that one element (they don't inherit). */
|
|
22
|
+
export declare function motionStyle(motion: MotionProp | undefined): CSSProperties | undefined;
|
|
23
|
+
/** Merges a motion prop into a style prop (style props that are functions of the state are wrapped). */
|
|
24
|
+
export declare function withMotionStyle<S>(style: S, motion: MotionProp | undefined): S;
|
|
25
|
+
/** Components whose default motion can be changed for the whole app. */
|
|
26
|
+
export type MotionComponent = 'popover' | 'select' | 'menu' | 'tooltip' | 'dialog' | 'drawer' | 'toast' | 'command' | 'hovercard' | 'datepicker' | 'tour';
|
|
27
|
+
export declare const MOTION_SELECTORS: Record<MotionComponent, string>;
|
|
28
|
+
export interface MotionConfig {
|
|
29
|
+
/** expressive (default), productive (shorter and quieter, for dense apps), reduced (fades only) or off (no animation). */
|
|
30
|
+
mode?: 'expressive' | 'productive' | 'reduced' | 'off';
|
|
31
|
+
/** Follow the OS reduced motion setting (system, default), always reduce, or never (only when you offer your own switch). */
|
|
32
|
+
reduced?: 'system' | 'always' | 'never';
|
|
33
|
+
/** Multiplies every duration: 0.8 is snappier, 1.2 calmer. */
|
|
34
|
+
speed?: number;
|
|
35
|
+
/** Multiplies distances, scales and blur: 0 is fades only, 1 the default, 1.5 bolder. */
|
|
36
|
+
intensity?: number;
|
|
37
|
+
/** The default motion per component type, for the whole app. */
|
|
38
|
+
components?: Partial<Record<MotionComponent, MotionProp>>;
|
|
39
|
+
}
|
|
40
|
+
/** The token overrides for speed and intensity (set them on the root or a wrapper). */
|
|
41
|
+
export declare function motionVariables(c?: MotionConfig): Record<string, string>;
|
|
42
|
+
/** The attributes for a root: data-alea-motion and data-alea-reduced. */
|
|
43
|
+
export declare function motionAttributes(c?: MotionConfig): Record<string, string>;
|
|
44
|
+
/** CSS for per-component defaults, scoped under a selector (":root" for the page). */
|
|
45
|
+
export declare function motionComponentCss(components?: MotionConfig['components'], scope?: string): string;
|
|
46
|
+
/** True when motion should be reduced: the OS setting, or data-alea-motion / data-alea-reduced on <html>. */
|
|
47
|
+
export declare function useReducedMotion(): boolean;
|
|
48
|
+
/** Whether an element is on screen (IntersectionObserver). With once, it stays true after the first time. */
|
|
49
|
+
export declare function useInView<T extends Element>(options?: {
|
|
50
|
+
once?: boolean;
|
|
51
|
+
margin?: string;
|
|
52
|
+
threshold?: number;
|
|
53
|
+
}): readonly [import("react").RefObject<T | null>, boolean];
|
|
54
|
+
/** Marks the element data-alea-offscreen while it is out of view, which pauses every animation inside it (motion.css). One IntersectionObserver is shared by all. Returns the cleanup. */
|
|
55
|
+
export declare function pauseWhenOffscreen(el: Element): () => void;
|
|
56
|
+
/** A ref for a looping decoration (an aurora, a marquee, meteors, orbs): its animations pause while it is off screen and resume when it comes back. */
|
|
57
|
+
export declare function useOffscreenPause<T extends Element = HTMLElement>(): import("react").RefObject<T | null>;
|
|
58
|
+
/** 'up' or 'down' as the page scrolls (after a small threshold), for headers that hide on scroll. */
|
|
59
|
+
export declare function useScrollDirection(threshold?: number): 'up' | 'down';
|
|
60
|
+
/** Ripple: spread the returned props on any element; a ripple grows from the pointer on press. */
|
|
61
|
+
export declare function useRipple<T extends HTMLElement>(): {
|
|
62
|
+
onPointerDown: (e: ReactPointerEvent<T>) => void;
|
|
63
|
+
className: string;
|
|
64
|
+
};
|
|
65
|
+
/** Runs a DOM update inside a view transition when the browser has them (the route pattern). */
|
|
66
|
+
export declare function startViewTransition(update: () => void | Promise<void>): void;
|
|
67
|
+
type AsProps = {
|
|
68
|
+
as?: ElementType;
|
|
69
|
+
className?: string;
|
|
70
|
+
style?: CSSProperties;
|
|
71
|
+
children?: ReactNode;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
};
|
|
74
|
+
/** Content that enters when it scrolls into view (once). Without JavaScript it is simply shown. */
|
|
75
|
+
export declare function Reveal({ as, motion, delay, once, stagger, className, style, children, ...rest }: AsProps & {
|
|
76
|
+
/** The enter preset. Default rise. */
|
|
77
|
+
motion?: MotionPreset | MotionOptions;
|
|
78
|
+
/** Delay in ms. */
|
|
79
|
+
delay?: number;
|
|
80
|
+
/** Plays only the first time it enters the view. Default true. */
|
|
81
|
+
once?: boolean;
|
|
82
|
+
/** Children enter one after another instead of the whole block. */
|
|
83
|
+
stagger?: boolean;
|
|
84
|
+
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
85
|
+
/** Keeps a child mounted while it plays its exit (the dissolve preset by default), then unmounts it. */
|
|
86
|
+
export declare function Presence({ show, exitClassName, children }: {
|
|
87
|
+
show: boolean; /** The class that plays the exit. Default alea-dissolve-out. */
|
|
88
|
+
exitClassName?: string;
|
|
89
|
+
children: ReactElement<{
|
|
90
|
+
className?: string;
|
|
91
|
+
ref?: unknown;
|
|
92
|
+
}>;
|
|
93
|
+
}): ReactElement<{
|
|
94
|
+
className?: string;
|
|
95
|
+
ref?: unknown;
|
|
96
|
+
}, string | import("react").JSXElementConstructor<any>> | null;
|
|
97
|
+
/** Text or an icon that changes with a short blur crossfade (the swap pattern). Give it a key-able value. */
|
|
98
|
+
export declare function TextSwap({ children, as, className, direction, variant }: {
|
|
99
|
+
children: ReactNode;
|
|
100
|
+
as?: ElementType;
|
|
101
|
+
className?: string; /** Which way the new text enters. Default up. */
|
|
102
|
+
direction?: 'up' | 'down'; /** blur (text) or scale (icons). */
|
|
103
|
+
variant?: 'blur' | 'scale';
|
|
104
|
+
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
105
|
+
/** A number whose digits roll to the new value (the roll pattern). Screen readers get the formatted value once. */
|
|
106
|
+
export declare function NumberRoll({ value, format, locale, className }: {
|
|
107
|
+
value: number; /** Intl.NumberFormat options: currency, percent, compact. */
|
|
108
|
+
format?: Intl.NumberFormatOptions; /** A BCP 47 locale. Default the browser's. */
|
|
109
|
+
locale?: string;
|
|
110
|
+
className?: string;
|
|
111
|
+
}): import("react").JSX.Element;
|
|
112
|
+
/** Animates its height when its content changes size (the resize pattern). */
|
|
113
|
+
export declare function AutoHeight({ children, className, as }: {
|
|
114
|
+
children: ReactNode;
|
|
115
|
+
className?: string;
|
|
116
|
+
as?: ElementType;
|
|
117
|
+
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
118
|
+
/** A thin bar at the top that fills as the page scrolls (CSS scroll timeline where supported). */
|
|
119
|
+
export declare function ScrollProgress({ className }: {
|
|
120
|
+
className?: string;
|
|
121
|
+
}): import("react").JSX.Element;
|
|
122
|
+
/** Text that arrives in chunks (AI answers): new chunks fade in, a caret shows while streaming. */
|
|
123
|
+
export declare function StreamingText({ chunks, streaming, className, as }: {
|
|
124
|
+
chunks: string[]; /** Shows a caret while more is coming. */
|
|
125
|
+
streaming?: boolean;
|
|
126
|
+
className?: string;
|
|
127
|
+
as?: ElementType;
|
|
128
|
+
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
129
|
+
export interface MorphProps {
|
|
130
|
+
/** Elements with the same id morph into each other: when one replaces the other, the new one grows from the old one's box. */
|
|
131
|
+
id: string;
|
|
132
|
+
/** The element to render. Default div. */
|
|
133
|
+
as?: ElementType;
|
|
134
|
+
/** Duration in ms. Default the slow motion token (480). */
|
|
135
|
+
duration?: number;
|
|
136
|
+
/** Easing. Default a strong deceleration with no overshoot. */
|
|
137
|
+
easing?: string;
|
|
138
|
+
/** Fades the content in after the box has moved (default true), so text never looks stretched. */
|
|
139
|
+
fadeContent?: boolean;
|
|
140
|
+
className?: string;
|
|
141
|
+
style?: CSSProperties;
|
|
142
|
+
children?: ReactNode;
|
|
143
|
+
[key: string]: unknown;
|
|
144
|
+
}
|
|
145
|
+
/** A shared element: give two elements the same id and, when one replaces the other (a card that opens into its detail, a button that becomes a panel), the new one morphs from the old one's position, size and corners. Works without View Transitions; respects reduced motion. */
|
|
146
|
+
export declare function Morph({ id, as, duration, easing, fadeContent, className, style, children, ...rest }: MorphProps): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
147
|
+
/** Two icons that morph into each other: the active one turns and grows in while the other blurs out (play and pause, menu and close, copy and check). */
|
|
148
|
+
export declare function MorphIcon({ from, to, active, className }: {
|
|
149
|
+
from: ReactNode; /** The icon while active. */
|
|
150
|
+
to: ReactNode; /** Shows the to icon. */
|
|
151
|
+
active: boolean;
|
|
152
|
+
className?: string;
|
|
153
|
+
}): import("react").JSX.Element;
|
|
154
|
+
/** The named patterns you can put on your own elements (the CSS behind them is .alea-m in utilities.css). */
|
|
155
|
+
export type MotionPattern = 'fade' | 'pop' | 'rise' | 'drop' | 'scale' | 'zoom' | 'blur' | 'flip' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'badge' | 'nudge' | 'pulse' | 'draw' | 'lift' | 'press' | 'tint' | 'glow' | 'hint' | 'stagger';
|
|
156
|
+
/** When a pattern plays: on mount (default), while hovered, pressed or focused, when it scrolls into view, each time a value changes, or in a loop. */
|
|
157
|
+
export type MotionTrigger = 'mount' | 'hover' | 'press' | 'focus' | 'visible' | 'change' | 'loop';
|
|
158
|
+
export interface UseMotionOptions {
|
|
159
|
+
/** When it plays. Default 'mount'. */
|
|
160
|
+
on?: MotionTrigger;
|
|
161
|
+
/** With on="change": the value that replays the pattern each time it changes (not on the first render). */
|
|
162
|
+
value?: unknown;
|
|
163
|
+
/** Wait before playing, in ms. */
|
|
164
|
+
delay?: number;
|
|
165
|
+
/** How long it takes, in ms. Default the pattern's token. */
|
|
166
|
+
duration?: number;
|
|
167
|
+
/** With on="visible": play only the first time (default) or each time it scrolls in. */
|
|
168
|
+
once?: boolean;
|
|
169
|
+
}
|
|
170
|
+
/** Any Alea Motion pattern on your own element: spread the result on it (it carries a ref, a class and data attributes). */
|
|
171
|
+
export declare function useMotion<T extends HTMLElement = HTMLElement>(pattern: MotionPattern, { on, value, delay, duration, once }?: UseMotionOptions): {
|
|
172
|
+
ref: import("react").RefObject<T | null>;
|
|
173
|
+
'data-stagger': string;
|
|
174
|
+
style: CSSProperties;
|
|
175
|
+
className?: undefined;
|
|
176
|
+
} | {
|
|
177
|
+
ref: import("react").RefObject<T | null>;
|
|
178
|
+
className: string;
|
|
179
|
+
style: CSSProperties;
|
|
180
|
+
'data-stagger'?: undefined;
|
|
181
|
+
} | {
|
|
182
|
+
style: CSSProperties;
|
|
183
|
+
'data-alea-loop'?: string | undefined;
|
|
184
|
+
ref: import("react").RefObject<T | null>;
|
|
185
|
+
className: string;
|
|
186
|
+
'data-m': "fade" | "scale" | "pop" | "rise" | "drop" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "blur" | "zoom" | "flip" | "badge" | "nudge" | "pulse" | "draw" | "lift" | "press" | "tint" | "glow" | "hint";
|
|
187
|
+
'data-m-on': MotionTrigger;
|
|
188
|
+
'data-stagger'?: undefined;
|
|
189
|
+
};
|
|
190
|
+
export interface MotionProps extends UseMotionOptions {
|
|
191
|
+
/** The pattern: pop, rise, nudge, pulse, badge, lift, press… */
|
|
192
|
+
pattern: MotionPattern;
|
|
193
|
+
/** One element (any Alea component or your own): it gets the pattern, no wrapper is added. */
|
|
194
|
+
children: ReactElement;
|
|
195
|
+
}
|
|
196
|
+
/** Puts an Alea Motion pattern on its child, with no wrapper: <Motion pattern="pop" on="change" value={count}><Badge>{count}</Badge></Motion>. */
|
|
197
|
+
export declare function Motion({ pattern, children, ...options }: MotionProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
198
|
+
/** A box whose layers drift with the pointer (and, with scroll, with the page): the hero pattern. Layers are
|
|
199
|
+
* ParallaxLayer children with a depth; a depth of 1 moves the full strength, 0.3 a third of it. Nothing moves
|
|
200
|
+
* with reduced motion, and without JavaScript the layers simply sit still. */
|
|
201
|
+
export declare function Parallax({ as, strength, scroll, className, style, children, ...rest }: AsProps & {
|
|
202
|
+
/** How far a depth-1 layer travels, in px. Default 16. */
|
|
203
|
+
strength?: number;
|
|
204
|
+
/** Also drift vertically as the box crosses the viewport. Default false. */
|
|
205
|
+
scroll?: boolean;
|
|
206
|
+
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
207
|
+
/** One layer of a Parallax: depth 1 moves the full strength, 0 stays put; negative depths move the other way. */
|
|
208
|
+
export declare function ParallaxLayer({ as, depth, className, style, children, ...rest }: AsProps & {
|
|
209
|
+
depth?: number;
|
|
210
|
+
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
211
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alea-design/motion",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Alea Motion: a motion system for interfaces. Tokens, named patterns, microinteractions and effects in CSS for any stack, plus small React helpers. Reduced motion built in.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"motion",
|
|
7
|
+
"animation",
|
|
8
|
+
"transitions",
|
|
9
|
+
"microinteractions",
|
|
10
|
+
"reduced motion",
|
|
11
|
+
"react",
|
|
12
|
+
"css",
|
|
13
|
+
"design system"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://alea.alevasquez.dev",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/alevascha/alea-design.git",
|
|
19
|
+
"directory": "packages/motion"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/alevascha/alea-design/issues"
|
|
23
|
+
},
|
|
24
|
+
"author": "Alejandro Vasquez (https://alevasquez.dev)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "dist/index.js",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./motion.css": "./src/motion.css",
|
|
35
|
+
"./patterns.css": "./src/patterns.css",
|
|
36
|
+
"./utilities.css": "./src/utilities.css"
|
|
37
|
+
},
|
|
38
|
+
"sideEffects": [
|
|
39
|
+
"*.css"
|
|
40
|
+
],
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"!dist/**/*.map",
|
|
44
|
+
"src/*.css",
|
|
45
|
+
"LICENSE",
|
|
46
|
+
"README.md"
|
|
47
|
+
],
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"test": "vitest run --root ../react src/__tests__/motion"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": ">=18.3"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/motion.css
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/* Alea Motion. Every animation in the kit is one of these patterns, built only
|
|
2
|
+
from the motion tokens (--alea-motion-*). Nothing here changes layout. With
|
|
3
|
+
reduced motion the distances, scales and stagger go to zero (things fade,
|
|
4
|
+
nothing moves) and decorative loops stop. See the Motion page in the docs.
|
|
5
|
+
|
|
6
|
+
pop anchored overlays grow from their trigger popover, select, combobox, menus, date pickers, hover card, tooltip
|
|
7
|
+
rise page-level overlays come up a little dialog, alert dialog, command palette, toast, tour
|
|
8
|
+
slide panels come in from their edge drawer, bottom sheet, mobile nav
|
|
9
|
+
stagger items enter one after another command palette results (popover options and menu items arrive with their popover)
|
|
10
|
+
expand content opens to its height accordion, spoiler, tree, navigation menu panels
|
|
11
|
+
glide the selection moves to the new item tabs, segmented control, toggle group
|
|
12
|
+
lift clickable surfaces rise on hover interactive cards, kanban cards, image tiles, float button
|
|
13
|
+
press controls shrink a little while pressed buttons, icon buttons, toggles, tags, pagination, tools
|
|
14
|
+
morph an icon turns into its other state chevrons, burger, check marks, theme toggle, copy
|
|
15
|
+
tint hover and selection colors fade in options, menu items, list rows, links, inputs
|
|
16
|
+
nudge an invalid field shakes once text fields, selects, pickers after a failed submit
|
|
17
|
+
draw strokes and bars grow into place check marks, progress, steps, charts
|
|
18
|
+
pulse something live or new breathes status dots, indicators, live badges
|
|
19
|
+
shimmer a sheen sweeps over a placeholder skeleton
|
|
20
|
+
(patterns.css: swap, roll, badge pop, success, dissolve, resize, fan, ripple, hold, hint, reveal, scroll, stream, route)
|
|
21
|
+
|
|
22
|
+
HOW TO CHANGE IT
|
|
23
|
+
1. Globally: set the tokens (--alea-motion-duration-base...), or data-alea-motion on <html>:
|
|
24
|
+
"productive" (shorter, quieter), "expressive" (default), "reduced" (fades only) or "off".
|
|
25
|
+
2. Per component type, in your CSS: .alea-popover { --alea-enter: alea-m-fade-in; --alea-exit: alea-m-fade-out; }
|
|
26
|
+
3. Per instance, with the motion prop: <Select motion="fade" />, <Dialog motion={{ enter: 'scale', duration: 300 }} />
|
|
27
|
+
The enter/exit variables do not inherit (@property), so a dialog's motion never leaks into the select inside it.
|
|
28
|
+
Presets: fade, scale, pop, rise, drop, slide-up, slide-down, slide-left, slide-right, blur, zoom, flip, morph, none. */
|
|
29
|
+
|
|
30
|
+
@import './patterns.css';
|
|
31
|
+
@import './utilities.css';
|
|
32
|
+
|
|
33
|
+
@property --alea-enter { syntax: '*'; inherits: false; }
|
|
34
|
+
@property --alea-exit { syntax: '*'; inherits: false; }
|
|
35
|
+
@property --alea-enter-duration { syntax: '*'; inherits: false; }
|
|
36
|
+
@property --alea-exit-duration { syntax: '*'; inherits: false; }
|
|
37
|
+
@property --alea-enter-ease { syntax: '*'; inherits: false; }
|
|
38
|
+
@property --alea-exit-ease { syntax: '*'; inherits: false; }
|
|
39
|
+
@property --alea-enter-delay { syntax: '*'; inherits: false; }
|
|
40
|
+
|
|
41
|
+
/* ------------------------------------------------------------------ the preset keyframes (alea-m-<preset>-in / -out) */
|
|
42
|
+
@keyframes alea-m-fade-in { from { opacity: 0.01; } }
|
|
43
|
+
@keyframes alea-m-fade-out { to { opacity: 0.01; } }
|
|
44
|
+
@keyframes alea-m-scale-in { from { opacity: 0.01; transform: scale(var(--alea-motion-scale-from)); } }
|
|
45
|
+
@keyframes alea-m-scale-out { to { opacity: 0.01; transform: scale(var(--alea-motion-scale-from)); } }
|
|
46
|
+
@keyframes alea-m-pop-in { from { opacity: 0.01; transform: translate(var(--alea-pop-x, 0), var(--alea-pop-y, 0)) scale(var(--alea-motion-scale-from)); } }
|
|
47
|
+
@keyframes alea-m-pop-out { to { opacity: 0.01; transform: scale(calc((1 + var(--alea-motion-scale-from)) / 2)); } }
|
|
48
|
+
@keyframes alea-m-rise-in { from { opacity: 0.01; transform: translateY(var(--alea-rise-y, var(--alea-motion-distance-lg))) scale(calc((1 + var(--alea-motion-scale-from)) / 2)); } }
|
|
49
|
+
@keyframes alea-m-rise-out { to { opacity: 0.01; transform: translateY(var(--alea-motion-distance-sm)) scale(calc((1 + var(--alea-motion-scale-from)) / 2)); } }
|
|
50
|
+
@keyframes alea-m-drop-in { from { opacity: 0.01; transform: translateY(calc(var(--alea-motion-distance-lg) * -1)); } }
|
|
51
|
+
@keyframes alea-m-drop-out { to { opacity: 0.01; transform: translateY(calc(var(--alea-motion-distance-sm) * -1)); } }
|
|
52
|
+
@keyframes alea-m-slide-up-in { from { opacity: 0.4; transform: translateY(var(--alea-slide-distance, calc(var(--alea-motion-distance-lg) * 2))); } }
|
|
53
|
+
@keyframes alea-m-slide-up-out { to { opacity: 0.01; transform: translateY(var(--alea-slide-distance, calc(var(--alea-motion-distance-lg) * 2))); } }
|
|
54
|
+
@keyframes alea-m-slide-down-in { from { opacity: 0.4; transform: translateY(calc(var(--alea-slide-distance, calc(var(--alea-motion-distance-lg) * 2)) * -1)); } }
|
|
55
|
+
@keyframes alea-m-slide-down-out { to { opacity: 0.01; transform: translateY(calc(var(--alea-slide-distance, calc(var(--alea-motion-distance-lg) * 2)) * -1)); } }
|
|
56
|
+
@keyframes alea-m-slide-left-in { from { opacity: 0.4; transform: translateX(var(--alea-slide-distance, calc(var(--alea-motion-distance-lg) * 2))); } }
|
|
57
|
+
@keyframes alea-m-slide-left-out { to { opacity: 0.01; transform: translateX(var(--alea-slide-distance, calc(var(--alea-motion-distance-lg) * 2))); } }
|
|
58
|
+
@keyframes alea-m-slide-right-in { from { opacity: 0.4; transform: translateX(calc(var(--alea-slide-distance, calc(var(--alea-motion-distance-lg) * 2)) * -1)); } }
|
|
59
|
+
@keyframes alea-m-slide-right-out { to { opacity: 0.01; transform: translateX(calc(var(--alea-slide-distance, calc(var(--alea-motion-distance-lg) * 2)) * -1)); } }
|
|
60
|
+
@keyframes alea-m-blur-in { from { opacity: 0.01; filter: blur(var(--alea-motion-blur-md)); transform: scale(calc((1 + var(--alea-motion-scale-from)) / 2)); } }
|
|
61
|
+
@keyframes alea-m-blur-out { to { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); } }
|
|
62
|
+
@keyframes alea-m-zoom-in { from { opacity: 0.01; transform: scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 4)); } }
|
|
63
|
+
@keyframes alea-m-zoom-out { to { opacity: 0.01; transform: scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 2)); } }
|
|
64
|
+
@keyframes alea-m-flip-in { from { opacity: 0.01; transform: perspective(800px) rotateX(calc(var(--alea-motion-rotate, 12deg) * -1)) translateY(var(--alea-motion-distance-sm)); } }
|
|
65
|
+
@keyframes alea-m-flip-out { to { opacity: 0.01; transform: perspective(800px) rotateX(calc(var(--alea-motion-rotate, 12deg) * 0.5)); } }
|
|
66
|
+
/* morph: an anchored menu grows out of its trigger's shape (React Aria sets --trigger-width) */
|
|
67
|
+
@keyframes alea-m-morph-in { from { opacity: 0.4; clip-path: inset(0 calc(100% - var(--trigger-width, 100%)) calc(100% - var(--alea-size-control-md, 40px)) 0 round var(--alea-radius-full)); } to { clip-path: inset(0 0 0 0 round var(--alea-radius-md)); } }
|
|
68
|
+
@keyframes alea-m-morph-out { to { opacity: 0.01; clip-path: inset(0 calc(100% - var(--trigger-width, 100%)) calc(100% - var(--alea-size-control-md, 40px)) 0 round var(--alea-radius-full)); } }
|
|
69
|
+
/* drawers: from their own edge (--alea-slide is set per placement below) */
|
|
70
|
+
@keyframes alea-m-edge-in { from { transform: var(--alea-slide); opacity: 0.4; } }
|
|
71
|
+
@keyframes alea-m-edge-out { to { transform: var(--alea-slide); opacity: 0.4; } }
|
|
72
|
+
@keyframes alea-m-toast-in { from { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); transform: translateY(var(--alea-motion-distance-md)) scale(var(--alea-motion-scale-from)); } }
|
|
73
|
+
@keyframes alea-m-toast-out { to { opacity: 0.01; transform: translateX(var(--alea-motion-distance-lg)); } }
|
|
74
|
+
|
|
75
|
+
@keyframes alea-item-in { from { opacity: 0.01; transform: translateY(var(--alea-motion-distance-sm)); } }
|
|
76
|
+
@keyframes alea-nudge { 0%, 100% { transform: none; } 20% { transform: translateX(calc(var(--alea-motion-distance-sm) * -1)); } 40% { transform: translateX(var(--alea-motion-distance-sm)); } 60% { transform: translateX(calc(var(--alea-motion-distance-sm) * -0.5)); } 80% { transform: translateX(calc(var(--alea-motion-distance-sm) * 0.5)); } }
|
|
77
|
+
@keyframes alea-ping { to { transform: scale(2.2); opacity: 0.01; } }
|
|
78
|
+
@keyframes alea-check-pop { 0% { transform: scale(var(--alea-motion-scale-press)); } 60% { transform: scale(calc(2 - var(--alea-motion-scale-press))); } 100% { transform: none; } }
|
|
79
|
+
|
|
80
|
+
/* ------------------------------------------------------------------ presets on an element (data-motion), used by the motion prop and by hand */
|
|
81
|
+
[data-motion='fade'] { --alea-enter: alea-m-fade-in; --alea-exit: alea-m-fade-out; }
|
|
82
|
+
[data-motion='scale'] { --alea-enter: alea-m-scale-in; --alea-exit: alea-m-scale-out; }
|
|
83
|
+
[data-motion='pop'] { --alea-enter: alea-m-pop-in; --alea-exit: alea-m-pop-out; }
|
|
84
|
+
[data-motion='rise'] { --alea-enter: alea-m-rise-in; --alea-exit: alea-m-rise-out; }
|
|
85
|
+
[data-motion='drop'] { --alea-enter: alea-m-drop-in; --alea-exit: alea-m-drop-out; }
|
|
86
|
+
[data-motion='slide-up'] { --alea-enter: alea-m-slide-up-in; --alea-exit: alea-m-slide-up-out; }
|
|
87
|
+
[data-motion='slide-down'] { --alea-enter: alea-m-slide-down-in; --alea-exit: alea-m-slide-down-out; }
|
|
88
|
+
[data-motion='slide-left'] { --alea-enter: alea-m-slide-left-in; --alea-exit: alea-m-slide-left-out; }
|
|
89
|
+
[data-motion='slide-right'] { --alea-enter: alea-m-slide-right-in; --alea-exit: alea-m-slide-right-out; }
|
|
90
|
+
[data-motion='blur'] { --alea-enter: alea-m-blur-in; --alea-exit: alea-m-blur-out; }
|
|
91
|
+
[data-motion='zoom'] { --alea-enter: alea-m-zoom-in; --alea-exit: alea-m-zoom-out; }
|
|
92
|
+
[data-motion='flip'] { --alea-enter: alea-m-flip-in; --alea-exit: alea-m-flip-out; }
|
|
93
|
+
[data-motion='morph'] { --alea-enter: alea-m-morph-in; --alea-exit: alea-m-morph-out; }
|
|
94
|
+
[data-motion='none'] { --alea-enter: none; --alea-exit: none; }
|
|
95
|
+
|
|
96
|
+
/* ------------------------------------------------------------------ pop: anchored overlays */
|
|
97
|
+
.alea-popover, .alea-tooltip { transform-origin: var(--trigger-anchor-point, top center); }
|
|
98
|
+
.alea-popover[data-placement='bottom'], .alea-tooltip[data-placement='bottom'] { --alea-pop-y: calc(var(--alea-motion-distance-sm) * -1); }
|
|
99
|
+
.alea-popover[data-placement='top'], .alea-tooltip[data-placement='top'] { --alea-pop-y: var(--alea-motion-distance-sm); }
|
|
100
|
+
.alea-popover[data-placement='left'], .alea-tooltip[data-placement='left'] { --alea-pop-x: var(--alea-motion-distance-sm); }
|
|
101
|
+
.alea-popover[data-placement='right'], .alea-tooltip[data-placement='right'] { --alea-pop-x: calc(var(--alea-motion-distance-sm) * -1); }
|
|
102
|
+
.alea-popover[data-entering] { animation: var(--alea-enter-duration, var(--alea-motion-duration-base)) var(--alea-enter-ease, var(--alea-motion-ease-out)) var(--alea-enter-delay, 0s) both var(--alea-enter, alea-m-pop-in); }
|
|
103
|
+
.alea-popover[data-exiting] { animation: var(--alea-exit-duration, var(--alea-motion-duration-fast)) var(--alea-exit-ease, var(--alea-motion-ease-in)) 0s forwards var(--alea-exit, alea-m-pop-out); }
|
|
104
|
+
.alea-tooltip[data-entering] { animation: var(--alea-enter-duration, var(--alea-motion-duration-fast)) var(--alea-enter-ease, var(--alea-motion-ease-out)) var(--alea-enter-delay, 0s) both var(--alea-enter, alea-m-pop-in); }
|
|
105
|
+
.alea-tooltip[data-exiting] { animation: var(--alea-exit-duration, var(--alea-motion-duration-instant)) var(--alea-exit-ease, var(--alea-motion-ease-in)) 0s forwards var(--alea-exit, alea-m-fade-out); }
|
|
106
|
+
.alea-navmenu-panel:not([hidden]) { transform-origin: top left; --alea-pop-y: calc(var(--alea-motion-distance-sm) * -1); animation: var(--alea-enter-duration, var(--alea-motion-duration-base)) var(--alea-enter-ease, var(--alea-motion-ease-out)) 0s both var(--alea-enter, alea-m-pop-in); }
|
|
107
|
+
|
|
108
|
+
/* ------------------------------------------------------------------ rise: page-level overlays */
|
|
109
|
+
:is(.alea-modal, .alea-command)[data-entering] { --alea-rise-y: var(--alea-motion-distance-md); animation: var(--alea-enter-duration, var(--alea-motion-duration-base)) var(--alea-enter-ease, var(--alea-motion-ease-out)) var(--alea-enter-delay, 0s) both var(--alea-enter, alea-m-rise-in); }
|
|
110
|
+
:is(.alea-modal, .alea-command)[data-exiting] { animation: var(--alea-exit-duration, var(--alea-motion-duration-fast)) var(--alea-exit-ease, var(--alea-motion-ease-in)) 0s forwards var(--alea-exit, alea-m-rise-out); }
|
|
111
|
+
:is(.alea-modal-overlay, .alea-command-overlay)[data-entering] { animation: alea-m-fade-in var(--alea-motion-duration-base) var(--alea-motion-ease-out); }
|
|
112
|
+
:is(.alea-modal-overlay, .alea-command-overlay)[data-exiting] { animation: alea-m-fade-out var(--alea-motion-duration-fast) var(--alea-motion-ease-in) forwards; }
|
|
113
|
+
.alea-toast { animation: var(--alea-enter-duration, var(--alea-motion-duration-slow)) var(--alea-enter-ease, var(--alea-motion-ease-out)) var(--alea-enter-delay, 0s) both var(--alea-enter, alea-m-toast-in); }
|
|
114
|
+
.alea-toast[data-exiting] { animation: var(--alea-exit-duration, var(--alea-motion-duration-fast)) var(--alea-exit-ease, var(--alea-motion-ease-in)) 0s forwards var(--alea-exit, alea-m-toast-out); pointer-events: none; }
|
|
115
|
+
.alea-tour-card { animation: var(--alea-enter-duration, var(--alea-motion-duration-slow)) var(--alea-enter-ease, var(--alea-motion-ease-out)) 0s both var(--alea-enter, alea-m-rise-in); }
|
|
116
|
+
.alea-alert[data-live] { animation: alea-item-in var(--alea-motion-duration-base) var(--alea-motion-ease-out); }
|
|
117
|
+
|
|
118
|
+
/* ------------------------------------------------------------------ slide: drawers from their edge; they fade a little too, so reduced motion still has an entrance */
|
|
119
|
+
.alea-drawer[data-entering] { animation: var(--alea-enter-duration, var(--alea-motion-duration-slow)) var(--alea-enter-ease, var(--alea-motion-ease-out)) var(--alea-enter-delay, 0s) both var(--alea-enter, alea-m-edge-in); }
|
|
120
|
+
.alea-drawer[data-exiting] { animation: var(--alea-exit-duration, var(--alea-motion-duration-base)) var(--alea-exit-ease, var(--alea-motion-ease-in)) 0s forwards var(--alea-exit, alea-m-edge-out); }
|
|
121
|
+
.alea-drawer[data-placement='end'] { --alea-slide: translateX(var(--alea-motion-slide, 100%)); }
|
|
122
|
+
.alea-drawer[data-placement='start'] { --alea-slide: translateX(calc(var(--alea-motion-slide, 100%) * -1)); }
|
|
123
|
+
.alea-drawer[data-placement='bottom'] { --alea-slide: translateY(var(--alea-motion-slide, 100%)); }
|
|
124
|
+
.alea-drawer[data-placement='top'] { --alea-slide: translateY(calc(var(--alea-motion-slide, 100%) * -1)); }
|
|
125
|
+
|
|
126
|
+
/* the drawer's backdrop is its parent: it enters and leaves with the panel, or the panel would fade out with it before it finished sliding */
|
|
127
|
+
.alea-drawer-overlay[data-entering] { animation-duration: var(--alea-enter-duration, var(--alea-motion-duration-slow)); }
|
|
128
|
+
.alea-drawer-overlay[data-exiting] { animation-duration: var(--alea-exit-duration, var(--alea-motion-duration-base)); }
|
|
129
|
+
|
|
130
|
+
/* ------------------------------------------------------------------ stagger: the first ten items of a list that just opened come in one after another */
|
|
131
|
+
/* command results only: the options and menu items of a popover arrive with it, so one surface carries one motion */
|
|
132
|
+
/* items come in from slightly above: what sticks out goes past the top edge, which never makes the list scroll (no scrollbar flash) */
|
|
133
|
+
.alea-command-item { animation: alea-item-drop var(--alea-motion-duration-base) var(--alea-motion-ease-out) both; }
|
|
134
|
+
@keyframes alea-item-drop { from { opacity: 0.01; transform: translateY(calc(var(--alea-motion-distance-sm) * -1)); } }
|
|
135
|
+
.alea-command-item:nth-child(2) { animation-delay: calc(var(--alea-motion-stagger) * 1); }
|
|
136
|
+
.alea-command-item:nth-child(3) { animation-delay: calc(var(--alea-motion-stagger) * 2); }
|
|
137
|
+
.alea-command-item:nth-child(4) { animation-delay: calc(var(--alea-motion-stagger) * 3); }
|
|
138
|
+
.alea-command-item:nth-child(5) { animation-delay: calc(var(--alea-motion-stagger) * 4); }
|
|
139
|
+
.alea-command-item:nth-child(6) { animation-delay: calc(var(--alea-motion-stagger) * 5); }
|
|
140
|
+
.alea-command-item:nth-child(7) { animation-delay: calc(var(--alea-motion-stagger) * 6); }
|
|
141
|
+
.alea-command-item:nth-child(8) { animation-delay: calc(var(--alea-motion-stagger) * 7); }
|
|
142
|
+
.alea-command-item:nth-child(9) { animation-delay: calc(var(--alea-motion-stagger) * 8); }
|
|
143
|
+
.alea-command-item:nth-child(n+10) { animation-delay: calc(var(--alea-motion-stagger) * 9); }
|
|
144
|
+
|
|
145
|
+
/* ------------------------------------------------------------------ expand */
|
|
146
|
+
.alea-accordion-item[data-expanded] .alea-accordion-content { animation: alea-item-in var(--alea-motion-duration-base) var(--alea-motion-ease-out); }
|
|
147
|
+
.alea-tree-item { animation: alea-item-in var(--alea-motion-duration-base) var(--alea-motion-ease-out); }
|
|
148
|
+
.alea-spoiler-body { transition-duration: var(--alea-motion-duration-slow); transition-timing-function: var(--alea-motion-ease-out); }
|
|
149
|
+
|
|
150
|
+
/* ------------------------------------------------------------------ glide: one indicator per group moves between items (React Aria SelectionIndicator) */
|
|
151
|
+
.alea-tab, .alea-segmented-item { position: relative; isolation: isolate; }
|
|
152
|
+
.alea-tab-label, .alea-segmented-label, .alea-toggle-label, .alea-toggle-icon { position: relative; z-index: 1; }
|
|
153
|
+
.alea-sel-indicator {
|
|
154
|
+
position: absolute; z-index: 0; inset: 0; width: 100%; border-radius: inherit; pointer-events: none;
|
|
155
|
+
transition: translate var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized), width var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized), height var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized), opacity var(--alea-motion-duration-fast) var(--alea-motion-ease-standard);
|
|
156
|
+
}
|
|
157
|
+
.alea-sel-indicator[data-entering] { animation: alea-m-fade-in var(--alea-motion-duration-fast) var(--alea-motion-ease-out); }
|
|
158
|
+
.alea-sel-indicator[data-exiting] { animation: alea-m-fade-out var(--alea-motion-duration-fast) var(--alea-motion-ease-in) forwards; }
|
|
159
|
+
.alea-tabs[data-variant='underline'] .alea-sel-indicator { inset: auto 0 0; left: var(--alea-space-3, 12px); width: calc(100% - var(--alea-space-3) * 2); height: 2px; border-radius: var(--alea-radius-2xs, 2px); background: var(--alea-gradient-accent-linear); }
|
|
160
|
+
.alea-tabs[data-orientation='vertical'][data-variant='underline'] .alea-sel-indicator { inset: var(--alea-space-2, 8px) auto var(--alea-space-2, 8px) 0; left: 0; width: 2px; height: calc(100% - var(--alea-space-2) * 2); }
|
|
161
|
+
.alea-tabs[data-variant='pills'] .alea-sel-indicator, .alea-segmented .alea-sel-indicator { background: var(--alea-chip-bg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
|
|
162
|
+
.alea-toggle-group .alea-sel-indicator { background: var(--alea-surface-raised); box-shadow: var(--alea-shadow-card), inset 0 0 0 1px var(--alea-border-strong); }
|
|
163
|
+
|
|
164
|
+
/* ------------------------------------------------------------------ lift */
|
|
165
|
+
:is(.alea-card[data-interactive], .alea-kanban-card, a.alea-imagelist-tile, .alea-float-btn, .alea-b-tile, .alea-b-pcard) {
|
|
166
|
+
transition: transform var(--alea-motion-duration-base) var(--alea-motion-ease-out), box-shadow var(--alea-motion-duration-base) var(--alea-motion-ease-out), background-color var(--alea-motion-duration-fast) var(--alea-motion-ease-standard);
|
|
167
|
+
}
|
|
168
|
+
:is(.alea-card[data-interactive], a.alea-imagelist-tile, .alea-float-btn):hover, .alea-kanban-card[data-hovered] { transform: translateY(var(--alea-motion-lift)); }
|
|
169
|
+
.alea-kanban-card[data-hovered] { box-shadow: var(--alea-shadow-pop), inset 0 0 0 1px var(--alea-border); }
|
|
170
|
+
|
|
171
|
+
/* ------------------------------------------------------------------ press */
|
|
172
|
+
:is(.alea-button, .alea-toggle-button, .alea-toggle-item, .alea-segmented-item, .alea-tag, .alea-page, .alea-rating-item, .alea-carousel-dot)[data-pressed],
|
|
173
|
+
:is(.alea-mdeditor-tool, .alea-menubar-item, .alea-bottomnav-item, .alea-burger, .alea-drag-handle, .alea-float-btn, .alea-navmenu-item, .alea-toast-action, .alea-grid-edit):active {
|
|
174
|
+
transform: scale(var(--alea-motion-scale-press));
|
|
175
|
+
}
|
|
176
|
+
:is(.alea-toggle-button, .alea-toggle-item, .alea-segmented-item, .alea-tag, .alea-page, .alea-mdeditor-tool, .alea-menubar-item, .alea-bottomnav-item, .alea-burger, .alea-drag-handle, .alea-navmenu-item, .alea-toast-action) {
|
|
177
|
+
transition-property: transform, background-color, color, box-shadow, opacity;
|
|
178
|
+
transition-duration: var(--alea-motion-duration-instant), var(--alea-motion-duration-fast), var(--alea-motion-duration-fast), var(--alea-motion-duration-fast), var(--alea-motion-duration-fast);
|
|
179
|
+
transition-timing-function: var(--alea-motion-ease-out);
|
|
180
|
+
}
|
|
181
|
+
.alea-card[data-interactive]:active { transform: translateY(0) scale(calc(1 - (1 - var(--alea-motion-scale-press)) * 0.125)); }
|
|
182
|
+
|
|
183
|
+
/* ------------------------------------------------------------------ morph */
|
|
184
|
+
.alea-select-chevron, .alea-combobox-chevron, .alea-tree-chevron, .alea-navmenu-chevron, .alea-accordion-chevron { transition: transform var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized); }
|
|
185
|
+
:is(.alea-select-trigger, .alea-combobox-button, .alea-select-trigger-button)[aria-expanded='true'] .alea-select-chevron, .alea-select[data-open] .alea-select-chevron, .alea-combobox[data-open] :is(.alea-select-chevron, .alea-combobox-chevron) { transform: rotate(180deg); }
|
|
186
|
+
.alea-tree-item[data-expanded] .alea-tree-chevron { transform: rotate(90deg); }
|
|
187
|
+
.alea-check[data-selected] .alea-check-box, .alea-radio[data-selected] .alea-radio-dot { animation: alea-check-pop var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized); }
|
|
188
|
+
.alea-check-box svg { transition-timing-function: var(--alea-motion-ease-emphasized); }
|
|
189
|
+
.alea-rating-item[data-selected] .alea-rating-star { animation: alea-check-pop var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized); }
|
|
190
|
+
.alea-burger span { transition-timing-function: var(--alea-motion-ease-emphasized); }
|
|
191
|
+
|
|
192
|
+
/* ------------------------------------------------------------------ tint */
|
|
193
|
+
:is(.alea-option, .alea-menu-item, .alea-command-item, .alea-list-item, .alea-tree-item, .alea-sidebar-link, .alea-navmenu-link, .alea-crumb-link, .alea-mdeditor-tool, .alea-menubar-item, .alea-accordion-trigger, .alea-anchor-link, .alea-icon-button, .alea-datagrid tr, .alea-tr) {
|
|
194
|
+
transition: background-color var(--alea-motion-duration-instant) var(--alea-motion-ease-standard), color var(--alea-motion-duration-instant) var(--alea-motion-ease-standard), box-shadow var(--alea-motion-duration-fast) var(--alea-motion-ease-standard);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* ------------------------------------------------------------------ nudge: once, when a field turns invalid */
|
|
198
|
+
.alea-field[data-invalid] :is(.alea-input-wrap, .alea-select-trigger, .alea-textarea, .alea-date-wrap) { animation: alea-nudge var(--alea-motion-duration-slow) var(--alea-motion-ease-out); }
|
|
199
|
+
|
|
200
|
+
/* ------------------------------------------------------------------ draw */
|
|
201
|
+
.alea-meter-fill { transition: width var(--alea-motion-duration-slow) var(--alea-motion-ease-out); }
|
|
202
|
+
.alea-step-dot { transition: background-color var(--alea-motion-duration-base) var(--alea-motion-ease-standard), box-shadow var(--alea-motion-duration-base) var(--alea-motion-ease-standard), transform var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized); }
|
|
203
|
+
|
|
204
|
+
/* ------------------------------------------------------------------ pulse */
|
|
205
|
+
.alea-badge[data-pulse] .alea-badge-dot, .alea-avatar-status[data-pulse] { position: relative; }
|
|
206
|
+
.alea-badge[data-pulse] .alea-badge-dot::after, .alea-avatar-status[data-pulse]::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: inherit; animation: alea-ping 1.6s var(--alea-motion-ease-out) infinite; }
|
|
207
|
+
|
|
208
|
+
/* ------------------------------------------------------------------ loops: paused while they are off screen (useOffscreenPause sets data-alea-offscreen) */
|
|
209
|
+
[data-alea-offscreen], [data-alea-offscreen]::before, [data-alea-offscreen]::after, [data-alea-offscreen] *, [data-alea-offscreen] *::before, [data-alea-offscreen] *::after { animation-play-state: paused !important; }
|
|
210
|
+
|
|
211
|
+
/* ------------------------------------------------------------------ global modes: data-alea-motion on <html> (or any .alea-root) */
|
|
212
|
+
/* productive: shorter and quieter, for dense apps and dashboards (brisk, minimal motion) */
|
|
213
|
+
[data-alea-motion='productive'] {
|
|
214
|
+
--alea-motion-duration-fast: 120ms; --alea-motion-duration-base: 200ms; --alea-motion-duration-slow: 280ms; --alea-motion-duration-slower: 400ms;
|
|
215
|
+
--alea-motion-distance-sm: 4px; --alea-motion-distance-md: 8px; --alea-motion-distance-lg: 12px; --alea-motion-scale-from: 0.96; --alea-motion-stagger: 16ms; --alea-motion-blur-md: 4px;
|
|
216
|
+
--alea-motion-ease-emphasized: var(--alea-motion-ease-out); --alea-motion-ease-spring: var(--alea-motion-ease-out); --alea-motion-spring: var(--alea-motion-ease-out);
|
|
217
|
+
}
|
|
218
|
+
/* expressive: the default values, named so a region can switch back */
|
|
219
|
+
[data-alea-motion='expressive'] { --alea-motion-duration-base: 320ms; --alea-motion-duration-slow: 480ms; }
|
|
220
|
+
/* off: no animation or transition at all (React Aria then opens and closes at once) */
|
|
221
|
+
[data-alea-motion='off'], [data-alea-motion='off'] *, [data-alea-motion='off'] *::before, [data-alea-motion='off'] *::after { animation: none !important; transition: none !important; }
|
|
222
|
+
|
|
223
|
+
/* ------------------------------------------------------------------ reduced motion: fade, don't move; stop decorative loops.
|
|
224
|
+
Applies with the OS setting (unless data-alea-reduced="never"), or always with data-alea-reduced="always" or data-alea-motion="reduced". */
|
|
225
|
+
@media (prefers-reduced-motion: reduce) {
|
|
226
|
+
:root:not([data-alea-reduced='never']), :root:not([data-alea-reduced='never']) :is(.alea-root, [data-theme], [data-alea-motion]) {
|
|
227
|
+
--alea-motion-distance-sm: 0px; --alea-motion-distance-md: 0px; --alea-motion-distance-lg: 0px; --alea-motion-rotate: 0deg;
|
|
228
|
+
--alea-motion-scale-from: 1; --alea-motion-scale-press: 1; --alea-motion-lift: 0px; --alea-motion-stagger: 0ms; --alea-motion-slide: 0%; --alea-slide-distance: 0px;
|
|
229
|
+
--alea-motion-blur-sm: 0px; --alea-motion-blur-md: 0px; --alea-motion-blur-lg: 0px;
|
|
230
|
+
--alea-motion-ease-emphasized: var(--alea-motion-ease-out); --alea-motion-ease-spring: var(--alea-motion-ease-out); --alea-motion-spring: var(--alea-motion-ease-out);
|
|
231
|
+
--alea-motion-duration-slow: var(--alea-motion-duration-base); --alea-motion-duration-slower: var(--alea-motion-duration-base);
|
|
232
|
+
}
|
|
233
|
+
:root:not([data-alea-reduced='never']) :is(.alea-field[data-invalid] :is(.alea-input-wrap, .alea-select-trigger, .alea-textarea, .alea-date-wrap), [data-alea-loop], .alea-badge[data-pulse] .alea-badge-dot::after, .alea-avatar-status[data-pulse]::after, .alea-status-dot[data-pulse]::after, .alea-indicator[data-processing]::before, .alea-image[data-state='loading'], .alea-orb, .alea-orbs *) { animation: none !important; }
|
|
234
|
+
:root:not([data-alea-reduced='never']) .alea-skeleton { animation-duration: 3s; }
|
|
235
|
+
/* loading spinners keep turning (they carry meaning), only slower; decorative pulses stop */
|
|
236
|
+
:root:not([data-alea-reduced='never']) :is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate]) { animation-duration: 2.4s; }
|
|
237
|
+
:root:not([data-alea-reduced='never']) .alea-gradient-dot[data-pulse] { animation: none !important; }
|
|
238
|
+
/* reveals (bars grow, lines draw, words rise) appear at once, a stroke is already drawn, the ripple is not shown, a morph fades */
|
|
239
|
+
:root:not([data-alea-reduced='never']) :is(.alea-chart-line, .alea-chart-area, .alea-chart-bar, .alea-pie-slice, .alea-funnel-bar, .alea-bullet-value, .alea-gauge-arc, .alea-radial-arc, .alea-progress-seg-part, .alea-split-word, .alea-success-check path, .alea-m[data-m='draw']) { animation: none !important; }
|
|
240
|
+
:root:not([data-alea-reduced='never']) :is(.alea-chart-line, .alea-success-check path) { stroke-dashoffset: 0; }
|
|
241
|
+
:root:not([data-alea-reduced='never']) .alea-ripple { display: none; }
|
|
242
|
+
:root:not([data-alea-reduced='never'])[data-motion='morph'], :root:not([data-alea-reduced='never']) [data-motion='morph'] { --alea-enter: alea-m-fade-in; --alea-exit: alea-m-fade-out; }
|
|
243
|
+
}
|
|
244
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']), :is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-root, [data-theme]) {
|
|
245
|
+
--alea-motion-distance-sm: 0px; --alea-motion-distance-md: 0px; --alea-motion-distance-lg: 0px; --alea-motion-rotate: 0deg;
|
|
246
|
+
--alea-motion-scale-from: 1; --alea-motion-scale-press: 1; --alea-motion-lift: 0px; --alea-motion-stagger: 0ms; --alea-motion-slide: 0%; --alea-slide-distance: 0px;
|
|
247
|
+
--alea-motion-blur-sm: 0px; --alea-motion-blur-md: 0px; --alea-motion-blur-lg: 0px;
|
|
248
|
+
--alea-motion-ease-emphasized: var(--alea-motion-ease-out); --alea-motion-ease-spring: var(--alea-motion-ease-out); --alea-motion-spring: var(--alea-motion-ease-out);
|
|
249
|
+
--alea-motion-duration-slow: var(--alea-motion-duration-base); --alea-motion-duration-slower: var(--alea-motion-duration-base);
|
|
250
|
+
}
|
|
251
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-field[data-invalid] :is(.alea-input-wrap, .alea-select-trigger, .alea-textarea, .alea-date-wrap), [data-alea-loop], .alea-badge[data-pulse] .alea-badge-dot::after, .alea-avatar-status[data-pulse]::after, .alea-status-dot[data-pulse]::after, .alea-indicator[data-processing]::before, .alea-image[data-state='loading'], .alea-orb, .alea-orbs *) { animation: none !important; }
|
|
252
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate]) { animation-duration: 2.4s; }
|
|
253
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) .alea-gradient-dot[data-pulse] { animation: none !important; }
|
|
254
|
+
/* reveals (bars grow, lines draw, words rise) appear at once, a stroke is already drawn, the ripple is not shown, a morph fades */
|
|
255
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-chart-line, .alea-chart-area, .alea-chart-bar, .alea-pie-slice, .alea-funnel-bar, .alea-bullet-value, .alea-gauge-arc, .alea-radial-arc, .alea-progress-seg-part, .alea-split-word, .alea-success-check path, .alea-m[data-m='draw']) { animation: none !important; }
|
|
256
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-chart-line, .alea-success-check path) { stroke-dashoffset: 0; }
|
|
257
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) .alea-ripple { display: none; }
|
|
258
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always'])[data-motion='morph'], :is([data-alea-motion='reduced'], [data-alea-reduced='always']) [data-motion='morph'] { --alea-enter: alea-m-fade-in; --alea-exit: alea-m-fade-out; }
|
|
259
|
+
|
|
260
|
+
/* ------------------------------------------------------------------ the patterns, applied to the rest of the kit */
|
|
261
|
+
/* rise: content that appears as a state of its own */
|
|
262
|
+
:is(.alea-empty, .alea-result) { animation: alea-m-rise-in var(--alea-motion-duration-slow) var(--alea-motion-ease-out) both; }
|
|
263
|
+
/* stagger: lists that arrive together */
|
|
264
|
+
:is(.alea-timeline, .alea-upload-list, .alea-transfer-list .alea-list) > * { animation: alea-item-in var(--alea-motion-duration-base) var(--alea-motion-ease-out) both; }
|
|
265
|
+
:is(.alea-timeline, .alea-upload-list) > :nth-child(2) { animation-delay: calc(var(--alea-motion-stagger) * 1); }
|
|
266
|
+
:is(.alea-timeline, .alea-upload-list) > :nth-child(3) { animation-delay: calc(var(--alea-motion-stagger) * 2); }
|
|
267
|
+
:is(.alea-timeline, .alea-upload-list) > :nth-child(4) { animation-delay: calc(var(--alea-motion-stagger) * 3); }
|
|
268
|
+
:is(.alea-timeline, .alea-upload-list) > :nth-child(n+5) { animation-delay: calc(var(--alea-motion-stagger) * 4); }
|
|
269
|
+
/* pop: a tag the user adds (the group sets data-added on tags that mount after it); the tags on first paint stay still */
|
|
270
|
+
.alea-tag[data-added] { animation: alea-m-scale-in var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized) both; }
|
|
271
|
+
/* pop + glide: chart tooltips appear softly and follow the pointer */
|
|
272
|
+
.alea-chart-tooltip { animation: alea-m-fade-in var(--alea-motion-duration-fast) var(--alea-motion-ease-out) both; transition: left var(--alea-motion-duration-fast) var(--alea-motion-ease-out), top var(--alea-motion-duration-fast) var(--alea-motion-ease-out), transform var(--alea-motion-duration-fast) var(--alea-motion-ease-out); }
|
|
273
|
+
/* slide: a calendar month comes in from the side you moved to */
|
|
274
|
+
.alea-calview-grid[data-dir] { animation: alea-calview-in var(--alea-motion-duration-base) var(--alea-motion-ease-out) both; }
|
|
275
|
+
@keyframes alea-calview-in { from { opacity: 0.01; transform: translateX(calc(var(--alea-motion-distance-lg) * var(--alea-cal-dir, 1))); } }
|
|
276
|
+
.alea-calview-grid[data-dir='-1'] { --alea-cal-dir: -1; }
|
|
277
|
+
/* press: swatches and color pickers */
|
|
278
|
+
:is(.alea-swatch, .alea-color-swatch, .alea-swatch-item) { transition: transform var(--alea-motion-duration-fast) var(--alea-motion-ease-out), box-shadow var(--alea-motion-duration-fast) var(--alea-motion-ease-standard); }
|
|
279
|
+
:is(.alea-swatch, .alea-swatch-item)[data-pressed], .alea-color-swatch:active { transform: scale(var(--alea-motion-scale-press)); }
|
|
280
|
+
|
|
281
|
+
/* Parallax: layers follow the pointer (--alea-par-x/y in -1..1) and, with scroll, the page (--alea-par-s) */
|
|
282
|
+
.alea-parallax { position: relative; }
|
|
283
|
+
.alea-parallax-layer { transform: translate3d(calc(var(--alea-par-x, 0) * var(--alea-par-strength, 16px) * var(--alea-depth, 0.5)), calc((var(--alea-par-y, 0) + var(--alea-par-s, 0) * 2) * var(--alea-par-strength, 16px) * var(--alea-depth, 0.5)), 0); transition: transform var(--alea-motion-duration-slow, 400ms) var(--alea-motion-ease-out, ease-out); will-change: transform; }
|
|
284
|
+
@media (prefers-reduced-motion: reduce) { .alea-parallax-layer { transform: none; transition: none; } }
|
|
285
|
+
[data-alea-motion='reduced'] .alea-parallax-layer, [data-alea-motion='off'] .alea-parallax-layer { transform: none; transition: none; }
|
package/src/patterns.css
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* Alea Motion: more patterns. Each answers "what changed?"; the React helpers in
|
|
2
|
+
@alea-design/motion (TextSwap, NumberRoll, Presence, AutoHeight, ScrollProgress,
|
|
3
|
+
StreamingText, useRipple, HoldButton in @alea-design/ui) set the classes, and any
|
|
4
|
+
stack can set them by hand.
|
|
5
|
+
|
|
6
|
+
swap text or an icon changes with a short blur crossfade Save -> Saved, status text, plan names
|
|
7
|
+
roll digits roll to the new number prices, counters, stats, cart count
|
|
8
|
+
badge a count or dot appears with a spring notification badge, cart badge
|
|
9
|
+
success the busy state turns into a check, then back submit, save, copy buttons
|
|
10
|
+
dissolve removed things blur, shrink and fade tags, rows, files, cleared search
|
|
11
|
+
resize size changes animate instead of jumping cards that grow, panels, autosize fields
|
|
12
|
+
fan overlapping items spread on hover avatar group, card stacks
|
|
13
|
+
ripple press feedback grows from the pointer buttons with ripple, rows on touch
|
|
14
|
+
hold holding fills a bar, then confirms destructive actions
|
|
15
|
+
hint an arrow or icon nudges toward where it goes on hover "Learn more" links, next buttons
|
|
16
|
+
scroll scroll-linked progress, a header that hides on scroll reading progress, navbar
|
|
17
|
+
stream streamed text fades in by chunk; a shimmer while thinking AI answers, generation
|
|
18
|
+
route page changes crossfade, slide or zoom (View Transitions) router pages, master to detail */
|
|
19
|
+
|
|
20
|
+
@property --alea-hold { syntax: '<number>'; inherits: true; initial-value: 0; }
|
|
21
|
+
|
|
22
|
+
/* ------------------------------------------------------------------ swap */
|
|
23
|
+
.alea-swap { display: inline-grid; vertical-align: bottom; }
|
|
24
|
+
.alea-swap > * { grid-area: 1 / 1; }
|
|
25
|
+
.alea-swap-in { animation: alea-swap-in var(--alea-motion-duration-base) var(--alea-motion-ease-out) both; }
|
|
26
|
+
.alea-swap-out { animation: alea-swap-out var(--alea-motion-duration-fast) var(--alea-motion-ease-in) both; pointer-events: none; }
|
|
27
|
+
@keyframes alea-swap-in { from { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); transform: translateY(calc(var(--alea-motion-distance-sm) * var(--alea-swap-dir, 1))); } }
|
|
28
|
+
@keyframes alea-swap-out { to { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); transform: translateY(calc(var(--alea-motion-distance-sm) * var(--alea-swap-dir, 1) * -1)); } }
|
|
29
|
+
|
|
30
|
+
/* ------------------------------------------------------------------ roll */
|
|
31
|
+
.alea-roll { display: inline-flex; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
32
|
+
.alea-roll-digit { display: inline-block; height: 1lh; overflow: hidden; }
|
|
33
|
+
.alea-roll-strip { display: flex; flex-direction: column; transform: translateY(calc(var(--alea-roll-n, 0) * -1lh)); transition: transform var(--alea-motion-duration-slow) var(--alea-motion-ease-emphasized); }
|
|
34
|
+
.alea-roll-strip > span { height: 1lh; }
|
|
35
|
+
|
|
36
|
+
/* ------------------------------------------------------------------ badge */
|
|
37
|
+
.alea-badge-pop { display: inline-block; animation: alea-badge-pop var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized); }
|
|
38
|
+
@keyframes alea-badge-pop { 0% { transform: scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 10)); opacity: 0.01; } 70% { transform: scale(calc(1 + (1 - var(--alea-motion-scale-from)) * 4)); opacity: 1; } 100% { transform: none; } }
|
|
39
|
+
|
|
40
|
+
/* ------------------------------------------------------------------ success */
|
|
41
|
+
.alea-success-check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: alea-draw-line var(--alea-motion-duration-slow) var(--alea-motion-ease-out) var(--alea-motion-duration-fast) forwards; }
|
|
42
|
+
.alea-success-in { animation: alea-badge-pop var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized); }
|
|
43
|
+
@keyframes alea-draw-line { to { stroke-dashoffset: 0; } }
|
|
44
|
+
|
|
45
|
+
/* ------------------------------------------------------------------ dissolve */
|
|
46
|
+
.alea-dissolve-out { animation: alea-dissolve-out var(--alea-motion-duration-base) var(--alea-motion-ease-in) forwards; pointer-events: none; }
|
|
47
|
+
@keyframes alea-dissolve-out { to { opacity: 0.01; filter: blur(var(--alea-motion-blur-md)); transform: scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 2)); } }
|
|
48
|
+
|
|
49
|
+
/* ------------------------------------------------------------------ resize */
|
|
50
|
+
.alea-autoheight { overflow: clip; transition: height var(--alea-motion-duration-base) var(--alea-motion-ease-out); }
|
|
51
|
+
|
|
52
|
+
/* ------------------------------------------------------------------ fan */
|
|
53
|
+
.alea-avatar-group[data-fan]:is(:hover, :focus-within) .alea-avatar + .alea-avatar { margin-inline-start: calc(var(--alea-motion-distance-sm) * 0.5); }
|
|
54
|
+
|
|
55
|
+
/* ------------------------------------------------------------------ ripple */
|
|
56
|
+
.alea-ripple-host { position: relative; overflow: hidden; isolation: isolate; }
|
|
57
|
+
.alea-ripple { position: absolute; z-index: -1; left: var(--alea-ripple-x); top: var(--alea-ripple-y); width: var(--alea-ripple-size); height: var(--alea-ripple-size); margin: calc(var(--alea-ripple-size) / -2) 0 0 calc(var(--alea-ripple-size) / -2); border-radius: 50%; background: currentColor; opacity: 0.18; pointer-events: none; animation: alea-ripple var(--alea-motion-duration-slower) var(--alea-motion-ease-out) forwards; }
|
|
58
|
+
@keyframes alea-ripple { from { transform: scale(0.1); opacity: 0.24; } to { transform: scale(1); opacity: 0.01; } }
|
|
59
|
+
|
|
60
|
+
/* ------------------------------------------------------------------ hold */
|
|
61
|
+
.alea-hold { position: relative; overflow: hidden; isolation: isolate; }
|
|
62
|
+
.alea-hold::before { content: ''; position: absolute; inset: 0; z-index: -1; background: color-mix(in srgb, currentColor 22%, transparent); transform-origin: left; transform: scaleX(var(--alea-hold)); }
|
|
63
|
+
.alea-hold[data-holding] { animation: alea-hold var(--alea-hold-duration, 1200ms) linear forwards; }
|
|
64
|
+
.alea-hold:not([data-holding]) { transition: --alea-hold var(--alea-motion-duration-base) var(--alea-motion-ease-out); }
|
|
65
|
+
@keyframes alea-hold { from { --alea-hold: 0; } to { --alea-hold: 1; } }
|
|
66
|
+
|
|
67
|
+
/* ------------------------------------------------------------------ hint */
|
|
68
|
+
.alea-hint-icon, .alea-hint > svg:last-child, .alea-link[data-variant='standalone'] > svg:last-child { transition: transform var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized); }
|
|
69
|
+
:is(.alea-hint, .alea-link[data-variant='standalone']):is(:hover, :focus-visible) :is(.alea-hint-icon, svg:last-child) { transform: translateX(var(--alea-hint-distance, 3px)); }
|
|
70
|
+
@media (prefers-reduced-motion: reduce) { :root:not([data-alea-reduced='never']) { --alea-hint-distance: 0px; } }
|
|
71
|
+
|
|
72
|
+
/* ------------------------------------------------------------------ scroll */
|
|
73
|
+
.alea-scroll-progress { position: fixed; inset: 0 0 auto; z-index: 60; height: 4px; background: var(--alea-gradient-accent-linear); transform-origin: left; transform: scaleX(var(--alea-scroll, 0)); pointer-events: none; }
|
|
74
|
+
@supports (animation-timeline: scroll()) {
|
|
75
|
+
.alea-scroll-progress[data-css] { animation: alea-scroll-progress linear both; animation-timeline: scroll(root); }
|
|
76
|
+
@keyframes alea-scroll-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
|
|
77
|
+
}
|
|
78
|
+
.alea-navbar { transition: transform var(--alea-motion-duration-base) var(--alea-motion-ease-out); }
|
|
79
|
+
.alea-navbar[data-scroll-hidden] { transform: translateY(-100%); }
|
|
80
|
+
|
|
81
|
+
/* ------------------------------------------------------------------ stream */
|
|
82
|
+
.alea-stream-chunk { animation: alea-stream-in var(--alea-motion-duration-slow) var(--alea-motion-ease-out) both; }
|
|
83
|
+
@keyframes alea-stream-in { from { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); } }
|
|
84
|
+
.alea-stream[data-streaming]::after { content: ''; display: inline-block; width: 0.5em; height: 1em; margin-left: var(--alea-space-0-5, 2px); vertical-align: -0.12em; border-radius: var(--alea-radius-2xs, 2px); background: currentColor; animation: alea-caret 1s steps(2, start) infinite; }
|
|
85
|
+
@keyframes alea-caret { to { visibility: hidden; } }
|
|
86
|
+
.alea-text-shimmer { background: linear-gradient(90deg, var(--alea-text-muted) 0%, var(--alea-text-muted) 40%, var(--alea-text) 50%, var(--alea-text-muted) 60%, var(--alea-text-muted) 100%) 0 0 / 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: alea-text-shimmer 2s linear infinite; }
|
|
87
|
+
@keyframes alea-text-shimmer { from { background-position: 125% 0; } to { background-position: -125% 0; } }
|
|
88
|
+
@media (prefers-reduced-motion: reduce) {
|
|
89
|
+
:root:not([data-alea-reduced='never']) :is(.alea-text-shimmer, .alea-stream[data-streaming]::after) { animation: none; }
|
|
90
|
+
:root:not([data-alea-reduced='never']) .alea-text-shimmer { color: var(--alea-text-muted); background: none; }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* ------------------------------------------------------------------ route (View Transitions API: document.startViewTransition, React Router's viewTransition) */
|
|
94
|
+
::view-transition-old(root) { animation: var(--alea-motion-duration-fast) var(--alea-motion-ease-in) both alea-m-fade-out; }
|
|
95
|
+
::view-transition-new(root) { animation: var(--alea-motion-duration-base) var(--alea-motion-ease-out) both alea-m-fade-in; }
|
|
96
|
+
[data-route-motion='slide']::view-transition-old(root) { animation: var(--alea-motion-duration-fast) var(--alea-motion-ease-in) both alea-route-out; }
|
|
97
|
+
[data-route-motion='slide']::view-transition-new(root) { animation: var(--alea-motion-duration-base) var(--alea-motion-ease-out) both alea-route-in; }
|
|
98
|
+
[data-route-motion='zoom']::view-transition-new(root) { animation: var(--alea-motion-duration-base) var(--alea-motion-ease-out) both alea-m-scale-in; }
|
|
99
|
+
[data-route-motion='none']::view-transition-old(root), [data-route-motion='none']::view-transition-new(root) { animation: none; }
|
|
100
|
+
@keyframes alea-route-in { from { opacity: 0.01; transform: translateX(calc(var(--alea-motion-distance-lg) * 2)); } }
|
|
101
|
+
@keyframes alea-route-out { to { opacity: 0.01; transform: translateX(calc(var(--alea-motion-distance-lg) * -2)); } }
|
|
102
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) { --alea-hint-distance: 0px; }
|
|
103
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-text-shimmer, .alea-stream[data-streaming]::after) { animation: none; }
|
|
104
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) .alea-text-shimmer { color: var(--alea-text-muted); background: none; }
|
|
105
|
+
|
|
106
|
+
/* ------------------------------------------------------------------ more patterns */
|
|
107
|
+
/* check draws itself (Checkbox paths have pathLength 1) */
|
|
108
|
+
.alea-check-box path { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset var(--alea-motion-duration-base) var(--alea-motion-ease-out) var(--alea-motion-duration-instant); }
|
|
109
|
+
.alea-check[data-selected] .alea-check-box path, .alea-check[data-indeterminate] .alea-check-box path { stroke-dashoffset: 0; }
|
|
110
|
+
/* success: the check comes in turning, with a blur */
|
|
111
|
+
.alea-success-in { animation: alea-success-in var(--alea-motion-duration-slow) var(--alea-motion-spring) both; }
|
|
112
|
+
@keyframes alea-success-in { from { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); transform: scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 5)) rotate(calc(var(--alea-motion-rotate, 12deg) * -2.5)); } }
|
|
113
|
+
/* swap, scale variant: for icons */
|
|
114
|
+
.alea-swap[data-variant='scale'] .alea-swap-in { animation-name: alea-swap-scale-in; animation-timing-function: var(--alea-motion-spring); }
|
|
115
|
+
.alea-swap[data-variant='scale'] .alea-swap-out { animation-name: alea-swap-scale-out; }
|
|
116
|
+
@keyframes alea-swap-scale-in { from { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); transform: scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 6)); } }
|
|
117
|
+
@keyframes alea-swap-scale-out { to { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); transform: scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 6)); } }
|
|
118
|
+
/* dissolve: cleared words leave one after another */
|
|
119
|
+
.alea-input-ghost { position: absolute; left: var(--alea-input-ghost-left, var(--alea-space-10, 40px)); top: 50%; translate: 0 -50%; display: flex; white-space: pre; pointer-events: none; color: var(--alea-text); font: inherit; }
|
|
120
|
+
.alea-input-ghost > span { display: inline-block; animation: alea-dissolve-out var(--alea-motion-duration-slow) var(--alea-motion-ease-in) both; animation-delay: calc(var(--alea-i, 0) * var(--alea-motion-stagger)); }
|
|
121
|
+
/* skeleton to content */
|
|
122
|
+
.alea-skeleton-reveal { display: contents; }
|
|
123
|
+
.alea-skeleton-reveal > * { animation: alea-m-blur-in var(--alea-motion-duration-slow) var(--alea-motion-ease-out) both; }
|
|
124
|
+
/* fan with falloff: the hovered avatar lifts most, its neighbours less, and they bounce back */
|
|
125
|
+
.alea-avatar-group[data-fan] .alea-avatar { transition: margin var(--alea-motion-duration-base) var(--alea-motion-ease-emphasized), translate var(--alea-motion-duration-slow) var(--alea-motion-spring); }
|
|
126
|
+
.alea-avatar-group[data-fan] .alea-avatar:hover { translate: 0 calc(var(--alea-motion-lift) * 2); }
|
|
127
|
+
.alea-avatar-group[data-fan] .alea-avatar:hover + .alea-avatar, .alea-avatar-group[data-fan] .alea-avatar:has(+ .alea-avatar:hover) { translate: 0 var(--alea-motion-lift); }
|
|
128
|
+
.alea-avatar-group[data-fan] .alea-avatar:hover + .alea-avatar + .alea-avatar, .alea-avatar-group[data-fan] .alea-avatar:has(+ .alea-avatar + .alea-avatar:hover) { translate: 0 calc(var(--alea-motion-lift) * 0.4); }
|
|
129
|
+
/* drop zones lean in when something is dragged over them; the border marches */
|
|
130
|
+
.alea-dropzone { transition: transform var(--alea-motion-duration-base) var(--alea-motion-spring), background-color var(--alea-motion-duration-fast) var(--alea-motion-ease-standard), border-color var(--alea-motion-duration-fast) var(--alea-motion-ease-standard); }
|
|
131
|
+
.alea-dropzone[data-drop-target] { transform: scale(calc(1 + (1 - var(--alea-motion-scale-press)) * 0.5)); }
|
|
132
|
+
/* dot loader: a 4 × 4 matrix that pulses in a diagonal wave */
|
|
133
|
+
.alea-dot-loader { display: inline-grid; grid-template-columns: repeat(4, 1fr); gap: var(--alea-space-0-5, 2px); width: 24px; height: 24px; }
|
|
134
|
+
.alea-dot-loader[data-size='sm'] { width: 16px; height: 16px; gap: var(--alea-space-0-25, 1px); }
|
|
135
|
+
.alea-dot-loader[data-size='lg'] { width: 40px; height: 40px; gap: var(--alea-space-1, 4px); }
|
|
136
|
+
.alea-dot-loader i { border-radius: 50%; background: var(--alea-accent); animation: alea-dot 1.2s var(--alea-motion-ease-in-out) infinite both; animation-delay: calc(var(--alea-dot-d, 0) * 90ms); }
|
|
137
|
+
@keyframes alea-dot { 0%, 100% { opacity: 0.2; transform: scale(0.6); } 40% { opacity: 1; transform: none; } }
|
|
138
|
+
|
|
139
|
+
/* ------------------------------------------------------------------ morph icon: one turns and grows in, the other blurs out */
|
|
140
|
+
.alea-morph-icon { position: relative; display: inline-grid; place-items: center; }
|
|
141
|
+
.alea-morph-icon > span { grid-area: 1 / 1; display: inline-flex; transition: opacity var(--alea-motion-duration-base) var(--alea-motion-ease-out), transform var(--alea-motion-duration-base) var(--alea-motion-spring, var(--alea-motion-ease-out)), filter var(--alea-motion-duration-base) var(--alea-motion-ease-out); }
|
|
142
|
+
.alea-morph-icon-b { opacity: 0; transform: rotate(calc(var(--alea-motion-rotate, 12deg) * -7.5)) scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 6)); filter: blur(var(--alea-motion-blur-sm)); }
|
|
143
|
+
.alea-morph-icon[data-active] .alea-morph-icon-a { opacity: 0; transform: rotate(calc(var(--alea-motion-rotate, 12deg) * 7.5)) scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 6)); filter: blur(var(--alea-motion-blur-sm)); }
|
|
144
|
+
.alea-morph-icon[data-active] .alea-morph-icon-b { opacity: 1; transform: none; filter: none; }
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* Alea Motion utilities: motion for your own elements, from the same tokens.
|
|
2
|
+
|
|
3
|
+
Enter on mount <div class="alea-enter" data-motion="rise"> (any preset; default fade)
|
|
4
|
+
Enter on scroll <Reveal motion="rise"> or data-reveal="pending|in" set by your own observer
|
|
5
|
+
Stagger children <ul data-stagger> ... </ul> (each child waits --alea-motion-stagger more)
|
|
6
|
+
Delay style="--alea-enter-delay: 120ms"
|
|
7
|
+
Hover and press alea-hover-lift, alea-hover-scale, alea-hover-glow, alea-hover-tint, alea-press, alea-hint */
|
|
8
|
+
|
|
9
|
+
/* ------------------------------------------------------------------ enter on mount and on reveal */
|
|
10
|
+
.alea-enter, [data-reveal='in'] { animation: var(--alea-enter-duration, var(--alea-motion-duration-slow)) var(--alea-enter-ease, var(--alea-motion-ease-out)) var(--alea-enter-delay, 0s) both var(--alea-enter, alea-m-fade-in); }
|
|
11
|
+
/* waiting off screen: fully transparent (the entrance itself starts at 0.01) */
|
|
12
|
+
[data-reveal='pending'] { opacity: 0; }
|
|
13
|
+
|
|
14
|
+
/* ------------------------------------------------------------------ stagger: children enter one after another (first 12) */
|
|
15
|
+
[data-stagger] > * { animation: var(--alea-motion-duration-slow) var(--alea-motion-ease-out) both alea-item-in; animation-delay: calc(var(--alea-i, 0) * var(--alea-motion-stagger)); }
|
|
16
|
+
[data-stagger='reveal'] > * { animation-name: alea-m-rise-in; }
|
|
17
|
+
[data-stagger] > :nth-child(2) { --alea-i: 1; } [data-stagger] > :nth-child(3) { --alea-i: 2; } [data-stagger] > :nth-child(4) { --alea-i: 3; }
|
|
18
|
+
[data-stagger] > :nth-child(5) { --alea-i: 4; } [data-stagger] > :nth-child(6) { --alea-i: 5; } [data-stagger] > :nth-child(7) { --alea-i: 6; }
|
|
19
|
+
[data-stagger] > :nth-child(8) { --alea-i: 7; } [data-stagger] > :nth-child(9) { --alea-i: 8; } [data-stagger] > :nth-child(10) { --alea-i: 9; }
|
|
20
|
+
[data-stagger] > :nth-child(11) { --alea-i: 10; } [data-stagger] > :nth-child(n+12) { --alea-i: 11; }
|
|
21
|
+
[data-stagger][data-reveal='pending'] { opacity: 1; }
|
|
22
|
+
[data-stagger][data-reveal='pending'] > * { animation: none; opacity: 0; }
|
|
23
|
+
|
|
24
|
+
/* ------------------------------------------------------------------ hover and press */
|
|
25
|
+
:is(.alea-hover-lift, .alea-hover-scale, .alea-hover-glow, .alea-hover-tint, .alea-press) {
|
|
26
|
+
transition: transform var(--alea-motion-duration-base) var(--alea-motion-ease-out), box-shadow var(--alea-motion-duration-base) var(--alea-motion-ease-out), background-color var(--alea-motion-duration-fast) var(--alea-motion-ease-standard);
|
|
27
|
+
}
|
|
28
|
+
.alea-hover-lift:hover { transform: translateY(var(--alea-motion-lift)); box-shadow: var(--alea-shadow-pop); }
|
|
29
|
+
.alea-hover-scale:hover { transform: scale(calc(2 - var(--alea-motion-scale-press))); }
|
|
30
|
+
.alea-hover-glow:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--alea-accent) 45%, transparent), 0 8px 32px -8px color-mix(in srgb, var(--alea-accent) 55%, transparent); }
|
|
31
|
+
.alea-hover-tint:hover { background-color: var(--alea-surface-hover); }
|
|
32
|
+
.alea-press:active { transform: scale(var(--alea-motion-scale-press)); transition-duration: var(--alea-motion-duration-instant); }
|
|
33
|
+
|
|
34
|
+
/* ------------------------------------------------------------------ any pattern on any element
|
|
35
|
+
<span class="alea-m" data-m="pop">…</span> plays once when it mounts
|
|
36
|
+
data-m-on="hover | press | focus | visible | change | loop" when it plays instead
|
|
37
|
+
visible: set data-m-in when it scrolls in (Motion and useMotion do it); change: re-set data-m-run to replay
|
|
38
|
+
style="--alea-m-delay: 120ms; --alea-m-duration: 480ms" per element (defaults: the tokens)
|
|
39
|
+
Hover and press patterns are utilities: alea-hover-lift, alea-press, alea-hover-tint, alea-hover-glow, alea-hint.
|
|
40
|
+
With reduced motion the entrances only fade (the distances and scales are tokens) and loops stop. */
|
|
41
|
+
.alea-m {
|
|
42
|
+
--alea-m-name: alea-m-fade-in;
|
|
43
|
+
animation-duration: var(--alea-m-duration, var(--alea-motion-duration-slow));
|
|
44
|
+
animation-timing-function: var(--alea-m-ease, var(--alea-motion-ease-out));
|
|
45
|
+
animation-delay: var(--alea-m-delay, 0s);
|
|
46
|
+
animation-fill-mode: both;
|
|
47
|
+
transform-origin: var(--alea-m-origin, center);
|
|
48
|
+
}
|
|
49
|
+
.alea-m[data-m='pop'] { --alea-m-name: alea-m-pop-in; --alea-m-ease: var(--alea-motion-ease-emphasized); --alea-m-duration: var(--alea-motion-duration-base); }
|
|
50
|
+
.alea-m[data-m='rise'] { --alea-m-name: alea-m-rise-in; }
|
|
51
|
+
.alea-m[data-m='drop'] { --alea-m-name: alea-m-drop-in; }
|
|
52
|
+
.alea-m[data-m='scale'] { --alea-m-name: alea-m-scale-in; }
|
|
53
|
+
.alea-m[data-m='zoom'] { --alea-m-name: alea-m-zoom-in; }
|
|
54
|
+
.alea-m[data-m='blur'] { --alea-m-name: alea-m-blur-in; }
|
|
55
|
+
.alea-m[data-m='flip'] { --alea-m-name: alea-m-flip-in; }
|
|
56
|
+
.alea-m[data-m='slide-up'] { --alea-m-name: alea-m-slide-up-in; }
|
|
57
|
+
.alea-m[data-m='slide-down'] { --alea-m-name: alea-m-slide-down-in; }
|
|
58
|
+
.alea-m[data-m='slide-left'] { --alea-m-name: alea-m-slide-left-in; }
|
|
59
|
+
.alea-m[data-m='slide-right'] { --alea-m-name: alea-m-slide-right-in; }
|
|
60
|
+
.alea-m[data-m='badge'] { --alea-m-name: alea-badge-pop; --alea-m-ease: var(--alea-motion-ease-emphasized); --alea-m-duration: var(--alea-motion-duration-base); }
|
|
61
|
+
.alea-m[data-m='nudge'] { --alea-m-name: alea-nudge; --alea-m-ease: var(--alea-motion-ease-in-out); --alea-m-duration: var(--alea-motion-duration-slow); }
|
|
62
|
+
.alea-m[data-m='pulse'] { --alea-m-name: alea-m-pulse; --alea-m-ease: var(--alea-motion-ease-in-out); --alea-m-duration: 1.2s; }
|
|
63
|
+
.alea-m[data-m='draw'] { --alea-m-name: alea-m-draw; --alea-m-origin: left center; }
|
|
64
|
+
.alea-m:is(:not([data-m-on]), [data-m-on='mount'], [data-m-on='hover']:hover, [data-m-on='press']:active, [data-m-on='focus']:focus-visible, [data-m-on='focus']:has(:focus-visible), [data-m-on='visible'][data-m-in], [data-m-on='change'][data-m-run]) { animation-name: var(--alea-m-name); }
|
|
65
|
+
.alea-m[data-m-on='loop'] { animation-name: var(--alea-m-name); animation-iteration-count: infinite; animation-direction: alternate; }
|
|
66
|
+
@keyframes alea-m-pulse { from { transform: scale(1); } to { transform: scale(calc(2 - var(--alea-motion-scale-press))); } }
|
|
67
|
+
@keyframes alea-m-draw { from { transform: scaleX(0.01); } }
|
|
68
|
+
@media (prefers-reduced-motion: reduce) { :root:not([data-alea-reduced='never']) .alea-m[data-m-on='loop'] { animation: none; } }
|
|
69
|
+
:is([data-alea-motion='reduced'], [data-alea-reduced='always']) .alea-m[data-m-on='loop'] { animation: none; }
|
|
70
|
+
:is([data-alea-motion='off']) .alea-m { animation: none; }
|