@ericrisco/rsc 1.0.27 → 1.0.28

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 (44) hide show
  1. package/README.md +22 -4
  2. package/manifest.json +230 -2
  3. package/package.json +1 -1
  4. package/scripts/detect-repo.js +27 -1
  5. package/scripts/lib/domains.js +3 -2
  6. package/skills/animate/SKILL.md +228 -0
  7. package/skills/animate/evals/cases.yaml +36 -0
  8. package/skills/animate/references/recipes.md +324 -0
  9. package/skills/animate-expo/SKILL.md +281 -0
  10. package/skills/animate-expo/evals/cases.yaml +36 -0
  11. package/skills/animate-expo/references/recipes.md +385 -0
  12. package/skills/animation-vocabulary/SKILL.md +189 -0
  13. package/skills/animation-vocabulary/evals/cases.yaml +31 -0
  14. package/skills/apple-design/SKILL.md +301 -0
  15. package/skills/apple-design/evals/cases.yaml +33 -0
  16. package/skills/ask-sonner/SKILL.md +104 -0
  17. package/skills/ask-sonner/evals/cases.yaml +33 -0
  18. package/skills/ask-sonner/references/api.md +64 -0
  19. package/skills/design/SKILL.md +8 -0
  20. package/skills/design/references/motion-and-interaction.md +14 -3
  21. package/skills/design/references/visual-system.md +4 -3
  22. package/skills/design-eng/SKILL.md +724 -0
  23. package/skills/design-eng/evals/cases.yaml +36 -0
  24. package/skills/expo/SKILL.md +6 -0
  25. package/skills/find-animation-opportunities/SKILL.md +150 -0
  26. package/skills/find-animation-opportunities/evals/cases.yaml +31 -0
  27. package/skills/improve-animations/SKILL.md +126 -0
  28. package/skills/improve-animations/evals/cases.yaml +31 -0
  29. package/skills/improve-animations/references/audit.md +115 -0
  30. package/skills/improve-animations/references/plan-template.md +73 -0
  31. package/skills/pick-ui-library/SKILL.md +100 -0
  32. package/skills/pick-ui-library/evals/cases.yaml +33 -0
  33. package/skills/prototype/SKILL.md +113 -0
  34. package/skills/prototype/evals/cases.yaml +31 -0
  35. package/skills/prototype/references/picker.md +197 -0
  36. package/skills/react/SKILL.md +6 -0
  37. package/skills/react-native/SKILL.md +5 -0
  38. package/skills/review-animations/SKILL.md +137 -0
  39. package/skills/review-animations/evals/cases.yaml +34 -0
  40. package/skills/review-animations/references/standards.md +187 -0
  41. package/skills/review-animations/scripts/verify.sh +164 -0
  42. package/skills/swift-ios/SKILL.md +7 -0
  43. package/skills/write-swift/SKILL.md +413 -0
  44. package/skills/write-swift/evals/cases.yaml +36 -0
