@rt-tools/agent-kit 0.32.0 → 0.34.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/README.md +8 -7
- package/assets/agents/goal-critic.md +67 -0
- package/assets/agents/product-strategist.md +90 -0
- package/assets/agents/qa-engineer.md +3 -0
- package/assets/checks/board.github.mjs +27 -0
- package/assets/checks/check-specs.mjs +11 -2
- package/assets/checks/rt-kit-checks.config.mjs +6 -0
- package/assets/checks/spec-common.mjs +6 -3
- package/assets/checks/spec-scenarios.mjs +9 -1
- package/assets/checks/task-new.github.mjs +6 -0
- package/assets/checks/tree-assignment.mjs +11 -3
- package/assets/defaults/project.sh +10 -81
- package/assets/defaults/push.sh +100 -0
- package/assets/docs/GLOSSARY.md +4 -0
- package/assets/hooks/browser-guard-no-other-drivers.sh +6 -3
- package/assets/hooks/claim-guard.sh +6 -6
- package/assets/hooks/dispatch.sh +56 -3
- package/assets/hooks/exam-guard.sh +1 -1
- package/assets/hooks/git-guard-delivery-body.sh +25 -3
- package/assets/hooks/git-guard-delivery-folder.sh +17 -1
- package/assets/hooks/git-guard-delivery-merged.sh +65 -0
- package/assets/hooks/git-guard-delivery-pipeline.sh +99 -0
- package/assets/hooks/git-guard-delivery.sh +22 -8
- package/assets/hooks/git-guard-main.sh +17 -4
- package/assets/hooks/git-guard-push-ahead.sh +89 -0
- package/assets/hooks/git-guard-push-marks.sh +99 -0
- package/assets/hooks/git-guard-push-tests.sh +101 -83
- package/assets/hooks/git-guard-tree-assignment.sh +1 -1
- package/assets/hooks/grill-gate-options.sh +50 -0
- package/assets/hooks/grill-gate.sh +9 -1
- package/assets/hooks/pre-push.sh +113 -0
- package/assets/hooks/push-set.sh +150 -0
- package/assets/hooks/push-sign.sh +433 -0
- package/assets/hooks/rerun-guard.sh +14 -6
- package/assets/hooks/turn-exit-guard.sh +2 -2
- package/assets/hooks/turn-exit-patterns.sh +4 -3
- package/assets/hooks/turn-exit-verdict.sh +18 -1
- package/assets/hooks/waiting-turn-guard.sh +2 -1
- package/assets/hooks/write-targets.sh +21 -0
- package/assets/patterns/dependencies-upgrade.md +5 -1
- package/assets/patterns/git-workflow-commit.github.md +14 -0
- package/assets/patterns/git-workflow-pr-body.github.md +20 -3
- package/assets/patterns/git-workflow-pr.azure.md +30 -0
- package/assets/patterns/git-workflow-pr.github.md +57 -1
- package/assets/patterns/git-workflow-pr.gitlab.md +33 -0
- package/assets/patterns/mockups-measure.needs-mockups.md +19 -3
- package/assets/patterns/reuse-first-extend.md +5 -0
- package/assets/patterns/task-flow-close.md +27 -16
- package/assets/patterns/task-flow-start.md +5 -4
- package/assets/pitfalls/task-flow.md +4 -0
- package/assets/rules/browser-verification.md +4 -0
- package/assets/rules/dependencies.md +3 -1
- package/assets/rules/deploy-flow.azure.md +5 -0
- package/assets/rules/deploy-flow.github.md +5 -0
- package/assets/rules/deploy-flow.gitlab.md +5 -0
- package/assets/rules/git-workflow.azure.md +15 -0
- package/assets/rules/git-workflow.github.md +15 -0
- package/assets/rules/git-workflow.gitlab.md +15 -0
- package/assets/rules/mockups.needs-mockups.md +13 -5
- package/assets/rules/reuse-first.md +3 -0
- package/assets/rules/task-flow.md +21 -16
- package/assets/rules/testing.md +5 -0
- package/assets/samples/tasks/_template/plan.md +7 -0
- package/assets/skills/interface-review-annotate.needs-mockups.md +142 -0
- package/assets/skills/interface-review-icons.needs-app.md +136 -0
- package/assets/skills/interface-review-motion-states.needs-app.md +230 -0
- package/assets/skills/interface-review-motion.needs-app.md +209 -0
- package/assets/skills/interface-review-performance.needs-app.md +110 -0
- package/assets/skills/interface-review-principles.needs-app.md +263 -0
- package/assets/skills/interface-review-surfaces.needs-app.md +249 -0
- package/assets/skills/interface-review.needs-app.md +199 -0
- package/assets/skills/write-a-skill.md +16 -3
- package/assets/workflows/feature.js +33 -5
- package/assets/workflows/plan.js +71 -4
- package/package.json +1 -1
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: interface-review-motion-states
|
|
3
|
+
description: Recipes for animated state changes in an interface review: contextual icon swaps with exact values, scale on press, no animation on page load, with CSS, Tailwind and Motion code. Load when such a finding is worded or fixed. Entrances and exits are in interface-review-motion.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Animated state changes
|
|
7
|
+
|
|
8
|
+
Contextual icon animations, scale on press and skipping animation on page load. Interruptible
|
|
9
|
+
animations, entrances and exits are in `interface-review-motion`; its scope applies here too.
|
|
10
|
+
|
|
11
|
+
## When to use
|
|
12
|
+
|
|
13
|
+
- A finding of `interface-review` is about an icon that pops instead of animating, missing press
|
|
14
|
+
feedback, or a toggle that animates its default state on page load.
|
|
15
|
+
|
|
16
|
+
## Contextual Icon Animations
|
|
17
|
+
|
|
18
|
+
When icons appear or disappear contextually (on hover, on state change), animate them with
|
|
19
|
+
`opacity`, `scale`, and `blur` rather than just toggling visibility.
|
|
20
|
+
|
|
21
|
+
### Motion Example
|
|
22
|
+
|
|
23
|
+
This example uses the `motion` package. If the project instead has `framer-motion`, import the same
|
|
24
|
+
APIs from `"framer-motion"`; never mix an installed package with the other package's import path.
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
28
|
+
|
|
29
|
+
function IconButton({ isActive, icon: Icon }) {
|
|
30
|
+
return (
|
|
31
|
+
<button>
|
|
32
|
+
<AnimatePresence mode="popLayout">
|
|
33
|
+
<motion.span
|
|
34
|
+
key={isActive ? "active" : "inactive"}
|
|
35
|
+
initial={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
36
|
+
animate={{ opacity: 1, scale: 1, filter: "blur(0px)" }}
|
|
37
|
+
exit={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
38
|
+
transition={{ type: "spring", duration: 0.3, bounce: 0 }}
|
|
39
|
+
>
|
|
40
|
+
<Icon />
|
|
41
|
+
</motion.span>
|
|
42
|
+
</AnimatePresence>
|
|
43
|
+
</button>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### CSS Transition Approach (No Motion)
|
|
49
|
+
|
|
50
|
+
If the project doesn't use Motion (Framer Motion), keep both icons in the DOM and cross-fade them
|
|
51
|
+
with CSS transitions. Because neither icon unmounts, both enter and exit animate smoothly.
|
|
52
|
+
|
|
53
|
+
The trick: one icon is absolutely positioned on top of the other. Toggling state cross-fades them:
|
|
54
|
+
the entering icon scales up from `0.25` while the exiting icon scales down to `0.25`, both with
|
|
55
|
+
opacity and blur.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
function IconButton({ isActive, ActiveIcon, InactiveIcon }) {
|
|
59
|
+
return (
|
|
60
|
+
<button>
|
|
61
|
+
<div className="relative">
|
|
62
|
+
<div
|
|
63
|
+
className={cn(
|
|
64
|
+
"absolute inset-0 flex items-center justify-center",
|
|
65
|
+
"transition-[opacity,filter,scale] duration-300",
|
|
66
|
+
"ease-[cubic-bezier(0.2,0,0,1)]",
|
|
67
|
+
isActive
|
|
68
|
+
? "scale-100 opacity-100 blur-0"
|
|
69
|
+
: "scale-[0.25] opacity-0 blur-[4px]"
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
<ActiveIcon />
|
|
73
|
+
</div>
|
|
74
|
+
<div
|
|
75
|
+
className={cn(
|
|
76
|
+
"transition-[opacity,filter,scale] duration-300",
|
|
77
|
+
"ease-[cubic-bezier(0.2,0,0,1)]",
|
|
78
|
+
isActive
|
|
79
|
+
? "scale-[0.25] opacity-0 blur-[4px]"
|
|
80
|
+
: "scale-100 opacity-100 blur-0"
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
<InactiveIcon />
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</button>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The non-absolute icon (InactiveIcon) defines the layout size. The absolute icon (ActiveIcon)
|
|
92
|
+
overlays it without affecting flow.
|
|
93
|
+
|
|
94
|
+
### Choosing Between Motion and CSS
|
|
95
|
+
|
|
96
|
+
| | Motion (Framer Motion) | CSS transitions (both icons in DOM) |
|
|
97
|
+
| --- | --- | --- |
|
|
98
|
+
| **Enter animation** | Yes | Yes |
|
|
99
|
+
| **Exit animation** | Yes (via `AnimatePresence`) | Yes (cross-fade, icon never unmounts) |
|
|
100
|
+
| **Spring physics** | Yes | No, use `cubic-bezier(0.2, 0, 0, 1)` as approximation |
|
|
101
|
+
| **When to use** | Project already uses `motion` or `framer-motion` | No motion dependency, or keeping bundle small |
|
|
102
|
+
|
|
103
|
+
**Rule:** Check the project's `package.json`. Import from `"motion/react"` when `motion` is
|
|
104
|
+
installed, or from `"framer-motion"` when `framer-motion` is installed. If both exist, follow the
|
|
105
|
+
imports already used by the component or its nearest peers. If neither is present, use the CSS
|
|
106
|
+
cross-fade pattern; don't add a dependency just for icon transitions.
|
|
107
|
+
|
|
108
|
+
### When to Animate Icons
|
|
109
|
+
|
|
110
|
+
| Animate | Don't animate |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| Icons that appear on hover (action buttons) | Static navigation icons |
|
|
113
|
+
| State change icons (play → pause, like → liked) | Decorative icons |
|
|
114
|
+
| Icons in contextual toolbars | Icons that are always visible |
|
|
115
|
+
| Loading/success state indicators | Icon labels (text next to icon) |
|
|
116
|
+
|
|
117
|
+
**Important:** Always use exactly these values for contextual icon animations; do not deviate:
|
|
118
|
+
- `scale`: `0.25` → `1` (never use `0.5` or `0.6`)
|
|
119
|
+
- `opacity`: `0` → `1`
|
|
120
|
+
- `filter`: `"blur(4px)"` → `"blur(0px)"`
|
|
121
|
+
- `transition`: `{ type: "spring", duration: 0.3, bounce: 0 }`; **bounce must always be `0`**, never
|
|
122
|
+
`0.1` or any other value
|
|
123
|
+
|
|
124
|
+
## Scale on Press
|
|
125
|
+
|
|
126
|
+
A subtle scale-down on click gives buttons tactile feedback. Always use `scale(0.96)`. Never use a
|
|
127
|
+
value smaller than `0.95`: anything below feels exaggerated. Use CSS transitions for
|
|
128
|
+
interruptibility, so that if the user releases mid-press, it smoothly returns.
|
|
129
|
+
|
|
130
|
+
Not every button needs this. Add a `static` prop to your button component that disables the scale
|
|
131
|
+
effect when the motion would be distracting.
|
|
132
|
+
|
|
133
|
+
### CSS Example
|
|
134
|
+
|
|
135
|
+
```css
|
|
136
|
+
.button {
|
|
137
|
+
transition-property: scale;
|
|
138
|
+
transition-duration: 150ms;
|
|
139
|
+
transition-timing-function: ease-out;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.button:active {
|
|
143
|
+
scale: 0.96;
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Tailwind Example
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<button className="transition-transform duration-150 ease-out active:scale-[0.96]">
|
|
151
|
+
Click me
|
|
152
|
+
</button>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Motion Example
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
<motion.button whileTap={{ scale: 0.96 }}>
|
|
159
|
+
Click me
|
|
160
|
+
</motion.button>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Static Prop Pattern
|
|
164
|
+
|
|
165
|
+
Extract the scale class into a variable and conditionally apply it based on a `static` prop:
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
const tapScale = "active:not-disabled:scale-[0.96]";
|
|
169
|
+
|
|
170
|
+
function Button({ static: isStatic, className, children, ...props }) {
|
|
171
|
+
return (
|
|
172
|
+
<button
|
|
173
|
+
className={cn(
|
|
174
|
+
"transition-transform duration-150 ease-out",
|
|
175
|
+
!isStatic && tapScale,
|
|
176
|
+
className,
|
|
177
|
+
)}
|
|
178
|
+
{...props}
|
|
179
|
+
>
|
|
180
|
+
{children}
|
|
181
|
+
</button>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Usage
|
|
186
|
+
<Button>Click me</Button> {/* scales on press */}
|
|
187
|
+
<Button static>Submit</Button> {/* no scale */}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Skip Animation on Page Load
|
|
191
|
+
|
|
192
|
+
Use `initial={false}` on `AnimatePresence` to prevent enter animations from firing on first render.
|
|
193
|
+
Elements that are already in their default state shouldn't animate in on page load, only on
|
|
194
|
+
subsequent state changes.
|
|
195
|
+
|
|
196
|
+
### When It Works
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
// Good: icon doesn't animate in on mount, only on state change
|
|
200
|
+
<AnimatePresence initial={false} mode="popLayout">
|
|
201
|
+
<motion.span
|
|
202
|
+
key={isActive ? "active" : "inactive"}
|
|
203
|
+
initial={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
204
|
+
animate={{ opacity: 1, scale: 1, filter: "blur(0px)" }}
|
|
205
|
+
exit={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
206
|
+
>
|
|
207
|
+
<Icon />
|
|
208
|
+
</motion.span>
|
|
209
|
+
</AnimatePresence>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Works well for: icon swaps, toggles, tabs, segmented controls: anything that has a default state on
|
|
213
|
+
page load.
|
|
214
|
+
|
|
215
|
+
### When It Breaks
|
|
216
|
+
|
|
217
|
+
Don't use `initial={false}` when the component relies on its `initial` prop to set up a first-time
|
|
218
|
+
enter animation, like a staggered page hero or a loading state. In those cases, removing the initial
|
|
219
|
+
animation skips the entire entrance.
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
// Bad: initial={false} would skip the staggered page enter entirely
|
|
223
|
+
<AnimatePresence initial={false}>
|
|
224
|
+
<motion.div initial="hidden" animate="visible" variants={...}>
|
|
225
|
+
...
|
|
226
|
+
</motion.div>
|
|
227
|
+
</AnimatePresence>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Verify the component still looks right on a full page refresh before applying this.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: interface-review-motion
|
|
3
|
+
description: Motion recipes for an interface review: interruptible transitions, staggered entrances, subtle exits, with CSS and Motion code. Load when a finding about an entrance, an exit or an interrupted animation is worded or fixed. Icon swaps and press feedback are in interface-review-motion-states.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Animations
|
|
7
|
+
|
|
8
|
+
Interruptible animations and enter/exit transitions. Contextual icon animations, scale on press and
|
|
9
|
+
skipping animation on page load are in `interface-review-motion-states`.
|
|
10
|
+
|
|
11
|
+
## When to use
|
|
12
|
+
|
|
13
|
+
- A finding of `interface-review` is about an animation that cannot be interrupted, a jarring
|
|
14
|
+
entrance or a dramatic exit.
|
|
15
|
+
|
|
16
|
+
## Interruptible Animations
|
|
17
|
+
|
|
18
|
+
Users change intent mid-interaction. If animations aren't interruptible, the interface feels broken.
|
|
19
|
+
|
|
20
|
+
### CSS Transitions vs. Keyframes
|
|
21
|
+
|
|
22
|
+
| | CSS Transitions | CSS Keyframe Animations |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| **Behavior** | Interpolate toward latest state | Run on a fixed timeline |
|
|
25
|
+
| **Interruptible** | Yes, retargets mid-animation | No, restarts from beginning |
|
|
26
|
+
| **Use for** | Interactive state changes (hover, toggle, open/close) | Staged sequences that run once (enter animations, loading) |
|
|
27
|
+
| **Duration** | Fixed; retargets the value mid-flight, not the timeline | Fixed timeline, restarts from the beginning |
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
/* Good: interruptible transition for a toggle */
|
|
31
|
+
.drawer {
|
|
32
|
+
transform: translateX(-100%);
|
|
33
|
+
transition: transform 200ms ease-out;
|
|
34
|
+
}
|
|
35
|
+
.drawer.open {
|
|
36
|
+
transform: translateX(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Clicking again mid-animation smoothly reverses, no jank */
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```css
|
|
43
|
+
/* Bad: keyframe animation for interactive element */
|
|
44
|
+
.drawer.open {
|
|
45
|
+
animation: slideIn 200ms ease-out forwards;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Closing mid-animation snaps or restarts, feels broken */
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Rule:** Always prefer CSS transitions for interactive elements. Reserve keyframes for one-shot
|
|
52
|
+
sequences.
|
|
53
|
+
|
|
54
|
+
## Enter Animations: Split and Stagger
|
|
55
|
+
|
|
56
|
+
Use this pattern for infrequent staged entrances where sequence helps communicate hierarchy, such as
|
|
57
|
+
the first load of a page hero, success state, or empty state. Break a large container into semantic
|
|
58
|
+
chunks and animate each individually. Stagger only where the entrance is infrequent; anything the
|
|
59
|
+
user triggers often should animate as one container, or not at all.
|
|
60
|
+
|
|
61
|
+
### Step by Step
|
|
62
|
+
|
|
63
|
+
1. **Split** into logical groups (title, description, buttons)
|
|
64
|
+
2. **Stagger** with ~100ms delay between groups
|
|
65
|
+
3. **For titles**, consider splitting into individual words with ~80ms stagger
|
|
66
|
+
4. **Combine** `opacity`, `blur`, and `translateY` for the enter effect
|
|
67
|
+
|
|
68
|
+
### Code Example
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
// Motion (Framer Motion): staggered enter
|
|
72
|
+
function PageHeader() {
|
|
73
|
+
return (
|
|
74
|
+
<motion.div
|
|
75
|
+
initial="hidden"
|
|
76
|
+
animate="visible"
|
|
77
|
+
variants={{
|
|
78
|
+
visible: { transition: { staggerChildren: 0.1 } },
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
<motion.h1
|
|
82
|
+
variants={{
|
|
83
|
+
hidden: { opacity: 0, y: 12, filter: "blur(4px)" },
|
|
84
|
+
visible: { opacity: 1, y: 0, filter: "blur(0px)" },
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
Welcome
|
|
88
|
+
</motion.h1>
|
|
89
|
+
|
|
90
|
+
<motion.p
|
|
91
|
+
variants={{
|
|
92
|
+
hidden: { opacity: 0, y: 12, filter: "blur(4px)" },
|
|
93
|
+
visible: { opacity: 1, y: 0, filter: "blur(0px)" },
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
A description of the page.
|
|
97
|
+
</motion.p>
|
|
98
|
+
|
|
99
|
+
<motion.div
|
|
100
|
+
variants={{
|
|
101
|
+
hidden: { opacity: 0, y: 12, filter: "blur(4px)" },
|
|
102
|
+
visible: { opacity: 1, y: 0, filter: "blur(0px)" },
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
<Button>Get started</Button>
|
|
106
|
+
</motion.div>
|
|
107
|
+
</motion.div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### CSS-Only Stagger
|
|
113
|
+
|
|
114
|
+
```css
|
|
115
|
+
.stagger-item {
|
|
116
|
+
opacity: 0;
|
|
117
|
+
transform: translateY(12px);
|
|
118
|
+
filter: blur(4px);
|
|
119
|
+
animation: fadeInUp 400ms ease-out forwards;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.stagger-item:nth-child(1) { animation-delay: 0ms; }
|
|
123
|
+
.stagger-item:nth-child(2) { animation-delay: 100ms; }
|
|
124
|
+
.stagger-item:nth-child(3) { animation-delay: 200ms; }
|
|
125
|
+
|
|
126
|
+
@keyframes fadeInUp {
|
|
127
|
+
to {
|
|
128
|
+
opacity: 1;
|
|
129
|
+
transform: translateY(0);
|
|
130
|
+
filter: blur(0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Exit Animations
|
|
136
|
+
|
|
137
|
+
Exit animations should be softer and less attention-grabbing than enter animations. The user's focus
|
|
138
|
+
is moving to the next thing; don't fight for attention.
|
|
139
|
+
|
|
140
|
+
### Subtle Exit (Recommended)
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
// Small fixed translateY: indicates direction without drama
|
|
144
|
+
<motion.div
|
|
145
|
+
exit={{
|
|
146
|
+
opacity: 0,
|
|
147
|
+
y: -12,
|
|
148
|
+
filter: "blur(4px)",
|
|
149
|
+
transition: { duration: 0.15, ease: "easeOut" },
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
{content}
|
|
153
|
+
</motion.div>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Full Exit (When Context Matters)
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
// Slide fully out: use when spatial context is important
|
|
160
|
+
// (e.g., a card returning to a list, a drawer closing)
|
|
161
|
+
<motion.div
|
|
162
|
+
exit={{
|
|
163
|
+
opacity: 0,
|
|
164
|
+
x: "-100%",
|
|
165
|
+
transition: { duration: 0.2, ease: "easeOut" },
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
{content}
|
|
169
|
+
</motion.div>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Good vs. Bad
|
|
173
|
+
|
|
174
|
+
```css
|
|
175
|
+
/* Good: subtle exit */
|
|
176
|
+
.item-exit {
|
|
177
|
+
opacity: 0;
|
|
178
|
+
transform: translateY(-12px);
|
|
179
|
+
transition: opacity 150ms ease-out, transform 150ms ease-out;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* Bad: dramatic exit that steals focus */
|
|
183
|
+
.item-exit {
|
|
184
|
+
opacity: 0;
|
|
185
|
+
transform: translateY(-100%) scale(0.5);
|
|
186
|
+
transition: all 400ms ease-out;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Sometimes correct: remove immediately when motion adds no context */
|
|
190
|
+
.item-exit {
|
|
191
|
+
display: none;
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Key points:**
|
|
196
|
+
- Use a small fixed `translateY` (e.g., `-12px`) instead of the full container height
|
|
197
|
+
- Keep some directional movement to indicate where the element went
|
|
198
|
+
- Exit duration should be shorter than enter duration (150ms vs 300ms)
|
|
199
|
+
- Use a subtle exit when it preserves spatial context. Remove immediately when motion adds no
|
|
200
|
+
information, the interaction repeats frequently, or reduced motion is requested.
|
|
201
|
+
|
|
202
|
+
## Scope
|
|
203
|
+
|
|
204
|
+
Everything in this section assumes the animation belongs. Whether it belongs at all — what it costs
|
|
205
|
+
the user at its trigger frequency, and whether it should be shortened, made one-sided, or deleted —
|
|
206
|
+
is a separate question, and the answer defaults to no.
|
|
207
|
+
|
|
208
|
+
Honoring `prefers-reduced-motion` is covered by the accessibility principles in
|
|
209
|
+
`interface-review-principles`; apply it to every animation in this section.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: interface-review-performance
|
|
3
|
+
description: Performance recipes for an interface review: transition only what changes instead of transition all, and will-change only for compositor properties on a seen stutter. Load when such a finding is worded or fixed. The animations are in interface-review-motion.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Performance
|
|
7
|
+
|
|
8
|
+
Transition specificity and GPU compositing hints.
|
|
9
|
+
|
|
10
|
+
## When to use
|
|
11
|
+
|
|
12
|
+
- A finding of `interface-review` is about `transition: all`, an unintended transition on a
|
|
13
|
+
property nobody meant to animate, a first-frame stutter, or `will-change` on everything.
|
|
14
|
+
|
|
15
|
+
## Transition Only What Changes
|
|
16
|
+
|
|
17
|
+
Never use `transition: all` or Tailwind's `transition-all`. Always specify the exact properties that
|
|
18
|
+
change. (Tailwind's bare `transition` maps to a curated default list of colors, opacity, shadow and
|
|
19
|
+
transforms, not to `all`; still prefer naming exactly what changes.)
|
|
20
|
+
|
|
21
|
+
### Why
|
|
22
|
+
|
|
23
|
+
- `transition: all` forces the browser to watch every property for changes
|
|
24
|
+
- Causes unexpected transitions on properties you didn't intend to animate (colors, padding,
|
|
25
|
+
shadows)
|
|
26
|
+
- Prevents browser optimizations
|
|
27
|
+
|
|
28
|
+
### CSS Example
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
/* Good: only transition what changes */
|
|
32
|
+
.button {
|
|
33
|
+
transition-property: scale, background-color;
|
|
34
|
+
transition-duration: 150ms;
|
|
35
|
+
transition-timing-function: ease-out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Bad: transition everything */
|
|
39
|
+
.button {
|
|
40
|
+
transition: all 150ms ease-out;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Tailwind
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
// Good: explicit properties
|
|
48
|
+
<button className="transition-[scale,background-color] duration-150 ease-out">
|
|
49
|
+
|
|
50
|
+
// Bad: transition all
|
|
51
|
+
<button className="transition-all duration-150 ease-out">
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Tailwind `transition-transform` Note
|
|
55
|
+
|
|
56
|
+
`transition-transform` in Tailwind maps to `transition-property: transform, translate, scale,
|
|
57
|
+
rotate`, so it covers all transform-related properties, not just `transform`. Use this when you're
|
|
58
|
+
only animating transforms. For multiple non-transform properties, use the bracket syntax:
|
|
59
|
+
`transition-[scale,opacity,filter]`.
|
|
60
|
+
|
|
61
|
+
## Use `will-change` Sparingly
|
|
62
|
+
|
|
63
|
+
`will-change` hints the browser to pre-promote an element to its own GPU compositing layer. Without
|
|
64
|
+
it, the browser promotes the element only when the animation starts; that one-time layer promotion
|
|
65
|
+
can cause a micro-stutter on the first frame.
|
|
66
|
+
|
|
67
|
+
This particularly helps when an element is changing `scale`, `rotation`, or moving around with
|
|
68
|
+
`transform`. For other properties, it doesn't help much: the browser can't composite them on the GPU
|
|
69
|
+
anyway.
|
|
70
|
+
|
|
71
|
+
### Rules
|
|
72
|
+
|
|
73
|
+
```css
|
|
74
|
+
/* Good: specific property that benefits from GPU compositing */
|
|
75
|
+
.animated-card {
|
|
76
|
+
will-change: transform;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Good: multiple compositor-friendly properties */
|
|
80
|
+
.animated-card {
|
|
81
|
+
will-change: transform, opacity;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Bad: never use will-change: all */
|
|
85
|
+
.animated-card {
|
|
86
|
+
will-change: all;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Bad: properties that can't be GPU-composited anyway */
|
|
90
|
+
.animated-card {
|
|
91
|
+
will-change: background-color, padding;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Useful Properties
|
|
96
|
+
|
|
97
|
+
| Property | GPU-compositable | Worth using `will-change` |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| `transform` | Yes | Yes |
|
|
100
|
+
| `opacity` | Yes | Yes |
|
|
101
|
+
| `filter` (blur, brightness) | Yes | Yes |
|
|
102
|
+
| `clip-path` | Newer Chromium only | Rarely; not reliable cross-browser |
|
|
103
|
+
| `top`, `left`, `width`, `height` | No | No |
|
|
104
|
+
| `background`, `border`, `color` | No | No |
|
|
105
|
+
|
|
106
|
+
### When to Skip
|
|
107
|
+
|
|
108
|
+
Modern browsers are already good at optimizing on their own. Only add `will-change` when you notice
|
|
109
|
+
first-frame stutter; Safari in particular benefits from it. Don't add it preemptively to every
|
|
110
|
+
animated element; each extra compositing layer costs memory.
|