@aura-react-comp/motion 0.2.11 → 0.3.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/esm/composed/confetti.d.ts.map +1 -1
- package/esm/composed/confetti.js +20 -2
- package/esm/config/index.js +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/index.js +1 -0
- package/esm/tokens.css +55 -1
- package/esm/tokens.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confetti.d.ts","sourceRoot":"","sources":["confetti.tsx"],"names":[],"mappings":";AAgBA,MAAM,WAAW,aAAa;IAC5B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,MAAM,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"confetti.d.ts","sourceRoot":"","sources":["confetti.tsx"],"names":[],"mappings":";AAgBA,MAAM,WAAW,aAAa;IAC5B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,MAAM,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAgDD,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,KAAW,EACX,MAA2B,EAC3B,MAAM,GACP,EAAE,aAAa,sCA0Gf"}
|
package/esm/composed/confetti.js
CHANGED
|
@@ -14,6 +14,21 @@ import { useReducedMotion } from 'motion/react';
|
|
|
14
14
|
import { motionConfettiColors } from "../tokens";
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
const DEFAULT_COLORS = [...motionConfettiColors];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 从全局令牌实时读取 Confetti 默认色板:
|
|
20
|
+
* --aura-motion-accent / cyan / blue / fuchsia 随双轴主题
|
|
21
|
+
* (data-mode × data-palette)切换,fire 时读取即与当前主题一致。
|
|
22
|
+
* 令牌缺失(SSR / 未引入 tokens.css)时回退 motionConfettiColors。
|
|
23
|
+
*/
|
|
24
|
+
function readThemeConfettiColors() {
|
|
25
|
+
if (typeof getComputedStyle !== 'function' || typeof document === 'undefined') {
|
|
26
|
+
return DEFAULT_COLORS;
|
|
27
|
+
}
|
|
28
|
+
const styles = getComputedStyle(document.documentElement);
|
|
29
|
+
const token = (name, fallback) => styles.getPropertyValue(name).trim() || fallback;
|
|
30
|
+
return [token('--aura-motion-accent', DEFAULT_COLORS[0]), token('--aura-motion-cyan', DEFAULT_COLORS[1]), token('--aura-motion-blue', DEFAULT_COLORS[2]), token('--aura-motion-fuchsia', DEFAULT_COLORS[3]), token('--aura-motion-accent-strong', DEFAULT_COLORS[4]), token('--aura-motion-cyan', DEFAULT_COLORS[5])];
|
|
31
|
+
}
|
|
17
32
|
export function Confetti({
|
|
18
33
|
fire,
|
|
19
34
|
count = 120,
|
|
@@ -21,7 +36,7 @@ export function Confetti({
|
|
|
21
36
|
x: 0.5,
|
|
22
37
|
y: 0.6
|
|
23
38
|
},
|
|
24
|
-
colors
|
|
39
|
+
colors
|
|
25
40
|
}) {
|
|
26
41
|
const canvasRef = useRef(null);
|
|
27
42
|
const reduced = useReducedMotion();
|
|
@@ -35,6 +50,9 @@ export function Confetti({
|
|
|
35
50
|
canvas.height = window.innerHeight;
|
|
36
51
|
const ox = origin.x * canvas.width;
|
|
37
52
|
const oy = origin.y * canvas.height;
|
|
53
|
+
|
|
54
|
+
// 发射瞬间取色:未显式传 colors 时跟当前主题(令牌实时值)
|
|
55
|
+
const palette = colors ?? readThemeConfettiColors();
|
|
38
56
|
const parts = Array.from({
|
|
39
57
|
length: count
|
|
40
58
|
}, (_, i) => {
|
|
@@ -53,7 +71,7 @@ export function Confetti({
|
|
|
53
71
|
tiltSpeed: 0.12 + Math.random() * 0.22,
|
|
54
72
|
w: ribbon ? 5 + Math.random() * 4 : 7 + Math.random() * 5,
|
|
55
73
|
h: ribbon ? 16 + Math.random() * 8 : 7 + Math.random() * 5,
|
|
56
|
-
color:
|
|
74
|
+
color: palette[i % palette.length],
|
|
57
75
|
life: 1,
|
|
58
76
|
decay: 0.007 + Math.random() * 0.007,
|
|
59
77
|
ribbon
|
package/esm/config/index.js
CHANGED
package/esm/hooks/index.js
CHANGED
package/esm/index.js
CHANGED
package/esm/tokens.css
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* 动效令牌(CSS 端)—— 与 src/tokens.ts 保持一致(tokens.test.ts 守护漂移)。
|
|
3
3
|
* 消费方:引入本包的 `tokens.css` 子路径,或依赖 ui/x/business
|
|
4
4
|
* 等联动包的级联引入。
|
|
5
|
+
*
|
|
6
|
+
* 颜色令牌随全局双轴主题切换:
|
|
7
|
+
* data-mode(light|dark) × data-palette(violet|ocean|sunset),
|
|
8
|
+
* 历史选择器 [data-theme="dark"] 保留兼容(= dark × violet)。
|
|
5
9
|
*/
|
|
6
10
|
:root {
|
|
7
11
|
--aura-motion-duration-instant: 80ms;
|
|
@@ -37,7 +41,8 @@
|
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
/* 暗色:同一套语义,换成更亮的霓虹与更低的表面亮度 */
|
|
40
|
-
[data-theme='dark']
|
|
44
|
+
[data-theme='dark'],
|
|
45
|
+
[data-mode='dark'][data-palette='violet'] {
|
|
41
46
|
--aura-motion-accent: #a855f7;
|
|
42
47
|
--aura-motion-accent-strong: #7c3aed;
|
|
43
48
|
--aura-motion-accent-soft: rgba(168, 85, 247, 0.18);
|
|
@@ -53,6 +58,55 @@
|
|
|
53
58
|
--aura-motion-focus-color: #a855f7;
|
|
54
59
|
}
|
|
55
60
|
|
|
61
|
+
/* ===== Light × Ocean =====
|
|
62
|
+
主锚 #2563eb(Tailwind blue-600),accent 系全部从主锚派生;
|
|
63
|
+
cyan / blue / fuchsia 为霓虹装饰阵列,刻意不跟色板。 */
|
|
64
|
+
[data-palette='ocean'] {
|
|
65
|
+
--aura-motion-accent: #2563eb;
|
|
66
|
+
--aura-motion-accent-strong: #1d4ed8;
|
|
67
|
+
--aura-motion-accent-soft: rgba(37, 99, 235, 0.12);
|
|
68
|
+
--aura-motion-accent-glow: rgba(37, 99, 235, 0.35);
|
|
69
|
+
--aura-motion-shimmer: rgba(37, 99, 235, 0.85);
|
|
70
|
+
--aura-motion-sheen: rgba(37, 99, 235, 0.12);
|
|
71
|
+
--aura-motion-focus-color: #2563eb;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* ===== Dark × Ocean ===== */
|
|
75
|
+
[data-mode='dark'][data-palette='ocean'] {
|
|
76
|
+
--aura-motion-accent: #60a5fa;
|
|
77
|
+
--aura-motion-accent-strong: #2563eb;
|
|
78
|
+
--aura-motion-accent-soft: rgba(96, 165, 250, 0.18);
|
|
79
|
+
--aura-motion-accent-glow: rgba(96, 165, 250, 0.45);
|
|
80
|
+
--aura-motion-blue: #60a5fa;
|
|
81
|
+
--aura-motion-shimmer: rgba(255, 255, 255, 0.85);
|
|
82
|
+
--aura-motion-sheen: rgba(255, 255, 255, 0.18);
|
|
83
|
+
--aura-motion-focus-color: #60a5fa;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* ===== Light × Sunset =====
|
|
87
|
+
主锚 #ea580c(Tailwind orange-600)。 */
|
|
88
|
+
[data-palette='sunset'] {
|
|
89
|
+
--aura-motion-accent: #ea580c;
|
|
90
|
+
--aura-motion-accent-strong: #c2410c;
|
|
91
|
+
--aura-motion-accent-soft: rgba(234, 88, 12, 0.12);
|
|
92
|
+
--aura-motion-accent-glow: rgba(234, 88, 12, 0.35);
|
|
93
|
+
--aura-motion-shimmer: rgba(234, 88, 12, 0.85);
|
|
94
|
+
--aura-motion-sheen: rgba(234, 88, 12, 0.12);
|
|
95
|
+
--aura-motion-focus-color: #ea580c;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* ===== Dark × Sunset ===== */
|
|
99
|
+
[data-mode='dark'][data-palette='sunset'] {
|
|
100
|
+
--aura-motion-accent: #fb923c;
|
|
101
|
+
--aura-motion-accent-strong: #ea580c;
|
|
102
|
+
--aura-motion-accent-soft: rgba(251, 146, 60, 0.18);
|
|
103
|
+
--aura-motion-accent-glow: rgba(251, 146, 60, 0.45);
|
|
104
|
+
--aura-motion-blue: #60a5fa;
|
|
105
|
+
--aura-motion-shimmer: rgba(255, 255, 255, 0.85);
|
|
106
|
+
--aura-motion-sheen: rgba(255, 255, 255, 0.18);
|
|
107
|
+
--aura-motion-focus-color: #fb923c;
|
|
108
|
+
}
|
|
109
|
+
|
|
56
110
|
/* 可访问性第一层降级:令牌驱动的样式(工具类 / 业务自研 less)在此整体归零。
|
|
57
111
|
引擎层与组件层的降级分别由 <MotionConfig reducedMotion> 与 useReducedMotion 承担。 */
|
|
58
112
|
@media (prefers-reduced-motion: reduce) {
|
package/esm/tokens.js
CHANGED