motion-ui-skill 2.0.0 → 2.1.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 (166) hide show
  1. package/README.md +71 -21
  2. package/SKILL.md +83 -9
  3. package/bin/index.mjs +2 -2
  4. package/bin/installer.mjs +6 -0
  5. package/catalog.json +1044 -139
  6. package/components/agents/thinking-states.tsx +156 -0
  7. package/components/buttons/aqua-button.tsx +145 -0
  8. package/components/buttons/ash-burst-button.tsx +528 -0
  9. package/components/buttons/brutal-button.tsx +68 -0
  10. package/components/buttons/chrome-button.tsx +444 -0
  11. package/components/buttons/click-powerup.tsx +203 -0
  12. package/components/buttons/command-button.tsx +226 -0
  13. package/components/buttons/confetti-button.tsx +132 -0
  14. package/components/buttons/cooldown-button.tsx +169 -0
  15. package/components/buttons/demonic-button.tsx +470 -0
  16. package/components/buttons/dither-button.tsx +192 -0
  17. package/components/buttons/doubt-button.tsx +240 -0
  18. package/components/buttons/evil-eye-button.tsx +563 -0
  19. package/components/buttons/frame-button.tsx +211 -0
  20. package/components/buttons/glitch-button.tsx +243 -0
  21. package/components/buttons/highlight-button.tsx +196 -0
  22. package/components/buttons/hold-button.tsx +245 -0
  23. package/components/buttons/minecraft-button.tsx +651 -0
  24. package/components/buttons/minimal-button.tsx +50 -0
  25. package/components/buttons/morph-status-button.tsx +264 -0
  26. package/components/buttons/movie-pass-button.tsx +205 -0
  27. package/components/buttons/realistic-switch.tsx +298 -0
  28. package/components/buttons/reveal-button.tsx +197 -0
  29. package/components/buttons/shiny-button.tsx +87 -0
  30. package/components/buttons/slide-to-detonate.tsx +444 -0
  31. package/components/buttons/sticky-button.tsx +184 -0
  32. package/components/buttons/thruster-button.tsx +920 -0
  33. package/components/buttons/troll-button.tsx +264 -0
  34. package/components/motion/banner-stacking.tsx +124 -0
  35. package/components/motion/delete-with-smoky-dissolve.tsx +145 -0
  36. package/components/motion/donut-chart.tsx +112 -0
  37. package/components/motion/drag-drop-with-physics.tsx +116 -0
  38. package/components/motion/dropdown-menu-morph.tsx +157 -0
  39. package/components/motion/get-pro-button.tsx +54 -0
  40. package/components/motion/image-open-tilt.tsx +79 -0
  41. package/components/motion/input-clear-with-dissolve.tsx +111 -0
  42. package/components/motion/learn-more-hover.tsx +71 -0
  43. package/components/motion/matrix-dot-loader.tsx +68 -0
  44. package/components/motion/organic-shimmer.tsx +49 -0
  45. package/components/motion/pro-gradient-text.tsx +46 -0
  46. package/components/motion/skeleton-loader-and-reveal.tsx +81 -0
  47. package/components/motion/spinner-to-check-morph.tsx +99 -0
  48. package/components/motion/spinning-counter.tsx +64 -0
  49. package/components/motion/text-morph.tsx +80 -0
  50. package/components/motion/texts-reveal.tsx +49 -0
  51. package/data/app-interface.csv +33 -0
  52. package/data/charts.csv +26 -0
  53. package/data/colors.csv +193 -0
  54. package/data/google-fonts.csv +1935 -0
  55. package/data/icons.csv +106 -0
  56. package/data/landing.csv +35 -0
  57. package/data/motion.csv +18 -0
  58. package/data/products.csv +193 -0
  59. package/data/react-performance.csv +45 -0
  60. package/data/stacks/angular.csv +51 -0
  61. package/data/stacks/astro.csv +54 -0
  62. package/data/stacks/avalonia.csv +57 -0
  63. package/data/stacks/flutter.csv +53 -0
  64. package/data/stacks/html-tailwind.csv +60 -0
  65. package/data/stacks/javafx.csv +76 -0
  66. package/data/stacks/jetpack-compose.csv +53 -0
  67. package/data/stacks/laravel.csv +51 -0
  68. package/data/stacks/nextjs.csv +62 -0
  69. package/data/stacks/nuxt-ui.csv +77 -0
  70. package/data/stacks/nuxtjs.csv +68 -0
  71. package/data/stacks/react-native.csv +52 -0
  72. package/data/stacks/react.csv +67 -0
  73. package/data/stacks/shadcn.csv +69 -0
  74. package/data/stacks/svelte.csv +56 -0
  75. package/data/stacks/swiftui.csv +51 -0
  76. package/data/stacks/threejs.csv +54 -0
  77. package/data/stacks/uno.csv +60 -0
  78. package/data/stacks/uwp.csv +56 -0
  79. package/data/stacks/vue.csv +50 -0
  80. package/data/stacks/winui.csv +60 -0
  81. package/data/stacks/wpf.csv +57 -0
  82. package/data/styles.csv +89 -0
  83. package/data/typography.csv +75 -0
  84. package/data/ui-reasoning.csv +193 -0
  85. package/data/ux-guidelines.csv +120 -0
  86. package/evals/catalog_eval.py +56 -0
  87. package/icons/annotations/loop-arrow.tsx +61 -0
  88. package/icons/brands/anthropic.tsx +26 -0
  89. package/icons/brands/apple.tsx +26 -0
  90. package/icons/brands/canva.tsx +26 -0
  91. package/icons/brands/claude-ai.tsx +26 -0
  92. package/icons/brands/discord.tsx +26 -0
  93. package/icons/brands/github.tsx +26 -0
  94. package/icons/brands/gmail.tsx +26 -0
  95. package/icons/brands/google.tsx +26 -0
  96. package/icons/brands/linkedin.tsx +29 -0
  97. package/icons/brands/microsoft.tsx +26 -0
  98. package/icons/brands/next-js.tsx +26 -0
  99. package/icons/brands/producthunt.tsx +26 -0
  100. package/icons/brands/react-js.tsx +29 -0
  101. package/icons/brands/shadcn-ui.tsx +26 -0
  102. package/icons/brands/tailwind-css.tsx +26 -0
  103. package/icons/brands/twitter.tsx +30 -0
  104. package/icons/brands/typescript.tsx +26 -0
  105. package/icons/brands/unsplash.tsx +27 -0
  106. package/icons/brands/vercel.tsx +26 -0
  107. package/icons/brands/whatsapp.tsx +26 -0
  108. package/package.json +9 -3
  109. package/prompts/install-motion-ui.md +17 -0
  110. package/references/agents/thinking-states.md +56 -0
  111. package/references/craft/aqua-button.md +53 -0
  112. package/references/craft/ash-burst-button.md +55 -0
  113. package/references/craft/brutal-button.md +52 -0
  114. package/references/craft/chrome-button.md +53 -0
  115. package/references/craft/click-powerup.md +53 -0
  116. package/references/craft/command-button.md +53 -0
  117. package/references/craft/confetti-button.md +54 -0
  118. package/references/craft/cooldown-button.md +54 -0
  119. package/references/craft/demonic-button.md +53 -0
  120. package/references/craft/dither-button.md +52 -0
  121. package/references/craft/doubt-button.md +53 -0
  122. package/references/craft/evil-eye-button.md +52 -0
  123. package/references/craft/frame-button.md +54 -0
  124. package/references/craft/glitch-button.md +52 -0
  125. package/references/craft/highlight-button.md +53 -0
  126. package/references/craft/hold-button.md +53 -0
  127. package/references/craft/minecraft-button.md +53 -0
  128. package/references/craft/minimal-button.md +52 -0
  129. package/references/craft/morph-status-button.md +53 -0
  130. package/references/craft/movie-pass-button.md +53 -0
  131. package/references/craft/realistic-switch.md +54 -0
  132. package/references/craft/reveal-button.md +53 -0
  133. package/references/craft/shiny-button.md +52 -0
  134. package/references/craft/slide-to-detonate.md +53 -0
  135. package/references/craft/sticky-button.md +54 -0
  136. package/references/craft/thruster-button.md +53 -0
  137. package/references/craft/troll-button.md +54 -0
  138. package/references/guides/design-intelligence.md +125 -0
  139. package/references/guides/interaction-transitions.md +56 -38
  140. package/references/guides/motion-polish-rules.md +75 -0
  141. package/references/guides/stack-best-practices.md +38 -0
  142. package/references/motion/banner-stacking.md +67 -0
  143. package/references/motion/delete-with-smoky-dissolve.md +60 -0
  144. package/references/motion/donut-chart.md +79 -0
  145. package/references/motion/drag-drop-with-physics.md +61 -0
  146. package/references/motion/dropdown-menu-morph.md +55 -0
  147. package/references/motion/get-pro-button.md +56 -0
  148. package/references/motion/image-open-tilt.md +60 -0
  149. package/references/motion/input-clear-with-dissolve.md +58 -0
  150. package/references/motion/learn-more-hover.md +56 -0
  151. package/references/motion/matrix-dot-loader.md +58 -0
  152. package/references/motion/organic-shimmer.md +63 -0
  153. package/references/motion/pro-gradient-text.md +57 -0
  154. package/references/motion/skeleton-loader-and-reveal.md +67 -0
  155. package/references/motion/spinner-to-check-morph.md +67 -0
  156. package/references/motion/spinning-counter.md +74 -0
  157. package/references/motion/text-morph.md +64 -0
  158. package/references/motion/texts-reveal.md +56 -0
  159. package/scripts/build_docs.py +39 -4
  160. package/scripts/core.py +993 -0
  161. package/scripts/design_system.py +1668 -0
  162. package/scripts/reasoning_contract.py +123 -0
  163. package/scripts/search.py +177 -0
  164. package/scripts/test_release.py +12 -0
  165. package/scripts/verify_skill.py +4 -4
  166. package/test/test_installer.mjs +133 -0
