tribunal-kit 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/history/architecture-explorer.html +352 -0
- package/.agent/history/architecture-graph.yaml +109 -0
- package/.agent/history/graph-cache.json +215 -0
- package/.agent/history/snapshots/migrate_refs.js.json +11 -0
- package/.agent/history/snapshots/scripts__changelog.js.json +12 -0
- package/.agent/history/snapshots/scripts__sync-version.js.json +11 -0
- package/.agent/history/snapshots/scripts__validate-payload.js.json +11 -0
- package/.agent/history/snapshots/test__integration__bridges.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__init.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__routing.test.js.json +11 -0
- package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__wave2.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__args.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__copyDir.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__semver.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +11 -0
- package/.agent/scripts/case_law_manager.js +684 -684
- package/.agent/scripts/dependency_analyzer.js +1 -1
- package/.agent/scripts/graph_builder.js +311 -0
- package/.agent/scripts/graph_visualizer.js +384 -0
- package/.agent/scripts/graph_zoom.js +154 -0
- package/.agent/scripts/mutation_runner.js +280 -0
- package/.agent/skills/agent-organizer/SKILL.md +9 -1
- package/.agent/skills/agentic-patterns/SKILL.md +9 -1
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +9 -1
- package/.agent/skills/api-patterns/SKILL.md +206 -198
- package/.agent/skills/api-security-auditor/SKILL.md +9 -1
- package/.agent/skills/app-builder/SKILL.md +9 -1
- package/.agent/skills/app-builder/templates/SKILL.md +77 -69
- package/.agent/skills/appflow-wireframe/SKILL.md +9 -1
- package/.agent/skills/architecture/SKILL.md +9 -1
- package/.agent/skills/authentication-best-practices/SKILL.md +9 -1
- package/.agent/skills/bash-linux/SKILL.md +9 -1
- package/.agent/skills/behavioral-modes/SKILL.md +9 -1
- package/.agent/skills/brainstorming/SKILL.md +9 -1
- package/.agent/skills/building-native-ui/SKILL.md +9 -1
- package/.agent/skills/clean-code/SKILL.md +9 -1
- package/.agent/skills/code-review-checklist/SKILL.md +9 -1
- package/.agent/skills/config-validator/SKILL.md +9 -1
- package/.agent/skills/csharp-developer/SKILL.md +9 -1
- package/.agent/skills/data-validation-schemas/SKILL.md +287 -279
- package/.agent/skills/database-design/SKILL.md +199 -191
- package/.agent/skills/deployment-procedures/SKILL.md +9 -1
- package/.agent/skills/devops-engineer/SKILL.md +9 -1
- package/.agent/skills/devops-incident-responder/SKILL.md +9 -1
- package/.agent/skills/documentation-templates/SKILL.md +9 -1
- package/.agent/skills/edge-computing/SKILL.md +9 -1
- package/.agent/skills/error-resilience/SKILL.md +387 -379
- package/.agent/skills/extract-design-system/SKILL.md +9 -1
- package/.agent/skills/framer-motion-expert/SKILL.md +203 -195
- package/.agent/skills/frontend-design/SKILL.md +160 -152
- package/.agent/skills/game-design-expert/SKILL.md +9 -1
- package/.agent/skills/game-engineering-expert/SKILL.md +9 -1
- package/.agent/skills/geo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/github-operations/SKILL.md +9 -1
- package/.agent/skills/gsap-core/SKILL.md +54 -46
- package/.agent/skills/gsap-frameworks/SKILL.md +54 -46
- package/.agent/skills/gsap-performance/SKILL.md +54 -46
- package/.agent/skills/gsap-plugins/SKILL.md +54 -46
- package/.agent/skills/gsap-react/SKILL.md +54 -46
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -46
- package/.agent/skills/gsap-timeline/SKILL.md +54 -46
- package/.agent/skills/gsap-utils/SKILL.md +54 -46
- package/.agent/skills/i18n-localization/SKILL.md +9 -1
- package/.agent/skills/intelligent-routing/SKILL.md +38 -30
- package/.agent/skills/knowledge-graph/SKILL.md +52 -0
- package/.agent/skills/lint-and-validate/SKILL.md +9 -1
- package/.agent/skills/llm-engineering/SKILL.md +9 -1
- package/.agent/skills/local-first/SKILL.md +9 -1
- package/.agent/skills/mcp-builder/SKILL.md +9 -1
- package/.agent/skills/mobile-design/SKILL.md +222 -214
- package/.agent/skills/monorepo-management/SKILL.md +293 -285
- package/.agent/skills/motion-engineering/SKILL.md +193 -185
- package/.agent/skills/nextjs-react-expert/SKILL.md +193 -185
- package/.agent/skills/nodejs-best-practices/SKILL.md +9 -1
- package/.agent/skills/observability/SKILL.md +9 -1
- package/.agent/skills/parallel-agents/SKILL.md +9 -1
- package/.agent/skills/performance-profiling/SKILL.md +9 -1
- package/.agent/skills/plan-writing/SKILL.md +9 -1
- package/.agent/skills/platform-engineer/SKILL.md +9 -1
- package/.agent/skills/playwright-best-practices/SKILL.md +9 -1
- package/.agent/skills/powershell-windows/SKILL.md +9 -1
- package/.agent/skills/project-idioms/SKILL.md +9 -1
- package/.agent/skills/python-patterns/SKILL.md +9 -1
- package/.agent/skills/python-pro/SKILL.md +282 -274
- package/.agent/skills/react-specialist/SKILL.md +236 -228
- package/.agent/skills/readme-builder/SKILL.md +9 -1
- package/.agent/skills/realtime-patterns/SKILL.md +9 -1
- package/.agent/skills/red-team-tactics/SKILL.md +9 -1
- package/.agent/skills/rust-pro/SKILL.md +9 -1
- package/.agent/skills/seo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/server-management/SKILL.md +9 -1
- package/.agent/skills/shadcn-ui-expert/SKILL.md +9 -1
- package/.agent/skills/skill-creator/SKILL.md +9 -1
- package/.agent/skills/sql-pro/SKILL.md +9 -1
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +9 -1
- package/.agent/skills/swiftui-expert/SKILL.md +9 -1
- package/.agent/skills/systematic-debugging/SKILL.md +9 -1
- package/.agent/skills/tailwind-patterns/SKILL.md +9 -1
- package/.agent/skills/tdd-workflow/SKILL.md +9 -1
- package/.agent/skills/test-result-analyzer/SKILL.md +9 -1
- package/.agent/skills/testing-patterns/SKILL.md +28 -3
- package/.agent/skills/trend-researcher/SKILL.md +9 -1
- package/.agent/skills/typescript-advanced/SKILL.md +294 -286
- package/.agent/skills/ui-ux-pro-max/SKILL.md +561 -116
- package/.agent/skills/ui-ux-researcher/SKILL.md +9 -1
- package/.agent/skills/vue-expert/SKILL.md +234 -226
- package/.agent/skills/vulnerability-scanner/SKILL.md +9 -1
- package/.agent/skills/web-accessibility-auditor/SKILL.md +9 -1
- package/.agent/skills/web-design-guidelines/SKILL.md +9 -1
- package/.agent/skills/webapp-testing/SKILL.md +9 -1
- package/.agent/skills/whimsy-injector/SKILL.md +9 -1
- package/.agent/skills/workflow-optimizer/SKILL.md +9 -1
- package/README.md +242 -242
- package/bin/tribunal-kit.js +157 -21
- package/package.json +81 -80
- package/scripts/validate-payload.js +73 -0
|
@@ -147,4 +147,12 @@ Review these questions before confirming output:
|
|
|
147
147
|
|
|
148
148
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
149
149
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
150
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
150
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
## Pre-Flight Checklist
|
|
154
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
155
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
156
|
+
|
|
157
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
158
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|
|
@@ -1,197 +1,197 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: framer-motion-expert
|
|
3
|
-
description: Framer Motion 12+ for React. Declarative animations, layout transitions, gestures, scroll-linked motion, AnimatePresence, useAnimate, LazyMotion. Use when building component animations, page transitions, shared layout animations, or gesture-driven UI.
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
-
version: 3.1.0
|
|
6
|
-
last-updated: 2026-04-06
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Framer Motion 12+ — Dense Reference
|
|
10
|
-
|
|
11
|
-
## Hallucination Traps (Read First)
|
|
12
|
-
- ❌ `<Motion>` (capital M) → ✅ `motion.div` (lowercase dot notation)
|
|
13
|
-
- ❌ `motion()` wrapper function → ✅ `motion.div`, `motion.span`, etc.
|
|
14
|
-
- ❌ `exitBeforeEnter` prop → ✅ `mode="wait"` on `<AnimatePresence>` (removed in FM7+)
|
|
15
|
-
- ❌ `exit` works without `<AnimatePresence>` → ✅ REQUIRES AnimatePresence wrapper
|
|
16
|
-
- ❌ `<AnimatePresence>` children without unique `key` → ✅ ALWAYS set `key`
|
|
17
|
-
- ❌ `stiffness + damping` AND `duration + bounce` together → ✅ pick ONE pair
|
|
18
|
-
- ❌ `m.div` without `<LazyMotion>` wrapper → ✅ REQUIRES LazyMotion parent
|
|
19
|
-
- ❌ `layout` animations with `domAnimation` feature set → ✅ requires `domMax`
|
|
20
|
-
- ❌ Force-animating `width`/`height`/`top`/`left` → ✅ use `x`,`y`,`scale`,`opacity` (GPU)
|
|
21
|
-
- ❌ `viewport.once` defaults to true → ✅ defaults to **false** — add `once: true` for entrance anims
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## Core Primitives
|
|
26
|
-
|
|
27
|
-
### `motion.X` / Declarative Animation
|
|
28
|
-
```tsx
|
|
29
|
-
import { motion } from "framer-motion";
|
|
30
|
-
<motion.div
|
|
31
|
-
initial={{ opacity: 0, y: 20 }}
|
|
32
|
-
animate={{ opacity: 1, y: 0 }}
|
|
33
|
-
exit={{ opacity: 0, y: -20 }}
|
|
34
|
-
transition={{ duration: 0.3, ease: "easeOut" }}
|
|
35
|
-
/>
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Variants (Stagger / Orchestration)
|
|
39
|
-
```tsx
|
|
40
|
-
const container = {
|
|
41
|
-
hidden: {},
|
|
42
|
-
visible: { transition: { staggerChildren: 0.08, delayChildren: 0.1 } },
|
|
43
|
-
};
|
|
44
|
-
const item = {
|
|
45
|
-
hidden: { opacity: 0, y: 20, filter: "blur(4px)" },
|
|
46
|
-
visible: { opacity: 1, y: 0, filter: "blur(0px)", transition: { duration: 0.4 } },
|
|
47
|
-
};
|
|
48
|
-
<motion.ul variants={container} initial="hidden" animate="visible">
|
|
49
|
-
{list.map(e => <motion.li key={e.id} variants={item}>{e.name}</motion.li>)}
|
|
50
|
-
</motion.ul>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Transitions
|
|
54
|
-
```tsx
|
|
55
|
-
// Tween (default)
|
|
56
|
-
transition={{ duration: 0.5, ease: "easeInOut", delay: 0.2, repeat: Infinity, repeatType: "reverse" }}
|
|
57
|
-
// Spring (physics)
|
|
58
|
-
transition={{ type: "spring", stiffness: 300, damping: 20 }} // OR use duration+bounce, not both
|
|
59
|
-
transition={{ type: "spring", duration: 0.8, bounce: 0.25 }}
|
|
60
|
-
// Per-property
|
|
61
|
-
transition={{ x: { type: "spring", stiffness: 300 }, opacity: { duration: 0.2 } }}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## Gestures
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
// Hover/Tap/Focus
|
|
70
|
-
<motion.button
|
|
71
|
-
whileHover={{ scale: 1.05 }}
|
|
72
|
-
whileTap={{ scale: 0.95 }}
|
|
73
|
-
whileFocus={{ boxShadow: "0 0 0 3px rgba(66,153,225,0.6)" }}
|
|
74
|
-
transition={{ type: "spring", stiffness: 400, damping: 15 }}
|
|
75
|
-
/>
|
|
76
|
-
// Drag
|
|
77
|
-
<motion.div
|
|
78
|
-
drag="x" // "x" | "y" | true
|
|
79
|
-
dragConstraints={{ left: -100, right: 100 }}
|
|
80
|
-
dragElastic={0.2} // 0=hard stop, 1=free
|
|
81
|
-
dragMomentum={true}
|
|
82
|
-
dragSnapToOrigin
|
|
83
|
-
/>
|
|
84
|
-
// Scroll-triggered
|
|
85
|
-
<motion.div
|
|
86
|
-
initial={{ opacity: 0, y: 50 }}
|
|
87
|
-
whileInView={{ opacity: 1, y: 0 }}
|
|
88
|
-
viewport={{ once: true, amount: 0.3 }} // ← once: true is almost always what you want
|
|
89
|
-
/>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
---
|
|
93
|
-
|
|
94
|
-
## Layout Animations
|
|
95
|
-
|
|
96
|
-
```tsx
|
|
97
|
-
// layout prop — auto-animates position/size changes
|
|
98
|
-
<motion.div layout transition={{ type: "spring", stiffness: 200 }}>
|
|
99
|
-
{/* layout="position" = only position, layout="size" = only size */}
|
|
100
|
-
</motion.div>
|
|
101
|
-
|
|
102
|
-
// layoutId — shared element transition (morph between renders)
|
|
103
|
-
// List thumbnail → expanded modal:
|
|
104
|
-
<motion.div key={item.id} layoutId={`card-${item.id}`} /> // in list
|
|
105
|
-
<motion.div layoutId={`card-${selectedId}`} className="modal" /> // in modal
|
|
106
|
-
// ❌ TRAP: Cross-tree layoutId requires <LayoutGroup> wrapper
|
|
107
|
-
import { LayoutGroup } from "framer-motion";
|
|
108
|
-
<LayoutGroup><Sidebar /><MainContent /></LayoutGroup>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### AnimatePresence
|
|
112
|
-
```tsx
|
|
113
|
-
<AnimatePresence mode="sync"> {/* "sync"|"wait"|"popLayout" */}
|
|
114
|
-
{items.map(item => (
|
|
115
|
-
<motion.div key={item.id} /* ← REQUIRED */
|
|
116
|
-
initial={{ opacity: 0, height: 0 }}
|
|
117
|
-
animate={{ opacity: 1, height: "auto" }}
|
|
118
|
-
exit={{ opacity: 0, height: 0 }}
|
|
119
|
-
/>
|
|
120
|
-
))}
|
|
121
|
-
</AnimatePresence>
|
|
122
|
-
// mode="wait" — waits for exit before entering
|
|
123
|
-
// initial={false} on AnimatePresence — skip first-render animation
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## Scroll Animations
|
|
129
|
-
|
|
130
|
-
```tsx
|
|
131
|
-
import { useScroll, useTransform } from "framer-motion";
|
|
132
|
-
// Page scroll progress (0–1)
|
|
133
|
-
const { scrollYProgress } = useScroll();
|
|
134
|
-
const y = useTransform(scrollYProgress, [0, 1], [0, -200]);
|
|
135
|
-
const opacity = useTransform(scrollYProgress, [0, 0.5], [1, 0]);
|
|
136
|
-
<motion.div style={{ y, opacity }} />
|
|
137
|
-
|
|
138
|
-
// Element-scoped scroll
|
|
139
|
-
const ref = useRef(null);
|
|
140
|
-
const { scrollYProgress } = useScroll({ target: ref, offset: ["start end", "end start"] });
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
## Hooks
|
|
146
|
-
|
|
147
|
-
### `useAnimate` — Imperative sequences
|
|
148
|
-
```tsx
|
|
149
|
-
import { useAnimate, stagger } from "framer-motion";
|
|
150
|
-
const [scope, animate] = useAnimate(); // ← returns [scope, animate] NOT [ref, controls]
|
|
151
|
-
await animate(".item", { opacity: 1 }, { delay: stagger(0.1) });
|
|
152
|
-
<div ref={scope}>...</div>
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### `useMotionValue` + `useTransform` — No re-renders
|
|
156
|
-
```tsx
|
|
157
|
-
const x = useMotionValue(0);
|
|
158
|
-
const rotateY = useTransform(x, [-200, 200], [-45, 45]);
|
|
159
|
-
// ✅ useMotionValue does NOT trigger React re-renders — key perf advantage over useState
|
|
160
|
-
<motion.div style={{ x, rotateY }} drag="x" />
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### `useSpring` / `useVelocity`
|
|
164
|
-
```tsx
|
|
165
|
-
const springX = useSpring(x, { stiffness: 300, damping: 30 });
|
|
166
|
-
const xVel = useVelocity(x);
|
|
167
|
-
const skewX = useTransform(xVel, [-1000, 0, 1000], [-15, 0, 15]);
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## Performance & Bundle
|
|
173
|
-
|
|
174
|
-
```tsx
|
|
175
|
-
// LazyMotion — ~5KB vs ~30KB full bundle
|
|
176
|
-
import { LazyMotion, domAnimation, m } from "framer-motion";
|
|
177
|
-
// domAnimation ≈ 5KB | domMax ≈ 20KB (needed for layout/drag)
|
|
178
|
-
<LazyMotion features={domAnimation}><m.div animate={{ opacity: 1 }} /></LazyMotion>
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Accessibility
|
|
182
|
-
```tsx
|
|
183
|
-
import { useReducedMotion } from "framer-motion";
|
|
184
|
-
const reduce = useReducedMotion();
|
|
185
|
-
// opacity/color: always safe | position/scale/rotation: must be disabled when reduce=true
|
|
186
|
-
<motion.div animate={{ x: reduce ? 0 : 100, opacity: 1 }} transition={{ duration: reduce ? 0 : 0.5 }} />
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### Rules
|
|
190
|
-
- ✅ Animate: `x`, `y`, `scale`, `rotation`, `opacity` (GPU composited)
|
|
191
|
-
- ❌ Never animate: `width`, `height`, `top`, `left`, `padding`, `margin` (causes layout thrashing)
|
|
192
|
-
- ✅ `useMotionValue` for animation-driven values — never `useState`
|
|
193
|
-
- ❌ Nest `AnimatePresence` only when necessary — each adds reconciler overhead
|
|
194
|
-
- `"use client"` required in Next.js — `motion.div` cannot run in Server Components
|
|
1
|
+
---
|
|
2
|
+
name: framer-motion-expert
|
|
3
|
+
description: Framer Motion 12+ for React. Declarative animations, layout transitions, gestures, scroll-linked motion, AnimatePresence, useAnimate, LazyMotion. Use when building component animations, page transitions, shared layout animations, or gesture-driven UI.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
version: 3.1.0
|
|
6
|
+
last-updated: 2026-04-06
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Framer Motion 12+ — Dense Reference
|
|
10
|
+
|
|
11
|
+
## Hallucination Traps (Read First)
|
|
12
|
+
- ❌ `<Motion>` (capital M) → ✅ `motion.div` (lowercase dot notation)
|
|
13
|
+
- ❌ `motion()` wrapper function → ✅ `motion.div`, `motion.span`, etc.
|
|
14
|
+
- ❌ `exitBeforeEnter` prop → ✅ `mode="wait"` on `<AnimatePresence>` (removed in FM7+)
|
|
15
|
+
- ❌ `exit` works without `<AnimatePresence>` → ✅ REQUIRES AnimatePresence wrapper
|
|
16
|
+
- ❌ `<AnimatePresence>` children without unique `key` → ✅ ALWAYS set `key`
|
|
17
|
+
- ❌ `stiffness + damping` AND `duration + bounce` together → ✅ pick ONE pair
|
|
18
|
+
- ❌ `m.div` without `<LazyMotion>` wrapper → ✅ REQUIRES LazyMotion parent
|
|
19
|
+
- ❌ `layout` animations with `domAnimation` feature set → ✅ requires `domMax`
|
|
20
|
+
- ❌ Force-animating `width`/`height`/`top`/`left` → ✅ use `x`,`y`,`scale`,`opacity` (GPU)
|
|
21
|
+
- ❌ `viewport.once` defaults to true → ✅ defaults to **false** — add `once: true` for entrance anims
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Core Primitives
|
|
26
|
+
|
|
27
|
+
### `motion.X` / Declarative Animation
|
|
28
|
+
```tsx
|
|
29
|
+
import { motion } from "framer-motion";
|
|
30
|
+
<motion.div
|
|
31
|
+
initial={{ opacity: 0, y: 20 }}
|
|
32
|
+
animate={{ opacity: 1, y: 0 }}
|
|
33
|
+
exit={{ opacity: 0, y: -20 }}
|
|
34
|
+
transition={{ duration: 0.3, ease: "easeOut" }}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Variants (Stagger / Orchestration)
|
|
39
|
+
```tsx
|
|
40
|
+
const container = {
|
|
41
|
+
hidden: {},
|
|
42
|
+
visible: { transition: { staggerChildren: 0.08, delayChildren: 0.1 } },
|
|
43
|
+
};
|
|
44
|
+
const item = {
|
|
45
|
+
hidden: { opacity: 0, y: 20, filter: "blur(4px)" },
|
|
46
|
+
visible: { opacity: 1, y: 0, filter: "blur(0px)", transition: { duration: 0.4 } },
|
|
47
|
+
};
|
|
48
|
+
<motion.ul variants={container} initial="hidden" animate="visible">
|
|
49
|
+
{list.map(e => <motion.li key={e.id} variants={item}>{e.name}</motion.li>)}
|
|
50
|
+
</motion.ul>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Transitions
|
|
54
|
+
```tsx
|
|
55
|
+
// Tween (default)
|
|
56
|
+
transition={{ duration: 0.5, ease: "easeInOut", delay: 0.2, repeat: Infinity, repeatType: "reverse" }}
|
|
57
|
+
// Spring (physics)
|
|
58
|
+
transition={{ type: "spring", stiffness: 300, damping: 20 }} // OR use duration+bounce, not both
|
|
59
|
+
transition={{ type: "spring", duration: 0.8, bounce: 0.25 }}
|
|
60
|
+
// Per-property
|
|
61
|
+
transition={{ x: { type: "spring", stiffness: 300 }, opacity: { duration: 0.2 } }}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Gestures
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
// Hover/Tap/Focus
|
|
70
|
+
<motion.button
|
|
71
|
+
whileHover={{ scale: 1.05 }}
|
|
72
|
+
whileTap={{ scale: 0.95 }}
|
|
73
|
+
whileFocus={{ boxShadow: "0 0 0 3px rgba(66,153,225,0.6)" }}
|
|
74
|
+
transition={{ type: "spring", stiffness: 400, damping: 15 }}
|
|
75
|
+
/>
|
|
76
|
+
// Drag
|
|
77
|
+
<motion.div
|
|
78
|
+
drag="x" // "x" | "y" | true
|
|
79
|
+
dragConstraints={{ left: -100, right: 100 }}
|
|
80
|
+
dragElastic={0.2} // 0=hard stop, 1=free
|
|
81
|
+
dragMomentum={true}
|
|
82
|
+
dragSnapToOrigin
|
|
83
|
+
/>
|
|
84
|
+
// Scroll-triggered
|
|
85
|
+
<motion.div
|
|
86
|
+
initial={{ opacity: 0, y: 50 }}
|
|
87
|
+
whileInView={{ opacity: 1, y: 0 }}
|
|
88
|
+
viewport={{ once: true, amount: 0.3 }} // ← once: true is almost always what you want
|
|
89
|
+
/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Layout Animations
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// layout prop — auto-animates position/size changes
|
|
98
|
+
<motion.div layout transition={{ type: "spring", stiffness: 200 }}>
|
|
99
|
+
{/* layout="position" = only position, layout="size" = only size */}
|
|
100
|
+
</motion.div>
|
|
101
|
+
|
|
102
|
+
// layoutId — shared element transition (morph between renders)
|
|
103
|
+
// List thumbnail → expanded modal:
|
|
104
|
+
<motion.div key={item.id} layoutId={`card-${item.id}`} /> // in list
|
|
105
|
+
<motion.div layoutId={`card-${selectedId}`} className="modal" /> // in modal
|
|
106
|
+
// ❌ TRAP: Cross-tree layoutId requires <LayoutGroup> wrapper
|
|
107
|
+
import { LayoutGroup } from "framer-motion";
|
|
108
|
+
<LayoutGroup><Sidebar /><MainContent /></LayoutGroup>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### AnimatePresence
|
|
112
|
+
```tsx
|
|
113
|
+
<AnimatePresence mode="sync"> {/* "sync"|"wait"|"popLayout" */}
|
|
114
|
+
{items.map(item => (
|
|
115
|
+
<motion.div key={item.id} /* ← REQUIRED */
|
|
116
|
+
initial={{ opacity: 0, height: 0 }}
|
|
117
|
+
animate={{ opacity: 1, height: "auto" }}
|
|
118
|
+
exit={{ opacity: 0, height: 0 }}
|
|
119
|
+
/>
|
|
120
|
+
))}
|
|
121
|
+
</AnimatePresence>
|
|
122
|
+
// mode="wait" — waits for exit before entering
|
|
123
|
+
// initial={false} on AnimatePresence — skip first-render animation
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Scroll Animations
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import { useScroll, useTransform } from "framer-motion";
|
|
132
|
+
// Page scroll progress (0–1)
|
|
133
|
+
const { scrollYProgress } = useScroll();
|
|
134
|
+
const y = useTransform(scrollYProgress, [0, 1], [0, -200]);
|
|
135
|
+
const opacity = useTransform(scrollYProgress, [0, 0.5], [1, 0]);
|
|
136
|
+
<motion.div style={{ y, opacity }} />
|
|
137
|
+
|
|
138
|
+
// Element-scoped scroll
|
|
139
|
+
const ref = useRef(null);
|
|
140
|
+
const { scrollYProgress } = useScroll({ target: ref, offset: ["start end", "end start"] });
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Hooks
|
|
146
|
+
|
|
147
|
+
### `useAnimate` — Imperative sequences
|
|
148
|
+
```tsx
|
|
149
|
+
import { useAnimate, stagger } from "framer-motion";
|
|
150
|
+
const [scope, animate] = useAnimate(); // ← returns [scope, animate] NOT [ref, controls]
|
|
151
|
+
await animate(".item", { opacity: 1 }, { delay: stagger(0.1) });
|
|
152
|
+
<div ref={scope}>...</div>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### `useMotionValue` + `useTransform` — No re-renders
|
|
156
|
+
```tsx
|
|
157
|
+
const x = useMotionValue(0);
|
|
158
|
+
const rotateY = useTransform(x, [-200, 200], [-45, 45]);
|
|
159
|
+
// ✅ useMotionValue does NOT trigger React re-renders — key perf advantage over useState
|
|
160
|
+
<motion.div style={{ x, rotateY }} drag="x" />
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### `useSpring` / `useVelocity`
|
|
164
|
+
```tsx
|
|
165
|
+
const springX = useSpring(x, { stiffness: 300, damping: 30 });
|
|
166
|
+
const xVel = useVelocity(x);
|
|
167
|
+
const skewX = useTransform(xVel, [-1000, 0, 1000], [-15, 0, 15]);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Performance & Bundle
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
// LazyMotion — ~5KB vs ~30KB full bundle
|
|
176
|
+
import { LazyMotion, domAnimation, m } from "framer-motion";
|
|
177
|
+
// domAnimation ≈ 5KB | domMax ≈ 20KB (needed for layout/drag)
|
|
178
|
+
<LazyMotion features={domAnimation}><m.div animate={{ opacity: 1 }} /></LazyMotion>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Accessibility
|
|
182
|
+
```tsx
|
|
183
|
+
import { useReducedMotion } from "framer-motion";
|
|
184
|
+
const reduce = useReducedMotion();
|
|
185
|
+
// opacity/color: always safe | position/scale/rotation: must be disabled when reduce=true
|
|
186
|
+
<motion.div animate={{ x: reduce ? 0 : 100, opacity: 1 }} transition={{ duration: reduce ? 0 : 0.5 }} />
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Rules
|
|
190
|
+
- ✅ Animate: `x`, `y`, `scale`, `rotation`, `opacity` (GPU composited)
|
|
191
|
+
- ❌ Never animate: `width`, `height`, `top`, `left`, `padding`, `margin` (causes layout thrashing)
|
|
192
|
+
- ✅ `useMotionValue` for animation-driven values — never `useState`
|
|
193
|
+
- ❌ Nest `AnimatePresence` only when necessary — each adds reconciler overhead
|
|
194
|
+
- `"use client"` required in Next.js — `motion.div` cannot run in Server Components
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
---
|
|
@@ -233,4 +233,12 @@ Review these questions before confirming output:
|
|
|
233
233
|
|
|
234
234
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
235
235
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
236
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
236
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
## Pre-Flight Checklist
|
|
240
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
241
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
242
|
+
|
|
243
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
244
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|