@moonwitness/ui 7.3.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/pixelfx-boundary.js +1 -1
  3. package/package.json +2 -3
  4. package/scripts/consumer-smoke.mjs +0 -45
  5. package/scripts/generate-icons.mjs +0 -110
  6. package/scripts/generate-token-artifacts.mjs +0 -90
  7. package/scripts/icon-svg-to-jsx.mjs +0 -249
  8. package/scripts/verification-diagnostics.mjs +0 -40
  9. package/scripts/verify-package.mjs +0 -412
  10. package/src/cartoon/anime-avatar.tsx +0 -628
  11. package/src/cartoon/anime-stage.tsx +0 -458
  12. package/src/cartoon/index.tsx +0 -542
  13. package/src/cartoon.tsx +0 -645
  14. package/src/characters.ts +0 -625
  15. package/src/components/accordion.tsx +0 -77
  16. package/src/components/alert.tsx +0 -139
  17. package/src/components/appearance-menu.tsx +0 -181
  18. package/src/components/artwork-frame.tsx +0 -49
  19. package/src/components/audio.tsx +0 -97
  20. package/src/components/avatar.tsx +0 -75
  21. package/src/components/badge.tsx +0 -94
  22. package/src/components/brand-mark.tsx +0 -73
  23. package/src/components/breadcrumbs.tsx +0 -98
  24. package/src/components/button.tsx +0 -340
  25. package/src/components/card.tsx +0 -171
  26. package/src/components/character-badge.tsx +0 -58
  27. package/src/components/character-preview.tsx +0 -104
  28. package/src/components/character-stage.tsx +0 -225
  29. package/src/components/chart.tsx +0 -481
  30. package/src/components/checkbox.tsx +0 -64
  31. package/src/components/comic-panel.tsx +0 -301
  32. package/src/components/comic-theater.tsx +0 -170
  33. package/src/components/command.tsx +0 -189
  34. package/src/components/confirm-dialog.tsx +0 -129
  35. package/src/components/copy-button.tsx +0 -62
  36. package/src/components/date-picker.tsx +0 -126
  37. package/src/components/dialog.tsx +0 -164
  38. package/src/components/dna-icon.tsx +0 -77
  39. package/src/components/dropdown-menu.tsx +0 -87
  40. package/src/components/effects.tsx +0 -1021
  41. package/src/components/empty-state.tsx +0 -93
  42. package/src/components/epistemic-branch-panel.tsx +0 -101
  43. package/src/components/error-state.tsx +0 -137
  44. package/src/components/field.tsx +0 -96
  45. package/src/components/filter-facet-bar.tsx +0 -91
  46. package/src/components/inbox-popover.tsx +0 -146
  47. package/src/components/input.tsx +0 -25
  48. package/src/components/kanban-board.tsx +0 -190
  49. package/src/components/label.tsx +0 -19
  50. package/src/components/layered-scene.tsx +0 -555
  51. package/src/components/log-console.tsx +0 -261
  52. package/src/components/metric-tile.tsx +0 -99
  53. package/src/components/mode-picker.tsx +0 -149
  54. package/src/components/motion-timeline.tsx +0 -848
  55. package/src/components/number-input.tsx +0 -104
  56. package/src/components/page-header.tsx +0 -123
  57. package/src/components/pagination.tsx +0 -83
  58. package/src/components/panel.tsx +0 -121
  59. package/src/components/paper-note.tsx +0 -77
  60. package/src/components/popover.tsx +0 -72
  61. package/src/components/progress.tsx +0 -127
  62. package/src/components/quest-card.tsx +0 -319
  63. package/src/components/radio-group.tsx +0 -50
  64. package/src/components/riot-sticker.tsx +0 -151
  65. package/src/components/scene-particles.tsx +0 -196
  66. package/src/components/scene-transitions.tsx +0 -130
  67. package/src/components/section-ribbon.tsx +0 -94
  68. package/src/components/select-field.tsx +0 -27
  69. package/src/components/select.tsx +0 -81
  70. package/src/components/separator.tsx +0 -58
  71. package/src/components/sheet.tsx +0 -96
  72. package/src/components/skeleton.tsx +0 -35
  73. package/src/components/sketch-annotation.tsx +0 -87
  74. package/src/components/smart-button-box.tsx +0 -114
  75. package/src/components/speech-bubble.tsx +0 -116
  76. package/src/components/spinner.tsx +0 -69
  77. package/src/components/sprite-player.tsx +0 -412
  78. package/src/components/status-bar.tsx +0 -63
  79. package/src/components/status-pill.tsx +0 -68
  80. package/src/components/switch.tsx +0 -76
  81. package/src/components/table.tsx +0 -163
  82. package/src/components/tabs.tsx +0 -101
  83. package/src/components/tag-input.tsx +0 -170
  84. package/src/components/textarea.tsx +0 -25
  85. package/src/components/toast.tsx +0 -14
  86. package/src/components/toolbar.tsx +0 -39
  87. package/src/components/tooltip.tsx +0 -49
  88. package/src/components/update-banner.tsx +0 -220
  89. package/src/components/xv-primitives.tsx +0 -256
  90. package/src/css-exports.ts +0 -142
  91. package/src/dna.tsx +0 -137
  92. package/src/game/boss-hud.tsx +0 -384
  93. package/src/game/index.tsx +0 -886
  94. package/src/game/tactical.tsx +0 -245
  95. package/src/game.tsx +0 -770
  96. package/src/icons/activity.tsx +0 -38
  97. package/src/icons/add.tsx +0 -38
  98. package/src/icons/addon.tsx +0 -37
  99. package/src/icons/anime-anger.tsx +0 -37
  100. package/src/icons/anime-shock.tsx +0 -37
  101. package/src/icons/anime-sparkle.tsx +0 -38
  102. package/src/icons/anime-sweatdrop.tsx +0 -38
  103. package/src/icons/archive.tsx +0 -37
  104. package/src/icons/arrow-left.tsx +0 -37
  105. package/src/icons/arrow-right.tsx +0 -37
  106. package/src/icons/attachment.tsx +0 -38
  107. package/src/icons/bank.tsx +0 -37
  108. package/src/icons/bolt.tsx +0 -37
  109. package/src/icons/book-open.tsx +0 -37
  110. package/src/icons/bookmark.tsx +0 -37
  111. package/src/icons/boss-skull.tsx +0 -40
  112. package/src/icons/calendar-clock.tsx +0 -40
  113. package/src/icons/calendar.tsx +0 -38
  114. package/src/icons/check-circle.tsx +0 -38
  115. package/src/icons/check-square.tsx +0 -38
  116. package/src/icons/check.tsx +0 -37
  117. package/src/icons/chevron-right.tsx +0 -37
  118. package/src/icons/chevrons-left.tsx +0 -37
  119. package/src/icons/chevrons-right.tsx +0 -37
  120. package/src/icons/clapperboard.tsx +0 -38
  121. package/src/icons/clock.tsx +0 -38
  122. package/src/icons/close.tsx +0 -37
  123. package/src/icons/code.tsx +0 -37
  124. package/src/icons/columns.tsx +0 -38
  125. package/src/icons/combo-flame.tsx +0 -38
  126. package/src/icons/company.tsx +0 -38
  127. package/src/icons/credit-card.tsx +0 -38
  128. package/src/icons/critical-star.tsx +0 -37
  129. package/src/icons/currency.tsx +0 -38
  130. package/src/icons/delete.tsx +0 -37
  131. package/src/icons/document.tsx +0 -38
  132. package/src/icons/download.tsx +0 -37
  133. package/src/icons/dpad.tsx +0 -38
  134. package/src/icons/edit.tsx +0 -38
  135. package/src/icons/element-fire.tsx +0 -37
  136. package/src/icons/element-ice.tsx +0 -38
  137. package/src/icons/element-solar.tsx +0 -38
  138. package/src/icons/element-void.tsx +0 -38
  139. package/src/icons/element-volt.tsx +0 -38
  140. package/src/icons/element-wind.tsx +0 -37
  141. package/src/icons/error.tsx +0 -38
  142. package/src/icons/external-link.tsx +0 -38
  143. package/src/icons/field.tsx +0 -38
  144. package/src/icons/file-spreadsheet.tsx +0 -38
  145. package/src/icons/filter.tsx +0 -37
  146. package/src/icons/gacha-ticket.tsx +0 -38
  147. package/src/icons/gamepad.tsx +0 -40
  148. package/src/icons/globe.tsx +0 -38
  149. package/src/icons/grid.tsx +0 -40
  150. package/src/icons/hash.tsx +0 -37
  151. package/src/icons/heart-hp.tsx +0 -38
  152. package/src/icons/history.tsx +0 -37
  153. package/src/icons/home.tsx +0 -37
  154. package/src/icons/image.tsx +0 -39
  155. package/src/icons/impact-slash.tsx +0 -38
  156. package/src/icons/inbox.tsx +0 -38
  157. package/src/icons/index.ts +0 -120
  158. package/src/icons/info.tsx +0 -38
  159. package/src/icons/jobs.tsx +0 -38
  160. package/src/icons/katana.tsx +0 -38
  161. package/src/icons/key.tsx +0 -38
  162. package/src/icons/keyboard.tsx +0 -38
  163. package/src/icons/keyframe-diamond.tsx +0 -38
  164. package/src/icons/knowledge.tsx +0 -38
  165. package/src/icons/language.tsx +0 -39
  166. package/src/icons/lock.tsx +0 -38
  167. package/src/icons/logout.tsx +0 -37
  168. package/src/icons/loot-chest.tsx +0 -39
  169. package/src/icons/mail.tsx +0 -38
  170. package/src/icons/mana-crystal.tsx +0 -38
  171. package/src/icons/map-pin.tsx +0 -38
  172. package/src/icons/mecha-helm.tsx +0 -38
  173. package/src/icons/menu.tsx +0 -37
  174. package/src/icons/message.tsx +0 -38
  175. package/src/icons/model.tsx +0 -38
  176. package/src/icons/moon.tsx +0 -37
  177. package/src/icons/notification.tsx +0 -38
  178. package/src/icons/partner.tsx +0 -41
  179. package/src/icons/pause.tsx +0 -37
  180. package/src/icons/phone.tsx +0 -37
  181. package/src/icons/play.tsx +0 -37
  182. package/src/icons/potion-flask.tsx +0 -40
  183. package/src/icons/quest-scroll.tsx +0 -39
  184. package/src/icons/radar-ping.tsx +0 -40
  185. package/src/icons/refresh.tsx +0 -38
  186. package/src/icons/relation.tsx +0 -40
  187. package/src/icons/save.tsx +0 -38
  188. package/src/icons/search.tsx +0 -38
  189. package/src/icons/security.tsx +0 -38
  190. package/src/icons/send.tsx +0 -38
  191. package/src/icons/settings.tsx +0 -39
  192. package/src/icons/shield-crest.tsx +0 -38
  193. package/src/icons/shuriken.tsx +0 -38
  194. package/src/icons/signal-off.tsx +0 -37
  195. package/src/icons/signal.tsx +0 -37
  196. package/src/icons/skill-node.tsx +0 -40
  197. package/src/icons/smartphone.tsx +0 -38
  198. package/src/icons/sort-ascending.tsx +0 -37
  199. package/src/icons/sort-descending.tsx +0 -37
  200. package/src/icons/sort.tsx +0 -37
  201. package/src/icons/sparkle.tsx +0 -38
  202. package/src/icons/speech-burst.tsx +0 -37
  203. package/src/icons/story.tsx +0 -37
  204. package/src/icons/sun.tsx +0 -38
  205. package/src/icons/tag.tsx +0 -38
  206. package/src/icons/team.tsx +0 -40
  207. package/src/icons/trophy-crown.tsx +0 -39
  208. package/src/icons/upload.tsx +0 -37
  209. package/src/icons/user.tsx +0 -38
  210. package/src/icons/users.tsx +0 -39
  211. package/src/icons/visibility-off.tsx +0 -38
  212. package/src/icons/visibility.tsx +0 -38
  213. package/src/icons/volume-off.tsx +0 -37
  214. package/src/icons/volume.tsx +0 -37
  215. package/src/icons/warning.tsx +0 -38
  216. package/src/icons/workflow.tsx +0 -40
  217. package/src/icons.tsx +0 -965
  218. package/src/index.ts +0 -89
  219. package/src/lib/asset-registry.ts +0 -534
  220. package/src/lib/audio-runtime.ts +0 -314
  221. package/src/lib/character-adapter.ts +0 -370
  222. package/src/lib/character-registry.ts +0 -2368
  223. package/src/lib/cn.ts +0 -6
  224. package/src/lib/compose-refs.ts +0 -16
  225. package/src/lib/sanitize-url.ts +0 -51
  226. package/src/lib/scene-camera.ts +0 -483
  227. package/src/lib/scene-playback.ts +0 -622
  228. package/src/lib/scene-soundscape.ts +0 -151
  229. package/src/lib/scene-test-harness.ts +0 -200
  230. package/src/lib/scene-timeline.ts +0 -398
  231. package/src/lib/use-animation-visibility.ts +0 -45
  232. package/src/lib/use-modal-focus.ts +0 -270
  233. package/src/lib/use-reduced-motion.ts +0 -37
  234. package/src/motion/easing-presets.ts +0 -262
  235. package/src/motion/index.tsx +0 -894
  236. package/src/motion/physics.ts +0 -259
  237. package/src/motion/timeline-math.ts +0 -358
  238. package/src/motion.tsx +0 -639
  239. package/src/pixelfx-boundary.ts +0 -188
  240. package/src/pixelfx-registry.ts +0 -1190
  241. package/src/pixelfx-types.d.ts +0 -73
  242. package/src/pixelfx.tsx +0 -1022
  243. package/src/provider.tsx +0 -63
  244. package/src/skin-catalog.ts +0 -306
  245. package/src/skin-tokens.ts +0 -425
  246. package/src/ssr/init-script.ts +0 -281
  247. package/src/ssr/resolve-skin.ts +0 -217
  248. package/src/ssr/theme-mismatch-dev.ts +0 -181
  249. package/src/templates/battle-arena.tsx +0 -688
  250. package/src/templates/index.tsx +0 -314
  251. package/src/templates.tsx +0 -225
  252. package/src/themes/dna-presets.ts +0 -119
  253. package/src/themes/index.ts +0 -56
  254. package/src/themes/provider.tsx +0 -183
  255. package/src/themes/types.ts +0 -111
  256. package/src/themes.ts +0 -9
  257. package/src/token-exporter.ts +0 -12
  258. package/src/token-exporters.ts +0 -343
  259. package/src/token-seeds.ts +0 -335
  260. package/src/token-snapshot.ts +0 -179
  261. package/src/utils.ts +0 -58
