@istmx/skills 1.2.0 → 2.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 (111) hide show
  1. package/README.md +38 -20
  2. package/bin/cli.js +50 -24
  3. package/istm-animate/SKILL.md +31 -26
  4. package/istm-animate/core/motion-principles/SKILL.md +284 -0
  5. package/istm-animate/core/motion-principles/references/designers.md +127 -0
  6. package/istm-animate/core/motion-principles/references/easing-guide.md +231 -0
  7. package/istm-animate/core/motion-principles/references/enter-exit-recipes.md +466 -0
  8. package/istm-animate/frameworks/canvas-generative/SKILL.md +325 -0
  9. package/istm-animate/frameworks/canvas-generative/references/algorithms.md +925 -0
  10. package/istm-animate/frameworks/css-native/SKILL.md +319 -0
  11. package/istm-animate/frameworks/css-native/references/modern-css.md +465 -0
  12. package/istm-animate/frameworks/framer-motion/SKILL.md +187 -0
  13. package/istm-animate/frameworks/framer-motion/references/api.md +312 -0
  14. package/istm-animate/frameworks/gsap/SKILL.md +188 -0
  15. package/istm-animate/frameworks/gsap/references/core.md +218 -0
  16. package/istm-animate/frameworks/gsap/references/plugins.md +371 -0
  17. package/istm-animate/frameworks/gsap/references/scrolltrigger.md +325 -0
  18. package/istm-animate/frameworks/gsap/references/timeline.md +218 -0
  19. package/istm-animate/frameworks/threejs-r3f/SKILL.md +243 -0
  20. package/istm-animate/frameworks/threejs-r3f/references/scene-setup.md +392 -0
  21. package/istm-animate/frameworks/threejs-r3f/references/shaders.md +446 -0
  22. package/istm-animate/mobile/android/compose-graphics/SKILL.md +503 -0
  23. package/istm-animate/mobile/android/compose-graphics/references/agsl-recipes.md +356 -0
  24. package/istm-animate/mobile/android/compose-graphics/references/canvas-generative.md +282 -0
  25. package/istm-animate/mobile/android/compose-graphics/references/m3-expressive-deep.md +303 -0
  26. package/istm-animate/mobile/android/compose-motion/SKILL.md +359 -0
  27. package/istm-animate/mobile/android/compose-motion/references/gestures-compose.md +273 -0
  28. package/istm-animate/mobile/android/compose-motion/references/recomposition-and-anim.md +196 -0
  29. package/istm-animate/mobile/android/compose-motion/references/shared-transitions.md +281 -0
  30. package/istm-animate/mobile/android/compose-multiplatform/SKILL.md +311 -0
  31. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-interop.md +288 -0
  32. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-platform-quirks.md +156 -0
  33. package/istm-animate/mobile/apple/swiftui-graphics/SKILL.md +408 -0
  34. package/istm-animate/mobile/apple/swiftui-graphics/references/canvas-swiftui.md +239 -0
  35. package/istm-animate/mobile/apple/swiftui-graphics/references/liquid-glass-deep.md +252 -0
  36. package/istm-animate/mobile/apple/swiftui-graphics/references/metal-recipes.md +382 -0
  37. package/istm-animate/mobile/apple/swiftui-motion/SKILL.md +379 -0
  38. package/istm-animate/mobile/apple/swiftui-motion/references/gestures-swiftui.md +336 -0
  39. package/istm-animate/mobile/apple/swiftui-motion/references/phase-keyframe-deep.md +231 -0
  40. package/istm-animate/mobile/apple/swiftui-motion/references/springs-cheatsheet.md +129 -0
  41. package/istm-animate/references/animate.md +199 -0
  42. package/istm-animate/references/audit.md +115 -0
  43. package/istm-animate/references/design-engineering.md +674 -0
  44. package/istm-animate/references/improve.md +101 -0
  45. package/istm-animate/references/opportunities.md +132 -0
  46. package/istm-animate/references/plan-template.md +73 -0
  47. package/istm-animate/references/recipes.md +324 -0
  48. package/istm-animate/references/review.md +112 -0
  49. package/istm-animate/references/standards.md +187 -0
  50. package/istm-animate/references/vocabulary.md +173 -0
  51. package/istm-awwward-designer/SKILL.md +29 -17
  52. package/istm-design/SKILL.md +31 -59
  53. package/istm-design/core/design-audit/SKILL.md +248 -0
  54. package/istm-design/core/desktop-principles/SKILL.md +363 -0
  55. package/istm-design/core/desktop-principles/references/keyboard-patterns.md +137 -0
  56. package/istm-design/core/desktop-principles/references/multi-window.md +105 -0
  57. package/istm-design/core/mobile-principles/SKILL.md +289 -0
  58. package/istm-design/core/mobile-principles/references/accessibility-mobile.md +175 -0
  59. package/istm-design/core/mobile-principles/references/gestures-deep.md +220 -0
  60. package/istm-design/core/ui-ux-pro-max/SKILL.md +392 -0
  61. package/istm-design/core/ui-ux-pro-max/UPSTREAM.md +23 -0
  62. package/istm-design/core/ui-ux-pro-max/data/app-interface.csv +31 -0
  63. package/istm-design/core/ui-ux-pro-max/data/charts.csv +26 -0
  64. package/istm-design/core/ui-ux-pro-max/data/colors.csv +193 -0
  65. package/istm-design/core/ui-ux-pro-max/data/google-fonts.csv +1924 -0
  66. package/istm-design/core/ui-ux-pro-max/data/icons.csv +106 -0
  67. package/istm-design/core/ui-ux-pro-max/data/landing.csv +35 -0
  68. package/istm-design/core/ui-ux-pro-max/data/motion.csv +17 -0
  69. package/istm-design/core/ui-ux-pro-max/data/products.csv +193 -0
  70. package/istm-design/core/ui-ux-pro-max/data/react-performance.csv +45 -0
  71. package/istm-design/core/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  72. package/istm-design/core/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  73. package/istm-design/core/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
  74. package/istm-design/core/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  75. package/istm-design/core/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  76. package/istm-design/core/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
  77. package/istm-design/core/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  78. package/istm-design/core/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  79. package/istm-design/core/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  80. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxt-ui.csv +71 -0
  81. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  82. package/istm-design/core/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  83. package/istm-design/core/ui-ux-pro-max/data/stacks/react.csv +54 -0
  84. package/istm-design/core/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  85. package/istm-design/core/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  86. package/istm-design/core/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  87. package/istm-design/core/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  88. package/istm-design/core/ui-ux-pro-max/data/stacks/uno.csv +60 -0
  89. package/istm-design/core/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
  90. package/istm-design/core/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  91. package/istm-design/core/ui-ux-pro-max/data/stacks/winui.csv +60 -0
  92. package/istm-design/core/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
  93. package/istm-design/core/ui-ux-pro-max/data/styles.csv +85 -0
  94. package/istm-design/core/ui-ux-pro-max/data/typography.csv +75 -0
  95. package/istm-design/core/ui-ux-pro-max/data/ui-reasoning.csv +162 -0
  96. package/istm-design/core/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  97. package/istm-design/core/ui-ux-pro-max/references/pro-rules.md +109 -0
  98. package/istm-design/core/ui-ux-pro-max/references/quick-reference.md +240 -0
  99. package/istm-design/core/ui-ux-pro-max/scripts/core.py +464 -0
  100. package/istm-design/core/ui-ux-pro-max/scripts/design_system.py +1371 -0
  101. package/istm-design/core/ui-ux-pro-max/scripts/search.py +162 -0
  102. package/istm-design/core/ui-ux-pro-max/scripts/tests/test_core.py +134 -0
  103. package/istm-design/core/ui-ux-pro-max/scripts/validate_data.py +114 -0
  104. package/istm-design/references/apple-design.md +282 -0
  105. package/istm-design/references/generation-guide.md +209 -0
  106. package/istm-design/references/pick-ui-library.md +77 -0
  107. package/istm-design/references/picker.md +197 -0
  108. package/istm-design/references/prototype.md +90 -0
  109. package/istm-design/references/schema.md +366 -0
  110. package/package.json +1 -1
  111. package/RELEASE_v1.2.0.md +0 -40
