agy-superpowers 5.1.1 → 5.1.3
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 +22 -2
- package/package.json +1 -1
- package/template/agent/.shared/mobile-uiux-promax/data/accessibility.csv +25 -0
- package/template/agent/.shared/mobile-uiux-promax/data/animation.csv +22 -0
- package/template/agent/.shared/mobile-uiux-promax/data/components.csv +21 -0
- package/template/agent/.shared/mobile-uiux-promax/data/gestures.csv +26 -0
- package/template/agent/.shared/mobile-uiux-promax/data/layout.csv +21 -0
- package/template/agent/.shared/mobile-uiux-promax/data/navigation.csv +27 -0
- package/template/agent/.shared/mobile-uiux-promax/data/onboarding.csv +17 -0
- package/template/agent/.shared/mobile-uiux-promax/data/platform.csv +22 -0
- package/template/agent/.shared/mobile-uiux-promax/data/stacks/flutter.csv +19 -0
- package/template/agent/.shared/mobile-uiux-promax/data/stacks/jetpack-compose.csv +18 -0
- package/template/agent/.shared/mobile-uiux-promax/data/stacks/react-native.csv +20 -0
- package/template/agent/.shared/mobile-uiux-promax/data/stacks/swiftui.csv +18 -0
- package/template/agent/.shared/mobile-uiux-promax/data/ux-laws.csv +16 -0
- package/template/agent/.shared/mobile-uiux-promax/scripts/mobile-search.py +157 -0
- package/template/agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/template/agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/template/agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/template/agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/template/agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/template/agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/template/agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/template/agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/template/agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/template/agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/template/agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/template/agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/template/agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/template/agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/template/agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/template/agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/template/agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/template/agent/.shared/ui-ux-pro-max/scripts/core.py +236 -0
- package/template/agent/.shared/ui-ux-pro-max/scripts/search.py +61 -0
- package/template/agent/.tests/TESTS.md +119 -0
- package/template/agent/.tests/mobile-uiux-promax/test_search.py +266 -0
- package/template/agent/.tests/run_tests.py +86 -0
- package/template/agent/patches/skills-patches.md +20 -0
- package/template/agent/skills/brainstorming/SKILL.md +57 -0
- package/template/agent/skills/frontend-design/SKILL.md +147 -0
- package/template/agent/skills/frontend-design/reference/color-and-contrast.md +117 -0
- package/template/agent/skills/frontend-design/reference/interaction-design.md +159 -0
- package/template/agent/skills/frontend-design/reference/motion-design.md +150 -0
- package/template/agent/skills/frontend-design/reference/responsive-design.md +161 -0
- package/template/agent/skills/frontend-design/reference/spatial-design.md +122 -0
- package/template/agent/skills/frontend-design/reference/typography.md +124 -0
- package/template/agent/skills/frontend-design/reference/ux-writing.md +127 -0
- package/template/agent/skills/mobile-uiux-promax/SKILL.md +139 -0
- package/template/agent/skills/subagent-driven-development/implementer-prompt.md +4 -1
- package/template/agent/skills/verification-before-completion/SKILL.md +11 -0
- package/template/agent/skills/writing-plans/SKILL.md +4 -1
- package/template/agent/workflows/mobile-uiux-promax.md +137 -0
- package/template/agent/workflows/ui-ux-pro-max.md +231 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Color & Contrast
|
|
2
|
+
|
|
3
|
+
## Color Spaces: Use OKLCH
|
|
4
|
+
|
|
5
|
+
**Stop using HSL.** Use OKLCH (or LCH) instead. It's perceptually uniform — equal steps in lightness *look* equal, unlike HSL where 50% lightness in yellow looks bright while 50% in blue looks dark.
|
|
6
|
+
|
|
7
|
+
```css
|
|
8
|
+
/* OKLCH: lightness (0-100%), chroma (0-0.4+), hue (0-360) */
|
|
9
|
+
--color-primary: oklch(60% 0.15 250); /* Blue */
|
|
10
|
+
--color-primary-light: oklch(85% 0.08 250); /* Same hue, lighter */
|
|
11
|
+
--color-primary-dark: oklch(35% 0.12 250); /* Same hue, darker */
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Key insight**: As you move toward white or black, reduce chroma. High chroma at extreme lightness looks garish. A light blue at 85% lightness needs ~0.08 chroma, not the 0.15 of your base color.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Building Functional Palettes
|
|
19
|
+
|
|
20
|
+
### The Tinted Neutral Trick
|
|
21
|
+
**Pure gray is dead.** Add a subtle hint of your brand hue to all neutrals:
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
/* Dead grays */
|
|
25
|
+
--gray-100: oklch(95% 0 0); /* No personality */
|
|
26
|
+
--gray-900: oklch(15% 0 0);
|
|
27
|
+
|
|
28
|
+
/* Warm-tinted grays */
|
|
29
|
+
--gray-100: oklch(95% 0.01 60); /* Hint of warmth */
|
|
30
|
+
--gray-900: oklch(15% 0.01 60);
|
|
31
|
+
|
|
32
|
+
/* Cool-tinted grays (tech, professional) */
|
|
33
|
+
--gray-100: oklch(95% 0.01 250); /* Hint of blue */
|
|
34
|
+
--gray-900: oklch(15% 0.01 250);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The chroma is tiny (0.01) but perceptible. It creates subconscious cohesion between your brand color and UI.
|
|
38
|
+
|
|
39
|
+
### Palette Structure
|
|
40
|
+
| Role | Purpose | Example |
|
|
41
|
+
|------|---------|---------|
|
|
42
|
+
| **Primary** | Brand, CTAs, key actions | 1 color, 3–5 shades |
|
|
43
|
+
| **Neutral** | Text, backgrounds, borders | 9–11 shade scale |
|
|
44
|
+
| **Semantic** | Success, error, warning, info | 4 colors, 2–3 shades each |
|
|
45
|
+
| **Surface** | Cards, modals, overlays | 2–3 elevation levels |
|
|
46
|
+
|
|
47
|
+
Skip secondary/tertiary unless you need them. Most apps work fine with one accent color.
|
|
48
|
+
|
|
49
|
+
### The 60-30-10 Rule (Applied Correctly)
|
|
50
|
+
This rule is about **visual weight**, not pixel count:
|
|
51
|
+
- **60%**: Neutral backgrounds, white space, base surfaces
|
|
52
|
+
- **30%**: Secondary — text, borders, inactive states
|
|
53
|
+
- **10%**: Accent — CTAs, highlights, focus states
|
|
54
|
+
|
|
55
|
+
The common mistake: using accent everywhere because it's "the brand color." Accent colors work *because* they're rare. Overuse kills their power.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Contrast & Accessibility
|
|
60
|
+
|
|
61
|
+
### WCAG Requirements
|
|
62
|
+
| Content Type | AA Minimum | AAA Target |
|
|
63
|
+
|--------------|------------|------------|
|
|
64
|
+
| Body text | 4.5:1 | 7:1 |
|
|
65
|
+
| Large text (18px+ or 14px bold) | 3:1 | 4.5:1 |
|
|
66
|
+
| UI components, icons | 3:1 | 4.5:1 |
|
|
67
|
+
| Decorative elements | None | None |
|
|
68
|
+
|
|
69
|
+
**The gotcha**: Placeholder text still needs 4.5:1. That light gray placeholder you see everywhere? Usually fails WCAG.
|
|
70
|
+
|
|
71
|
+
### Dangerous Color Combinations
|
|
72
|
+
- Light gray text on white (the #1 accessibility fail)
|
|
73
|
+
- **Gray text on any colored background** — looks washed out; use a darker shade of the background color
|
|
74
|
+
- Red on green (or vice versa) — 8% of men can't distinguish
|
|
75
|
+
- Blue on red background (vibrates visually)
|
|
76
|
+
- Yellow text on white (almost always fails)
|
|
77
|
+
|
|
78
|
+
### Never Use Pure Gray or Pure Black
|
|
79
|
+
Pure gray and `#000` don't exist in nature — real shadows always have a color cast. Even chroma of 0.005–0.01 feels natural without being obviously tinted.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Theming: Light & Dark Mode
|
|
84
|
+
|
|
85
|
+
### Dark Mode Is Not Inverted Light Mode
|
|
86
|
+
You can't just swap colors. Dark mode requires different design decisions:
|
|
87
|
+
|
|
88
|
+
| Light Mode | Dark Mode |
|
|
89
|
+
|------------|-----------|
|
|
90
|
+
| Shadows for depth | Lighter surfaces for depth (no shadows) |
|
|
91
|
+
| Dark text on light | Light text on dark (reduce font weight slightly) |
|
|
92
|
+
| Vibrant accents | Desaturate accents slightly |
|
|
93
|
+
| White backgrounds | Never pure black — use dark gray (oklch 12–18%) |
|
|
94
|
+
|
|
95
|
+
```css
|
|
96
|
+
/* Dark mode depth via surface color, not shadow */
|
|
97
|
+
[data-theme="dark"] {
|
|
98
|
+
--surface-1: oklch(15% 0.01 250);
|
|
99
|
+
--surface-2: oklch(20% 0.01 250); /* "Higher" = lighter */
|
|
100
|
+
--surface-3: oklch(25% 0.01 250);
|
|
101
|
+
|
|
102
|
+
--body-weight: 350; /* Reduce from 400, perceived weight is lighter */
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Token Hierarchy
|
|
107
|
+
Use two layers: primitive tokens (`--blue-500`) and semantic tokens (`--color-primary: var(--blue-500)`). For dark mode, only redefine the semantic layer.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Alpha Is A Design Smell
|
|
112
|
+
|
|
113
|
+
Heavy use of transparency usually means an incomplete palette. Alpha creates unpredictable contrast, performance overhead, and inconsistency. Define explicit overlay colors for each context. Exception: focus rings and interactive states where see-through is needed.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
**Avoid**: Relying on color alone to convey information. Using pure black (#000) for large areas. Skipping color blindness testing (8% of men affected).
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Interaction Design
|
|
2
|
+
|
|
3
|
+
## Make Interactions Feel Fast
|
|
4
|
+
|
|
5
|
+
Use **optimistic UI** — update immediately, sync later. This is the single biggest perceived-performance improvement you can make.
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
// BAD: Wait for server
|
|
9
|
+
async function likePost(id) {
|
|
10
|
+
const result = await api.like(id);
|
|
11
|
+
setLiked(result.liked);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// GOOD: Optimistic update
|
|
15
|
+
function likePost(id) {
|
|
16
|
+
setLiked(true); // Instant feedback
|
|
17
|
+
api.like(id).catch(() => {
|
|
18
|
+
setLiked(false); // Revert on failure
|
|
19
|
+
showError('Could not save like');
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use optimistic UI for low-stakes actions. Avoid for payments, destructive operations, or anything requiring server validation first.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Progressive Disclosure
|
|
29
|
+
|
|
30
|
+
Start simple, reveal sophistication through interaction:
|
|
31
|
+
|
|
32
|
+
- Basic options visible immediately
|
|
33
|
+
- Advanced options behind expandable sections
|
|
34
|
+
- Hover/focus states reveal secondary actions
|
|
35
|
+
- "Show more" patterns for secondary content
|
|
36
|
+
|
|
37
|
+
This prevents overwhelming users while keeping power-user features accessible.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Form Design
|
|
42
|
+
|
|
43
|
+
### Fields
|
|
44
|
+
- Show format with placeholders, not fixed instruction text (instructions disappear on focus)
|
|
45
|
+
- For non-obvious fields, explain **why** you're asking, not just what to enter
|
|
46
|
+
- Group related fields visually with spacing, not just labels
|
|
47
|
+
- Use `autocomplete` attributes — they're free UX
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<input
|
|
51
|
+
type="email"
|
|
52
|
+
autocomplete="email"
|
|
53
|
+
placeholder="you@company.com"
|
|
54
|
+
aria-describedby="email-hint"
|
|
55
|
+
>
|
|
56
|
+
<span id="email-hint">We'll send your receipt here</span>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Validation
|
|
60
|
+
**Validate on blur, not on keystroke** — keystroke validation creates stress (errors appear before you've finished typing). Clear errors immediately when the user corrects them.
|
|
61
|
+
|
|
62
|
+
```css
|
|
63
|
+
/* Visual validation state */
|
|
64
|
+
input:invalid:not(:focus):not(:placeholder-shown) {
|
|
65
|
+
border-color: oklch(55% 0.2 25);
|
|
66
|
+
background: oklch(98% 0.01 25);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Loading States
|
|
73
|
+
|
|
74
|
+
Three types — use the right one:
|
|
75
|
+
|
|
76
|
+
| State | When | Pattern |
|
|
77
|
+
|-------|------|---------|
|
|
78
|
+
| **Skeleton** | Content structure is known | Placeholder shapes in layout position |
|
|
79
|
+
| **Spinner** | Action feedback (button click) | Small inline spinner, disable button |
|
|
80
|
+
| **Progress** | Long operations | Bar with estimated time if >10s |
|
|
81
|
+
|
|
82
|
+
**Specific loading messages beat generic ones:**
|
|
83
|
+
- `"Saving your draft..."` not `"Loading..."`
|
|
84
|
+
- `"Analyzing 40 files..."` not `"Processing..."`
|
|
85
|
+
- `"This usually takes 30 seconds"` for long waits
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Error States
|
|
90
|
+
|
|
91
|
+
Every error needs: (1) What happened, (2) Why, (3) How to fix it.
|
|
92
|
+
|
|
93
|
+
- `"Email address isn't valid. Please include an @ symbol."` ✅
|
|
94
|
+
- `"Invalid input"` ❌
|
|
95
|
+
|
|
96
|
+
For field errors, place them directly below the field, not in a banner far away.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Empty States
|
|
101
|
+
|
|
102
|
+
Empty states are **onboarding moments**:
|
|
103
|
+
1. Acknowledge briefly ("No projects yet")
|
|
104
|
+
2. Explain the value of filling it
|
|
105
|
+
3. Provide a clear action ("Create your first project →")
|
|
106
|
+
|
|
107
|
+
Empty states that just say "No items found" are missed opportunities.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Focus Management
|
|
112
|
+
|
|
113
|
+
Always visible focus indicators — don't set `outline: none` without providing an alternative.
|
|
114
|
+
|
|
115
|
+
```css
|
|
116
|
+
:focus-visible {
|
|
117
|
+
outline: 2px solid oklch(60% 0.15 250);
|
|
118
|
+
outline-offset: 2px;
|
|
119
|
+
border-radius: 2px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Hide focus ring for mouse users */
|
|
123
|
+
:focus:not(:focus-visible) {
|
|
124
|
+
outline: none;
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Move focus intentionally after actions — after closing a modal, return focus to the trigger. After deleting an item, move focus to the next item.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Button Hierarchy
|
|
133
|
+
|
|
134
|
+
Not every action deserves a primary button. Create clear hierarchy:
|
|
135
|
+
|
|
136
|
+
| Style | Use For | Frequency |
|
|
137
|
+
|-------|---------|-----------|
|
|
138
|
+
| **Primary** (filled) | The one main action | 1 per view |
|
|
139
|
+
| **Secondary** (outlined) | Important but not primary | 2–3 max |
|
|
140
|
+
| **Ghost/text** | Low-priority actions | Multiple OK |
|
|
141
|
+
| **Destructive** (red) | Delete, remove | When needed |
|
|
142
|
+
|
|
143
|
+
Never put two primary buttons side by side — the user can't tell which is "more primary."
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Modals: Use Sparingly
|
|
148
|
+
|
|
149
|
+
Modals are lazy default design. Ask: does this need to interrupt the user? Alternatives:
|
|
150
|
+
- **Inline editing**: Edit in place
|
|
151
|
+
- **Slide-over panel**: For complex forms
|
|
152
|
+
- **Undo**: For destructive actions instead of confirmation
|
|
153
|
+
- **Toast**: For confirmations that don't need user input
|
|
154
|
+
|
|
155
|
+
When you must use a modal: trap focus inside, close on Escape and backdrop click, return focus to trigger on close.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
**Avoid**: Confirming every action with a modal. Showing errors only in banners. Disabled buttons without explanation. Making hover the only way to access functionality (touch users can't hover).
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Motion Design
|
|
2
|
+
|
|
3
|
+
## Duration: The 100/300/500 Rule
|
|
4
|
+
|
|
5
|
+
Timing matters more than easing. These durations feel right for most UI:
|
|
6
|
+
|
|
7
|
+
| Duration | Use Case | Examples |
|
|
8
|
+
|----------|----------|----------|
|
|
9
|
+
| **100–150ms** | Instant feedback | Button press, toggle, color change |
|
|
10
|
+
| **200–300ms** | State changes | Menu open, tooltip, hover states |
|
|
11
|
+
| **300–500ms** | Layout changes | Accordion, modal, drawer |
|
|
12
|
+
| **500–800ms** | Entrance animations | Page load, hero reveals |
|
|
13
|
+
|
|
14
|
+
**Exit animations are faster than entrances** — use ~75% of enter duration.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Easing: Pick the Right Curve
|
|
19
|
+
|
|
20
|
+
**Don't use `ease`.** It's a compromise that's rarely optimal. Instead:
|
|
21
|
+
|
|
22
|
+
| Curve | Use For | CSS |
|
|
23
|
+
|-------|---------|-----|
|
|
24
|
+
| **ease-out** | Elements entering | `cubic-bezier(0.16, 1, 0.3, 1)` |
|
|
25
|
+
| **ease-in** | Elements leaving | `cubic-bezier(0.7, 0, 0.84, 0)` |
|
|
26
|
+
| **ease-in-out** | State toggles (there → back) | `cubic-bezier(0.65, 0, 0.35, 1)` |
|
|
27
|
+
|
|
28
|
+
**For micro-interactions, use exponential curves — they mimic real physics:**
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
--ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1); /* Smooth, refined (recommended) */
|
|
32
|
+
--ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1); /* Slightly more dramatic */
|
|
33
|
+
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1); /* Snappy, confident */
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Avoid bounce and elastic curves.** They were trendy in 2015 but now feel tacky and amateurish. Real objects decelerate smoothly — they don't bounce when they stop.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## The Only Two Properties You Should Animate
|
|
41
|
+
|
|
42
|
+
**`transform` and `opacity` only** — everything else causes layout recalculation.
|
|
43
|
+
|
|
44
|
+
For height animations (accordions, expandables), use `grid-template-rows: 0fr → 1fr` instead of animating `height` directly:
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
.expandable {
|
|
48
|
+
display: grid;
|
|
49
|
+
grid-template-rows: 0fr;
|
|
50
|
+
transition: grid-template-rows 300ms var(--ease-out-quart);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.expandable.open {
|
|
54
|
+
grid-template-rows: 1fr;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.expandable > div {
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Staggered Animations
|
|
65
|
+
|
|
66
|
+
Use CSS custom properties for cleaner stagger:
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
.item {
|
|
70
|
+
animation: slide-up 500ms var(--ease-out-expo) both;
|
|
71
|
+
animation-delay: calc(var(--i, 0) * 50ms);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```html
|
|
76
|
+
<div class="item" style="--i: 0">...</div>
|
|
77
|
+
<div class="item" style="--i: 1">...</div>
|
|
78
|
+
<div class="item" style="--i: 2">...</div>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Cap total stagger time** — 10 items at 50ms = 500ms total. For many items, reduce per-item delay or cap staggered count.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Reduced Motion
|
|
86
|
+
|
|
87
|
+
This is not optional. Vestibular disorders affect ~35% of adults over 40.
|
|
88
|
+
|
|
89
|
+
```css
|
|
90
|
+
/* Define animations normally */
|
|
91
|
+
.card {
|
|
92
|
+
animation: slide-up 500ms ease-out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Provide crossfade alternative */
|
|
96
|
+
@media (prefers-reduced-motion: reduce) {
|
|
97
|
+
.card {
|
|
98
|
+
animation: fade-in 200ms ease-out;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Or disable all motion */
|
|
103
|
+
@media (prefers-reduced-motion: reduce) {
|
|
104
|
+
*, *::before, *::after {
|
|
105
|
+
animation-duration: 0.01ms !important;
|
|
106
|
+
transition-duration: 0.01ms !important;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**What to preserve**: Progress bars, loading spinners (slowed), and focus indicators should still work — just without spatial movement.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Perceived Performance
|
|
116
|
+
|
|
117
|
+
Nobody cares how fast your site is — just how fast it **feels**.
|
|
118
|
+
|
|
119
|
+
**The 80ms threshold**: Anything under 80ms feels instant. This is your target for micro-interactions.
|
|
120
|
+
|
|
121
|
+
**Strategies:**
|
|
122
|
+
- **Optimistic UI**: Update immediately, sync later. Instagram likes work offline — the UI updates instantly. Use for low-stakes actions; avoid for payments or destructive operations.
|
|
123
|
+
- **Skeleton screens**: Show structure before content. Beats blank loading states.
|
|
124
|
+
- **Progressive loading**: Show content as it arrives — don't wait for everything.
|
|
125
|
+
|
|
126
|
+
**Caution**: Too-fast responses can decrease perceived value. Users may distrust instant results for complex operations (search, analysis). Sometimes a brief delay signals "real work" is happening.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Performance
|
|
131
|
+
|
|
132
|
+
Don't use `will-change` preemptively — only when animation is imminent (`:hover`, `.animating`). For scroll-triggered animations, use Intersection Observer instead of scroll events; unobserve after animating once.
|
|
133
|
+
|
|
134
|
+
Create motion tokens for consistency:
|
|
135
|
+
|
|
136
|
+
```css
|
|
137
|
+
:root {
|
|
138
|
+
--duration-instant: 100ms;
|
|
139
|
+
--duration-fast: 200ms;
|
|
140
|
+
--duration-normal: 300ms;
|
|
141
|
+
--duration-slow: 500ms;
|
|
142
|
+
--ease-out: cubic-bezier(0.16, 1, 0.3, 1);
|
|
143
|
+
--ease-in: cubic-bezier(0.7, 0, 0.84, 0);
|
|
144
|
+
--ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
**Avoid**: Animating everything (animation fatigue is real). Using >500ms for UI feedback. Ignoring `prefers-reduced-motion`. Using animation to hide slow loading.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Responsive Design
|
|
2
|
+
|
|
3
|
+
## Mobile-First: Write It Right
|
|
4
|
+
|
|
5
|
+
Start with base styles for mobile, use `min-width` queries to layer complexity. Desktop-first (`max-width`) means mobile loads unnecessary styles first.
|
|
6
|
+
|
|
7
|
+
```css
|
|
8
|
+
/* Mobile-first (correct) */
|
|
9
|
+
.container { padding: 1rem; }
|
|
10
|
+
|
|
11
|
+
@media (min-width: 768px) {
|
|
12
|
+
.container { padding: 2rem; }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* Desktop-first (wrong way) */
|
|
16
|
+
.container { padding: 2rem; }
|
|
17
|
+
|
|
18
|
+
@media (max-width: 768px) {
|
|
19
|
+
.container { padding: 1rem; }
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Breakpoints: Content-Driven
|
|
26
|
+
|
|
27
|
+
Don't chase device sizes — let content tell you where to break. Start narrow, stretch until design breaks, add breakpoint there. Three breakpoints usually suffice: 640, 768, 1024px. Use `clamp()` for fluid values without breakpoints.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Detect Input Method, Not Just Screen Size
|
|
32
|
+
|
|
33
|
+
Screen size doesn't tell you input method. A laptop with touchscreen, a tablet with keyboard — use pointer and hover queries:
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
/* Fine pointer (mouse, trackpad) */
|
|
37
|
+
@media (pointer: fine) {
|
|
38
|
+
.button { padding: 8px 16px; }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Coarse pointer (touch, stylus) */
|
|
42
|
+
@media (pointer: coarse) {
|
|
43
|
+
.button { padding: 12px 20px; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Device supports hover */
|
|
47
|
+
@media (hover: hover) {
|
|
48
|
+
.card:hover { transform: translateY(-2px); }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Device doesn't support hover (touch) */
|
|
52
|
+
@media (hover: none) {
|
|
53
|
+
.card { /* No hover state — use active instead */ }
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Critical**: Don't rely on hover for functionality. Touch users can't hover.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Safe Areas: Handle the Notch
|
|
62
|
+
|
|
63
|
+
Modern phones have notches, rounded corners, and home indicators:
|
|
64
|
+
|
|
65
|
+
```css
|
|
66
|
+
body {
|
|
67
|
+
padding-top: env(safe-area-inset-top);
|
|
68
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
69
|
+
padding-left: env(safe-area-inset-left);
|
|
70
|
+
padding-right: env(safe-area-inset-right);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* With fallback */
|
|
74
|
+
.footer {
|
|
75
|
+
padding-bottom: max(1rem, env(safe-area-inset-bottom));
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Enable viewport-fit in your meta tag:
|
|
80
|
+
```html
|
|
81
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Responsive Images
|
|
87
|
+
|
|
88
|
+
### srcset with Width Descriptors
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<img
|
|
92
|
+
src="hero-800.jpg"
|
|
93
|
+
srcset="
|
|
94
|
+
hero-400.jpg 400w,
|
|
95
|
+
hero-800.jpg 800w,
|
|
96
|
+
hero-1200.jpg 1200w
|
|
97
|
+
"
|
|
98
|
+
sizes="(max-width: 768px) 100vw, 50vw"
|
|
99
|
+
alt="Hero image"
|
|
100
|
+
>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- `srcset` lists available images with their actual widths
|
|
104
|
+
- `sizes` tells the browser how wide the image will display
|
|
105
|
+
- Browser picks the best file based on viewport width AND device pixel ratio
|
|
106
|
+
|
|
107
|
+
### Picture Element for Art Direction
|
|
108
|
+
|
|
109
|
+
When you need different crops/compositions (not just resolutions):
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<picture>
|
|
113
|
+
<source media="(min-width: 768px)" srcset="wide.jpg">
|
|
114
|
+
<source media="(max-width: 767px)" srcset="tall.jpg">
|
|
115
|
+
<img src="fallback.jpg" alt="...">
|
|
116
|
+
</picture>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Layout Adaptation Patterns
|
|
122
|
+
|
|
123
|
+
**Navigation** — three stages:
|
|
124
|
+
- Mobile: hamburger + drawer
|
|
125
|
+
- Tablet: horizontal compact
|
|
126
|
+
- Desktop: full with labels
|
|
127
|
+
|
|
128
|
+
**Tables** — transform to cards on mobile:
|
|
129
|
+
```css
|
|
130
|
+
@media (max-width: 640px) {
|
|
131
|
+
table, thead, tbody, tr, td {
|
|
132
|
+
display: block;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
td::before {
|
|
136
|
+
content: attr(data-label) ": ";
|
|
137
|
+
font-weight: bold;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
thead { display: none; }
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Progressive disclosure** — use `<details>/<summary>` for content that can collapse on mobile.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Testing: Don't Trust DevTools Alone
|
|
149
|
+
|
|
150
|
+
DevTools device emulation is useful for layout but misses:
|
|
151
|
+
- Actual touch interactions
|
|
152
|
+
- Real CPU/memory constraints
|
|
153
|
+
- Network latency patterns
|
|
154
|
+
- Font rendering differences
|
|
155
|
+
- Browser chrome/keyboard appearances
|
|
156
|
+
|
|
157
|
+
**Test on at least**: One real iPhone, one real Android, a tablet if relevant. Cheap Android phones reveal performance issues you'll never see on simulators.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
**Avoid**: Desktop-first design. Device detection instead of feature detection. Separate mobile/desktop codebases. Ignoring tablet and landscape. Assuming all mobile devices are powerful.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Spatial Design
|
|
2
|
+
|
|
3
|
+
## Spacing Systems
|
|
4
|
+
|
|
5
|
+
### Use 4pt Base, Not 8pt
|
|
6
|
+
8pt systems are too coarse — you'll frequently need 12px (between 8 and 16). Use 4pt for granularity: 4, 8, 12, 16, 24, 32, 48, 64, 96px.
|
|
7
|
+
|
|
8
|
+
### Name Tokens Semantically
|
|
9
|
+
Name by relationship (`--space-sm`, `--space-lg`), not value (`--spacing-8`). Use `gap` instead of margins for sibling spacing — it eliminates margin collapse and cleanup hacks.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Grid Systems
|
|
14
|
+
|
|
15
|
+
### The Self-Adjusting Grid
|
|
16
|
+
Use `repeat(auto-fit, minmax(280px, 1fr))` for responsive grids without breakpoints. Columns are at least 280px, as many as fit per row, leftovers stretch.
|
|
17
|
+
|
|
18
|
+
For complex layouts, use named grid areas (`grid-template-areas`) and redefine them at breakpoints.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Visual Hierarchy
|
|
23
|
+
|
|
24
|
+
### The Squint Test
|
|
25
|
+
Blur your eyes (or screenshot and blur). Can you still identify:
|
|
26
|
+
- The most important element?
|
|
27
|
+
- The second most important?
|
|
28
|
+
- Clear groupings?
|
|
29
|
+
|
|
30
|
+
If everything looks the same weight blurred, you have a hierarchy problem.
|
|
31
|
+
|
|
32
|
+
### Hierarchy Through Multiple Dimensions
|
|
33
|
+
Don't rely on size alone. Combine:
|
|
34
|
+
|
|
35
|
+
| Tool | Strong Hierarchy | Weak Hierarchy |
|
|
36
|
+
|------|------------------|----------------|
|
|
37
|
+
| **Size** | 3:1 ratio or more | <2:1 ratio |
|
|
38
|
+
| **Weight** | Bold vs Regular | Medium vs Regular |
|
|
39
|
+
| **Color** | High contrast | Similar tones |
|
|
40
|
+
| **Position** | Top/left (primary) | Bottom/right |
|
|
41
|
+
| **Space** | Surrounded by white space | Crowded |
|
|
42
|
+
|
|
43
|
+
**The best hierarchy uses 2–3 dimensions at once**: A heading that's larger, bolder, AND has more space above it.
|
|
44
|
+
|
|
45
|
+
### Cards Are Not Required
|
|
46
|
+
Cards are overused. Spacing and alignment create visual grouping naturally. Use cards only when:
|
|
47
|
+
- Content is truly distinct and actionable
|
|
48
|
+
- Items need visual comparison in a grid
|
|
49
|
+
- Content needs clear interaction boundaries
|
|
50
|
+
|
|
51
|
+
**Never nest cards inside cards** — use spacing, typography, and subtle dividers for hierarchy within a card.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Container Queries
|
|
56
|
+
|
|
57
|
+
Viewport queries are for page layouts. **Container queries are for components**:
|
|
58
|
+
|
|
59
|
+
```css
|
|
60
|
+
.card-container {
|
|
61
|
+
container-type: inline-size;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.card {
|
|
65
|
+
display: grid;
|
|
66
|
+
gap: var(--space-md);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Card layout changes based on its container, not viewport */
|
|
70
|
+
@container (min-width: 400px) {
|
|
71
|
+
.card {
|
|
72
|
+
grid-template-columns: 120px 1fr;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Why this matters**: A card in a narrow sidebar stays compact, while the same card in a main content area expands — automatically, without viewport hacks.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Optical Adjustments
|
|
82
|
+
|
|
83
|
+
- Text at `margin-left: 0` looks indented due to letterform whitespace — use negative margin (`-0.05em`) to optically align
|
|
84
|
+
- Geometrically centered icons often look off-center; play icons need to shift right, arrows shift toward their direction
|
|
85
|
+
|
|
86
|
+
### Touch Targets vs Visual Size
|
|
87
|
+
Buttons can look small but need large touch targets (44px minimum). Use padding or pseudo-elements:
|
|
88
|
+
|
|
89
|
+
```css
|
|
90
|
+
.icon-button {
|
|
91
|
+
width: 24px;
|
|
92
|
+
height: 24px;
|
|
93
|
+
position: relative;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.icon-button::before {
|
|
97
|
+
content: '';
|
|
98
|
+
position: absolute;
|
|
99
|
+
inset: -10px; /* Expand tap target to 44px */
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Depth & Elevation
|
|
106
|
+
|
|
107
|
+
Create semantic z-index scales (dropdown → sticky → modal-backdrop → modal → toast → tooltip) instead of arbitrary numbers.
|
|
108
|
+
|
|
109
|
+
For shadows, create a consistent elevation scale (sm → md → lg → xl). **Key insight**: Shadows should be subtle — if you can clearly see it, it's probably too strong.
|
|
110
|
+
|
|
111
|
+
```css
|
|
112
|
+
:root {
|
|
113
|
+
--shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.05);
|
|
114
|
+
--shadow-md: 0 4px 6px oklch(0% 0 0 / 0.07);
|
|
115
|
+
--shadow-lg: 0 10px 15px oklch(0% 0 0 / 0.1);
|
|
116
|
+
--shadow-xl: 0 20px 25px oklch(0% 0 0 / 0.12);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
**Avoid**: Arbitrary spacing values outside your scale. Making all spacing equal (variety creates hierarchy). Creating hierarchy through size alone. Nesting cards in cards.
|