package/src/motion.tsx DELETED
@@ -1,639 +0,0 @@
1
- import {
2
- createContext,
3
- useContext,
4
- useEffect,
5
- useMemo,
6
- useState,
7
- type CSSProperties,
8
- type ReactNode,
9
- } from "react";
10
- import { Button } from "./components/button.js";
11
- import { Badge } from "./components/badge.js";
12
-
13
- export type MotionProfile = "off" | "subtle" | "expressive" | "cartoon";
14
-
15
- export const MOTION_EASING_NAMES = [
16
- "linear",
17
- "ease-out",
18
- "ease-in-out",
19
- "expo-out",
20
- "overshoot",
21
- "anticipation",
22
- "spring",
23
- "elastic",
24
- "bounce",
25
- "steps-8",
26
- "steps-12",
27
- "steps-24",
28
- ] as const;
29
-
30
- export type MotionEasingName = (typeof MOTION_EASING_NAMES)[number];
31
-
32
- export type MotionEasingPreset = {
33
- readonly id: MotionEasingName;
34
- readonly label: string;
35
- readonly category: "standard" | "physics" | "cel";
36
- };
37
-
38
- export const MOTION_EASING_PRESETS: readonly MotionEasingPreset[] = [
39
- { id: "linear", label: "Linear", category: "standard" },
40
- { id: "ease-out", label: "Ease Out", category: "standard" },
41
- { id: "ease-in-out", label: "Ease In-Out", category: "standard" },
42
- { id: "expo-out", label: "Expo Out", category: "standard" },
43
- { id: "overshoot", label: "Back Overshoot", category: "physics" },
44
- { id: "anticipation", label: "Anticipation", category: "physics" },
45
- { id: "spring", label: "Spring", category: "physics" },
46
- { id: "elastic", label: "Elastic", category: "physics" },
47
- { id: "bounce", label: "Bounce", category: "physics" },
48
- { id: "steps-8", label: "8fps Cel", category: "cel" },
49
- { id: "steps-12", label: "12fps Cel", category: "cel" },
50
- { id: "steps-24", label: "24fps Cel", category: "cel" },
51
- ];
52
-
53
- export type MotionTimelineKeyframe = {
54
- readonly id: string;
55
- readonly label: string;
56
- readonly at: number;
57
- readonly value: number;
58
- readonly easing?: MotionEasingName;
59
- };
60
-
61
- export const DEFAULT_MOTION_TIMELINE_KEYFRAMES: readonly MotionTimelineKeyframe[] = [
62
- { id: "kf-0", label: "Anticipate", at: 0, value: 0.08, easing: "anticipation" },
63
- { id: "kf-1", label: "Launch", at: 0.35, value: 1.0, easing: "overshoot" },
64
- { id: "kf-2", label: "Settle", at: 0.72, value: 0.84, easing: "spring" },
65
- { id: "kf-3", label: "Rest", at: 1.0, value: 0.88, easing: "ease-out" },
66
- ];
67
-
68
- export type ProceduralSfxPreset =
69
- | "click-soft"
70
- | "toggle-pop"
71
- | "success-chime"
72
- | "hit-impact"
73
- | "boing"
74
- | "cut-in-slash"
75
- | "level-up"
76
- | "gacha-sparkle"
77
- | "gacha-fanfare";
78
-
79
- export type ScreenFXKind =
80
- | "speedlines-burst"
81
- | "flash"
82
- | "chromatic-pulse"
83
- | "vignette"
84
- | "vignette-impact";
85
-
86
- export function evaluateEasing(
87
- rawT: number,
88
- name: MotionEasingName = "ease-out",
89
- ): number {
90
- const t = Math.max(0, Math.min(1, rawT));
91
- switch (name) {
92
- case "linear":
93
- return t;
94
- case "ease-out":
95
- return 1 - Math.pow(1 - t, 3);
96
- case "ease-in-out":
97
- return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
98
- case "expo-out":
99
- return t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
100
- case "overshoot": {
101
- const c1 = 1.70158;
102
- const c3 = c1 + 1;
103
- return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
104
- }
105
- case "anticipation": {
106
- const c1 = 1.70158;
107
- const c3 = c1 + 1;
108
- return c3 * t * t * t - c1 * t * t;
109
- }
110
- case "spring":
111
- return 1 - Math.exp(-6 * t) * Math.cos(12 * t);
112
- case "elastic": {
113
- if (t === 0 || t === 1) return t;
114
- return (
115
- Math.pow(2, -10 * t) * Math.sin(((t * 10 - 0.75) * (2 * Math.PI)) / 3) +
116
- 1
117
- );
118
- }
119
- case "bounce": {
120
- const n1 = 7.5625;
121
- const d1 = 2.75;
122
- if (t < 1 / d1) return n1 * t * t;
123
- if (t < 2 / d1) {
124
- const u = t - 1.5 / d1;
125
- return n1 * u * u + 0.75;
126
- }
127
- if (t < 2.5 / d1) {
128
- const u = t - 2.25 / d1;
129
- return n1 * u * u + 0.9375;
130
- }
131
- const u = t - 2.625 / d1;
132
- return n1 * u * u + 0.984375;
133
- }
134
- case "steps-8":
135
- return Math.floor(t * 8) / 8;
136
- case "steps-12":
137
- return Math.floor(t * 12) / 12;
138
- case "steps-24":
139
- return Math.floor(t * 24) / 24;
140
- default:
141
- return t;
142
- }
143
- }
144
-
145
- export function sampleEasingCurve(
146
- name: MotionEasingName,
147
- samples = 48,
148
- ): ReadonlyArray<{ t: number; y: number }> {
149
- const count = Math.max(4, samples);
150
- return Array.from({ length: count + 1 }, (_, i) => {
151
- const t = i / count;
152
- return { t, y: evaluateEasing(t, name) };
153
- });
154
- }
155
-
156
- export function applyEasingPresetToKeyframes(
157
- keyframes: readonly MotionTimelineKeyframe[],
158
- easing: MotionEasingName,
159
- scope: "all" | "segment" = "all",
160
- segmentIndex = 0,
161
- ): readonly MotionTimelineKeyframe[] {
162
- return keyframes.map((kf, idx) => {
163
- if (scope === "all" || idx === segmentIndex) {
164
- return { ...kf, easing };
165
- }
166
- return kf;
167
- });
168
- }
169
-
170
- let sharedAudioCtx: AudioContext | null = null;
171
-
172
- export function playProceduralSfx(
173
- preset: ProceduralSfxPreset,
174
- enabled = true,
175
- userGesture = true,
176
- pitchScale = 1,
177
- ): void {
178
- if (!enabled || !userGesture || typeof window === "undefined") return;
179
- try {
180
- const Ctor =
181
- window.AudioContext ||
182
- (window as unknown as { webkitAudioContext?: typeof AudioContext })
183
- .webkitAudioContext;
184
- if (!Ctor) return;
185
- if (!sharedAudioCtx) sharedAudioCtx = new Ctor();
186
- const ctx = sharedAudioCtx;
187
- if (ctx.state === "suspended") {
188
- void ctx.resume().catch(() => undefined);
189
- }
190
- const now = ctx.currentTime;
191
- const osc = ctx.createOscillator();
192
- const gain = ctx.createGain();
193
- const pitch = Math.max(0.5, Math.min(2, pitchScale));
194
-
195
- const freqMap: Record<ProceduralSfxPreset, [number, number, number]> = {
196
- "click-soft": [520 * pitch, 680 * pitch, 0.05],
197
- "toggle-pop": [360 * pitch, 720 * pitch, 0.08],
198
- "success-chime": [523 * pitch, 784 * pitch, 0.16],
199
- "hit-impact": [180 * pitch, 64 * pitch, 0.14],
200
- boing: [240 * pitch, 540 * pitch, 0.18],
201
- "cut-in-slash": [880 * pitch, 240 * pitch, 0.2],
202
- "level-up": [440 * pitch, 880 * pitch, 0.24],
203
- "gacha-sparkle": [660 * pitch, 1180 * pitch, 0.22],
204
- "gacha-fanfare": [523 * pitch, 1046 * pitch, 0.28],
205
- };
206
-
207
- const [startHz, endHz, dur] = freqMap[preset] ?? [440, 660, 0.1];
208
- osc.type = preset === "hit-impact" ? "sawtooth" : "triangle";
209
- osc.frequency.setValueAtTime(startHz, now);
210
- osc.frequency.exponentialRampToValueAtTime(Math.max(40, endHz), now + dur);
211
-
212
- gain.gain.setValueAtTime(0.08, now);
213
- gain.gain.exponentialRampToValueAtTime(0.001, now + dur);
214
-
215
- osc.connect(gain);
216
- gain.connect(ctx.destination);
217
- osc.start(now);
218
- osc.stop(now + dur);
219
- } catch {
220
- // Audio playback optional in restricted browser environments.
221
- }
222
- }
223
-
224
- type MotionContextValue = {
225
- profile: MotionProfile;
226
- sfxEnabled: boolean;
227
- };
228
-
229
- const MotionContext = createContext<MotionContextValue>({
230
- profile: "expressive",
231
- sfxEnabled: false,
232
- });
233
-
234
- export function useMotionContext() {
235
- return useContext(MotionContext);
236
- }
237
-
238
- export function MotionProvider({
239
- profile = "expressive",
240
- sfxEnabled = false,
241
- syncDocumentAttribute = false,
242
- children,
243
- }: {
244
- profile?: MotionProfile;
245
- sfxEnabled?: boolean;
246
- syncDocumentAttribute?: boolean;
247
- children: ReactNode;
248
- }) {
249
- useEffect(() => {
250
- if (!syncDocumentAttribute || typeof document === "undefined") return;
251
- document.documentElement.setAttribute("data-mw-motion", profile);
252
- }, [profile, syncDocumentAttribute]);
253
-
254
- return (
255
- <MotionContext.Provider value={{ profile, sfxEnabled }}>
256
- {children}
257
- </MotionContext.Provider>
258
- );
259
- }
260
-
261
- export function MotionStage({
262
- children,
263
- className = "",
264
- style,
265
- }: {
266
- children: ReactNode;
267
- className?: string;
268
- style?: CSSProperties;
269
- }) {
270
- const { profile } = useMotionContext();
271
- return (
272
- <div
273
- className={`mw-ui-motion-stage ${className}`.trim()}
274
- data-motion-profile={profile}
275
- style={{ position: "relative", ...style }}
276
- >
277
- {children}
278
- </div>
279
- );
280
- }
281
-
282
- export function ScrollReveal({
283
- children,
284
- className = "",
285
- }: {
286
- children: ReactNode;
287
- className?: string;
288
- }) {
289
- return (
290
- <div className={`mw-ui-scroll-reveal ${className}`.trim()}>{children}</div>
291
- );
292
- }
293
-
294
- export function KineticText({
295
- text,
296
- splitBy = "word",
297
- staggerMs = 45,
298
- className = "",
299
- }: {
300
- text: string;
301
- splitBy?: "word" | "char";
302
- staggerMs?: number;
303
- className?: string;
304
- }) {
305
- const { profile } = useMotionContext();
306
- const tokens = splitBy === "char" ? Array.from(text) : text.split(/(\s+)/u);
307
-
308
- return (
309
- <span
310
- className={`mw-ui-kinetic-text ${className}`.trim()}
311
- data-split={splitBy}
312
- style={{
313
- display: "inline-flex",
314
- flexWrap: "wrap",
315
- fontFamily: "var(--mw-font-display)",
316
- fontSize: "1.65rem",
317
- lineHeight: 1.1,
318
- letterSpacing: "0.02em",
319
- }}
320
- >
321
- {tokens.map((tok, i) => (
322
- <span
323
- key={`${i}-${tok}`}
324
- style={{
325
- display: "inline-block",
326
- whiteSpace: "pre",
327
- transition:
328
- profile === "off"
329
- ? "none"
330
- : `transform 260ms ease ${i * staggerMs}ms`,
331
- }}
332
- >
333
- {tok}
334
- </span>
335
- ))}
336
- </span>
337
- );
338
- }
339
-
340
- export function AnimatedNumber({
341
- value,
342
- locale = "en-US",
343
- className = "",
344
- }: {
345
- value: number;
346
- locale?: string;
347
- className?: string;
348
- }) {
349
- return (
350
- <span
351
- className={`mw-ui-animated-number ${className}`.trim()}
352
- style={{ fontVariantNumeric: "tabular-nums" }}
353
- >
354
- {new Intl.NumberFormat(locale).format(value)}
355
- </span>
356
- );
357
- }
358
-
359
- export type MotionTimelineProps = {
360
- title?: string;
361
- subtitle?: string;
362
- keyframes?: readonly MotionTimelineKeyframe[];
363
- durationMs?: number;
364
- defaultProgress?: number;
365
- defaultLoop?: boolean;
366
- showPreview?: boolean;
367
- showPresetLibrary?: boolean;
368
- onApplyEasingPreset?: (
369
- easing: MotionEasingName,
370
- scope: "all" | "segment",
371
- segmentIndex: number,
372
- ) => void;
373
- className?: string;
374
- };
375
-
376
- export function MotionTimeline({
377
- title = "Motion Timeline",
378
- subtitle,
379
- keyframes = DEFAULT_MOTION_TIMELINE_KEYFRAMES,
380
- durationMs = 1600,
381
- defaultProgress = 0.28,
382
- defaultLoop = true,
383
- showPreview = true,
384
- showPresetLibrary = false,
385
- onApplyEasingPreset,
386
- className = "",
387
- }: MotionTimelineProps) {
388
- const [progress, setProgress] = useState(defaultProgress);
389
- const [playing, setPlaying] = useState(false);
390
- const [selectedSegment, setSelectedSegment] = useState(0);
391
-
392
- useEffect(() => {
393
- if (!playing) return;
394
- let raf = 0;
395
- let last = performance.now();
396
- const tick = (now: number) => {
397
- const dt = (now - last) / Math.max(200, durationMs);
398
- last = now;
399
- setProgress((prev) => {
400
- const next = prev + dt;
401
- if (next >= 1) {
402
- if (defaultLoop) return next - 1;
403
- setPlaying(false);
404
- return 1;
405
- }
406
- return next;
407
- });
408
- raf = window.requestAnimationFrame(tick);
409
- };
410
- raf = window.requestAnimationFrame(tick);
411
- return () => window.cancelAnimationFrame(raf);
412
- }, [playing, durationMs, defaultLoop]);
413
-
414
- const currentVal = useMemo(() => {
415
- if (keyframes.length === 0) return progress;
416
- if (keyframes.length === 1) return keyframes[0].value;
417
- for (let i = 0; i < keyframes.length - 1; i++) {
418
- const a = keyframes[i];
419
- const b = keyframes[i + 1];
420
- if (progress >= a.at && progress <= b.at) {
421
- const span = Math.max(0.0001, b.at - a.at);
422
- const localT = (progress - a.at) / span;
423
- const eased = evaluateEasing(localT, b.easing ?? "ease-out");
424
- return a.value + (b.value - a.value) * eased;
425
- }
426
- }
427
- return keyframes[keyframes.length - 1].value;
428
- }, [keyframes, progress]);
429
-
430
- const polylinePoints = useMemo(() => {
431
- const pts: string[] = [];
432
- for (let i = 0; i <= 40; i++) {
433
- const p = i / 40;
434
- let val = p;
435
- for (let k = 0; k < keyframes.length - 1; k++) {
436
- const a = keyframes[k];
437
- const b = keyframes[k + 1];
438
- if (p >= a.at && p <= b.at) {
439
- const span = Math.max(0.0001, b.at - a.at);
440
- val =
441
- a.value +
442
- (b.value - a.value) *
443
- evaluateEasing((p - a.at) / span, b.easing ?? "ease-out");
444
- break;
445
- }
446
- }
447
- const x = 14 + p * 272;
448
- const y = 84 - Math.max(-0.15, Math.min(1.15, val)) * 68;
449
- pts.push(`${x.toFixed(1)},${y.toFixed(1)}`);
450
- }
451
- return pts.join(" ");
452
- }, [keyframes]);
453
-
454
- return (
455
- <section
456
- className={`mw-ui-motion-timeline ${className}`.trim()}
457
- style={{
458
- display: "grid",
459
- gap: "0.85rem",
460
- padding: "1rem",
461
- border: "2px solid var(--mw-border-strong)",
462
- background: "var(--mw-surface)",
463
- boxShadow: "var(--mw-shadow-ink)",
464
- }}
465
- >
466
- <header
467
- style={{
468
- display: "flex",
469
- flexWrap: "wrap",
470
- alignItems: "center",
471
- justifyContent: "space-between",
472
- gap: "0.5rem",
473
- }}
474
- >
475
- <div>
476
- <strong style={{ fontSize: "0.96rem" }}>{title}</strong>
477
- {subtitle ? (
478
- <p style={{ margin: "0.2rem 0 0", fontSize: "0.8rem", color: "var(--mw-muted-foreground)" }}>
479
- {subtitle}
480
- </p>
481
- ) : null}
482
- </div>
483
- <div style={{ display: "flex", alignItems: "center", gap: "0.45rem" }}>
484
- <Badge size="sm" variant="cyan">
485
- {Math.round(progress * durationMs)}ms / {durationMs}ms
486
- </Badge>
487
- <Button
488
- size="xs"
489
- variant={playing ? "magenta" : "default"}
490
- onClick={() => setPlaying((p) => !p)}
491
- >
492
- {playing ? "Pause" : "Play"}
493
- </Button>
494
- </div>
495
- </header>
496
-
497
- <svg
498
- viewBox="0 0 300 96"
499
- role="img"
500
- aria-label={`${title} curve`}
501
- style={{
502
- width: "100%",
503
- height: "6rem",
504
- background: "var(--mw-surface-muted)",
505
- border: "1px solid var(--mw-border)",
506
- }}
507
- >
508
- <polyline
509
- fill="none"
510
- stroke="var(--mw-primary)"
511
- strokeWidth="2.5"
512
- points={polylinePoints}
513
- />
514
- {keyframes.map((kf, idx) => (
515
- <circle
516
- key={kf.id}
517
- cx={14 + kf.at * 272}
518
- cy={84 - Math.max(-0.15, Math.min(1.15, kf.value)) * 68}
519
- r={idx === selectedSegment ? 5 : 3.5}
520
- fill={idx === selectedSegment ? "var(--mw-magenta)" : "var(--mw-cyan)"}
521
- stroke="var(--mw-ink)"
522
- strokeWidth="1.2"
523
- />
524
- ))}
525
- <line
526
- x1={14 + progress * 272}
527
- y1="6"
528
- x2={14 + progress * 272}
529
- y2="90"
530
- stroke="var(--mw-magenta)"
531
- strokeWidth="1.5"
532
- strokeDasharray="3 2"
533
- />
534
- </svg>
535
-
536
- <label style={{ display: "grid", gap: "0.25rem", fontSize: "0.78rem" }}>
537
- <span>
538
- Scrub timeline: {(progress * 100).toFixed(0)}% · val{" "}
539
- {currentVal.toFixed(2)}
540
- </span>
541
- <input
542
- type="range"
543
- min={0}
544
- max={1}
545
- step={0.01}
546
- value={progress}
547
- onChange={(e) => setProgress(Number(e.currentTarget.value))}
548
- aria-label="Timeline scrub position"
549
- />
550
- </label>
551
-
552
- {showPreview ? (
553
- <div
554
- style={{
555
- position: "relative",
556
- height: "2.4rem",
557
- border: "1px solid var(--mw-border)",
558
- background: "var(--mw-surface-muted)",
559
- overflow: "hidden",
560
- }}
561
- >
562
- <div
563
- style={{
564
- position: "absolute",
565
- top: "0.45rem",
566
- left: `calc(8px + ${Math.max(0, Math.min(1, currentVal)).toFixed(3)} * (100% - 42px))`,
567
- width: "1.5rem",
568
- height: "1.5rem",
569
- background: "var(--mw-magenta)",
570
- border: "2px solid var(--mw-ink)",
571
- }}
572
- />
573
- </div>
574
- ) : null}
575
-
576
- {showPresetLibrary && onApplyEasingPreset ? (
577
- <div style={{ display: "flex", flexWrap: "wrap", gap: "0.35rem" }}>
578
- {keyframes.map((kf, idx) => (
579
- <Button
580
- key={kf.id}
581
- size="xs"
582
- variant={selectedSegment === idx ? "default" : "outline"}
583
- onClick={() => setSelectedSegment(idx)}
584
- >
585
- {kf.label} ({kf.easing ?? "ease-out"})
586
- </Button>
587
- ))}
588
- {(["overshoot", "elastic", "bounce", "steps-12"] as const).map(
589
- (preset) => (
590
- <Button
591
- key={preset}
592
- size="xs"
593
- variant="ghost"
594
- onClick={() =>
595
- onApplyEasingPreset(preset, "segment", selectedSegment)
596
- }
597
- >
598
- Apply {preset}
599
- </Button>
600
- ),
601
- )}
602
- </div>
603
- ) : null}
604
- </section>
605
- );
606
- }
607
-
608
- export function ScreenFXOverlay({
609
- effect,
610
- active = false,
611
- }: {
612
- effect: ScreenFXKind;
613
- active?: boolean;
614
- }) {
615
- if (!active) return null;
616
- const bg =
617
- effect === "flash"
618
- ? "var(--mw-fx-flash)"
619
- : effect === "chromatic-pulse"
620
- ? "var(--mw-fx-chromatic-pulse)"
621
- : effect === "speedlines-burst"
622
- ? "var(--mw-fx-speedlines-burst)"
623
- : "var(--mw-fx-vignette)";
624
-
625
- return (
626
- <div
627
- aria-hidden="true"
628
- className="mw-ui-screen-fx-overlay"
629
- data-effect={effect}
630
- style={{
631
- position: "absolute",
632
- inset: 0,
633
- pointerEvents: "none",
634
- background: bg,
635
- zIndex: 8,
636
- }}
637
- />
638
- );
639
- }