@@ -0,0 +1,465 @@
1
+ # Modern CSS — Browser Support, Fallbacks & Progressive Enhancement
2
+
3
+ > Last verified: March 2026
4
+
5
+ ---
6
+
7
+ ## Browser Support Tables
8
+
9
+ ### Scroll-Driven Animations (`animation-timeline`)
10
+
11
+ | Browser | Version | Status |
12
+ |---|---|---|
13
+ | Chrome | 115+ | Supported |
14
+ | Edge | 115+ | Supported |
15
+ | Firefox | 128+ | Supported (shipped July 2024) |
16
+ | Safari | 18.4+ | Supported (shipped early 2025) |
17
+
18
+ **Global coverage**: ~90%+ (as of March 2026)
19
+
20
+ ### View Transitions API
21
+
22
+ | Feature | Chrome | Edge | Firefox | Safari |
23
+ |---|---|---|---|---|
24
+ | Same-document (`startViewTransition`) | 111+ | 111+ | 133+ | 18+ |
25
+ | Cross-document (`@view-transition`) | 126+ | 126+ | Not yet | 18.2+ |
26
+ | `view-transition-class` | 125+ | 125+ | Not yet | 18.2+ |
27
+
28
+ **Note**: Cross-document view transitions are an Interop 2026 focus area — Firefox support expected to land in 2026.
29
+
30
+ ### @starting-style
31
+
32
+ | Browser | Version | Status |
33
+ |---|---|---|
34
+ | Chrome | 117+ | Supported |
35
+ | Edge | 117+ | Supported |
36
+ | Firefox | 129+ | Supported |
37
+ | Safari | 17.5+ | Supported |
38
+
39
+ **Global coverage**: ~93%+ — Baseline Newly Available (2024)
40
+
41
+ ### CSS Anchor Positioning
42
+
43
+ | Browser | Version | Status |
44
+ |---|---|---|
45
+ | Chrome | 125+ | Supported |
46
+ | Edge | 125+ | Supported |
47
+ | Firefox | Nightly | In development (Interop 2026) |
48
+ | Safari | 26+ | Supported (shipped 2026) |
49
+
50
+ **Note**: Anchor positioning is an Interop 2026 focus area. Firefox expected to ship stable support in 2026.
51
+
52
+ ### Container Queries
53
+
54
+ | Feature | Chrome | Edge | Firefox | Safari |
55
+ |---|---|---|---|---|
56
+ | Size queries (`@container`) | 105+ | 105+ | 110+ | 16+ |
57
+ | Container-relative units (`cqw`, `cqh`) | 105+ | 105+ | 110+ | 16+ |
58
+ | Style queries (`@container style()`) | 111+ | 111+ | Not yet | 18+ |
59
+
60
+ **Global coverage (size queries)**: ~95%+
61
+
62
+ ---
63
+
64
+ ## Fallback Patterns
65
+
66
+ ### Scroll-Driven Animations
67
+
68
+ ```css
69
+ /* Base: no scroll animation, element is always visible */
70
+ .reveal {
71
+ opacity: 1;
72
+ transform: translateY(0);
73
+ }
74
+
75
+ /* Progressive enhancement for supporting browsers */
76
+ @supports (animation-timeline: scroll()) {
77
+ .reveal {
78
+ animation: reveal-up linear both;
79
+ animation-timeline: view();
80
+ animation-range: entry 10% entry 90%;
81
+ }
82
+
83
+ @keyframes reveal-up {
84
+ from {
85
+ opacity: 0;
86
+ transform: translateY(2rem);
87
+ }
88
+ to {
89
+ opacity: 1;
90
+ transform: translateY(0);
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ **Strategy**: Content is always visible by default. Scroll animation is purely decorative enhancement. Never hide content behind a scroll-driven animation without fallback.
97
+
98
+ ### View Transitions (Same-Document)
99
+
100
+ ```js
101
+ function navigate(updateFn) {
102
+ // Fallback: just update the DOM instantly
103
+ if (!document.startViewTransition) {
104
+ updateFn();
105
+ return;
106
+ }
107
+
108
+ document.startViewTransition(() => updateFn());
109
+ }
110
+ ```
111
+
112
+ ```css
113
+ /* Only apply transition styles if supported */
114
+ @supports (view-transition-name: none) {
115
+ .hero { view-transition-name: hero; }
116
+
117
+ ::view-transition-old(hero) {
118
+ animation: fade-scale-out 250ms ease-out both;
119
+ }
120
+ ::view-transition-new(hero) {
121
+ animation: fade-scale-in 300ms ease-in both;
122
+ }
123
+ }
124
+ ```
125
+
126
+ ### View Transitions (Cross-Document)
127
+
128
+ ```css
129
+ /* This rule is safely ignored by browsers that don't support it */
130
+ @view-transition {
131
+ navigation: auto;
132
+ }
133
+
134
+ /* Guard transition-specific styles */
135
+ @supports (view-transition-name: none) {
136
+ .page-header { view-transition-name: header; }
137
+ .main-content { view-transition-name: content; }
138
+
139
+ ::view-transition-group(header) {
140
+ animation-duration: 300ms;
141
+ }
142
+ ::view-transition-group(content) {
143
+ animation-duration: 250ms;
144
+ }
145
+ }
146
+ ```
147
+
148
+ **Strategy**: Pages load normally in unsupported browsers. The `@view-transition` rule is unknown and ignored — no breakage.
149
+
150
+ ### @starting-style
151
+
152
+ ```css
153
+ /* Broad support — but guard with @supports for very old browsers */
154
+ .popover {
155
+ opacity: 1;
156
+ transform: scale(1);
157
+ transition: opacity 200ms ease, transform 200ms ease;
158
+ }
159
+
160
+ /* @starting-style is baseline — this works in all modern browsers */
161
+ .popover {
162
+ @starting-style {
163
+ opacity: 0;
164
+ transform: scale(0.95);
165
+ }
166
+ }
167
+
168
+ /* For the display transition, check discrete support */
169
+ @supports (transition-behavior: allow-discrete) {
170
+ .popover {
171
+ transition: opacity 200ms ease, transform 200ms ease,
172
+ display 200ms allow-discrete, overlay 200ms allow-discrete;
173
+ }
174
+
175
+ .popover:not(:popover-open) {
176
+ opacity: 0;
177
+ transform: scale(0.95);
178
+ display: none;
179
+ }
180
+ }
181
+ ```
182
+
183
+ **Strategy**: `@starting-style` itself is well-supported. The main concern is `transition-behavior: allow-discrete` for `display`/`overlay` transitions. Guard that part specifically.
184
+
185
+ ### Anchor Positioning
186
+
187
+ ```css
188
+ /* Feature detection for anchor positioning */
189
+ @supports (anchor-name: --a) {
190
+ .trigger { anchor-name: --trigger; }
191
+
192
+ .tooltip {
193
+ position: fixed;
194
+ position-anchor: --trigger;
195
+ position-area: top center;
196
+ margin-bottom: 0.5rem;
197
+
198
+ position-try-fallbacks: --bottom;
199
+ }
200
+
201
+ @position-try --bottom {
202
+ position-area: bottom center;
203
+ margin-top: 0.5rem;
204
+ }
205
+ }
206
+
207
+ /* Fallback for unsupported browsers: manual absolute positioning */
208
+ @supports not (anchor-name: --a) {
209
+ .tooltip-wrapper {
210
+ position: relative;
211
+ }
212
+
213
+ .tooltip {
214
+ position: absolute;
215
+ bottom: 100%;
216
+ left: 50%;
217
+ transform: translateX(-50%);
218
+ margin-bottom: 0.5rem;
219
+ }
220
+ }
221
+ ```
222
+
223
+ **Strategy**: Use `@supports (anchor-name: --a)` to detect. Provide a classic `position: absolute` fallback. For JS-heavy apps, Floating UI remains a solid fallback.
224
+
225
+ ### Container Queries
226
+
227
+ ```css
228
+ /* Container queries are baseline — safe for production */
229
+ .card-wrapper {
230
+ container-type: inline-size;
231
+ container-name: card;
232
+ }
233
+
234
+ /* Size queries: well supported */
235
+ @container card (min-width: 400px) {
236
+ .card { flex-direction: row; }
237
+ }
238
+
239
+ /* Style queries: Chrome/Edge/Safari only — use with care */
240
+ @supports (container-type: inline-size) {
241
+ /* Size queries are safe — 95%+ coverage */
242
+ }
243
+
244
+ /* Style queries: progressive enhancement only */
245
+ @container style(--theme: dark) {
246
+ .card { background: oklch(0.2 0.02 250); }
247
+ }
248
+ /* Fallback: use a class or media query for unsupported browsers */
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Progressive Enhancement Strategies
254
+
255
+ ### Strategy 1: Layered Animation (Recommended)
256
+
257
+ Build in layers — each layer adds richness but nothing breaks without it.
258
+
259
+ ```css
260
+ /* Layer 0: Content is visible, no animation */
261
+ .section-title {
262
+ opacity: 1;
263
+ }
264
+
265
+ /* Layer 1: Simple transition (universally supported) */
266
+ .section-title {
267
+ transition: opacity 400ms ease, transform 400ms ease;
268
+ }
269
+ .section-title.visible {
270
+ opacity: 1;
271
+ transform: translateY(0);
272
+ }
273
+
274
+ /* Layer 2: Scroll-driven (modern browsers only) */
275
+ @supports (animation-timeline: scroll()) {
276
+ .section-title {
277
+ animation: reveal linear both;
278
+ animation-timeline: view();
279
+ animation-range: entry 0% entry 80%;
280
+ /* Remove the JS-toggled class approach */
281
+ transition: none;
282
+ }
283
+
284
+ @keyframes reveal {
285
+ from { opacity: 0; transform: translateY(1.5rem); }
286
+ to { opacity: 1; transform: translateY(0); }
287
+ }
288
+ }
289
+ ```
290
+
291
+ ### Strategy 2: View Transition as Enhancement
292
+
293
+ ```js
294
+ // Router integration example (works with any framework)
295
+ async function navigateTo(url) {
296
+ const response = await fetch(url);
297
+ const html = await response.text();
298
+ const parser = new DOMParser();
299
+ const doc = parser.parseFromString(html, 'text/html');
300
+
301
+ const updateDOM = () => {
302
+ document.title = doc.title;
303
+ document.querySelector('main').replaceWith(
304
+ doc.querySelector('main')
305
+ );
306
+ };
307
+
308
+ if (document.startViewTransition) {
309
+ document.startViewTransition(updateDOM);
310
+ } else {
311
+ updateDOM();
312
+ }
313
+ }
314
+ ```
315
+
316
+ ```css
317
+ /* Cross-document: progressive by nature */
318
+ @view-transition { navigation: auto; }
319
+
320
+ /* Reduce motion: respect user preferences */
321
+ @media (prefers-reduced-motion: reduce) {
322
+ ::view-transition-group(*),
323
+ ::view-transition-old(*),
324
+ ::view-transition-new(*) {
325
+ animation-duration: 0.01ms !important;
326
+ }
327
+ }
328
+ ```
329
+
330
+ ### Strategy 3: @starting-style + Popover API
331
+
332
+ Full native modal with enter/exit animation, zero JavaScript.
333
+
334
+ ```html
335
+ <button popovertarget="menu">Open</button>
336
+
337
+ <div id="menu" popover>
338
+ <p>Menu content</p>
339
+ </div>
340
+ ```
341
+
342
+ ```css
343
+ [popover] {
344
+ /* Open state */
345
+ opacity: 1;
346
+ transform: translateY(0) scale(1);
347
+ transition: opacity 250ms ease, transform 250ms ease,
348
+ display 250ms allow-discrete, overlay 250ms allow-discrete;
349
+
350
+ /* Entry animation */
351
+ @starting-style {
352
+ opacity: 0;
353
+ transform: translateY(-0.5rem) scale(0.97);
354
+ }
355
+ }
356
+
357
+ /* Exit animation */
358
+ [popover]:not(:popover-open) {
359
+ opacity: 0;
360
+ transform: translateY(-0.5rem) scale(0.97);
361
+ }
362
+ ```
363
+
364
+ ### Strategy 4: Anchor + Popover Combo (Animated Tooltip)
365
+
366
+ ```html
367
+ <button anchor="tip" popovertarget="tip">Hover me</button>
368
+
369
+ <div id="tip" popover="hint" anchor="trigger">
370
+ Tooltip content
371
+ </div>
372
+ ```
373
+
374
+ ```css
375
+ [popover="hint"] {
376
+ position: fixed;
377
+ position-anchor: --trigger;
378
+ position-area: top center;
379
+ margin-bottom: 0.5rem;
380
+
381
+ /* Animation */
382
+ opacity: 1;
383
+ transform: translateY(0);
384
+ transition: opacity 150ms ease, transform 150ms ease,
385
+ display 150ms allow-discrete, overlay 150ms allow-discrete;
386
+
387
+ @starting-style {
388
+ opacity: 0;
389
+ transform: translateY(4px);
390
+ }
391
+
392
+ position-try-fallbacks: --bottom, --left, --right;
393
+ }
394
+
395
+ @position-try --bottom {
396
+ position-area: bottom center;
397
+ margin-top: 0.5rem;
398
+ }
399
+ @position-try --left {
400
+ position-area: left center;
401
+ margin-right: 0.5rem;
402
+ }
403
+ @position-try --right {
404
+ position-area: right center;
405
+ margin-left: 0.5rem;
406
+ }
407
+
408
+ /* Respect reduced motion */
409
+ @media (prefers-reduced-motion: reduce) {
410
+ [popover="hint"] {
411
+ transition-duration: 0.01ms;
412
+ }
413
+ }
414
+ ```
415
+
416
+ ---
417
+
418
+ ## Accessibility Checklist
419
+
420
+ ```css
421
+ /* ALWAYS include this in any project with animations */
422
+ @media (prefers-reduced-motion: reduce) {
423
+ *,
424
+ *::before,
425
+ *::after {
426
+ animation-duration: 0.01ms !important;
427
+ animation-iteration-count: 1 !important;
428
+ transition-duration: 0.01ms !important;
429
+ scroll-behavior: auto !important;
430
+ }
431
+ }
432
+ ```
433
+
434
+ For scroll-driven animations specifically:
435
+
436
+ ```css
437
+ @media (prefers-reduced-motion: reduce) {
438
+ .reveal {
439
+ animation: none;
440
+ opacity: 1;
441
+ transform: none;
442
+ }
443
+ }
444
+ ```
445
+
446
+ ---
447
+
448
+ ## Performance Notes
449
+
450
+ | Property | Rendering Cost | GPU Composited |
451
+ |---|---|---|
452
+ | `transform` | Low | Yes |
453
+ | `opacity` | Low | Yes |
454
+ | `filter` / `backdrop-filter` | Medium | Yes |
455
+ | `clip-path` | Medium | Yes (in most browsers) |
456
+ | `background` (gradients) | Medium | No — repaint |
457
+ | `width` / `height` | High | No — reflow + repaint |
458
+ | `top` / `left` / `right` / `bottom` | High | No — reflow + repaint |
459
+ | `box-shadow` | High | No — repaint |
460
+
461
+ Best practices:
462
+ - Use `will-change` sparingly and only on elements about to animate — never `will-change: transform` on 50 elements
463
+ - Prefer `translate`, `scale`, `rotate` individual properties over `transform` shorthand when only one axis changes (allows independent transitions)
464
+ - For scroll-driven animations, the browser automatically optimizes — no `will-change` needed
465
+ - Test with Chrome DevTools > Rendering > "Highlight areas outside the compositing layers" to verify GPU compositing
@@ -0,0 +1,187 @@
1
+ ---
2
+ name: framer-motion
3
+ description: "Framer Motion / Motion sub-skill - AnimatePresence, layout animations, gestures, motion values."
4
+ ---
5
+
6
+ # Framer Motion — Sub-skill
7
+
8
+ > Package: `motion` (v11+, formerly `framer-motion`). Import: `import { motion, AnimatePresence } from "motion/react"`
9
+
10
+ ## When to use Framer Motion vs alternatives
11
+
12
+ | Criteria | Framer Motion | GSAP | Native CSS |
13
+ |---------|--------------|------|-----------|
14
+ | Layout animations | Excellent (layoutId) | Manual | Impossible |
15
+ | Exit animations | AnimatePresence | Timeline reverse | Limited (display) |
16
+ | Gestures (drag, hover) | Native, declarative | Draggable plugin | Basic |
17
+ | Scroll-driven | useScroll + useTransform | ScrollTrigger (more powerful) | scroll-timeline |
18
+ | Complex orchestration | Variants + propagation | Timeline (more flexible) | @keyframes |
19
+ | Bundle size | ~50kb tree-shaken | ~30kb core | 0kb |
20
+ | React integration | Native, component-first | Refs + useGSAP | className toggle |
21
+
22
+ **Rule**: Framer Motion for React UI interactions (modals, toasts, reorder, shared layout). GSAP for complex timelines, cinematic scroll-driven, SVG morphing.
23
+
24
+ ## AnimatePresence — Exit animations
25
+
26
+ ```tsx
27
+ <AnimatePresence mode="wait">
28
+ {isVisible && (
29
+ <motion.div
30
+ key="unique-key" // REQUIRED — identifies the component
31
+ initial={{ opacity: 0 }}
32
+ animate={{ opacity: 1 }}
33
+ exit={{ opacity: 0 }}
34
+ />
35
+ )}
36
+ </AnimatePresence>
37
+ ```
38
+
39
+ - `mode="wait"` — waits for exit to finish before enter (page transitions)
40
+ - `mode="sync"` — exit and enter simultaneously
41
+ - `mode="popLayout"` — removes from flow immediately (good for lists)
42
+ - `onExitComplete` — callback when all exit animations are finished
43
+
44
+ ## Layout animations
45
+
46
+ ```tsx
47
+ // Shared layout — the element "slides" between two positions
48
+ <motion.div layoutId="highlight" className={activeTab === id ? "active" : ""} />
49
+
50
+ // Auto layout — animates position/size when layout changes
51
+ <motion.div layout>
52
+ {isExpanded && <motion.p layout>Additional content</motion.p>}
53
+ </motion.div>
54
+
55
+ // layout="position" — animates position only (not size)
56
+ // layout="size" — animates size only
57
+ // layout="preserve-aspect" — preserves the ratio during the transition
58
+ ```
59
+
60
+ ## Variants — Propagation and orchestration
61
+
62
+ ```tsx
63
+ const container = {
64
+ hidden: { opacity: 0 },
65
+ show: {
66
+ opacity: 1,
67
+ transition: {
68
+ staggerChildren: 0.08,
69
+ delayChildren: 0.2,
70
+ staggerDirection: 1, // 1 = normal, -1 = reverse
71
+ },
72
+ },
73
+ };
74
+
75
+ const item = {
76
+ hidden: { opacity: 0, y: 20 },
77
+ show: { opacity: 1, y: 0 },
78
+ };
79
+
80
+ <motion.ul variants={container} initial="hidden" animate="show">
81
+ {items.map((i) => (
82
+ <motion.li key={i.id} variants={item} />
83
+ ))}
84
+ </motion.ul>
85
+ ```
86
+
87
+ Variants **automatically propagate** to motion children — no need for `initial`/`animate` on children.
88
+
89
+ ## Gestures
90
+
91
+ ```tsx
92
+ <motion.div
93
+ whileHover={{ scale: 1.05 }}
94
+ whileTap={{ scale: 0.95 }}
95
+ whileFocus={{ borderColor: "#3b82f6" }}
96
+ // Drag
97
+ drag // true = x+y, "x" = horizontal only, "y" = vertical only
98
+ dragConstraints={{ left: -100, right: 100, top: -50, bottom: 50 }}
99
+ dragElastic={0.2} // 0 = rigid, 1 = free (default 0.35)
100
+ dragSnapToOrigin // returns to initial position
101
+ onDragEnd={(e, info) => {
102
+ if (info.offset.x > 100) handleSwipe("right");
103
+ }}
104
+ />
105
+ ```
106
+
107
+ ## Motion values — Reactive without re-render
108
+
109
+ ```tsx
110
+ const x = useMotionValue(0);
111
+ const opacity = useTransform(x, [-200, 0, 200], [0, 1, 0]);
112
+ const background = useTransform(x, [-200, 200], ["#ff0000", "#00ff00"]);
113
+
114
+ // Spring-based smoothing
115
+ const smoothX = useSpring(x, { stiffness: 300, damping: 30 });
116
+
117
+ // Scroll tracking
118
+ const { scrollY, scrollYProgress } = useScroll();
119
+ const parallaxY = useTransform(scrollYProgress, [0, 1], [0, -300]);
120
+
121
+ // Element-scoped scroll
122
+ const ref = useRef(null);
123
+ const { scrollYProgress } = useScroll({
124
+ target: ref,
125
+ offset: ["start end", "end start"],
126
+ });
127
+ ```
128
+
129
+ **Motion values do NOT trigger React re-renders** — they update the DOM directly via `style`.
130
+
131
+ ## Do Not
132
+
133
+ ### Do not setState in callbacks without a guard
134
+
135
+ ```tsx
136
+ // BAD — infinite re-render if animate depends on state
137
+ onUpdate={(latest) => setPosition(latest.x)}
138
+
139
+ // GOOD — guard or useMotionValueEvent
140
+ const x = useMotionValue(0);
141
+ useMotionValueEvent(x, "change", (latest) => {
142
+ if (latest > threshold) onThresholdReached();
143
+ });
144
+ ```
145
+
146
+ ### Do not use layout animation without a stable key
147
+
148
+ ```tsx
149
+ // BAD — key changes every render, breaks layout tracking
150
+ <motion.div layout key={Math.random()} />
151
+
152
+ // GOOD — stable key derived from data
153
+ <motion.div layout key={item.id} />
154
+ ```
155
+
156
+ ### Do not forget the unique key on AnimatePresence
157
+
158
+ ```tsx
159
+ // BAD — no key, exit animation does not trigger
160
+ <AnimatePresence>
161
+ {isOpen && <motion.div exit={{ opacity: 0 }} />}
162
+ </AnimatePresence>
163
+
164
+ // GOOD — unique key for each conditional child
165
+ <AnimatePresence>
166
+ {isOpen && <motion.div key="modal" exit={{ opacity: 0 }} />}
167
+ </AnimatePresence>
168
+ ```
169
+
170
+ ### Do not wrap an already animated component with motion.div
171
+
172
+ ```tsx
173
+ // BAD — double animation, transform conflicts
174
+ <motion.div animate={{ x: 100 }}>
175
+ <motion.div animate={{ x: -50 }}>Content</motion.div>
176
+ </motion.div>
177
+
178
+ // GOOD — single animation level per transform axis
179
+ <motion.div animate={{ x: 100 }}>
180
+ <motion.div animate={{ opacity: 0.5 }}>Content</motion.div>
181
+ </motion.div>
182
+
183
+ // GOOD — use variants to coordinate parent/child
184
+ <motion.div variants={parent} animate="active">
185
+ <motion.div variants={child} />
186
+ </motion.div>
187
+ ```