ccg-workflow 1.8.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/shared/{ccg-workflow.B1RHp04H.mjs → ccg-workflow.iK6lgCG3.mjs} +204 -6
- package/package.json +1 -1
- package/templates/commands/agents/team-architect.md +97 -0
- package/templates/commands/agents/team-qa.md +121 -0
- package/templates/commands/agents/team-reviewer.md +112 -0
- package/templates/output-styles/abyss-command.md +56 -0
- package/templates/output-styles/abyss-concise.md +89 -0
- package/templates/output-styles/abyss-ritual.md +70 -0
- package/templates/rules/ccg-skill-routing.md +83 -0
- package/templates/skills/domains/ai/SKILL.md +34 -0
- package/templates/skills/domains/ai/agent-dev.md +242 -0
- package/templates/skills/domains/ai/llm-security.md +288 -0
- package/templates/skills/domains/ai/prompt-and-eval.md +279 -0
- package/templates/skills/domains/ai/rag-system.md +542 -0
- package/templates/skills/domains/architecture/SKILL.md +42 -0
- package/templates/skills/domains/architecture/api-design.md +225 -0
- package/templates/skills/domains/architecture/caching.md +299 -0
- package/templates/skills/domains/architecture/cloud-native.md +285 -0
- package/templates/skills/domains/architecture/message-queue.md +329 -0
- package/templates/skills/domains/architecture/security-arch.md +297 -0
- package/templates/skills/domains/data-engineering/SKILL.md +207 -0
- package/templates/skills/domains/development/SKILL.md +46 -0
- package/templates/skills/domains/development/cpp.md +246 -0
- package/templates/skills/domains/development/go.md +323 -0
- package/templates/skills/domains/development/java.md +277 -0
- package/templates/skills/domains/development/python.md +288 -0
- package/templates/skills/domains/development/rust.md +313 -0
- package/templates/skills/domains/development/shell.md +313 -0
- package/templates/skills/domains/development/typescript.md +277 -0
- package/templates/skills/domains/devops/SKILL.md +39 -0
- package/templates/skills/domains/devops/cost-optimization.md +272 -0
- package/templates/skills/domains/devops/database.md +217 -0
- package/templates/skills/domains/devops/devsecops.md +198 -0
- package/templates/skills/domains/devops/git-workflow.md +181 -0
- package/templates/skills/domains/devops/observability.md +280 -0
- package/templates/skills/domains/devops/performance.md +336 -0
- package/templates/skills/domains/devops/testing.md +283 -0
- package/templates/skills/domains/frontend-design/SKILL.md +242 -0
- package/templates/skills/domains/frontend-design/agents/openai.yaml +4 -0
- package/templates/skills/domains/frontend-design/claymorphism/SKILL.md +119 -0
- package/templates/skills/domains/frontend-design/claymorphism/references/tokens.css +52 -0
- package/templates/skills/domains/frontend-design/component-patterns.md +202 -0
- package/templates/skills/domains/frontend-design/engineering.md +287 -0
- package/templates/skills/domains/frontend-design/glassmorphism/SKILL.md +140 -0
- package/templates/skills/domains/frontend-design/glassmorphism/references/tokens.css +32 -0
- package/templates/skills/domains/frontend-design/liquid-glass/SKILL.md +137 -0
- package/templates/skills/domains/frontend-design/liquid-glass/references/tokens.css +81 -0
- package/templates/skills/domains/frontend-design/neubrutalism/SKILL.md +143 -0
- package/templates/skills/domains/frontend-design/neubrutalism/references/tokens.css +44 -0
- package/templates/skills/domains/frontend-design/reference/color-and-contrast.md +132 -0
- package/templates/skills/domains/frontend-design/reference/interaction-design.md +195 -0
- package/templates/skills/domains/frontend-design/reference/motion-design.md +99 -0
- package/templates/skills/domains/frontend-design/reference/responsive-design.md +114 -0
- package/templates/skills/domains/frontend-design/reference/spatial-design.md +100 -0
- package/templates/skills/domains/frontend-design/reference/typography.md +133 -0
- package/templates/skills/domains/frontend-design/reference/ux-writing.md +107 -0
- package/templates/skills/domains/frontend-design/state-management.md +680 -0
- package/templates/skills/domains/frontend-design/ui-aesthetics.md +110 -0
- package/templates/skills/domains/frontend-design/ux-principles.md +156 -0
- package/templates/skills/domains/infrastructure/SKILL.md +200 -0
- package/templates/skills/domains/mobile/SKILL.md +224 -0
- package/templates/skills/domains/orchestration/SKILL.md +29 -0
- package/templates/skills/domains/orchestration/multi-agent.md +263 -0
- package/templates/skills/domains/security/SKILL.md +72 -0
- package/templates/skills/domains/security/blue-team.md +436 -0
- package/templates/skills/domains/security/code-audit.md +265 -0
- package/templates/skills/domains/security/pentest.md +226 -0
- package/templates/skills/domains/security/red-team.md +374 -0
- package/templates/skills/domains/security/threat-intel.md +372 -0
- package/templates/skills/domains/security/vuln-research.md +369 -0
- package/templates/skills/impeccable/adapt/SKILL.md +199 -0
- package/templates/skills/impeccable/animate/SKILL.md +174 -0
- package/templates/skills/impeccable/arrange/SKILL.md +124 -0
- package/templates/skills/impeccable/audit/SKILL.md +147 -0
- package/templates/skills/impeccable/bolder/SKILL.md +116 -0
- package/templates/skills/impeccable/clarify/SKILL.md +183 -0
- package/templates/skills/impeccable/colorize/SKILL.md +142 -0
- package/templates/skills/impeccable/critique/SKILL.md +201 -0
- package/templates/skills/impeccable/critique/reference/cognitive-load.md +106 -0
- package/templates/skills/impeccable/critique/reference/heuristics-scoring.md +234 -0
- package/templates/skills/impeccable/critique/reference/personas.md +178 -0
- package/templates/skills/impeccable/delight/SKILL.md +303 -0
- package/templates/skills/impeccable/distill/SKILL.md +121 -0
- package/templates/skills/impeccable/extract/SKILL.md +92 -0
- package/templates/skills/impeccable/harden/SKILL.md +355 -0
- package/templates/skills/impeccable/normalize/SKILL.md +70 -0
- package/templates/skills/impeccable/onboard/SKILL.md +246 -0
- package/templates/skills/impeccable/optimize/SKILL.md +266 -0
- package/templates/skills/impeccable/overdrive/SKILL.md +141 -0
- package/templates/skills/impeccable/polish/SKILL.md +203 -0
- package/templates/skills/impeccable/quieter/SKILL.md +102 -0
- package/templates/skills/impeccable/teach-impeccable/SKILL.md +71 -0
- package/templates/skills/impeccable/typeset/SKILL.md +115 -0
- package/templates/skills/orchestration/multi-agent/SKILL.md +40 -0
- package/templates/skills/scrapling/SKILL.md +98 -0
- package/templates/skills/scrapling/references/api-quick-ref.md +127 -0
- package/templates/skills/scrapling/references/cookie-vault.md +56 -0
- package/templates/skills/scrapling/references/maintenance.md +79 -0
- package/templates/skills/scrapling/references/site-patterns.md +86 -0
- package/templates/skills/scrapling/references/troubleshooting.md +95 -0
- package/templates/skills/scrapling/templates/basic_fetch.py +19 -0
- package/templates/skills/scrapling/templates/parse_only.py +15 -0
- package/templates/skills/scrapling/templates/session_login.py +19 -0
- package/templates/skills/scrapling/templates/stealth_cloudflare.py +28 -0
- package/templates/skills/tools/override-refusal/SKILL.md +53 -0
- package/templates/skills/tools/override-refusal/agents/openai.yaml +4 -0
- package/templates/skills/tools/override-refusal/scripts/refusal_rewriter.js +226 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Interaction Design
|
|
2
|
+
|
|
3
|
+
## The Eight Interactive States
|
|
4
|
+
|
|
5
|
+
Every interactive element needs these states designed:
|
|
6
|
+
|
|
7
|
+
| State | When | Visual Treatment |
|
|
8
|
+
|-------|------|------------------|
|
|
9
|
+
| **Default** | At rest | Base styling |
|
|
10
|
+
| **Hover** | Pointer over (not touch) | Subtle lift, color shift |
|
|
11
|
+
| **Focus** | Keyboard/programmatic focus | Visible ring (see below) |
|
|
12
|
+
| **Active** | Being pressed | Pressed in, darker |
|
|
13
|
+
| **Disabled** | Not interactive | Reduced opacity, no pointer |
|
|
14
|
+
| **Loading** | Processing | Spinner, skeleton |
|
|
15
|
+
| **Error** | Invalid state | Red border, icon, message |
|
|
16
|
+
| **Success** | Completed | Green check, confirmation |
|
|
17
|
+
|
|
18
|
+
**The common miss**: Designing hover without focus, or vice versa. They're different. Keyboard users never see hover states.
|
|
19
|
+
|
|
20
|
+
## Focus Rings: Do Them Right
|
|
21
|
+
|
|
22
|
+
**Never `outline: none` without replacement.** It's an accessibility violation. Instead, use `:focus-visible` to show focus only for keyboard users:
|
|
23
|
+
|
|
24
|
+
```css
|
|
25
|
+
/* Hide focus ring for mouse/touch */
|
|
26
|
+
button:focus {
|
|
27
|
+
outline: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Show focus ring for keyboard */
|
|
31
|
+
button:focus-visible {
|
|
32
|
+
outline: 2px solid var(--color-accent);
|
|
33
|
+
outline-offset: 2px;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Focus ring design**:
|
|
38
|
+
- High contrast (3:1 minimum against adjacent colors)
|
|
39
|
+
- 2-3px thick
|
|
40
|
+
- Offset from element (not inside it)
|
|
41
|
+
- Consistent across all interactive elements
|
|
42
|
+
|
|
43
|
+
## Form Design: The Non-Obvious
|
|
44
|
+
|
|
45
|
+
**Placeholders aren't labels**—they disappear on input. Always use visible `<label>` elements. **Validate on blur**, not on every keystroke (exception: password strength). Place errors **below** fields with `aria-describedby` connecting them.
|
|
46
|
+
|
|
47
|
+
## Loading States
|
|
48
|
+
|
|
49
|
+
**Optimistic updates**: Show success immediately, rollback on failure. Use for low-stakes actions (likes, follows), not payments or destructive actions. **Skeleton screens > spinners**—they preview content shape and feel faster than generic spinners.
|
|
50
|
+
|
|
51
|
+
## Modals: The Inert Approach
|
|
52
|
+
|
|
53
|
+
Focus trapping in modals used to require complex JavaScript. Now use the `inert` attribute:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<!-- When modal is open -->
|
|
57
|
+
<main inert>
|
|
58
|
+
<!-- Content behind modal can't be focused or clicked -->
|
|
59
|
+
</main>
|
|
60
|
+
<dialog open>
|
|
61
|
+
<h2>Modal Title</h2>
|
|
62
|
+
<!-- Focus stays inside modal -->
|
|
63
|
+
</dialog>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or use the native `<dialog>` element:
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
const dialog = document.querySelector('dialog');
|
|
70
|
+
dialog.showModal(); // Opens with focus trap, closes on Escape
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## The Popover API
|
|
74
|
+
|
|
75
|
+
For tooltips, dropdowns, and non-modal overlays, use native popovers:
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<button popovertarget="menu">Open menu</button>
|
|
79
|
+
<div id="menu" popover>
|
|
80
|
+
<button>Option 1</button>
|
|
81
|
+
<button>Option 2</button>
|
|
82
|
+
</div>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Benefits**: Light-dismiss (click outside closes), proper stacking, no z-index wars, accessible by default.
|
|
86
|
+
|
|
87
|
+
## Dropdown & Overlay Positioning
|
|
88
|
+
|
|
89
|
+
Dropdowns rendered with `position: absolute` inside a container that has `overflow: hidden` or `overflow: auto` will be clipped. This is the single most common dropdown bug in generated code.
|
|
90
|
+
|
|
91
|
+
### CSS Anchor Positioning
|
|
92
|
+
|
|
93
|
+
The modern solution uses the CSS Anchor Positioning API to tether an overlay to its trigger without JavaScript:
|
|
94
|
+
|
|
95
|
+
```css
|
|
96
|
+
.trigger {
|
|
97
|
+
anchor-name: --menu-trigger;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.dropdown {
|
|
101
|
+
position: fixed;
|
|
102
|
+
position-anchor: --menu-trigger;
|
|
103
|
+
position-area: block-end span-inline-end;
|
|
104
|
+
margin-top: 4px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Flip above if no room below */
|
|
108
|
+
@position-try --flip-above {
|
|
109
|
+
position-area: block-start span-inline-end;
|
|
110
|
+
margin-bottom: 4px;
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Because the dropdown uses `position: fixed`, it escapes any `overflow` clipping on ancestor elements. The `@position-try` block handles viewport edges automatically. **Browser support**: Chrome 125+, Edge 125+. Not yet in Firefox or Safari - use a fallback for those browsers.
|
|
115
|
+
|
|
116
|
+
### Popover + Anchor Combo
|
|
117
|
+
|
|
118
|
+
Combining the Popover API with anchor positioning gives you stacking, light-dismiss, accessibility, and correct positioning in one pattern:
|
|
119
|
+
|
|
120
|
+
```html
|
|
121
|
+
<button popovertarget="menu" class="trigger">Open</button>
|
|
122
|
+
<div id="menu" popover class="dropdown">
|
|
123
|
+
<button>Option 1</button>
|
|
124
|
+
<button>Option 2</button>
|
|
125
|
+
</div>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The `popover` attribute places the element in the **top layer**, which sits above all other content regardless of z-index or overflow. No portal needed.
|
|
129
|
+
|
|
130
|
+
### Portal / Teleport Pattern
|
|
131
|
+
|
|
132
|
+
In component frameworks, render the dropdown at the document root and position it with JavaScript:
|
|
133
|
+
|
|
134
|
+
- **React**: `createPortal(dropdown, document.body)`
|
|
135
|
+
- **Vue**: `<Teleport to="body">`
|
|
136
|
+
- **Svelte**: Use a portal library or mount to `document.body`
|
|
137
|
+
|
|
138
|
+
Calculate position from the trigger's `getBoundingClientRect()`, then apply `position: fixed` with `top` and `left` values. Recalculate on scroll and resize.
|
|
139
|
+
|
|
140
|
+
### Fixed Positioning Fallback
|
|
141
|
+
|
|
142
|
+
For browsers without anchor positioning support, `position: fixed` with manual coordinates avoids overflow clipping:
|
|
143
|
+
|
|
144
|
+
```css
|
|
145
|
+
.dropdown {
|
|
146
|
+
position: fixed;
|
|
147
|
+
/* top/left set via JS from trigger's getBoundingClientRect() */
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Check viewport boundaries before rendering. If the dropdown would overflow the bottom edge, flip it above the trigger. If it would overflow the right edge, align it to the trigger's right side instead.
|
|
152
|
+
|
|
153
|
+
### Anti-Patterns
|
|
154
|
+
|
|
155
|
+
- **`position: absolute` inside `overflow: hidden`** - The dropdown will be clipped. Use `position: fixed` or the top layer instead.
|
|
156
|
+
- **Arbitrary z-index values** like `z-index: 9999` - Use a semantic z-index scale: `dropdown (100) -> sticky (200) -> modal-backdrop (300) -> modal (400) -> toast (500) -> tooltip (600)`.
|
|
157
|
+
- **Rendering dropdown markup inline** without an escape hatch from the parent's stacking context. Either use `popover` (top layer), a portal, or `position: fixed`.
|
|
158
|
+
|
|
159
|
+
## Destructive Actions: Undo > Confirm
|
|
160
|
+
|
|
161
|
+
**Undo is better than confirmation dialogs**—users click through confirmations mindlessly. Remove from UI immediately, show undo toast, actually delete after toast expires. Use confirmation only for truly irreversible actions (account deletion), high-cost actions, or batch operations.
|
|
162
|
+
|
|
163
|
+
## Keyboard Navigation Patterns
|
|
164
|
+
|
|
165
|
+
### Roving Tabindex
|
|
166
|
+
|
|
167
|
+
For component groups (tabs, menu items, radio groups), one item is tabbable; arrow keys move within:
|
|
168
|
+
|
|
169
|
+
```html
|
|
170
|
+
<div role="tablist">
|
|
171
|
+
<button role="tab" tabindex="0">Tab 1</button>
|
|
172
|
+
<button role="tab" tabindex="-1">Tab 2</button>
|
|
173
|
+
<button role="tab" tabindex="-1">Tab 3</button>
|
|
174
|
+
</div>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Arrow keys move `tabindex="0"` between items. Tab moves to the next component entirely.
|
|
178
|
+
|
|
179
|
+
### Skip Links
|
|
180
|
+
|
|
181
|
+
Provide skip links (`<a href="#main-content">Skip to main content</a>`) for keyboard users to jump past navigation. Hide off-screen, show on focus.
|
|
182
|
+
|
|
183
|
+
## Gesture Discoverability
|
|
184
|
+
|
|
185
|
+
Swipe-to-delete and similar gestures are invisible. Hint at their existence:
|
|
186
|
+
|
|
187
|
+
- **Partially reveal**: Show delete button peeking from edge
|
|
188
|
+
- **Onboarding**: Coach marks on first use
|
|
189
|
+
- **Alternative**: Always provide a visible fallback (menu with "Delete")
|
|
190
|
+
|
|
191
|
+
Don't rely on gestures as the only way to perform actions.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
**Avoid**: Removing focus indicators without alternatives. Using placeholder text as labels. Touch targets <44x44px. Generic error messages. Custom controls without ARIA/keyboard support.
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
## Easing: Pick the Right Curve
|
|
17
|
+
|
|
18
|
+
**Don't use `ease`.** It's a compromise that's rarely optimal. Instead:
|
|
19
|
+
|
|
20
|
+
| Curve | Use For | CSS |
|
|
21
|
+
|-------|---------|-----|
|
|
22
|
+
| **ease-out** | Elements entering | `cubic-bezier(0.16, 1, 0.3, 1)` |
|
|
23
|
+
| **ease-in** | Elements leaving | `cubic-bezier(0.7, 0, 0.84, 0)` |
|
|
24
|
+
| **ease-in-out** | State toggles (there → back) | `cubic-bezier(0.65, 0, 0.35, 1)` |
|
|
25
|
+
|
|
26
|
+
**For micro-interactions, use exponential curves**—they feel natural because they mimic real physics (friction, deceleration):
|
|
27
|
+
|
|
28
|
+
```css
|
|
29
|
+
/* Quart out - smooth, refined (recommended default) */
|
|
30
|
+
--ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
|
|
31
|
+
|
|
32
|
+
/* Quint out - slightly more dramatic */
|
|
33
|
+
--ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
|
|
34
|
+
|
|
35
|
+
/* Expo out - snappy, confident */
|
|
36
|
+
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Avoid bounce and elastic curves.** They were trendy in 2015 but now feel tacky and amateurish. Real objects don't bounce when they stop—they decelerate smoothly. Overshoot effects draw attention to the animation itself rather than the content.
|
|
40
|
+
|
|
41
|
+
## The Only Two Properties You Should Animate
|
|
42
|
+
|
|
43
|
+
**transform** and **opacity** only—everything else causes layout recalculation. For height animations (accordions), use `grid-template-rows: 0fr → 1fr` instead of animating `height` directly.
|
|
44
|
+
|
|
45
|
+
## Staggered Animations
|
|
46
|
+
|
|
47
|
+
Use CSS custom properties for cleaner stagger: `animation-delay: calc(var(--i, 0) * 50ms)` with `style="--i: 0"` on each item. **Cap total stagger time**—10 items at 50ms = 500ms total. For many items, reduce per-item delay or cap staggered count.
|
|
48
|
+
|
|
49
|
+
## Reduced Motion
|
|
50
|
+
|
|
51
|
+
This is not optional. Vestibular disorders affect ~35% of adults over 40.
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
/* Define animations normally */
|
|
55
|
+
.card {
|
|
56
|
+
animation: slide-up 500ms ease-out;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Provide alternative for reduced motion */
|
|
60
|
+
@media (prefers-reduced-motion: reduce) {
|
|
61
|
+
.card {
|
|
62
|
+
animation: fade-in 200ms ease-out; /* Crossfade instead of motion */
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Or disable entirely */
|
|
67
|
+
@media (prefers-reduced-motion: reduce) {
|
|
68
|
+
*, *::before, *::after {
|
|
69
|
+
animation-duration: 0.01ms !important;
|
|
70
|
+
transition-duration: 0.01ms !important;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**What to preserve**: Functional animations like progress bars, loading spinners (slowed down), and focus indicators should still work—just without spatial movement.
|
|
76
|
+
|
|
77
|
+
## Perceived Performance
|
|
78
|
+
|
|
79
|
+
**Nobody cares how fast your site is—just how fast it feels.** Perception can be as effective as actual performance.
|
|
80
|
+
|
|
81
|
+
**The 80ms threshold**: Our brains buffer sensory input for ~80ms to synchronize perception. Anything under 80ms feels instant and simultaneous. This is your target for micro-interactions.
|
|
82
|
+
|
|
83
|
+
**Active vs passive time**: Passive waiting (staring at a spinner) feels longer than active engagement. Strategies to shift the balance:
|
|
84
|
+
|
|
85
|
+
- **Preemptive start**: Begin transitions immediately while loading (iOS app zoom, skeleton UI). Users perceive work happening.
|
|
86
|
+
- **Early completion**: Show content progressively—don't wait for everything. Video buffering, progressive images, streaming HTML.
|
|
87
|
+
- **Optimistic UI**: Update the interface immediately, handle failures gracefully. Instagram likes work offline—the UI updates instantly, syncs later. Use for low-stakes actions; avoid for payments or destructive operations.
|
|
88
|
+
|
|
89
|
+
**Easing affects perceived duration**: Ease-in (accelerating toward completion) makes tasks feel shorter because the peak-end effect weights final moments heavily. Ease-out feels satisfying for entrances, but ease-in toward a task's end compresses perceived time.
|
|
90
|
+
|
|
91
|
+
**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.
|
|
92
|
+
|
|
93
|
+
## Performance
|
|
94
|
+
|
|
95
|
+
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. Create motion tokens for consistency (durations, easings, common transitions).
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
**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,114 @@
|
|
|
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
|
+
## Breakpoints: Content-Driven
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## Detect Input Method, Not Just Screen Size
|
|
12
|
+
|
|
13
|
+
**Screen size doesn't tell you input method.** A laptop with touchscreen, a tablet with keyboard—use pointer and hover queries:
|
|
14
|
+
|
|
15
|
+
```css
|
|
16
|
+
/* Fine pointer (mouse, trackpad) */
|
|
17
|
+
@media (pointer: fine) {
|
|
18
|
+
.button { padding: 8px 16px; }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Coarse pointer (touch, stylus) */
|
|
22
|
+
@media (pointer: coarse) {
|
|
23
|
+
.button { padding: 12px 20px; } /* Larger touch target */
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Device supports hover */
|
|
27
|
+
@media (hover: hover) {
|
|
28
|
+
.card:hover { transform: translateY(-2px); }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Device doesn't support hover (touch) */
|
|
32
|
+
@media (hover: none) {
|
|
33
|
+
.card { /* No hover state - use active instead */ }
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Critical**: Don't rely on hover for functionality. Touch users can't hover.
|
|
38
|
+
|
|
39
|
+
## Safe Areas: Handle the Notch
|
|
40
|
+
|
|
41
|
+
Modern phones have notches, rounded corners, and home indicators. Use `env()`:
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
body {
|
|
45
|
+
padding-top: env(safe-area-inset-top);
|
|
46
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
47
|
+
padding-left: env(safe-area-inset-left);
|
|
48
|
+
padding-right: env(safe-area-inset-right);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* With fallback */
|
|
52
|
+
.footer {
|
|
53
|
+
padding-bottom: max(1rem, env(safe-area-inset-bottom));
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Enable viewport-fit** in your meta tag:
|
|
58
|
+
```html
|
|
59
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Responsive Images: Get It Right
|
|
63
|
+
|
|
64
|
+
### srcset with Width Descriptors
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<img
|
|
68
|
+
src="hero-800.jpg"
|
|
69
|
+
srcset="
|
|
70
|
+
hero-400.jpg 400w,
|
|
71
|
+
hero-800.jpg 800w,
|
|
72
|
+
hero-1200.jpg 1200w
|
|
73
|
+
"
|
|
74
|
+
sizes="(max-width: 768px) 100vw, 50vw"
|
|
75
|
+
alt="Hero image"
|
|
76
|
+
>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**How it works**:
|
|
80
|
+
- `srcset` lists available images with their actual widths (`w` descriptors)
|
|
81
|
+
- `sizes` tells the browser how wide the image will display
|
|
82
|
+
- Browser picks the best file based on viewport width AND device pixel ratio
|
|
83
|
+
|
|
84
|
+
### Picture Element for Art Direction
|
|
85
|
+
|
|
86
|
+
When you need different crops/compositions (not just resolutions):
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<picture>
|
|
90
|
+
<source media="(min-width: 768px)" srcset="wide.jpg">
|
|
91
|
+
<source media="(max-width: 767px)" srcset="tall.jpg">
|
|
92
|
+
<img src="fallback.jpg" alt="...">
|
|
93
|
+
</picture>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Layout Adaptation Patterns
|
|
97
|
+
|
|
98
|
+
**Navigation**: Three stages—hamburger + drawer on mobile, horizontal compact on tablet, full with labels on desktop. **Tables**: Transform to cards on mobile using `display: block` and `data-label` attributes. **Progressive disclosure**: Use `<details>/<summary>` for content that can collapse on mobile.
|
|
99
|
+
|
|
100
|
+
## Testing: Don't Trust DevTools Alone
|
|
101
|
+
|
|
102
|
+
DevTools device emulation is useful for layout but misses:
|
|
103
|
+
|
|
104
|
+
- Actual touch interactions
|
|
105
|
+
- Real CPU/memory constraints
|
|
106
|
+
- Network latency patterns
|
|
107
|
+
- Font rendering differences
|
|
108
|
+
- Browser chrome/keyboard appearances
|
|
109
|
+
|
|
110
|
+
**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.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
**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,100 @@
|
|
|
1
|
+
# Spatial Design
|
|
2
|
+
|
|
3
|
+
## Spacing Systems
|
|
4
|
+
|
|
5
|
+
### Use 4pt Base, Not 8pt
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
### Name Tokens Semantically
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
## Grid Systems
|
|
14
|
+
|
|
15
|
+
### The Self-Adjusting Grid
|
|
16
|
+
|
|
17
|
+
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. For complex layouts, use named grid areas (`grid-template-areas`) and redefine them at breakpoints.
|
|
18
|
+
|
|
19
|
+
## Visual Hierarchy
|
|
20
|
+
|
|
21
|
+
### The Squint Test
|
|
22
|
+
|
|
23
|
+
Blur your eyes (or screenshot and blur). Can you still identify:
|
|
24
|
+
- The most important element?
|
|
25
|
+
- The second most important?
|
|
26
|
+
- Clear groupings?
|
|
27
|
+
|
|
28
|
+
If everything looks the same weight blurred, you have a hierarchy problem.
|
|
29
|
+
|
|
30
|
+
### Hierarchy Through Multiple Dimensions
|
|
31
|
+
|
|
32
|
+
Don't rely on size alone. Combine:
|
|
33
|
+
|
|
34
|
+
| Tool | Strong Hierarchy | Weak Hierarchy |
|
|
35
|
+
|------|------------------|----------------|
|
|
36
|
+
| **Size** | 3:1 ratio or more | <2:1 ratio |
|
|
37
|
+
| **Weight** | Bold vs Regular | Medium vs Regular |
|
|
38
|
+
| **Color** | High contrast | Similar tones |
|
|
39
|
+
| **Position** | Top/left (primary) | Bottom/right |
|
|
40
|
+
| **Space** | Surrounded by white space | Crowded |
|
|
41
|
+
|
|
42
|
+
**The best hierarchy uses 2-3 dimensions at once**: A heading that's larger, bolder, AND has more space above it.
|
|
43
|
+
|
|
44
|
+
### Cards Are Not Required
|
|
45
|
+
|
|
46
|
+
Cards are overused. Spacing and alignment create visual grouping naturally. Use cards only when content is truly distinct and actionable, items need visual comparison in a grid, or content needs clear interaction boundaries. **Never nest cards inside cards**—use spacing, typography, and subtle dividers for hierarchy within a card.
|
|
47
|
+
|
|
48
|
+
## Container Queries
|
|
49
|
+
|
|
50
|
+
Viewport queries are for page layouts. **Container queries are for components**:
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
.card-container {
|
|
54
|
+
container-type: inline-size;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.card {
|
|
58
|
+
display: grid;
|
|
59
|
+
gap: var(--space-md);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Card layout changes based on its container, not viewport */
|
|
63
|
+
@container (min-width: 400px) {
|
|
64
|
+
.card {
|
|
65
|
+
grid-template-columns: 120px 1fr;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**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.
|
|
71
|
+
|
|
72
|
+
## Optical Adjustments
|
|
73
|
+
|
|
74
|
+
Text at `margin-left: 0` looks indented due to letterform whitespace—use negative margin (`-0.05em`) to optically align. Geometrically centered icons often look off-center; play icons need to shift right, arrows shift toward their direction.
|
|
75
|
+
|
|
76
|
+
### Touch Targets vs Visual Size
|
|
77
|
+
|
|
78
|
+
Buttons can look small but need large touch targets (44px minimum). Use padding or pseudo-elements:
|
|
79
|
+
|
|
80
|
+
```css
|
|
81
|
+
.icon-button {
|
|
82
|
+
width: 24px; /* Visual size */
|
|
83
|
+
height: 24px;
|
|
84
|
+
position: relative;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.icon-button::before {
|
|
88
|
+
content: '';
|
|
89
|
+
position: absolute;
|
|
90
|
+
inset: -10px; /* Expand tap target to 44px */
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Depth & Elevation
|
|
95
|
+
|
|
96
|
+
Create semantic z-index scales (dropdown → sticky → modal-backdrop → modal → toast → tooltip) instead of arbitrary numbers. 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.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
**Avoid**: Arbitrary spacing values outside your scale. Making all spacing equal (variety creates hierarchy). Creating hierarchy through size alone - combine size, weight, color, and space.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Typography
|
|
2
|
+
|
|
3
|
+
## Classic Typography Principles
|
|
4
|
+
|
|
5
|
+
### Vertical Rhythm
|
|
6
|
+
|
|
7
|
+
Your line-height should be the base unit for ALL vertical spacing. If body text has `line-height: 1.5` on `16px` type (= 24px), spacing values should be multiples of 24px. This creates subconscious harmony—text and space share a mathematical foundation.
|
|
8
|
+
|
|
9
|
+
### Modular Scale & Hierarchy
|
|
10
|
+
|
|
11
|
+
The common mistake: too many font sizes that are too close together (14px, 15px, 16px, 18px...). This creates muddy hierarchy.
|
|
12
|
+
|
|
13
|
+
**Use fewer sizes with more contrast.** A 5-size system covers most needs:
|
|
14
|
+
|
|
15
|
+
| Role | Typical Ratio | Use Case |
|
|
16
|
+
|------|---------------|----------|
|
|
17
|
+
| xs | 0.75rem | Captions, legal |
|
|
18
|
+
| sm | 0.875rem | Secondary UI, metadata |
|
|
19
|
+
| base | 1rem | Body text |
|
|
20
|
+
| lg | 1.25-1.5rem | Subheadings, lead text |
|
|
21
|
+
| xl+ | 2-4rem | Headlines, hero text |
|
|
22
|
+
|
|
23
|
+
Popular ratios: 1.25 (major third), 1.333 (perfect fourth), 1.5 (perfect fifth). Pick one and commit.
|
|
24
|
+
|
|
25
|
+
### Readability & Measure
|
|
26
|
+
|
|
27
|
+
Use `ch` units for character-based measure (`max-width: 65ch`). Line-height scales inversely with line length—narrow columns need tighter leading, wide columns need more.
|
|
28
|
+
|
|
29
|
+
**Non-obvious**: Increase line-height for light text on dark backgrounds. The perceived weight is lighter, so text needs more breathing room. Add 0.05-0.1 to your normal line-height.
|
|
30
|
+
|
|
31
|
+
## Font Selection & Pairing
|
|
32
|
+
|
|
33
|
+
### Choosing Distinctive Fonts
|
|
34
|
+
|
|
35
|
+
**Avoid the invisible defaults**: Inter, Roboto, Open Sans, Lato, Montserrat. These are everywhere, making your design feel generic. They're fine for documentation or tools where personality isn't the goal—but if you want distinctive design, look elsewhere.
|
|
36
|
+
|
|
37
|
+
**Better Google Fonts alternatives**:
|
|
38
|
+
- Instead of Inter → **Instrument Sans**, **Plus Jakarta Sans**, **Outfit**
|
|
39
|
+
- Instead of Roboto → **Onest**, **Figtree**, **Urbanist**
|
|
40
|
+
- Instead of Open Sans → **Source Sans 3**, **Nunito Sans**, **DM Sans**
|
|
41
|
+
- For editorial/premium feel → **Fraunces**, **Newsreader**, **Lora**
|
|
42
|
+
|
|
43
|
+
**System fonts are underrated**: `-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui` looks native, loads instantly, and is highly readable. Consider this for apps where performance > personality.
|
|
44
|
+
|
|
45
|
+
### Pairing Principles
|
|
46
|
+
|
|
47
|
+
**The non-obvious truth**: You often don't need a second font. One well-chosen font family in multiple weights creates cleaner hierarchy than two competing typefaces. Only add a second font when you need genuine contrast (e.g., display headlines + body serif).
|
|
48
|
+
|
|
49
|
+
When pairing, contrast on multiple axes:
|
|
50
|
+
- Serif + Sans (structure contrast)
|
|
51
|
+
- Geometric + Humanist (personality contrast)
|
|
52
|
+
- Condensed display + Wide body (proportion contrast)
|
|
53
|
+
|
|
54
|
+
**Never pair fonts that are similar but not identical** (e.g., two geometric sans-serifs). They create visual tension without clear hierarchy.
|
|
55
|
+
|
|
56
|
+
### Web Font Loading
|
|
57
|
+
|
|
58
|
+
The layout shift problem: fonts load late, text reflows, and users see content jump. Here's the fix:
|
|
59
|
+
|
|
60
|
+
```css
|
|
61
|
+
/* 1. Use font-display: swap for visibility */
|
|
62
|
+
@font-face {
|
|
63
|
+
font-family: 'CustomFont';
|
|
64
|
+
src: url('font.woff2') format('woff2');
|
|
65
|
+
font-display: swap;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* 2. Match fallback metrics to minimize shift */
|
|
69
|
+
@font-face {
|
|
70
|
+
font-family: 'CustomFont-Fallback';
|
|
71
|
+
src: local('Arial');
|
|
72
|
+
size-adjust: 105%; /* Scale to match x-height */
|
|
73
|
+
ascent-override: 90%; /* Match ascender height */
|
|
74
|
+
descent-override: 20%; /* Match descender depth */
|
|
75
|
+
line-gap-override: 10%; /* Match line spacing */
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
body {
|
|
79
|
+
font-family: 'CustomFont', 'CustomFont-Fallback', sans-serif;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Tools like [Fontaine](https://github.com/unjs/fontaine) calculate these overrides automatically.
|
|
84
|
+
|
|
85
|
+
## Modern Web Typography
|
|
86
|
+
|
|
87
|
+
### Fluid Type
|
|
88
|
+
|
|
89
|
+
Fluid typography via `clamp(min, preferred, max)` scales text smoothly with the viewport. The middle value (e.g., `5vw + 1rem`) controls scaling rate—higher vw = faster scaling. Add a rem offset so it doesn't collapse to 0 on small screens.
|
|
90
|
+
|
|
91
|
+
**Use fluid type for**: Headings and display text on marketing/content pages where text dominates the layout and needs to breathe across viewport sizes.
|
|
92
|
+
|
|
93
|
+
**Use fixed `rem` scales for**: App UIs, dashboards, and data-dense interfaces. No major app design system (Material, Polaris, Primer, Carbon) uses fluid type in product UI — fixed scales with optional breakpoint adjustments give the spatial predictability that container-based layouts need. Body text should also be fixed even on marketing pages, since the size difference across viewports is too small to warrant it.
|
|
94
|
+
|
|
95
|
+
### OpenType Features
|
|
96
|
+
|
|
97
|
+
Most developers don't know these exist. Use them for polish:
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
/* Tabular numbers for data alignment */
|
|
101
|
+
.data-table { font-variant-numeric: tabular-nums; }
|
|
102
|
+
|
|
103
|
+
/* Proper fractions */
|
|
104
|
+
.recipe-amount { font-variant-numeric: diagonal-fractions; }
|
|
105
|
+
|
|
106
|
+
/* Small caps for abbreviations */
|
|
107
|
+
abbr { font-variant-caps: all-small-caps; }
|
|
108
|
+
|
|
109
|
+
/* Disable ligatures in code */
|
|
110
|
+
code { font-variant-ligatures: none; }
|
|
111
|
+
|
|
112
|
+
/* Enable kerning (usually on by default, but be explicit) */
|
|
113
|
+
body { font-kerning: normal; }
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Check what features your font supports at [Wakamai Fondue](https://wakamaifondue.com/).
|
|
117
|
+
|
|
118
|
+
## Typography System Architecture
|
|
119
|
+
|
|
120
|
+
Name tokens semantically (`--text-body`, `--text-heading`), not by value (`--font-size-16`). Include font stacks, size scale, weights, line-heights, and letter-spacing in your token system.
|
|
121
|
+
|
|
122
|
+
## Accessibility Considerations
|
|
123
|
+
|
|
124
|
+
Beyond contrast ratios (which are well-documented), consider:
|
|
125
|
+
|
|
126
|
+
- **Never disable zoom**: `user-scalable=no` breaks accessibility. If your layout breaks at 200% zoom, fix the layout.
|
|
127
|
+
- **Use rem/em for font sizes**: This respects user browser settings. Never `px` for body text.
|
|
128
|
+
- **Minimum 16px body text**: Smaller than this strains eyes and fails WCAG on mobile.
|
|
129
|
+
- **Adequate touch targets**: Text links need padding or line-height that creates 44px+ tap targets.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
**Avoid**: More than 2-3 font families per project. Skipping fallback font definitions. Ignoring font loading performance (FOUT/FOIT). Using decorative fonts for body text.
|