@@ -0,0 +1,264 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import {
5
+ AnimatePresence,
6
+ animate,
7
+ motion,
8
+ useMotionValue,
9
+ useReducedMotion,
10
+ useSpring,
11
+ useTransform,
12
+ useVelocity,
13
+ type AnimationPlaybackControls,
14
+ } from "motion/react";
15
+ import { cn } from "@/lib/utils";
16
+
17
+ export interface TrollButtonProps
18
+ extends Omit<
19
+ React.ButtonHTMLAttributes<HTMLButtonElement>,
20
+ "onDrag" | "onDragStart" | "onDragEnd" | "onAnimationStart"
21
+ > {
22
+ /** Label used when no children are provided. */
23
+ label?: React.ReactNode;
24
+ /** Label shown once the button gives up and lets itself be clicked. */
25
+ surrenderLabel?: React.ReactNode;
26
+ /** Milliseconds of chasing before the button gets tired and gives up. */
27
+ giveUpAfter?: number;
28
+ /** How close in px the cursor can get to the button's edge before it dodges. */
29
+ fleeRadius?: number;
30
+ /** Maximum distance in px the button strays from its resting spot. */
31
+ range?: number;
32
+ /** Milliseconds after a successful click before the button starts fleeing again. Set to 0 to stay caught. */
33
+ resetAfter?: number;
34
+ }
35
+
36
+ type TrollState = "fleeing" | "tired";
37
+
38
+ const DODGE_SPRING = { stiffness: 520, damping: 30, mass: 0.6 };
39
+
40
+ const labelVariants = {
41
+ enter: { y: 8, opacity: 0 },
42
+ center: { y: 0, opacity: 1 },
43
+ exit: { y: -8, opacity: 0 },
44
+ };
45
+
46
+ const TrollButton = React.forwardRef<HTMLButtonElement, TrollButtonProps>(
47
+ (
48
+ {
49
+ children,
50
+ label = "Click Me",
51
+ surrenderLabel = "Fine, click me",
52
+ giveUpAfter = 3500,
53
+ fleeRadius = 56,
54
+ range = 140,
55
+ resetAfter = 1500,
56
+ onClick,
57
+ onPointerDown,
58
+ className,
59
+ disabled,
60
+ type = "button",
61
+ ...props
62
+ },
63
+ ref,
64
+ ) => {
65
+ const wrapperRef = React.useRef<HTMLSpanElement>(null);
66
+ const offsetRef = React.useRef({ x: 0, y: 0 });
67
+ const staminaRef = React.useRef<AnimationPlaybackControls | null>(null);
68
+ const resetTimerRef = React.useRef<number | undefined>(undefined);
69
+ const [state, setState] = React.useState<TrollState>("fleeing");
70
+ const reduceMotion = useReducedMotion();
71
+ const evasive = state === "fleeing" && !reduceMotion && !disabled;
72
+
73
+ const targetX = useMotionValue(0);
74
+ const targetY = useMotionValue(0);
75
+ const x = useSpring(targetX, DODGE_SPRING);
76
+ const y = useSpring(targetY, DODGE_SPRING);
77
+ // Lean into each dodge based on how fast the button is moving sideways.
78
+ const velocityX = useVelocity(x);
79
+ const rotate = useTransform(velocityX, [-2400, 0, 2400], [-10, 0, 10]);
80
+ const stamina = useMotionValue(1);
81
+ const staminaOpacity = useTransform(stamina, (value) => (value < 1 ? 1 : 0));
82
+
83
+ const moveTo = React.useCallback(
84
+ (nextX: number, nextY: number) => {
85
+ offsetRef.current = { x: nextX, y: nextY };
86
+ targetX.set(nextX);
87
+ targetY.set(nextY);
88
+ },
89
+ [targetX, targetY],
90
+ );
91
+
92
+ const startTiring = React.useCallback(() => {
93
+ if (staminaRef.current) return;
94
+ staminaRef.current = animate(stamina, 0, {
95
+ duration: giveUpAfter / 1000,
96
+ ease: "linear",
97
+ onComplete: () => {
98
+ moveTo(0, 0);
99
+ setState("tired");
100
+ },
101
+ });
102
+ }, [giveUpAfter, moveTo, stamina]);
103
+
104
+ const dodge = React.useCallback(
105
+ (pointerX: number, pointerY: number, force = false) => {
106
+ const wrapper = wrapperRef.current;
107
+ if (!wrapper) return;
108
+
109
+ // Measure from the resting slot, then add the current offset to find the button.
110
+ const rest = wrapper.getBoundingClientRect();
111
+ const { x: offsetX, y: offsetY } = offsetRef.current;
112
+ const centerX = rest.left + rest.width / 2 + offsetX;
113
+ const centerY = rest.top + rest.height / 2 + offsetY;
114
+ const dx = centerX - pointerX;
115
+ const dy = centerY - pointerY;
116
+ const outsideX = Math.max(Math.abs(dx) - rest.width / 2, 0);
117
+ const outsideY = Math.max(Math.abs(dy) - rest.height / 2, 0);
118
+ const gap = Math.hypot(outsideX, outsideY);
119
+
120
+ if (!force && gap >= fleeRadius) return;
121
+
122
+ const length = Math.hypot(dx, dy) || 1;
123
+ const push = fleeRadius - gap + 24;
124
+ let nextX = offsetX + (dx / length) * push;
125
+ let nextY = offsetY + (dy / length) * push;
126
+ const rangeY = range * 0.6;
127
+
128
+ // Cornered: slip past the cursor to the opposite side of the slot.
129
+ if (Math.abs(nextX) > range || Math.abs(nextY) > rangeY) {
130
+ nextX = -Math.sign(offsetX || dx || 1) * range * 0.7;
131
+ nextY = -offsetY * 0.5;
132
+ }
133
+
134
+ moveTo(nextX, nextY);
135
+ startTiring();
136
+ },
137
+ [fleeRadius, moveTo, range, startTiring],
138
+ );
139
+
140
+ React.useEffect(() => {
141
+ if (!evasive) return;
142
+
143
+ const onPointerMove = (event: PointerEvent) => {
144
+ if (event.pointerType === "touch") return;
145
+ dodge(event.clientX, event.clientY);
146
+ };
147
+
148
+ window.addEventListener("pointermove", onPointerMove, { passive: true });
149
+ return () => window.removeEventListener("pointermove", onPointerMove);
150
+ }, [dodge, evasive]);
151
+
152
+ React.useEffect(
153
+ () => () => {
154
+ staminaRef.current?.stop();
155
+ window.clearTimeout(resetTimerRef.current);
156
+ },
157
+ [],
158
+ );
159
+
160
+ const handlePointerDown = (event: React.PointerEvent<HTMLButtonElement>) => {
161
+ onPointerDown?.(event);
162
+ // Touch has no hover to flee from, so tapping triggers a dodge instead.
163
+ if (evasive && event.pointerType === "touch") {
164
+ dodge(event.clientX, event.clientY, true);
165
+ }
166
+ };
167
+
168
+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
169
+ // Keyboard activation (detail 0) always goes through.
170
+ if (evasive && event.detail !== 0) {
171
+ event.preventDefault();
172
+ return;
173
+ }
174
+ onClick?.(event);
175
+
176
+ if (state === "tired" && resetAfter > 0) {
177
+ window.clearTimeout(resetTimerRef.current);
178
+ resetTimerRef.current = window.setTimeout(() => {
179
+ staminaRef.current = null;
180
+ stamina.set(1);
181
+ setState("fleeing");
182
+ }, resetAfter);
183
+ }
184
+ };
185
+
186
+ const idleLabel = children ?? label;
187
+ const currentLabel = state === "tired" ? surrenderLabel : idleLabel;
188
+
189
+ return (
190
+ <span ref={wrapperRef} className="relative inline-flex">
191
+ <motion.button
192
+ ref={ref}
193
+ type={type}
194
+ disabled={disabled}
195
+ style={{ x, y, rotate }}
196
+ onPointerDown={handlePointerDown}
197
+ onClick={handleClick}
198
+ animate={
199
+ state === "tired" && !reduceMotion
200
+ ? { scaleY: [1, 0.92, 1.03, 1], scaleX: [1, 1.05, 0.98, 1] }
201
+ : undefined
202
+ }
203
+ transition={{ duration: 0.45, ease: "easeOut" }}
204
+ className={cn(
205
+ "relative inline-flex h-9 cursor-pointer items-center justify-center overflow-hidden rounded-[10px] px-4 text-sm font-medium text-neutral-50 outline-none select-none",
206
+ // Graded dark surface: dark outer hairline, faint inner ring, top highlight, soft drop.
207
+ "bg-linear-to-b from-[#353535] to-[#272727] shadow-[0_0_0_1px_rgb(0_0_0/0.9),inset_0_0_0_1px_rgb(255_255_255/0.06),inset_0_1px_0_rgb(255_255_255/0.14),0_1px_2px_rgb(0_0_0/0.25),0_4px_12px_-4px_rgb(0_0_0/0.4)]",
208
+ // Motion owns `transform` for the dodge, lean, and squash, so the press animates the separate `scale` property.
209
+ "transition-[scale,filter,box-shadow] duration-300 ease-[cubic-bezier(0.34,1.35,0.64,1)] hover:brightness-110",
210
+ // Press eases in fast and settles the shadow; release springs back on the slower base curve.
211
+ "active:scale-[0.97] active:brightness-95 active:duration-100 active:ease-out active:shadow-[0_0_0_1px_rgb(0_0_0/0.9),inset_0_0_0_1px_rgb(255_255_255/0.05),inset_0_1px_0_rgb(255_255_255/0.08),0_0_1px_rgb(0_0_0/0.2),0_1px_3px_-2px_rgb(0_0_0/0.3)] motion-reduce:active:scale-100",
212
+ "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
213
+ className,
214
+ )}
215
+ {...props}
216
+ >
217
+ <span className="relative inline-grid">
218
+ {/* Invisible copies reserve the wider label so the button never resizes. */}
219
+ <span
220
+ aria-hidden
221
+ className="invisible col-start-1 row-start-1 whitespace-nowrap"
222
+ >
223
+ {idleLabel}
224
+ </span>
225
+ <span
226
+ aria-hidden
227
+ className="invisible col-start-1 row-start-1 whitespace-nowrap"
228
+ >
229
+ {surrenderLabel}
230
+ </span>
231
+ <AnimatePresence initial={false} mode="popLayout">
232
+ <motion.span
233
+ key={state}
234
+ variants={labelVariants}
235
+ initial="enter"
236
+ animate="center"
237
+ exit="exit"
238
+ transition={{ type: "spring", stiffness: 420, damping: 30 }}
239
+ className="col-start-1 row-start-1 whitespace-nowrap text-center"
240
+ >
241
+ {currentLabel}
242
+ </motion.span>
243
+ </AnimatePresence>
244
+ </span>
245
+
246
+ {/* Stamina drains while the button is being chased. */}
247
+ <motion.span
248
+ aria-hidden
249
+ className="pointer-events-none absolute inset-x-0 bottom-0 h-0.5 origin-left bg-neutral-50/35"
250
+ style={{
251
+ scaleX: stamina,
252
+ opacity: state === "fleeing" ? staminaOpacity : 0,
253
+ }}
254
+ />
255
+ </motion.button>
256
+ </span>
257
+ );
258
+ },
259
+ );
260
+
261
+ TrollButton.displayName = "TrollButton";
262
+
263
+ export { TrollButton };
264
+ export default TrollButton;
@@ -0,0 +1,124 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { useState } from "react";
5
+ import { AnimatePresence, motion } from "motion/react";
6
+ import { cn } from "@/lib/utils";
7
+ import { SPRING_PANEL, SPRING_SWAP } from "@/lib/ease";
8
+
9
+ export interface BannerItem {
10
+ id: string;
11
+ title: string;
12
+ description?: string;
13
+ timestamp?: string;
14
+ variant?: "default" | "success" | "warning" | "info";
15
+ }
16
+
17
+ export interface BannerStackingProps {
18
+ banners: BannerItem[];
19
+ onDismiss?: (id: string) => void;
20
+ maxVisible?: number;
21
+ className?: string;
22
+ }
23
+
24
+ export function BannerStacking({
25
+ banners,
26
+ onDismiss,
27
+ maxVisible = 3,
28
+ className,
29
+ }: BannerStackingProps) {
30
+ const [isHovered, setIsHovered] = useState(false);
31
+
32
+ const visibleBanners = banners.slice(0, maxVisible);
33
+
34
+ return (
35
+ <div
36
+ className={cn("relative w-full max-w-md mx-auto select-none", className)}
37
+ onMouseEnter={() => setIsHovered(true)}
38
+ onMouseLeave={() => setIsHovered(false)}
39
+ >
40
+ <div className={cn("relative min-h-[80px]", isHovered ? "space-y-2" : "")}>
41
+ <AnimatePresence mode="popLayout" initial={false}>
42
+ {visibleBanners.map((banner, index) => {
43
+ const isTop = index === 0;
44
+ const offset = isHovered ? 0 : index * 10;
45
+ const scale = isHovered ? 1 : 1 - index * 0.05;
46
+ const opacity = isHovered ? 1 : 1 - index * 0.2;
47
+ const zIndex = visibleBanners.length - index;
48
+
49
+ return (
50
+ <motion.div
51
+ key={banner.id}
52
+ layout
53
+ initial={{ opacity: 0, y: -20, scale: 0.9 }}
54
+ animate={{
55
+ opacity,
56
+ y: isHovered ? index * 68 : offset,
57
+ scale,
58
+ zIndex,
59
+ }}
60
+ exit={{ opacity: 0, scale: 0.85, y: -10 }}
61
+ transition={SPRING_PANEL}
62
+ className={cn(
63
+ "rounded-2xl border border-neutral-200 dark:border-neutral-800 bg-white/95 dark:bg-neutral-900/95 backdrop-blur-md p-4 shadow-xl transition-colors",
64
+ isHovered ? "relative" : "absolute top-0 left-0 right-0",
65
+ banner.variant === "success" && "border-emerald-500/30",
66
+ banner.variant === "warning" && "border-amber-500/30",
67
+ banner.variant === "info" && "border-sky-500/30"
68
+ )}
69
+ style={{
70
+ transformOrigin: "top center",
71
+ }}
72
+ >
73
+ <div className="flex items-start justify-between gap-3">
74
+ <div className="space-y-1 pr-2">
75
+ <div className="flex items-center gap-2">
76
+ <span className="text-sm font-semibold text-neutral-900 dark:text-neutral-100">
77
+ {banner.title}
78
+ </span>
79
+ {banner.timestamp && (
80
+ <span className="text-xs text-neutral-400">
81
+ {banner.timestamp}
82
+ </span>
83
+ )}
84
+ </div>
85
+ {banner.description && (
86
+ <p className="text-xs text-neutral-500 dark:text-neutral-400 leading-relaxed">
87
+ {banner.description}
88
+ </p>
89
+ )}
90
+ </div>
91
+ {onDismiss && (
92
+ <button
93
+ type="button"
94
+ onClick={(e) => {
95
+ e.stopPropagation();
96
+ onDismiss(banner.id);
97
+ }}
98
+ className="rounded-full p-1 text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors"
99
+ aria-label="Dismiss banner"
100
+ >
101
+ <svg
102
+ className="size-3.5"
103
+ fill="none"
104
+ viewBox="0 0 24 24"
105
+ stroke="currentColor"
106
+ strokeWidth={2}
107
+ >
108
+ <path
109
+ strokeLinecap="round"
110
+ strokeLinejoin="round"
111
+ d="M6 18L18 6M6 6l12 12"
112
+ />
113
+ </svg>
114
+ </button>
115
+ )}
116
+ </div>
117
+ </motion.div>
118
+ );
119
+ })}
120
+ </AnimatePresence>
121
+ </div>
122
+ </div>
123
+ );
124
+ }
@@ -0,0 +1,145 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { useState, useRef } from "react";
5
+ import { motion, AnimatePresence } from "motion/react";
6
+ import { cn } from "@/lib/utils";
7
+ import { SPRING_PRESS, SPRING_PANEL } from "@/lib/ease";
8
+
9
+ export interface DeleteWithSmokyDissolveProps {
10
+ label?: string;
11
+ itemTitle?: string;
12
+ onDelete?: () => void;
13
+ className?: string;
14
+ }
15
+
16
+ interface SmokeParticle {
17
+ id: number;
18
+ x: number;
19
+ y: number;
20
+ vx: number;
21
+ vy: number;
22
+ size: number;
23
+ opacity: number;
24
+ rotation: number;
25
+ color: string;
26
+ }
27
+
28
+ export function DeleteWithSmokyDissolve({
29
+ label = "Delete Item",
30
+ itemTitle = "Project Invoice #1042",
31
+ onDelete,
32
+ className,
33
+ }: DeleteWithSmokyDissolveProps) {
34
+ const [isDeleting, setIsDeleting] = useState(false);
35
+ const [particles, setParticles] = useState<SmokeParticle[]>([]);
36
+ const containerRef = useRef<HTMLDivElement>(null);
37
+
38
+ const handleDelete = () => {
39
+ if (isDeleting) return;
40
+ setIsDeleting(true);
41
+
42
+ const colors = ["#404040", "#525252", "#737373", "#a3a3a3", "#f97316", "#ef4444"];
43
+ const newParticles: SmokeParticle[] = [];
44
+
45
+ for (let i = 0; i < 32; i++) {
46
+ newParticles.push({
47
+ id: i,
48
+ x: Math.random() * 260 - 130,
49
+ y: Math.random() * -60 - 20,
50
+ vx: (Math.random() - 0.5) * 80,
51
+ vy: -Math.random() * 70 - 30,
52
+ size: Math.random() * 16 + 6,
53
+ opacity: Math.random() * 0.7 + 0.3,
54
+ rotation: Math.random() * 360,
55
+ color: colors[Math.floor(Math.random() * colors.length)],
56
+ });
57
+ }
58
+
59
+ setParticles(newParticles);
60
+
61
+ setTimeout(() => {
62
+ onDelete?.();
63
+ }, 700);
64
+ };
65
+
66
+ return (
67
+ <div
68
+ ref={containerRef}
69
+ className={cn("relative inline-flex flex-col items-center", className)}
70
+ >
71
+ <AnimatePresence mode="wait">
72
+ {!isDeleting ? (
73
+ <motion.div
74
+ initial={{ opacity: 1, scale: 1 }}
75
+ exit={{
76
+ opacity: 0,
77
+ filter: "blur(8px)",
78
+ scale: 0.95,
79
+ transition: { duration: 0.35 },
80
+ }}
81
+ className="flex items-center justify-between gap-4 w-72 px-4 py-3 rounded-xl border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-neutral-900 shadow-sm"
82
+ >
83
+ <div className="flex flex-col min-w-0">
84
+ <span className="text-xs font-medium text-neutral-400">Document</span>
85
+ <span className="text-sm font-semibold text-neutral-900 dark:text-neutral-100 truncate">
86
+ {itemTitle}
87
+ </span>
88
+ </div>
89
+ <motion.button
90
+ type="button"
91
+ whileTap={{ scale: 0.94 }}
92
+ transition={SPRING_PRESS}
93
+ onClick={handleDelete}
94
+ className="px-3 py-1.5 text-xs font-semibold text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 bg-red-50 hover:bg-red-100 dark:bg-red-950/40 dark:hover:bg-red-900/40 rounded-lg transition-colors border border-red-200 dark:border-red-900/50"
95
+ >
96
+ {label}
97
+ </motion.button>
98
+ </motion.div>
99
+ ) : (
100
+ <div className="relative w-72 h-14 flex items-center justify-center pointer-events-none">
101
+ {particles.map((p) => (
102
+ <motion.div
103
+ key={p.id}
104
+ initial={{
105
+ x: 0,
106
+ y: 0,
107
+ scale: 1,
108
+ opacity: p.opacity,
109
+ rotate: 0,
110
+ }}
111
+ animate={{
112
+ x: p.x + p.vx,
113
+ y: p.y + p.vy,
114
+ scale: 0,
115
+ opacity: 0,
116
+ rotate: p.rotation,
117
+ filter: "blur(4px)",
118
+ }}
119
+ transition={{
120
+ duration: 0.7,
121
+ ease: [0.16, 1, 0.3, 1],
122
+ }}
123
+ style={{
124
+ position: "absolute",
125
+ width: p.size,
126
+ height: p.size,
127
+ backgroundColor: p.color,
128
+ borderRadius: p.size > 12 ? "50%" : "30%",
129
+ }}
130
+ />
131
+ ))}
132
+ <motion.span
133
+ initial={{ opacity: 0, scale: 0.8 }}
134
+ animate={{ opacity: [0, 1, 0], scale: 1 }}
135
+ transition={{ duration: 0.6 }}
136
+ className="text-xs font-medium text-neutral-400"
137
+ >
138
+ Dissolved
139
+ </motion.span>
140
+ </div>
141
+ )}
142
+ </AnimatePresence>
143
+ </div>
144
+ );
145
+ }
@@ -0,0 +1,112 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { motion } from "motion/react";
5
+ import { cn } from "@/lib/utils";
6
+ import { SPRING_PANEL } from "@/lib/ease";
7
+
8
+ export interface DonutSegment {
9
+ id: string;
10
+ label: string;
11
+ value: number;
12
+ color: string;
13
+ }
14
+
15
+ export interface DonutChartProps {
16
+ data?: DonutSegment[];
17
+ size?: number;
18
+ thickness?: number;
19
+ centerLabel?: string;
20
+ centerValue?: string;
21
+ className?: string;
22
+ }
23
+
24
+ const DEFAULT_SEGMENTS: DonutSegment[] = [
25
+ { id: "direct", label: "Direct", value: 45, color: "#6366f1" },
26
+ { id: "organic", label: "Organic", value: 30, color: "#10b981" },
27
+ { id: "referral", label: "Referral", value: 15, color: "#f59e0b" },
28
+ { id: "social", label: "Social", value: 10, color: "#ec4899" },
29
+ ];
30
+
31
+ export function DonutChart({
32
+ data = DEFAULT_SEGMENTS,
33
+ size = 180,
34
+ thickness = 18,
35
+ centerLabel = "Total",
36
+ centerValue = "100%",
37
+ className,
38
+ }: DonutChartProps) {
39
+ const total = data.reduce((acc, curr) => acc + curr.value, 0) || 1;
40
+ const radius = (size - thickness) / 2;
41
+ const circumference = 2 * Math.PI * radius;
42
+
43
+ let accumulatedPercent = 0;
44
+
45
+ return (
46
+ <div
47
+ className={cn(
48
+ "relative inline-flex flex-col items-center justify-center select-none",
49
+ className
50
+ )}
51
+ >
52
+ <div
53
+ className="relative flex items-center justify-center"
54
+ style={{ width: size, height: size }}
55
+ >
56
+ <svg
57
+ width={size}
58
+ height={size}
59
+ viewBox={`0 0 ${size} ${size}`}
60
+ className="overflow-visible -rotate-90"
61
+ >
62
+ {data.map((item) => {
63
+ const percent = item.value / total;
64
+ const strokeDasharray = `${circumference * percent} ${circumference * (1 - percent)}`;
65
+ const strokeDashoffset = -circumference * accumulatedPercent;
66
+ accumulatedPercent += percent;
67
+
68
+ return (
69
+ <motion.circle
70
+ key={item.id}
71
+ cx={size / 2}
72
+ cy={size / 2}
73
+ r={radius}
74
+ fill="none"
75
+ stroke={item.color}
76
+ strokeWidth={thickness}
77
+ strokeDasharray={strokeDasharray}
78
+ strokeDashoffset={strokeDashoffset}
79
+ strokeLinecap="round"
80
+ initial={{ opacity: 0 }}
81
+ animate={{ opacity: 1 }}
82
+ transition={SPRING_PANEL}
83
+ className="hover:opacity-80 transition-opacity cursor-pointer"
84
+ />
85
+ );
86
+ })}
87
+ </svg>
88
+
89
+ <div className="absolute inset-0 flex flex-col items-center justify-center text-center pointer-events-none">
90
+ <span className="text-xl font-bold tracking-tight text-neutral-900 dark:text-neutral-100 tabular-nums">
91
+ {centerValue}
92
+ </span>
93
+ <span className="text-xs font-medium text-neutral-500 uppercase tracking-wider">
94
+ {centerLabel}
95
+ </span>
96
+ </div>
97
+ </div>
98
+
99
+ <div className="flex flex-wrap items-center justify-center gap-4 mt-4">
100
+ {data.map((item) => (
101
+ <div key={item.id} className="flex items-center gap-1.5 text-xs text-neutral-600 dark:text-neutral-300">
102
+ <span
103
+ className="size-2 rounded-full shrink-0"
104
+ style={{ backgroundColor: item.color }}
105
+ />
106
+ <span>{item.label}</span>
107
+ </div>
108
+ ))}
109
+ </div>
110
+ </div>
111
+ );
112
+ }