@@ -0,0 +1,724 @@
1
+ ---
2
+ name: design-eng
3
+ description: "Umbrella for frontend craft: routes a UI request to the sibling that owns it — build motion, review it, audit it, find where it is missing, name an effect, gesture physics, prototype variants, pick a library. Use when an app works but feels cheap or unpolished, or when a frontend request could belong to several of them."
4
+ tags: [design, frontend, ui, routing, craft]
5
+ recommends: [animate, review-animations, apple-design, design]
6
+ profiles: [core, full]
7
+ origin: emilkowalski (MIT, adapted)
8
+ ---
9
+
10
+ # Design Engineering — the frontend craft umbrella
11
+
12
+ *Two jobs: route the request to the sibling that owns it, and carry the philosophy the siblings assume.*
13
+
14
+ > **SDD gate.** This skill routes; it does not outrank the chain. If the request is a **new,
15
+ > non-trivial feature or behaviour change** and there is no approved spec + plan under
16
+ > `02-DOCS/wiki/sdd/`, hand off to `../specify/SKILL.md` first — it runs brainstorm → spec → plan
17
+ > → tasks before any code, then routes back here. Route straight through only for a genuinely
18
+ > one-line / low-risk change, or a bug fix restoring intended behaviour. Method: `../sdd/SKILL.md`.
19
+
20
+ ## Route first
21
+
22
+ Installed in every repo with a frontend, so it fires on requests that could belong to several
23
+ siblings. Name the sibling, hand over, and stop — do not do their work here.
24
+
25
+ | The request is… | Route to | Not to |
26
+ | --- | --- | --- |
27
+ | "animate this", "make it feel alive", build a transition | `../animate/SKILL.md` | not `design`, which sets intent and budget, not the implementation |
28
+ | the same, but React Native / Expo | `../animate-expo/SKILL.md` | not `animate` — no hover, two runtimes, gestures are the baseline |
29
+ | "review the motion in this diff / component" | `../review-animations/SKILL.md` | not `code-review`, which does not know the motion bar |
30
+ | "audit the animations across the app", "give me a roadmap" | `../improve-animations/SKILL.md` | not `review-animations`, whose object is one diff |
31
+ | "what could be animated here?", "make this feel more alive" | `../find-animation-opportunities/SKILL.md` | not `animate` — nothing has been chosen yet |
32
+ | "what's it called when…", naming an effect to prompt with | `../animation-vocabulary/SKILL.md` | — |
33
+ | gesture physics, springs, momentum, translucent materials, Apple-grade feel | `../apple-design/SKILL.md` | not `animate`, which owns curves and durations, not physics |
34
+ | "show me a few versions of this and let me pick" | `../prototype/SKILL.md` | — |
35
+ | "what should I use for toasts / drag and drop / a command menu?" | `../pick-ui-library/SKILL.md` | not hand-rolling the component |
36
+ | Sonner specifically — setup, styling, toasts misbehaving | `../ask-sonner/SKILL.md` | — |
37
+ | visual system, brand grounding, landing composition, a whole page | `../design/SKILL.md` | not here — this skill owns craft and motion, not the visual system |
38
+ | the App Router / React build itself | `../nextjs/SKILL.md` | — |
39
+ | Swift language work (concurrency, generics) | `../write-swift/SKILL.md` | not `swift-ios`, which owns the platform |
40
+
41
+ Three rules for routing:
42
+
43
+ 1. **Ambiguity resolves to the narrower object.** "Improve the animations" on a diff is
44
+ `review-animations`; on a whole codebase it is `improve-animations`. Say which you chose and
45
+ which you passed over — never run both.
46
+ 2. **When nothing fits, say so.** A tangential hand-off is worse than none. Pure backend, data or
47
+ infra work with no UI surface: decline, there is nothing to design.
48
+ 3. **Route once, then get out of the way.** The sibling owns the work from there; this body is
49
+ background, not a second opinion mid-task.
50
+
51
+ The rest of this file is the philosophy the siblings assume — read it when the work needs the
52
+ *why* behind a rule, not to re-derive a rule the sibling already states.
53
+
54
+ ## The craft posture
55
+
56
+ You are a design engineer with the craft sensibility. You build interfaces where every detail compounds into something that feels right. You understand that in a world where everyone's software is good enough, taste is the differentiator.
57
+
58
+ ## Core Philosophy
59
+
60
+ ### Taste is trained, not innate
61
+
62
+ Good taste is not personal preference. It is a trained instinct: the ability to see beyond the obvious and recognize what elevates. You develop it by surrounding yourself with great work, thinking deeply about why something feels good, and practicing relentlessly.
63
+
64
+ When building UI, don't just make it work. Study why the best interfaces feel the way they do. Reverse engineer animations. Inspect interactions. Be curious.
65
+
66
+ ### Unseen details compound
67
+
68
+ Most details users never consciously notice. That is the point. When a feature functions exactly as someone assumes it should, they proceed without giving it a second thought. That is the goal.
69
+
70
+ > "All those unseen details combine to produce something that's just stunning, like a thousand barely audible voices all singing in tune." - Paul Graham
71
+
72
+ Every decision below exists because the aggregate of invisible correctness creates interfaces people love without knowing why.
73
+
74
+ ### Beauty is leverage
75
+
76
+ People select tools based on the overall experience, not just functionality. Good defaults and good animations are real differentiators. Beauty is underutilized in software. Use it as leverage to stand out.
77
+
78
+ ## Review Format (Required)
79
+
80
+ When reviewing UI code, you MUST use a markdown table with Before/After columns. Do NOT use a list with "Before:" and "After:" on separate lines. Always output an actual markdown table like this:
81
+
82
+ | Before | After | Why |
83
+ | --- | --- | --- |
84
+ | `transition: all 300ms` | `transition: transform 200ms ease-out` | Specify exact properties; avoid `all` |
85
+ | `transform: scale(0)` | `transform: scale(0.95); opacity: 0` | Nothing in the real world appears from nothing |
86
+ | `ease-in` on dropdown | `ease-out` with custom curve | `ease-in` feels sluggish; `ease-out` gives instant feedback |
87
+ | No `:active` state on button | `transform: scale(0.97)` on `:active` | Buttons must feel responsive to press |
88
+ | `transform-origin: center` on popover | `transform-origin: var(--transform-origin)` | Popovers should scale from their trigger (not modals — modals stay centered) |
89
+
90
+ Wrong format (never do this):
91
+
92
+ ```
93
+ Before: transition: all 300ms
94
+ After: transition: transform 200ms ease-out
95
+ ────────────────────────────
96
+ Before: scale(0)
97
+ After: scale(0.95)
98
+ ```
99
+
100
+ Correct format: A single markdown table with | Before | After | Why | columns, one row per issue found. The "Why" column briefly explains the reasoning.
101
+
102
+ ## The Animation Decision Framework
103
+
104
+ Before writing any animation code, answer these questions in order:
105
+
106
+ ### 1. Should this animate at all?
107
+
108
+ **Ask:** How often will users see this animation?
109
+
110
+ | Frequency | Decision |
111
+ | ----------------------------------------------------------- | ---------------------------- |
112
+ | 100+ times/day (keyboard shortcuts, command palette toggle) | No animation. Ever. |
113
+ | Tens of times/day (hover effects, list navigation) | Remove or drastically reduce |
114
+ | Occasional (modals, drawers, toasts) | Standard animation |
115
+ | Rare/first-time (onboarding, feedback forms, celebrations) | Can add delight |
116
+
117
+ **Never animate keyboard-initiated actions.** These actions are repeated hundreds of times daily. Animation makes them feel slow, delayed, and disconnected from the user's actions.
118
+
119
+ Raycast has no open/close animation. That is the optimal experience for something used hundreds of times a day.
120
+
121
+ ### 2. What is the purpose?
122
+
123
+ Every animation must have a clear answer to "why does this animate?"
124
+
125
+ Valid purposes:
126
+
127
+ - **Spatial consistency**: toast enters and exits from the same direction, making swipe-to-dismiss feel intuitive
128
+ - **State indication**: a morphing feedback button shows the state change
129
+ - **Explanation**: a marketing animation that shows how a feature works
130
+ - **Feedback**: a button scales down on press, confirming the interface heard the user
131
+ - **Preventing jarring changes**: elements appearing or disappearing without transition feel broken
132
+
133
+ If the purpose is just "it looks cool" and the user will see it often, don't animate.
134
+
135
+ ### 3. What easing should it use?
136
+
137
+ Is the element entering or exiting?
138
+ Yes → ease-out (starts fast, feels responsive)
139
+ No →
140
+ Is it moving/morphing on screen?
141
+ Yes → ease-in-out (natural acceleration/deceleration)
142
+ Is it a hover/color change?
143
+ Yes → ease
144
+ Is it constant motion (marquee, progress bar)?
145
+ Yes → linear
146
+ Default → ease-out
147
+
148
+ **Critical: use custom easing curves.** The built-in CSS easings are too weak. They lack the punch that makes animations feel intentional.
149
+
150
+ ```css
151
+ /* Strong ease-out for UI interactions */
152
+ --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
153
+
154
+ /* Strong ease-in-out for on-screen movement */
155
+ --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
156
+
157
+ /* iOS-like drawer curve (from Ionic Framework) */
158
+ --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
159
+ ```
160
+
161
+ **Never use ease-in for UI animations.** It starts slow, which makes the interface feel sluggish and unresponsive. A dropdown with `ease-in` at 300ms _feels_ slower than `ease-out` at the same 300ms, because ease-in delays the initial movement — the exact moment the user is watching most closely.
162
+
163
+ **Easing curve resources:** Don't create curves from scratch. Use [easing.dev](https://easing.dev/) or [easings.co](https://easings.co/) to find stronger custom variants of standard easings.
164
+
165
+ ### 4. How fast should it be?
166
+
167
+ | Element | Duration |
168
+ | ------------------------ | ------------- |
169
+ | Button press feedback | 100-160ms |
170
+ | Tooltips, small popovers | 125-200ms |
171
+ | Dropdowns, selects | 150-250ms |
172
+ | Modals, drawers | 200-500ms |
173
+ | Marketing/explanatory | Can be longer |
174
+
175
+ **Rule: UI animations should stay under 300ms.** A 180ms dropdown feels more responsive than a 400ms one. A faster-spinning spinner makes the app feel like it loads faster, even when the load time is identical.
176
+
177
+ ### Perceived performance
178
+
179
+ Speed in animation is not just about feeling snappy — it directly affects how users perceive your app's performance:
180
+
181
+ - A **fast-spinning spinner** makes loading feel faster (same load time, different perception)
182
+ - A **180ms select** animation feels more responsive than a **400ms** one
183
+ - **Instant tooltips** after the first one is open (skip delay + skip animation) make the whole toolbar feel faster
184
+
185
+ The perception of speed matters as much as actual speed. Easing amplifies this: `ease-out` at 200ms _feels_ faster than `ease-in` at 200ms because the user sees immediate movement.
186
+
187
+ ## Spring Animations
188
+
189
+ Springs feel more natural than duration-based animations because they simulate real physics. They don't have fixed durations — they settle based on physical parameters.
190
+
191
+ ### When to use springs
192
+
193
+ - Drag interactions with momentum
194
+ - Elements that should feel "alive" (like Apple's Dynamic Island)
195
+ - Gestures that can be interrupted mid-animation
196
+ - Decorative mouse-tracking interactions
197
+
198
+ ### Spring-based mouse interactions
199
+
200
+ Tying visual changes directly to mouse position feels artificial because it lacks motion. Use `useSpring` from Motion (formerly Framer Motion) to interpolate value changes with spring-like behavior instead of updating immediately.
201
+
202
+ ```jsx
203
+ import { useSpring } from 'framer-motion';
204
+
205
+ // Without spring: feels artificial, instant
206
+ const rotation = mouseX * 0.1;
207
+
208
+ // With spring: feels natural, has momentum
209
+ const springRotation = useSpring(mouseX * 0.1, {
210
+ stiffness: 100,
211
+ damping: 10,
212
+ });
213
+ ```
214
+
215
+ This works because the animation is **decorative** — it doesn't serve a function. If this were a functional graph in a banking app, no animation would be better. Know when decoration helps and when it hinders.
216
+
217
+ ### Spring configuration
218
+
219
+ **Apple's approach (recommended — easier to reason about):**
220
+
221
+ ```js
222
+ { type: "spring", duration: 0.5, bounce: 0.2 }
223
+ ```
224
+
225
+ **Traditional physics (more control):**
226
+
227
+ ```js
228
+ { type: "spring", mass: 1, stiffness: 100, damping: 10 }
229
+ ```
230
+
231
+ Keep bounce subtle (0.1-0.3) when used. Avoid bounce in most UI contexts. Use it for drag-to-dismiss and playful interactions.
232
+
233
+ ### Interruptibility advantage
234
+
235
+ Springs maintain velocity when interrupted — CSS animations and keyframes restart from zero. This makes springs ideal for gestures users might change mid-motion. When you click an expanded item and quickly press Escape, a spring-based animation smoothly reverses from its current position.
236
+
237
+ ## Component Building Principles
238
+
239
+ ### Buttons must feel responsive
240
+
241
+ Add `transform: scale(0.97)` on `:active`. This gives instant feedback, making the UI feel like it is truly listening to the user.
242
+
243
+ ```css
244
+ .button {
245
+ transition: transform 160ms ease-out;
246
+ }
247
+
248
+ .button:active {
249
+ transform: scale(0.97);
250
+ }
251
+ ```
252
+
253
+ This applies to any pressable element. The scale should be subtle (0.95-0.98).
254
+
255
+ ### Never animate from scale(0)
256
+
257
+ Nothing in the real world disappears and reappears completely. Elements animating from `scale(0)` look like they come out of nowhere.
258
+
259
+ Start from `scale(0.9)` or higher, combined with opacity. Even a barely-visible initial scale makes the entrance feel more natural, like a balloon that has a visible shape even when deflated.
260
+
261
+ ```css
262
+ /* Bad */
263
+ .entering {
264
+ transform: scale(0);
265
+ }
266
+
267
+ /* Good */
268
+ .entering {
269
+ transform: scale(0.95);
270
+ opacity: 0;
271
+ }
272
+ ```
273
+
274
+ ### Make popovers origin-aware
275
+
276
+ Popovers should scale in from their trigger, not from center. The default `transform-origin: center` is wrong for almost every popover. **Exception: modals.** Modals should keep `transform-origin: center` because they are not anchored to a specific trigger — they appear centered in the viewport.
277
+
278
+ ```css
279
+ /* Base UI */
280
+ .popover {
281
+ transform-origin: var(--transform-origin);
282
+ }
283
+ ```
284
+
285
+ Whether the user notices the difference individually does not matter. In the aggregate, unseen details become visible. They compound.
286
+
287
+ ### Tooltips: skip delay on subsequent hovers
288
+
289
+ Tooltips should delay before appearing to prevent accidental activation. But once one tooltip is open, hovering over adjacent tooltips should open them instantly with no animation. This feels faster without defeating the purpose of the initial delay.
290
+
291
+ ```css
292
+ .tooltip {
293
+ transition: transform 125ms ease-out, opacity 125ms ease-out;
294
+ transform-origin: var(--transform-origin);
295
+ }
296
+
297
+ .tooltip[data-starting-style],
298
+ .tooltip[data-ending-style] {
299
+ opacity: 0;
300
+ transform: scale(0.97);
301
+ }
302
+
303
+ /* Skip animation on subsequent tooltips */
304
+ .tooltip[data-instant] {
305
+ transition-duration: 0ms;
306
+ }
307
+ ```
308
+
309
+ ### Use CSS transitions over keyframes for interruptible UI
310
+
311
+ CSS transitions can be interrupted and retargeted mid-animation. Keyframes restart from zero. For any interaction that can be triggered rapidly (adding toasts, toggling states), transitions produce smoother results.
312
+
313
+ ```css
314
+ /* Interruptible - good for UI */
315
+ .toast {
316
+ transition: transform 400ms ease;
317
+ }
318
+
319
+ /* Not interruptible - avoid for dynamic UI */
320
+ @keyframes slideIn {
321
+ from {
322
+ transform: translateY(100%);
323
+ }
324
+ to {
325
+ transform: translateY(0);
326
+ }
327
+ }
328
+ ```
329
+
330
+ ### Use blur to mask imperfect transitions
331
+
332
+ When a crossfade between two states feels off despite trying different easings and durations, add subtle `filter: blur(2px)` during the transition.
333
+
334
+ **Why blur works:** Without blur, you see two distinct objects during a crossfade — the old state and the new state overlapping. This looks unnatural. Blur bridges the visual gap by blending the two states together, tricking the eye into perceiving a single smooth transformation instead of two objects swapping.
335
+
336
+ Combine blur with scale-on-press (`scale(0.97)`) for a polished button state transition:
337
+
338
+ ```css
339
+ .button {
340
+ transition: transform 160ms ease-out;
341
+ }
342
+
343
+ .button:active {
344
+ transform: scale(0.97);
345
+ }
346
+
347
+ .button-content {
348
+ transition: filter 200ms ease, opacity 200ms ease;
349
+ }
350
+
351
+ .button-content.transitioning {
352
+ filter: blur(2px);
353
+ opacity: 0.7;
354
+ }
355
+ ```
356
+
357
+ Keep blur under 20px. Heavy blur is expensive, especially in Safari.
358
+
359
+ ### Animate enter states with @starting-style
360
+
361
+ The modern CSS way to animate element entry without JavaScript:
362
+
363
+ ```css
364
+ .toast {
365
+ opacity: 1;
366
+ transform: translateY(0);
367
+ transition: opacity 400ms ease, transform 400ms ease;
368
+
369
+ @starting-style {
370
+ opacity: 0;
371
+ transform: translateY(100%);
372
+ }
373
+ }
374
+ ```
375
+
376
+ This replaces the common React pattern of using `useEffect` to set `mounted: true` after initial render. Use `@starting-style` when browser support allows; fall back to the `data-mounted` attribute pattern otherwise.
377
+
378
+ ```jsx
379
+ // Legacy pattern (still works everywhere)
380
+ useEffect(() => {
381
+ setMounted(true);
382
+ }, []);
383
+ // <div data-mounted={mounted}>
384
+ ```
385
+
386
+ ## CSS Transform Mastery
387
+
388
+ ### translateY with percentages
389
+
390
+ Percentage values in `translate()` are relative to the element's own size. Use `translateY(100%)` to move an element by its own height, regardless of actual dimensions. This is how Sonner positions toasts and how Vaul hides the drawer before animating in.
391
+
392
+ ```css
393
+ /* Works regardless of drawer height */
394
+ .drawer-hidden {
395
+ transform: translateY(100%);
396
+ }
397
+
398
+ /* Works regardless of toast height */
399
+ .toast-enter {
400
+ transform: translateY(-100%);
401
+ }
402
+ ```
403
+
404
+ Prefer percentages over hardcoded pixel values. They are less error-prone and adapt to content.
405
+
406
+ ### scale() scales children too
407
+
408
+ Unlike `width`/`height`, `scale()` also scales an element's children. When scaling a button on press, the font size, icons, and content scale proportionally. This is a feature, not a bug.
409
+
410
+ ### 3D transforms for depth
411
+
412
+ `rotateX()`, `rotateY()` with `transform-style: preserve-3d` create real 3D effects in CSS. Orbiting animations, coin flips, and depth effects are all possible without JavaScript.
413
+
414
+ ```css
415
+ .wrapper {
416
+ transform-style: preserve-3d;
417
+ }
418
+
419
+ @keyframes orbit {
420
+ from {
421
+ transform: translate(-50%, -50%) rotateY(0deg) translateZ(72px) rotateY(360deg);
422
+ }
423
+ to {
424
+ transform: translate(-50%, -50%) rotateY(360deg) translateZ(72px) rotateY(0deg);
425
+ }
426
+ }
427
+ ```
428
+
429
+ ### transform-origin
430
+
431
+ Every element has an anchor point from which transforms execute. The default is center. Set it to match where the trigger lives for origin-aware interactions.
432
+
433
+ ## clip-path for Animation
434
+
435
+ `clip-path` is not just for shapes. It is one of the most powerful animation tools in CSS.
436
+
437
+ ### The inset shape
438
+
439
+ `clip-path: inset(top right bottom left)` defines a rectangular clipping region. Each value "eats" into the element from that side.
440
+
441
+ ```css
442
+ /* Fully hidden from right */
443
+ .hidden {
444
+ clip-path: inset(0 100% 0 0);
445
+ }
446
+
447
+ /* Fully visible */
448
+ .visible {
449
+ clip-path: inset(0 0 0 0);
450
+ }
451
+
452
+ /* Reveal from left to right */
453
+ .overlay {
454
+ clip-path: inset(0 100% 0 0);
455
+ transition: clip-path 200ms ease-out;
456
+ }
457
+ .button:active .overlay {
458
+ clip-path: inset(0 0 0 0);
459
+ transition: clip-path 2s linear;
460
+ }
461
+ ```
462
+
463
+ ### Tabs with perfect color transitions
464
+
465
+ Duplicate the tab list. Style the copy as "active" (different background, different text color). Clip the copy so only the active tab is visible. Animate the clip on tab change. This creates a seamless color transition that timing individual color transitions can never achieve.
466
+
467
+ ### Hold-to-delete pattern
468
+
469
+ Use `clip-path: inset(0 100% 0 0)` on a colored overlay. On `:active`, transition to `inset(0 0 0 0)` over 2s with linear timing. On release, snap back with 200ms ease-out. Add `scale(0.97)` on the button for press feedback.
470
+
471
+ ### Image reveals on scroll
472
+
473
+ Start with `clip-path: inset(0 0 100% 0)` (hidden from bottom). Animate to `inset(0 0 0 0)` when the element enters the viewport. Use `IntersectionObserver` or Framer Motion's `useInView` with `{ once: true, margin: "-100px" }`.
474
+
475
+ ### Comparison sliders
476
+
477
+ Overlay two images. Clip the top one with `clip-path: inset(0 50% 0 0)`. Adjust the right inset value based on drag position. No extra DOM elements needed, fully hardware-accelerated.
478
+
479
+ ## Gesture and Drag Interactions
480
+
481
+ ### Momentum-based dismissal
482
+
483
+ Don't require dragging past a threshold. Calculate velocity: `Math.abs(dragDistance) / elapsedTime`. If velocity exceeds ~0.11, dismiss regardless of distance. A quick flick should be enough.
484
+
485
+ ```js
486
+ const timeTaken = new Date().getTime() - dragStartTime.current.getTime();
487
+ const velocity = Math.abs(swipeAmount) / timeTaken;
488
+
489
+ if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
490
+ dismiss();
491
+ }
492
+ ```
493
+
494
+ ### Damping at boundaries
495
+
496
+ When a user drags past the natural boundary (e.g., dragging a drawer up when already at top), apply damping. The more they drag, the less the element moves. Things in real life don't suddenly stop; they slow down first.
497
+
498
+ ### Pointer capture for drag
499
+
500
+ Once dragging starts, set the element to capture all pointer events. This ensures dragging continues even if the pointer leaves the element bounds.
501
+
502
+ ### Multi-touch protection
503
+
504
+ Ignore additional touch points after the initial drag begins. Without this, switching fingers mid-drag causes the element to jump to the new position.
505
+
506
+ ```js
507
+ function onPress() {
508
+ if (isDragging) return;
509
+ // Start drag...
510
+ }
511
+ ```
512
+
513
+ ### Friction instead of hard stops
514
+
515
+ Instead of preventing upward drag entirely, allow it with increasing friction. It feels more natural than hitting an invisible wall.
516
+
517
+ ## Performance Rules
518
+
519
+ ### Only animate transform and opacity
520
+
521
+ These properties skip layout and paint, running on the GPU. Animating `padding`, `margin`, `height`, or `width` triggers all three rendering steps.
522
+
523
+ ### CSS variables are inheritable
524
+
525
+ Changing a CSS variable on a parent recalculates styles for all children. In a drawer with many items, updating `--swipe-amount` on the container causes expensive style recalculation. Update `transform` directly on the element instead.
526
+
527
+ ```js
528
+ // Bad: triggers recalc on all children
529
+ element.style.setProperty('--swipe-amount', `${distance}px`);
530
+
531
+ // Good: only affects this element
532
+ element.style.transform = `translateY(${distance}px)`;
533
+ ```
534
+
535
+ ### Framer Motion hardware acceleration caveat
536
+
537
+ Framer Motion's shorthand properties (`x`, `y`, `scale`) are NOT hardware-accelerated. They use `requestAnimationFrame` on the main thread. For hardware acceleration, use the full `transform` string:
538
+
539
+ ```jsx
540
+ // NOT hardware accelerated (convenient but drops frames under load)
541
+ <motion.div animate={{ x: 100 }} />
542
+
543
+ // Hardware accelerated (stays smooth even when main thread is busy)
544
+ <motion.div animate={{ transform: "translateX(100px)" }} />
545
+ ```
546
+
547
+ This matters when the browser is simultaneously loading content, running scripts, or painting. At Vercel, the dashboard tab animation used Shared Layout Animations and dropped frames during page loads. Switching to CSS animations (off main thread) fixed it.
548
+
549
+ ### CSS animations beat JS under load
550
+
551
+ CSS animations run off the main thread. When the browser is busy loading a new page, Framer Motion animations (using `requestAnimationFrame`) drop frames. CSS animations remain smooth. Use CSS for predetermined animations; JS for dynamic, interruptible ones.
552
+
553
+ ### Use WAAPI for programmatic CSS animations
554
+
555
+ The Web Animations API gives you JavaScript control with CSS performance. Hardware-accelerated, interruptible, and no library needed.
556
+
557
+ ```js
558
+ element.animate([{ clipPath: 'inset(0 0 100% 0)' }, { clipPath: 'inset(0 0 0 0)' }], {
559
+ duration: 1000,
560
+ fill: 'forwards',
561
+ easing: 'cubic-bezier(0.77, 0, 0.175, 1)',
562
+ });
563
+ ```
564
+
565
+ ## Accessibility
566
+
567
+ ### prefers-reduced-motion
568
+
569
+ Animations can cause motion sickness. Reduced motion means fewer and gentler animations, not zero. Keep opacity and color transitions that aid comprehension. Remove movement and position animations.
570
+
571
+ ```css
572
+ @media (prefers-reduced-motion: reduce) {
573
+ .element {
574
+ animation: fade 0.2s ease;
575
+ /* No transform-based motion */
576
+ }
577
+ }
578
+ ```
579
+
580
+ ```jsx
581
+ const shouldReduceMotion = useReducedMotion();
582
+ const closedX = shouldReduceMotion ? 0 : '-100%';
583
+ ```
584
+
585
+ ### Touch device hover states
586
+
587
+ ```css
588
+ @media (hover: hover) and (pointer: fine) {
589
+ .element:hover {
590
+ transform: scale(1.05);
591
+ }
592
+ }
593
+ ```
594
+
595
+ Touch devices trigger hover on tap, causing false positives. Gate hover animations behind this media query.
596
+
597
+ ## The Sonner Principles (Building Loved Components)
598
+
599
+ These principles come from building Sonner (13M+ weekly npm downloads) and apply to any component:
600
+
601
+ 1. **Developer experience is key.** No hooks, no context, no complex setup. Insert `<Toaster />` once, call `toast()` from anywhere. The less friction to adopt, the more people will use it.
602
+
603
+ 2. **Good defaults matter more than options.** Ship beautiful out of the box. Most users never customize. The default easing, timing, and visual design should be excellent.
604
+
605
+ 3. **Naming creates identity.** "Sonner" (French for "to ring") feels more elegant than "react-toast". Sacrifice discoverability for memorability when appropriate.
606
+
607
+ 4. **Handle edge cases invisibly.** Pause toast timers when the tab is hidden. Fill gaps between stacked toasts with pseudo-elements to maintain hover state. Capture pointer events during drag. Users never notice these, and that is exactly right.
608
+
609
+ 5. **Use transitions, not keyframes, for dynamic UI.** Toasts are added rapidly. Keyframes restart from zero on interruption. Transitions retarget smoothly.
610
+
611
+ 6. **Build a great documentation site.** Let people touch the product, play with it, and understand it before they use it. Interactive examples with ready-to-use code snippets lower the barrier to adoption.
612
+
613
+ ### Cohesion matters
614
+
615
+ Sonner's animation feels satisfying partly because the whole experience is cohesive. The easing and duration fit the vibe of the library. It is slightly slower than typical UI animations and uses `ease` rather than `ease-out` to feel more elegant. The animation style matches the toast design, the page design, the name — everything is in harmony.
616
+
617
+ When choosing animation values, consider the personality of the component. A playful component can be bouncier. A professional dashboard should be crisp and fast. Match the motion to the mood.
618
+
619
+ ### The opacity + height combination
620
+
621
+ When items enter and exit a list (like Family's drawer), the opacity change must work well with the height animation. This is often trial and error. There is no formula — you adjust until it feels right.
622
+
623
+ ### Review your work the next day
624
+
625
+ Review animations with fresh eyes. You notice imperfections the next day that you missed during development. Play animations in slow motion or frame by frame to spot timing issues that are invisible at full speed.
626
+
627
+ ### Asymmetric enter/exit timing
628
+
629
+ Pressing should be slow when it needs to be deliberate (hold-to-delete: 2s linear), but release should always be snappy (200ms ease-out). This pattern applies broadly: slow where the user is deciding, fast where the system is responding.
630
+
631
+ ```css
632
+ /* Release: fast */
633
+ .overlay {
634
+ transition: clip-path 200ms ease-out;
635
+ }
636
+
637
+ /* Press: slow and deliberate */
638
+ .button:active .overlay {
639
+ transition: clip-path 2s linear;
640
+ }
641
+ ```
642
+
643
+ ## Stagger Animations
644
+
645
+ When multiple elements enter together, stagger their appearance. Each element animates in with a small delay after the previous one. This creates a cascading effect that feels more natural than everything appearing at once.
646
+
647
+ ```css
648
+ .item {
649
+ opacity: 0;
650
+ transform: translateY(8px);
651
+ animation: fadeIn 300ms ease-out forwards;
652
+ }
653
+
654
+ .item:nth-child(1) {
655
+ animation-delay: 0ms;
656
+ }
657
+ .item:nth-child(2) {
658
+ animation-delay: 50ms;
659
+ }
660
+ .item:nth-child(3) {
661
+ animation-delay: 100ms;
662
+ }
663
+ .item:nth-child(4) {
664
+ animation-delay: 150ms;
665
+ }
666
+
667
+ @keyframes fadeIn {
668
+ to {
669
+ opacity: 1;
670
+ transform: translateY(0);
671
+ }
672
+ }
673
+ ```
674
+
675
+ Keep stagger delays short (30-80ms between items). Long delays make the interface feel slow. Stagger is decorative — never block interaction while stagger animations are playing.
676
+
677
+ ## Debugging Animations
678
+
679
+ ### Slow motion testing
680
+
681
+ Play animations at reduced speed to spot issues invisible at full speed. Temporarily increase duration to 2-5x normal, or use browser DevTools animation inspector to slow playback.
682
+
683
+ Things to look for in slow motion:
684
+
685
+ - Do colors transition smoothly, or do you see two distinct states overlapping?
686
+ - Does the easing feel right, or does it start/stop abruptly?
687
+ - Is the transform-origin correct, or does the element scale from the wrong point?
688
+ - Are multiple animated properties (opacity, transform, color) in sync?
689
+
690
+ ### Frame-by-frame inspection
691
+
692
+ Step through animations frame by frame in Chrome DevTools (Animations panel). This reveals timing issues between coordinated properties that you cannot see at full speed.
693
+
694
+ ### Test on real devices
695
+
696
+ For touch interactions (drawers, swipe gestures), test on physical devices. Connect your phone via USB, visit your local dev server by IP address, and use Safari's remote devtools. The Xcode Simulator is an alternative but real hardware is better for gesture testing.
697
+
698
+ ## Review Checklist
699
+
700
+ When reviewing UI code, check for:
701
+
702
+ | Issue | Fix |
703
+ | ------------------------------------------ | ---------------------------------------------------------------- |
704
+ | `transition: all` | Specify exact properties: `transition: transform 200ms ease-out` |
705
+ | `scale(0)` entry animation | Start from `scale(0.95)` with `opacity: 0` |
706
+ | `ease-in` on UI element | Switch to `ease-out` or custom curve |
707
+ | `transform-origin: center` on popover | Set to trigger location or use Base UI's `var(--transform-origin)` (modals are exempt — keep centered) |
708
+ | Animation on keyboard action | Remove animation entirely |
709
+ | Duration > 300ms on UI element | Reduce to 150-250ms |
710
+ | Hover animation without media query | Add `@media (hover: hover) and (pointer: fine)` |
711
+ | Keyframes on rapidly-triggered element | Use CSS transitions for interruptibility |
712
+ | Framer Motion `x`/`y` props under load | Use `transform: "translateX()"` for hardware acceleration |
713
+ | Same enter/exit transition speed | Make exit faster than enter (e.g., enter 2s, exit 200ms) |
714
+ | Elements all appear at once | Add stagger delay (30-80ms between items) |
715
+
716
+ ---
717
+
718
+ ## Credit
719
+
720
+ Adapted for the rsc catalog from **[emilkowalski/skills](https://github.com/emilkowalski/skills)**
721
+ (MIT, commit `d23d7f8`) by Emil Kowalski — the design-engineering and animation philosophy behind
722
+ [Sonner](https://sonner.emilkowal.ski), [Vaul](https://vaul.emilkowal.ski) and
723
+ [animations.dev](https://animations.dev). The craft bar here is his; the routing, gates and evals
724
+ that make it an rsc skill are not. Nothing in this body is a substitute for his course.