@ziamana/bruine 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +315 -0
- package/THIRD_PARTY_NOTICES.md +24 -0
- package/cordis.patch.yml +166 -0
- package/dist/bin.js +5358 -0
- package/dist/compat.js +40 -0
- package/dist/plugins/approval.js +147 -0
- package/dist/plugins/headless.js +236 -0
- package/dist/plugins/herdr.js +470 -0
- package/dist/plugins/mcp.js +275 -0
- package/dist/plugins/modes.js +850 -0
- package/dist/plugins/render.js +3723 -0
- package/dist/plugins/repl.js +9589 -0
- package/dist/plugins/silence.js +234 -0
- package/dist/plugins/startup.js +42 -0
- package/dist/plugins/web-search.js +138 -0
- package/package.json +93 -0
- package/skills/code-review/SKILL.md +30 -0
- package/skills/git-workflow/SKILL.md +31 -0
- package/skills/impeccable/LICENSE +191 -0
- package/skills/impeccable/NOTICE.md +11 -0
- package/skills/impeccable/SKILL.md +87 -0
- package/skills/impeccable/reference/adapt.md +318 -0
- package/skills/impeccable/reference/adapt.native.md +58 -0
- package/skills/impeccable/reference/android.md +46 -0
- package/skills/impeccable/reference/animate.md +89 -0
- package/skills/impeccable/reference/audit.md +137 -0
- package/skills/impeccable/reference/audit.native.md +139 -0
- package/skills/impeccable/reference/bolder.md +33 -0
- package/skills/impeccable/reference/clarify.md +94 -0
- package/skills/impeccable/reference/colorize.md +86 -0
- package/skills/impeccable/reference/component-review.md +63 -0
- package/skills/impeccable/reference/craft-floor.md +44 -0
- package/skills/impeccable/reference/craft.md +5 -0
- package/skills/impeccable/reference/critique.md +806 -0
- package/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- package/skills/impeccable/reference/degraded/documenter.md +24 -0
- package/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -0
- package/skills/impeccable/reference/delight.md +70 -0
- package/skills/impeccable/reference/distill.md +111 -0
- package/skills/impeccable/reference/doctor.md +54 -0
- package/skills/impeccable/reference/document.md +416 -0
- package/skills/impeccable/reference/extract.md +69 -0
- package/skills/impeccable/reference/generate.md +101 -0
- package/skills/impeccable/reference/harden.md +345 -0
- package/skills/impeccable/reference/hooks.md +113 -0
- package/skills/impeccable/reference/init.md +131 -0
- package/skills/impeccable/reference/ios.md +51 -0
- package/skills/impeccable/reference/layout.md +84 -0
- package/skills/impeccable/reference/live-setup.md +104 -0
- package/skills/impeccable/reference/live.md +325 -0
- package/skills/impeccable/reference/mode-operate.md +21 -0
- package/skills/impeccable/reference/mode-persuade.md +19 -0
- package/skills/impeccable/reference/mode-read.md +21 -0
- package/skills/impeccable/reference/new-work.md +154 -0
- package/skills/impeccable/reference/onboard.md +234 -0
- package/skills/impeccable/reference/operate.md +61 -0
- package/skills/impeccable/reference/optimize.md +258 -0
- package/skills/impeccable/reference/overdrive.md +127 -0
- package/skills/impeccable/reference/polish.md +105 -0
- package/skills/impeccable/reference/quieter.md +99 -0
- package/skills/impeccable/reference/region-map.md +26 -0
- package/skills/impeccable/reference/routing.md +24 -0
- package/skills/impeccable/reference/shape.md +59 -0
- package/skills/impeccable/reference/typeset.md +80 -0
- package/skills/impeccable/reference/visualize.md +46 -0
- package/skills/impeccable/scripts/VERSION +1 -0
- package/skills/impeccable/scripts/command-metadata.json +98 -0
- package/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- package/skills/impeccable/scripts/data/font-index.json +1 -0
- package/skills/impeccable/scripts/impeccable +206 -0
- package/skills/impeccable/scripts/impeccable.cmd +214 -0
- package/skills/impeccable/scripts/live-browser-dom.js +167 -0
- package/skills/impeccable/scripts/live-browser-ignores.js +242 -0
- package/skills/impeccable/scripts/live-browser-session.js +148 -0
- package/skills/impeccable/scripts/live-browser.js +13510 -0
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/skills/make-interfaces-feel-better/LICENSE +21 -0
- package/skills/make-interfaces-feel-better/SKILL.md +187 -0
- package/skills/make-interfaces-feel-better/agents/openai.yaml +3 -0
- package/skills/make-interfaces-feel-better/animations.md +403 -0
- package/skills/make-interfaces-feel-better/icons.md +63 -0
- package/skills/make-interfaces-feel-better/performance.md +88 -0
- package/skills/make-interfaces-feel-better/surfaces.md +256 -0
- package/skills/make-interfaces-feel-better/typography.md +157 -0
- package/skills/playwright-cli/LICENSE +201 -0
- package/skills/playwright-cli/SKILL.md +489 -0
- package/skills/playwright-cli/references/element-attributes.md +23 -0
- package/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/skills/playwright-cli/references/pr-attachments.md +60 -0
- package/skills/playwright-cli/references/request-mocking.md +87 -0
- package/skills/playwright-cli/references/running-code.md +245 -0
- package/skills/playwright-cli/references/session-management.md +227 -0
- package/skills/playwright-cli/references/storage-state.md +275 -0
- package/skills/playwright-cli/references/test-generation.md +433 -0
- package/skills/playwright-cli/references/tracing.md +139 -0
- package/skills/playwright-cli/references/video-recording.md +216 -0
- package/skills/remotion/SKILL.md +42 -0
- package/skills/systematic-debugging/SKILL.md +26 -0
- package/skills/thermo-nuclear-code-quality-review/LICENSE +21 -0
- package/skills/thermo-nuclear-code-quality-review/SKILL.md +192 -0
- package/skills/write-tests/SKILL.md +35 -0
- package/skills/youtube-transcript/LICENSE +21 -0
- package/skills/youtube-transcript/SKILL.md +41 -0
- package/skills/youtube-transcript/package.json +8 -0
- package/skills/youtube-transcript/transcript.js +44 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
# Animations
|
|
2
|
+
|
|
3
|
+
Interruptible animations, enter/exit transitions, contextual icon animations, and motion restraint.
|
|
4
|
+
|
|
5
|
+
## Interruptible Animations
|
|
6
|
+
|
|
7
|
+
Users change intent mid-interaction. If animations aren't interruptible, the interface feels broken.
|
|
8
|
+
|
|
9
|
+
### CSS Transitions vs. Keyframes
|
|
10
|
+
|
|
11
|
+
| | CSS Transitions | CSS Keyframe Animations |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| **Behavior** | Interpolate toward latest state | Run on a fixed timeline |
|
|
14
|
+
| **Interruptible** | Yes — retargets mid-animation | No — restarts from beginning |
|
|
15
|
+
| **Use for** | Interactive state changes (hover, toggle, open/close) | Staged sequences that run once (enter animations, loading) |
|
|
16
|
+
| **Duration** | Fixed; retargets the value mid-flight, not the timeline | Fixed timeline, restarts from the beginning |
|
|
17
|
+
|
|
18
|
+
```css
|
|
19
|
+
/* Good — interruptible transition for a toggle */
|
|
20
|
+
.drawer {
|
|
21
|
+
transform: translateX(-100%);
|
|
22
|
+
transition: transform 200ms ease-out;
|
|
23
|
+
}
|
|
24
|
+
.drawer.open {
|
|
25
|
+
transform: translateX(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Clicking again mid-animation smoothly reverses — no jank */
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
/* Bad — keyframe animation for interactive element */
|
|
33
|
+
.drawer.open {
|
|
34
|
+
animation: slideIn 200ms ease-out forwards;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Closing mid-animation snaps or restarts — feels broken */
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Rule:** Always prefer CSS transitions for interactive elements. Reserve keyframes for one-shot sequences.
|
|
41
|
+
|
|
42
|
+
## Enter Animations: Split and Stagger
|
|
43
|
+
|
|
44
|
+
Use this pattern for infrequent staged entrances where sequence helps communicate hierarchy, such as the first load of a page hero, success state, or empty state. Break a large container into semantic chunks and animate each individually. Do not stagger routine interactions such as row hovers, keystrokes, or repeated tab changes.
|
|
45
|
+
|
|
46
|
+
### Step by Step
|
|
47
|
+
|
|
48
|
+
1. **Split** into logical groups (title, description, buttons)
|
|
49
|
+
2. **Stagger** with ~100ms delay between groups
|
|
50
|
+
3. **For titles**, consider splitting into individual words with ~80ms stagger
|
|
51
|
+
4. **Combine** `opacity`, `blur`, and `translateY` for the enter effect
|
|
52
|
+
|
|
53
|
+
### Code Example
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
// Motion (Framer Motion) — staggered enter
|
|
57
|
+
function PageHeader() {
|
|
58
|
+
return (
|
|
59
|
+
<motion.div
|
|
60
|
+
initial="hidden"
|
|
61
|
+
animate="visible"
|
|
62
|
+
variants={{
|
|
63
|
+
visible: { transition: { staggerChildren: 0.1 } },
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<motion.h1
|
|
67
|
+
variants={{
|
|
68
|
+
hidden: { opacity: 0, y: 12, filter: "blur(4px)" },
|
|
69
|
+
visible: { opacity: 1, y: 0, filter: "blur(0px)" },
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
Welcome
|
|
73
|
+
</motion.h1>
|
|
74
|
+
|
|
75
|
+
<motion.p
|
|
76
|
+
variants={{
|
|
77
|
+
hidden: { opacity: 0, y: 12, filter: "blur(4px)" },
|
|
78
|
+
visible: { opacity: 1, y: 0, filter: "blur(0px)" },
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
A description of the page.
|
|
82
|
+
</motion.p>
|
|
83
|
+
|
|
84
|
+
<motion.div
|
|
85
|
+
variants={{
|
|
86
|
+
hidden: { opacity: 0, y: 12, filter: "blur(4px)" },
|
|
87
|
+
visible: { opacity: 1, y: 0, filter: "blur(0px)" },
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<Button>Get started</Button>
|
|
91
|
+
</motion.div>
|
|
92
|
+
</motion.div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### CSS-Only Stagger
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
.stagger-item {
|
|
101
|
+
opacity: 0;
|
|
102
|
+
transform: translateY(12px);
|
|
103
|
+
filter: blur(4px);
|
|
104
|
+
animation: fadeInUp 400ms ease-out forwards;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.stagger-item:nth-child(1) { animation-delay: 0ms; }
|
|
108
|
+
.stagger-item:nth-child(2) { animation-delay: 100ms; }
|
|
109
|
+
.stagger-item:nth-child(3) { animation-delay: 200ms; }
|
|
110
|
+
|
|
111
|
+
@keyframes fadeInUp {
|
|
112
|
+
to {
|
|
113
|
+
opacity: 1;
|
|
114
|
+
transform: translateY(0);
|
|
115
|
+
filter: blur(0);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Exit Animations
|
|
121
|
+
|
|
122
|
+
Exit animations should be softer and less attention-grabbing than enter animations. The user's focus is moving to the next thing — don't fight for attention.
|
|
123
|
+
|
|
124
|
+
### Subtle Exit (Recommended)
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
// Small fixed translateY — indicates direction without drama
|
|
128
|
+
<motion.div
|
|
129
|
+
exit={{
|
|
130
|
+
opacity: 0,
|
|
131
|
+
y: -12,
|
|
132
|
+
filter: "blur(4px)",
|
|
133
|
+
transition: { duration: 0.15, ease: "easeOut" },
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
{content}
|
|
137
|
+
</motion.div>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Full Exit (When Context Matters)
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
// Slide fully out — use when spatial context is important
|
|
144
|
+
// (e.g., a card returning to a list, a drawer closing)
|
|
145
|
+
<motion.div
|
|
146
|
+
exit={{
|
|
147
|
+
opacity: 0,
|
|
148
|
+
x: "-100%",
|
|
149
|
+
transition: { duration: 0.2, ease: "easeOut" },
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
{content}
|
|
153
|
+
</motion.div>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Good vs. Bad
|
|
157
|
+
|
|
158
|
+
```css
|
|
159
|
+
/* Good — subtle exit */
|
|
160
|
+
.item-exit {
|
|
161
|
+
opacity: 0;
|
|
162
|
+
transform: translateY(-12px);
|
|
163
|
+
transition: opacity 150ms ease-out, transform 150ms ease-out;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* Bad — dramatic exit that steals focus */
|
|
167
|
+
.item-exit {
|
|
168
|
+
opacity: 0;
|
|
169
|
+
transform: translateY(-100%) scale(0.5);
|
|
170
|
+
transition: all 400ms ease-out;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* Sometimes correct — remove immediately when motion adds no context */
|
|
174
|
+
.item-exit {
|
|
175
|
+
display: none;
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Key points:**
|
|
180
|
+
- Use a small fixed `translateY` (e.g., `-12px`) instead of the full container height
|
|
181
|
+
- Keep some directional movement to indicate where the element went
|
|
182
|
+
- Exit duration should be shorter than enter duration (150ms vs 300ms)
|
|
183
|
+
- Use a subtle exit when it preserves spatial context. Remove immediately when motion adds no information, the interaction repeats frequently, or reduced motion is requested.
|
|
184
|
+
|
|
185
|
+
## Contextual Icon Animations
|
|
186
|
+
|
|
187
|
+
When icons appear or disappear contextually (on hover, on state change), animate them with `opacity`, `scale`, and `blur` rather than just toggling visibility.
|
|
188
|
+
|
|
189
|
+
### Motion Example
|
|
190
|
+
|
|
191
|
+
This example uses the `motion` package. If the project instead has `framer-motion`, import the same APIs from `"framer-motion"`; never mix an installed package with the other package's import path.
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
195
|
+
|
|
196
|
+
function IconButton({ isActive, icon: Icon }) {
|
|
197
|
+
return (
|
|
198
|
+
<button>
|
|
199
|
+
<AnimatePresence mode="popLayout">
|
|
200
|
+
<motion.span
|
|
201
|
+
key={isActive ? "active" : "inactive"}
|
|
202
|
+
initial={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
203
|
+
animate={{ opacity: 1, scale: 1, filter: "blur(0px)" }}
|
|
204
|
+
exit={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
205
|
+
transition={{ type: "spring", duration: 0.3, bounce: 0 }}
|
|
206
|
+
>
|
|
207
|
+
<Icon />
|
|
208
|
+
</motion.span>
|
|
209
|
+
</AnimatePresence>
|
|
210
|
+
</button>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### CSS Transition Approach (No Motion)
|
|
216
|
+
|
|
217
|
+
If the project doesn't use Motion (Framer Motion), keep both icons in the DOM and cross-fade them with CSS transitions. Because neither icon unmounts, both enter and exit animate smoothly.
|
|
218
|
+
|
|
219
|
+
The trick: one icon is absolutely positioned on top of the other. Toggling state cross-fades them — the entering icon scales up from `0.25` while the exiting icon scales down to `0.25`, both with opacity and blur.
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
function IconButton({ isActive, ActiveIcon, InactiveIcon }) {
|
|
223
|
+
return (
|
|
224
|
+
<button>
|
|
225
|
+
<div className="relative">
|
|
226
|
+
<div
|
|
227
|
+
className={cn(
|
|
228
|
+
"absolute inset-0 flex items-center justify-center",
|
|
229
|
+
"transition-[opacity,filter,scale] duration-300",
|
|
230
|
+
"ease-[cubic-bezier(0.2,0,0,1)]",
|
|
231
|
+
isActive
|
|
232
|
+
? "scale-100 opacity-100 blur-0"
|
|
233
|
+
: "scale-[0.25] opacity-0 blur-[4px]"
|
|
234
|
+
)}
|
|
235
|
+
>
|
|
236
|
+
<ActiveIcon />
|
|
237
|
+
</div>
|
|
238
|
+
<div
|
|
239
|
+
className={cn(
|
|
240
|
+
"transition-[opacity,filter,scale] duration-300",
|
|
241
|
+
"ease-[cubic-bezier(0.2,0,0,1)]",
|
|
242
|
+
isActive
|
|
243
|
+
? "scale-[0.25] opacity-0 blur-[4px]"
|
|
244
|
+
: "scale-100 opacity-100 blur-0"
|
|
245
|
+
)}
|
|
246
|
+
>
|
|
247
|
+
<InactiveIcon />
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
</button>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
The non-absolute icon (InactiveIcon) defines the layout size. The absolute icon (ActiveIcon) overlays it without affecting flow.
|
|
256
|
+
|
|
257
|
+
### Choosing Between Motion and CSS
|
|
258
|
+
|
|
259
|
+
| | Motion (Framer Motion) | CSS transitions (both icons in DOM) |
|
|
260
|
+
| --- | --- | --- |
|
|
261
|
+
| **Enter animation** | Yes | Yes |
|
|
262
|
+
| **Exit animation** | Yes (via `AnimatePresence`) | Yes (cross-fade — icon never unmounts) |
|
|
263
|
+
| **Spring physics** | Yes | No — use `cubic-bezier(0.2, 0, 0, 1)` as approximation |
|
|
264
|
+
| **When to use** | Project already uses `motion` or `framer-motion` | No motion dependency, or keeping bundle small |
|
|
265
|
+
|
|
266
|
+
**Rule:** Check the project's `package.json`. Import from `"motion/react"` when `motion` is installed, or from `"framer-motion"` when `framer-motion` is installed. If both exist, follow the imports already used by the component or its nearest peers. If neither is present, use the CSS cross-fade pattern — don't add a dependency just for icon transitions.
|
|
267
|
+
|
|
268
|
+
### When to Animate Icons
|
|
269
|
+
|
|
270
|
+
| Animate | Don't animate |
|
|
271
|
+
| --- | --- |
|
|
272
|
+
| Icons that appear on hover (action buttons) | Static navigation icons |
|
|
273
|
+
| State change icons (play → pause, like → liked) | Decorative icons |
|
|
274
|
+
| Icons in contextual toolbars | Icons that are always visible |
|
|
275
|
+
| Loading/success state indicators | Icon labels (text next to icon) |
|
|
276
|
+
|
|
277
|
+
**Important:** Always use exactly these values for contextual icon animations — do not deviate:
|
|
278
|
+
- `scale`: `0.25` → `1` (never use `0.5` or `0.6`)
|
|
279
|
+
- `opacity`: `0` → `1`
|
|
280
|
+
- `filter`: `"blur(4px)"` → `"blur(0px)"`
|
|
281
|
+
- `transition`: `{ type: "spring", duration: 0.3, bounce: 0 }` — **bounce must always be `0`**, never `0.1` or any other value
|
|
282
|
+
|
|
283
|
+
## Scale on Press
|
|
284
|
+
|
|
285
|
+
A subtle scale-down on click gives buttons tactile feedback. Always use `scale(0.96)`. Never use a value smaller than `0.95` — anything below feels exaggerated. Use CSS transitions for interruptibility — if the user releases mid-press, it should smoothly return.
|
|
286
|
+
|
|
287
|
+
Not every button needs this. Add a `static` prop to your button component that disables the scale effect when the motion would be distracting.
|
|
288
|
+
|
|
289
|
+
### CSS Example
|
|
290
|
+
|
|
291
|
+
```css
|
|
292
|
+
.button {
|
|
293
|
+
transition-property: scale;
|
|
294
|
+
transition-duration: 150ms;
|
|
295
|
+
transition-timing-function: ease-out;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.button:active {
|
|
299
|
+
scale: 0.96;
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Tailwind Example
|
|
304
|
+
|
|
305
|
+
```tsx
|
|
306
|
+
<button className="transition-transform duration-150 ease-out active:scale-[0.96]">
|
|
307
|
+
Click me
|
|
308
|
+
</button>
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Motion Example
|
|
312
|
+
|
|
313
|
+
```tsx
|
|
314
|
+
<motion.button whileTap={{ scale: 0.96 }}>
|
|
315
|
+
Click me
|
|
316
|
+
</motion.button>
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Static Prop Pattern
|
|
320
|
+
|
|
321
|
+
Extract the scale class into a variable and conditionally apply it based on a `static` prop:
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
const tapScale = "active:not-disabled:scale-[0.96]";
|
|
325
|
+
|
|
326
|
+
function Button({ static: isStatic, className, children, ...props }) {
|
|
327
|
+
return (
|
|
328
|
+
<button
|
|
329
|
+
className={cn(
|
|
330
|
+
"transition-transform duration-150 ease-out",
|
|
331
|
+
!isStatic && tapScale,
|
|
332
|
+
className,
|
|
333
|
+
)}
|
|
334
|
+
{...props}
|
|
335
|
+
>
|
|
336
|
+
{children}
|
|
337
|
+
</button>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Usage
|
|
342
|
+
<Button>Click me</Button> {/* scales on press */}
|
|
343
|
+
<Button static>Submit</Button> {/* no scale */}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Skip Animation on Page Load
|
|
347
|
+
|
|
348
|
+
Use `initial={false}` on `AnimatePresence` to prevent enter animations from firing on first render. Elements that are already in their default state shouldn't animate in on page load — only on subsequent state changes.
|
|
349
|
+
|
|
350
|
+
### When It Works
|
|
351
|
+
|
|
352
|
+
```tsx
|
|
353
|
+
// Good — icon doesn't animate in on mount, only on state change
|
|
354
|
+
<AnimatePresence initial={false} mode="popLayout">
|
|
355
|
+
<motion.span
|
|
356
|
+
key={isActive ? "active" : "inactive"}
|
|
357
|
+
initial={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
358
|
+
animate={{ opacity: 1, scale: 1, filter: "blur(0px)" }}
|
|
359
|
+
exit={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
360
|
+
>
|
|
361
|
+
<Icon />
|
|
362
|
+
</motion.span>
|
|
363
|
+
</AnimatePresence>
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Works well for: icon swaps, toggles, tabs, segmented controls — anything that has a default state on page load.
|
|
367
|
+
|
|
368
|
+
### When It Breaks
|
|
369
|
+
|
|
370
|
+
Don't use `initial={false}` when the component relies on its `initial` prop to set up a first-time enter animation, like a staggered page hero or a loading state. In those cases, removing the initial animation skips the entire entrance.
|
|
371
|
+
|
|
372
|
+
```tsx
|
|
373
|
+
// Bad — initial={false} would skip the staggered page enter entirely
|
|
374
|
+
<AnimatePresence initial={false}>
|
|
375
|
+
<motion.div initial="hidden" animate="visible" variants={...}>
|
|
376
|
+
...
|
|
377
|
+
</motion.div>
|
|
378
|
+
</AnimatePresence>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Verify the component still looks right on a full page refresh before applying this.
|
|
382
|
+
|
|
383
|
+
## Motion Restraint
|
|
384
|
+
|
|
385
|
+
Motion is a budget, not a garnish:
|
|
386
|
+
|
|
387
|
+
- **No custom animation on high-frequency interactions.** Repeated interactions get instant feedback or a minimal `opacity` or `background-color` transition at ≤150ms.
|
|
388
|
+
- **Motion is never the only feedback channel.** Every animated state change also needs a static cue such as color, icon, or label.
|
|
389
|
+
- **Brief and precise beats prominent.** If a shorter, smaller animation communicates the same thing, use it.
|
|
390
|
+
- **Honor reduced-motion preferences.** Preserve the static cue and remove unnecessary movement.
|
|
391
|
+
|
|
392
|
+
```css
|
|
393
|
+
/* Good: high-frequency hover gets a minimal transition */
|
|
394
|
+
.row:hover {
|
|
395
|
+
background-color: var(--surface-hover);
|
|
396
|
+
transition: background-color 100ms ease-out;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/* Bad: every hover replays a full entrance */
|
|
400
|
+
.row:hover .row-icon {
|
|
401
|
+
animation: bounceIn 500ms;
|
|
402
|
+
}
|
|
403
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Icons
|
|
2
|
+
|
|
3
|
+
Icon weight, states, sizing, and direction: the details that make icons sit naturally in an interface.
|
|
4
|
+
|
|
5
|
+
## Match Icon Stroke to Text Weight
|
|
6
|
+
|
|
7
|
+
An icon next to text should carry the same optical weight as the text.
|
|
8
|
+
|
|
9
|
+
| Adjacent text | Icon stroke width (24px grid) |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| Regular (400), 14–16px | `1.5px` |
|
|
12
|
+
| Medium/Semibold (500–600) | `2px` |
|
|
13
|
+
| Bold (700), or emphasized standalone | `2.5px` |
|
|
14
|
+
|
|
15
|
+
Use one stroke weight per icon set on a surface. Size inline icons relative to the text's cap height, typically `1em`–`1.25em`.
|
|
16
|
+
|
|
17
|
+
## One SVG, Recolored per State
|
|
18
|
+
|
|
19
|
+
Use one SVG drawn with `currentColor`; let CSS drive hover, selected, and disabled states. Strip hardcoded `fill` and `stroke` colors when importing icons.
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<svg fill="none" stroke="currentColor" stroke-width="2">…</svg>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```css
|
|
26
|
+
.icon-button { color: oklch(0.552 0.016 285.938); }
|
|
27
|
+
.icon-button:hover { color: oklch(0.21 0.006 285.885); }
|
|
28
|
+
.icon-button[aria-pressed="true"] { color: oklch(0.623 0.188 259.815); }
|
|
29
|
+
.icon-button:disabled { opacity: 0.4; }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Outline Default, Fill Active
|
|
33
|
+
|
|
34
|
+
| Variant | Use for |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| Outline | Default state: toolbars, list rows, inline with text |
|
|
37
|
+
| Fill | Selected or active state: active tab, toggled bookmark, liked heart |
|
|
38
|
+
|
|
39
|
+
The swap between variants is a contextual icon animation; use the exact cross-fade values in [animations.md](animations.md).
|
|
40
|
+
|
|
41
|
+
## Design at Render Size
|
|
42
|
+
|
|
43
|
+
- Test every icon at the smallest size it will render, often `16px`.
|
|
44
|
+
- Prefer simplified glyphs for small contexts over scaled-down detailed artwork.
|
|
45
|
+
- Use the icon set's native grid sizes (`16`, `20`, `24`) rather than arbitrary fractional scales.
|
|
46
|
+
- Use SVG rather than raster assets.
|
|
47
|
+
|
|
48
|
+
## Icons in RTL
|
|
49
|
+
|
|
50
|
+
| Flip | Don't flip |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| Back/forward arrows, navigation chevrons | Logos and brand marks |
|
|
53
|
+
| Text alignment, lists, indent | Checkmarks |
|
|
54
|
+
| Directional send glyphs | Clocks, cups, pencils |
|
|
55
|
+
| Speaker waves tied to reading direction | Media playback controls |
|
|
56
|
+
|
|
57
|
+
```css
|
|
58
|
+
[dir="rtl"] .icon-directional {
|
|
59
|
+
scale: -1 1;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Analyze composite icons part by part: an overlay may keep its position even when the base glyph flips. Give every icon-only control an accessible name and mark purely decorative icons hidden from assistive technology.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Performance
|
|
2
|
+
|
|
3
|
+
Transition specificity and GPU compositing hints.
|
|
4
|
+
|
|
5
|
+
## Transition Only What Changes
|
|
6
|
+
|
|
7
|
+
Never use `transition: all` or Tailwind's `transition-all`. Always specify the exact properties that change. Tailwind's bare `transition` maps to a curated default list of colors, opacity, shadow, and transforms, not to `all`; still prefer naming exactly what changes.
|
|
8
|
+
|
|
9
|
+
### Why
|
|
10
|
+
|
|
11
|
+
- `transition: all` forces the browser to watch every property for changes
|
|
12
|
+
- Causes unexpected transitions on properties you didn't intend to animate (colors, padding, shadows)
|
|
13
|
+
- Prevents browser optimizations
|
|
14
|
+
|
|
15
|
+
### CSS Example
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
/* Good — only transition what changes */
|
|
19
|
+
.button {
|
|
20
|
+
transition-property: scale, background-color;
|
|
21
|
+
transition-duration: 150ms;
|
|
22
|
+
transition-timing-function: ease-out;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Bad — transition everything */
|
|
26
|
+
.button {
|
|
27
|
+
transition: all 150ms ease-out;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Tailwind
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
// Good — explicit properties
|
|
35
|
+
<button className="transition-[scale,background-color] duration-150 ease-out">
|
|
36
|
+
|
|
37
|
+
// Bad — transition all
|
|
38
|
+
<button className="transition-all duration-150 ease-out">
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Tailwind `transition-transform` Note
|
|
42
|
+
|
|
43
|
+
`transition-transform` in Tailwind maps to `transition-property: transform, translate, scale, rotate` — it covers all transform-related properties, not just `transform`. Use this when you're only animating transforms. For multiple non-transform properties, use the bracket syntax: `transition-[scale,opacity,filter]`.
|
|
44
|
+
|
|
45
|
+
## Use `will-change` Sparingly
|
|
46
|
+
|
|
47
|
+
`will-change` hints the browser to pre-promote an element to its own GPU compositing layer. Without it, the browser promotes the element only when the animation starts — that one-time layer promotion can cause a micro-stutter on the first frame.
|
|
48
|
+
|
|
49
|
+
This particularly helps when an element is changing `scale`, `rotation`, or moving around with `transform`. For other properties, it doesn't help much — the browser can't composite them on the GPU anyway.
|
|
50
|
+
|
|
51
|
+
### Rules
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
/* Good — specific property that benefits from GPU compositing */
|
|
55
|
+
.animated-card {
|
|
56
|
+
will-change: transform;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Good — multiple compositor-friendly properties */
|
|
60
|
+
.animated-card {
|
|
61
|
+
will-change: transform, opacity;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Bad — never use will-change: all */
|
|
65
|
+
.animated-card {
|
|
66
|
+
will-change: all;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Bad — properties that can't be GPU-composited anyway */
|
|
70
|
+
.animated-card {
|
|
71
|
+
will-change: background-color, padding;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Useful Properties
|
|
76
|
+
|
|
77
|
+
| Property | GPU-compositable | Worth using `will-change` |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `transform` | Yes | Yes |
|
|
80
|
+
| `opacity` | Yes | Yes |
|
|
81
|
+
| `filter` (blur, brightness) | Yes | Yes |
|
|
82
|
+
| `clip-path` | Newer Chromium only | Rarely; not reliable cross-browser |
|
|
83
|
+
| `top`, `left`, `width`, `height` | No | No |
|
|
84
|
+
| `background`, `border`, `color` | No | No |
|
|
85
|
+
|
|
86
|
+
### When to Skip
|
|
87
|
+
|
|
88
|
+
Modern browsers are already good at optimizing on their own. Only add `will-change` when you notice first-frame stutter — Safari in particular benefits from it. Don't add it preemptively to every animated element; each extra compositing layer costs memory.
|