codexkit 1.0.1 → 1.0.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/.codex/.template-manifest.json +32 -24
- package/.codex/.version +1 -1
- package/.codex/agents/builder.toml +6 -1
- package/.codex/agents/debugger.toml +1 -0
- package/.codex/agents/general.toml +6 -1
- package/.codex/agents/painter.toml +1 -0
- package/.codex/agents/planner.toml +1 -0
- package/.codex/agents/refactorer.toml +1 -0
- package/.codex/agents/reviewer.toml +1 -0
- package/.codex/agents/runner.toml +1 -0
- package/.codex/agents/scout.toml +1 -0
- package/.codex/agents/shipper.toml +1 -0
- package/.codex/agents/vision.toml +1 -0
- package/.codex/config.toml +8 -3
- package/.codex/mcp/README.md +19 -3
- package/.codex/mcp/context7.toml.example +25 -8
- package/.codex/mcp/exa.toml.example +8 -1
- package/.codex/prompts/create.md +63 -26
- package/.codex/prompts/init.md +24 -0
- package/.codex/prompts/ship.md +36 -25
- package/.codex/prompts/start.md +2 -2
- package/.codex/prompts/ui-slop-check.md +119 -0
- package/.codex/scripts/start_bead.sh +9 -5
- package/.codex/scripts/verify_bead.sh +18 -6
- package/.codex/skills/frontend-design/SKILL.md +137 -55
- package/.codex/skills/frontend-design/references/color-system.md +125 -0
- package/.codex/skills/frontend-design/references/interaction.md +115 -0
- package/.codex/skills/frontend-design/references/motion-core.md +102 -0
- package/.codex/skills/frontend-design/references/responsive-design.md +104 -0
- package/.codex/skills/frontend-design/references/spatial-design.md +103 -0
- package/.codex/skills/frontend-design/references/typography-rules.md +118 -0
- package/.codex/skills/frontend-design/references/ux-writing.md +105 -0
- package/.template-manifest.json +32 -24
- package/AGENTS.md +3 -3
- package/CHANGELOG.md +33 -0
- package/README.md +3 -1
- package/bin/codexkit +20 -1
- package/package.json +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Color System
|
|
2
|
+
|
|
3
|
+
> Reference for the `frontend-design` skill. Covers OKLCH-first color pipeline, tinted neutrals, dark mode, and accessibility.
|
|
4
|
+
> Adapted from [pbakaus/impeccable](https://github.com/pbakaus/impeccable) (Apache 2.0).
|
|
5
|
+
|
|
6
|
+
## Color Spaces: Use OKLCH
|
|
7
|
+
|
|
8
|
+
**Stop using HSL.** Use OKLCH (or LCH) instead. It's perceptually uniform, meaning equal steps in lightness *look* equal. In HSL, 50% lightness in yellow looks bright while 50% in blue looks dark.
|
|
9
|
+
|
|
10
|
+
```css
|
|
11
|
+
/* OKLCH: lightness (0-100%), chroma (0-0.4+), hue (0-360) */
|
|
12
|
+
--color-primary: oklch(60% 0.15 250); /* Blue */
|
|
13
|
+
--color-primary-light: oklch(85% 0.08 250); /* Same hue, lighter */
|
|
14
|
+
--color-primary-dark: oklch(35% 0.12 250); /* Same hue, darker */
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Key insight**: As you move toward white or black, reduce chroma (saturation). High chroma at extreme lightness looks garish.
|
|
18
|
+
|
|
19
|
+
## Tinted Neutrals
|
|
20
|
+
|
|
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 (add brand warmth) */
|
|
29
|
+
--gray-100: oklch(95% 0.01 60);
|
|
30
|
+
--gray-900: oklch(15% 0.01 60);
|
|
31
|
+
|
|
32
|
+
/* Cool-tinted grays (tech, professional) */
|
|
33
|
+
--gray-100: oklch(95% 0.01 250);
|
|
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 your UI.
|
|
38
|
+
|
|
39
|
+
## Palette Structure
|
|
40
|
+
|
|
41
|
+
A complete system needs:
|
|
42
|
+
|
|
43
|
+
| Role | Purpose | Example |
|
|
44
|
+
|------|---------|---------|
|
|
45
|
+
| **Primary** | Brand, CTAs, key actions | 1 color, 3-5 shades |
|
|
46
|
+
| **Neutral** | Text, backgrounds, borders | 9-11 shade scale |
|
|
47
|
+
| **Semantic** | Success, error, warning, info | 4 colors, 2-3 shades each |
|
|
48
|
+
| **Surface** | Cards, modals, overlays | 2-3 elevation levels |
|
|
49
|
+
|
|
50
|
+
**Skip secondary/tertiary unless you need them.** Most apps work fine with one accent color.
|
|
51
|
+
|
|
52
|
+
## The 60-30-10 Rule
|
|
53
|
+
|
|
54
|
+
This rule is about **visual weight**, not pixel count:
|
|
55
|
+
|
|
56
|
+
- **60%**: Neutral backgrounds, white space, base surfaces
|
|
57
|
+
- **30%**: Secondary colors — text, borders, inactive states
|
|
58
|
+
- **10%**: Accent — CTAs, highlights, focus states
|
|
59
|
+
|
|
60
|
+
The common mistake: using the accent color everywhere because it's "the brand color." Accent colors work *because* they're rare.
|
|
61
|
+
|
|
62
|
+
## Contrast & Accessibility
|
|
63
|
+
|
|
64
|
+
| Content Type | AA Minimum | AAA Target |
|
|
65
|
+
|--------------|------------|------------|
|
|
66
|
+
| Body text | 4.5:1 | 7:1 |
|
|
67
|
+
| Large text (18px+ or 14px bold) | 3:1 | 4.5:1 |
|
|
68
|
+
| UI components, icons | 3:1 | 4.5:1 |
|
|
69
|
+
| Non-essential decorations | None | None |
|
|
70
|
+
|
|
71
|
+
**Gotcha**: Placeholder text still needs 4.5:1. That light gray placeholder you see everywhere usually fails WCAG.
|
|
72
|
+
|
|
73
|
+
### Dangerous Color Combinations
|
|
74
|
+
|
|
75
|
+
- Light gray text on white (the #1 accessibility fail)
|
|
76
|
+
- **Gray text on any colored background** — gray looks washed out on color; use a darker shade of the background color or transparency instead
|
|
77
|
+
- Red text on green background (or vice versa) — 8% of men can't distinguish these
|
|
78
|
+
- Blue text on red background (vibrates visually)
|
|
79
|
+
- Yellow text on white (almost always fails)
|
|
80
|
+
- Thin light text on images (unpredictable contrast)
|
|
81
|
+
|
|
82
|
+
### Never Use Pure Gray or Pure Black
|
|
83
|
+
|
|
84
|
+
Pure gray (`oklch(50% 0 0)`) and pure black (`#000`) don't exist in nature. Even a chroma of 0.005-0.01 is enough to feel natural without being obviously tinted.
|
|
85
|
+
|
|
86
|
+
### Testing
|
|
87
|
+
|
|
88
|
+
- [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/)
|
|
89
|
+
- Browser DevTools: Rendering > Emulate vision deficiencies
|
|
90
|
+
- [Polypane](https://polypane.app/) for real-time testing
|
|
91
|
+
|
|
92
|
+
## Dark Mode
|
|
93
|
+
|
|
94
|
+
### Dark Mode Is Not Inverted Light Mode
|
|
95
|
+
|
|
96
|
+
| Light Mode | Dark Mode |
|
|
97
|
+
|------------|-----------|
|
|
98
|
+
| Shadows for depth | Lighter surfaces for depth (no shadows) |
|
|
99
|
+
| Dark text on light | Light text on dark (reduce font weight) |
|
|
100
|
+
| Vibrant accents | Desaturate accents slightly |
|
|
101
|
+
| White backgrounds | Never pure black — use dark gray (oklch 12-18%) |
|
|
102
|
+
|
|
103
|
+
```css
|
|
104
|
+
/* Dark mode depth via surface color, not shadow */
|
|
105
|
+
:root[data-theme="dark"] {
|
|
106
|
+
--surface-1: oklch(15% 0.01 250);
|
|
107
|
+
--surface-2: oklch(20% 0.01 250); /* "Higher" = lighter */
|
|
108
|
+
--surface-3: oklch(25% 0.01 250);
|
|
109
|
+
|
|
110
|
+
/* Reduce text weight slightly */
|
|
111
|
+
--body-weight: 350; /* Instead of 400 */
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Token Hierarchy
|
|
116
|
+
|
|
117
|
+
Use two layers: primitive tokens (`--blue-500`) and semantic tokens (`--color-primary: var(--blue-500)`). For dark mode, only redefine the semantic layer — primitives stay the same.
|
|
118
|
+
|
|
119
|
+
## Alpha Is A Design Smell
|
|
120
|
+
|
|
121
|
+
Heavy use of transparency (rgba, hsla) usually means an incomplete palette. Alpha creates unpredictable contrast, performance overhead, and inconsistency. Define explicit overlay colors for each context instead. Exception: focus rings and interactive states where see-through is needed.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
**Avoid**: Relying on color alone to convey information. Creating palettes without clear roles for each color. Using pure black (#000) for large areas. Skipping color blindness testing (8% of men affected).
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Interaction Design
|
|
2
|
+
|
|
3
|
+
> Reference for the `frontend-design` skill. Covers touch/click targets, feedback, focus management, forms, and loading patterns.
|
|
4
|
+
> Adapted from [pbakaus/impeccable](https://github.com/pbakaus/impeccable) (Apache 2.0).
|
|
5
|
+
|
|
6
|
+
## The Eight Interactive States
|
|
7
|
+
|
|
8
|
+
Every interactive element needs these states designed:
|
|
9
|
+
|
|
10
|
+
| State | When | Visual Treatment |
|
|
11
|
+
|-------|------|------------------|
|
|
12
|
+
| **Default** | At rest | Base styling |
|
|
13
|
+
| **Hover** | Pointer over (not touch) | Subtle lift, color shift |
|
|
14
|
+
| **Focus** | Keyboard/programmatic focus | Visible ring (see below) |
|
|
15
|
+
| **Active** | Being pressed | Pressed in, darker |
|
|
16
|
+
| **Disabled** | Not interactive | Reduced opacity, no pointer |
|
|
17
|
+
| **Loading** | Processing | Spinner, skeleton |
|
|
18
|
+
| **Error** | Invalid state | Red border, icon, message |
|
|
19
|
+
| **Success** | Completed | Green check, confirmation |
|
|
20
|
+
|
|
21
|
+
**The common miss**: Designing hover without focus, or vice versa. Keyboard users never see hover states.
|
|
22
|
+
|
|
23
|
+
## Focus Rings: Do Them Right
|
|
24
|
+
|
|
25
|
+
**Never `outline: none` without replacement.** Use `:focus-visible` to show focus only for keyboard users:
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
/* Hide focus ring for mouse/touch */
|
|
29
|
+
button:focus {
|
|
30
|
+
outline: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Show focus ring for keyboard */
|
|
34
|
+
button:focus-visible {
|
|
35
|
+
outline: 2px solid var(--color-accent);
|
|
36
|
+
outline-offset: 2px;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Focus ring design**:
|
|
41
|
+
- High contrast (3:1 minimum against adjacent colors)
|
|
42
|
+
- 2-3px thick
|
|
43
|
+
- Offset from element (not inside it)
|
|
44
|
+
- Consistent across all interactive elements
|
|
45
|
+
|
|
46
|
+
## Form Design
|
|
47
|
+
|
|
48
|
+
**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.
|
|
49
|
+
|
|
50
|
+
## Loading States
|
|
51
|
+
|
|
52
|
+
**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.
|
|
53
|
+
|
|
54
|
+
## Modals: The Inert Approach
|
|
55
|
+
|
|
56
|
+
Use the native `<dialog>` element:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
const dialog = document.querySelector('dialog');
|
|
60
|
+
dialog.showModal(); // Opens with focus trap, closes on Escape
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or use the `inert` attribute on the background content when a modal is open.
|
|
64
|
+
|
|
65
|
+
## The Popover API
|
|
66
|
+
|
|
67
|
+
For tooltips, dropdowns, and non-modal overlays, use native popovers:
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<button popovertarget="menu">Open menu</button>
|
|
71
|
+
<div id="menu" popover>
|
|
72
|
+
<button>Option 1</button>
|
|
73
|
+
<button>Option 2</button>
|
|
74
|
+
</div>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Benefits**: Light-dismiss (click outside closes), proper stacking, no z-index wars, accessible by default.
|
|
78
|
+
|
|
79
|
+
## Destructive Actions: Undo > Confirm
|
|
80
|
+
|
|
81
|
+
**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.
|
|
82
|
+
|
|
83
|
+
## Keyboard Navigation Patterns
|
|
84
|
+
|
|
85
|
+
### Roving Tabindex
|
|
86
|
+
|
|
87
|
+
For component groups (tabs, menu items, radio groups), one item is tabbable; arrow keys move within:
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<div role="tablist">
|
|
91
|
+
<button role="tab" tabindex="0">Tab 1</button>
|
|
92
|
+
<button role="tab" tabindex="-1">Tab 2</button>
|
|
93
|
+
<button role="tab" tabindex="-1">Tab 3</button>
|
|
94
|
+
</div>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Arrow keys move `tabindex="0"` between items. Tab moves to the next component entirely.
|
|
98
|
+
|
|
99
|
+
### Skip Links
|
|
100
|
+
|
|
101
|
+
Provide skip links (`<a href="#main-content" class="sr-only focus:not-sr-only">Skip to main content</a>`) for keyboard users to jump past navigation. Hide off-screen, show on focus.
|
|
102
|
+
|
|
103
|
+
## Gesture Discoverability
|
|
104
|
+
|
|
105
|
+
Swipe-to-delete and similar gestures are invisible. Hint at their existence:
|
|
106
|
+
|
|
107
|
+
- **Partially reveal**: Show delete button peeking from edge
|
|
108
|
+
- **Onboarding**: Coach marks on first use
|
|
109
|
+
- **Alternative**: Always provide a visible fallback (menu with "Delete")
|
|
110
|
+
|
|
111
|
+
Don't rely on gestures as the only way to perform actions.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
**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,102 @@
|
|
|
1
|
+
# Motion Core
|
|
2
|
+
|
|
3
|
+
> Reference for the `frontend-design` skill. Covers timing, easing, spring defaults, stagger, reduced motion, and perceived performance.
|
|
4
|
+
> Adapted from [pbakaus/impeccable](https://github.com/pbakaus/impeccable) (Apache 2.0).
|
|
5
|
+
|
|
6
|
+
## Duration: The 100/300/500 Rule
|
|
7
|
+
|
|
8
|
+
Timing matters more than easing:
|
|
9
|
+
|
|
10
|
+
| Duration | Use Case | Examples |
|
|
11
|
+
|----------|----------|----------|
|
|
12
|
+
| **100-150ms** | Instant feedback | Button press, toggle, color change |
|
|
13
|
+
| **200-300ms** | State changes | Menu open, tooltip, hover states |
|
|
14
|
+
| **300-500ms** | Layout changes | Accordion, modal, drawer |
|
|
15
|
+
| **500-800ms** | Entrance animations | Page load, hero reveals |
|
|
16
|
+
|
|
17
|
+
**Exit animations are faster than entrances** — use ~75% of enter duration.
|
|
18
|
+
|
|
19
|
+
## Easing: Pick the Right Curve
|
|
20
|
+
|
|
21
|
+
**Don't use `ease`.** It's a compromise that's rarely optimal.
|
|
22
|
+
|
|
23
|
+
| Curve | Use For | CSS |
|
|
24
|
+
|-------|---------|-----|
|
|
25
|
+
| **ease-out** | Elements entering | `cubic-bezier(0.16, 1, 0.3, 1)` |
|
|
26
|
+
| **ease-in** | Elements leaving | `cubic-bezier(0.7, 0, 0.84, 0)` |
|
|
27
|
+
| **ease-in-out** | State toggles (there and back) | `cubic-bezier(0.65, 0, 0.35, 1)` |
|
|
28
|
+
|
|
29
|
+
**For micro-interactions, use exponential curves** — they mimic real physics:
|
|
30
|
+
|
|
31
|
+
```css
|
|
32
|
+
/* Quart out - smooth, refined (recommended default) */
|
|
33
|
+
--ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
|
|
34
|
+
|
|
35
|
+
/* Quint out - slightly more dramatic */
|
|
36
|
+
--ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
|
|
37
|
+
|
|
38
|
+
/* Expo out - snappy, confident */
|
|
39
|
+
--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**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.
|
|
43
|
+
|
|
44
|
+
## The Only Two Properties You Should Animate
|
|
45
|
+
|
|
46
|
+
**transform** and **opacity** only — everything else causes layout recalculation. For height animations (accordions), use `grid-template-rows: 0fr -> 1fr` instead of animating `height` directly.
|
|
47
|
+
|
|
48
|
+
## Staggered Animations
|
|
49
|
+
|
|
50
|
+
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.
|
|
51
|
+
|
|
52
|
+
## Reduced Motion
|
|
53
|
+
|
|
54
|
+
This is not optional. Vestibular disorders affect ~35% of adults over 40.
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
/* Define animations normally */
|
|
58
|
+
.card {
|
|
59
|
+
animation: slide-up 500ms ease-out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Provide alternative for reduced motion */
|
|
63
|
+
@media (prefers-reduced-motion: reduce) {
|
|
64
|
+
.card {
|
|
65
|
+
animation: fade-in 200ms ease-out; /* Crossfade instead of motion */
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Or disable entirely */
|
|
70
|
+
@media (prefers-reduced-motion: reduce) {
|
|
71
|
+
*, *::before, *::after {
|
|
72
|
+
animation-duration: 0.01ms !important;
|
|
73
|
+
transition-duration: 0.01ms !important;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**What to preserve**: Functional animations like progress bars, loading spinners (slowed down), and focus indicators should still work — just without spatial movement.
|
|
79
|
+
|
|
80
|
+
## Perceived Performance
|
|
81
|
+
|
|
82
|
+
**Nobody cares how fast your site is — just how fast it feels.**
|
|
83
|
+
|
|
84
|
+
**The 80ms threshold**: Our brains buffer sensory input for ~80ms to synchronize perception. Anything under 80ms feels instant. This is your target for micro-interactions.
|
|
85
|
+
|
|
86
|
+
**Active vs passive time**: Passive waiting (staring at a spinner) feels longer than active engagement. Strategies:
|
|
87
|
+
|
|
88
|
+
- **Preemptive start**: Begin transitions immediately while loading (skeleton UI). Users perceive work happening.
|
|
89
|
+
- **Early completion**: Show content progressively — don't wait for everything.
|
|
90
|
+
- **Optimistic UI**: Update the interface immediately, handle failures gracefully. Use for low-stakes actions; avoid for payments or destructive operations.
|
|
91
|
+
|
|
92
|
+
**Easing affects perceived duration**: Ease-in (accelerating toward completion) makes tasks feel shorter because the peak-end effect weights final moments heavily.
|
|
93
|
+
|
|
94
|
+
**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.
|
|
95
|
+
|
|
96
|
+
## Performance
|
|
97
|
+
|
|
98
|
+
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).
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
**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,104 @@
|
|
|
1
|
+
# Responsive Design
|
|
2
|
+
|
|
3
|
+
> Reference for the `frontend-design` skill. Covers mobile-first approach, fluid design, input detection, and container queries.
|
|
4
|
+
> Adapted from [pbakaus/impeccable](https://github.com/pbakaus/impeccable) (Apache 2.0).
|
|
5
|
+
|
|
6
|
+
## Mobile-First: Write It Right
|
|
7
|
+
|
|
8
|
+
Start with base styles for mobile, use `min-width` queries to layer complexity. Desktop-first (`max-width`) means mobile loads unnecessary styles first.
|
|
9
|
+
|
|
10
|
+
## Breakpoints: Content-Driven
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
## Detect Input Method, Not Just Screen Size
|
|
15
|
+
|
|
16
|
+
**Screen size doesn't tell you input method.** A laptop with touchscreen, a tablet with keyboard — use pointer and hover queries:
|
|
17
|
+
|
|
18
|
+
```css
|
|
19
|
+
/* Fine pointer (mouse, trackpad) */
|
|
20
|
+
@media (pointer: fine) {
|
|
21
|
+
.button { padding: 8px 16px; }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Coarse pointer (touch, stylus) */
|
|
25
|
+
@media (pointer: coarse) {
|
|
26
|
+
.button { padding: 12px 20px; } /* Larger touch target */
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Device supports hover */
|
|
30
|
+
@media (hover: hover) {
|
|
31
|
+
.card:hover { transform: translateY(-2px); }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Device doesn't support hover (touch) */
|
|
35
|
+
@media (hover: none) {
|
|
36
|
+
.card { /* No hover state - use active instead */ }
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Critical**: Don't rely on hover for functionality. Touch users can't hover.
|
|
41
|
+
|
|
42
|
+
## Safe Areas: Handle the Notch
|
|
43
|
+
|
|
44
|
+
Modern phones have notches, rounded corners, and home indicators:
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
body {
|
|
48
|
+
padding-top: env(safe-area-inset-top);
|
|
49
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
50
|
+
padding-left: env(safe-area-inset-left);
|
|
51
|
+
padding-right: env(safe-area-inset-right);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* With fallback */
|
|
55
|
+
.footer {
|
|
56
|
+
padding-bottom: max(1rem, env(safe-area-inset-bottom));
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Enable viewport-fit in your meta tag:
|
|
61
|
+
```html
|
|
62
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Responsive Images
|
|
66
|
+
|
|
67
|
+
### srcset with Width Descriptors
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<img
|
|
71
|
+
src="hero-800.jpg"
|
|
72
|
+
srcset="hero-400.jpg 400w, hero-800.jpg 800w, hero-1200.jpg 1200w"
|
|
73
|
+
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 800px"
|
|
74
|
+
alt="Hero image"
|
|
75
|
+
>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- `srcset` lists available images with their actual widths (`w` descriptors)
|
|
79
|
+
- `sizes` tells the browser how wide the image will display
|
|
80
|
+
- Browser picks the best file based on viewport width AND device pixel ratio
|
|
81
|
+
|
|
82
|
+
### Picture Element for Art Direction
|
|
83
|
+
|
|
84
|
+
When you need different crops/compositions (not just resolutions), use the `<picture>` element with `<source>` elements for each breakpoint.
|
|
85
|
+
|
|
86
|
+
## Layout Adaptation Patterns
|
|
87
|
+
|
|
88
|
+
**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.
|
|
89
|
+
|
|
90
|
+
## Testing: Don't Trust DevTools Alone
|
|
91
|
+
|
|
92
|
+
DevTools device emulation is useful for layout but misses:
|
|
93
|
+
|
|
94
|
+
- Actual touch interactions
|
|
95
|
+
- Real CPU/memory constraints
|
|
96
|
+
- Network latency patterns
|
|
97
|
+
- Font rendering differences
|
|
98
|
+
- Browser chrome/keyboard appearances
|
|
99
|
+
|
|
100
|
+
**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.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
**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,103 @@
|
|
|
1
|
+
# Spatial Design
|
|
2
|
+
|
|
3
|
+
> Reference for the `frontend-design` skill. Covers spacing systems, grids, visual hierarchy, and container queries.
|
|
4
|
+
> Adapted from [pbakaus/impeccable](https://github.com/pbakaus/impeccable) (Apache 2.0).
|
|
5
|
+
|
|
6
|
+
## Spacing Systems
|
|
7
|
+
|
|
8
|
+
### Use 4pt Base, Not 8pt
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
### Name Tokens Semantically
|
|
13
|
+
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
## Grid Systems
|
|
17
|
+
|
|
18
|
+
### The Self-Adjusting Grid
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
## Visual Hierarchy
|
|
23
|
+
|
|
24
|
+
### The Squint Test
|
|
25
|
+
|
|
26
|
+
Blur your eyes (or screenshot and blur). Can you still identify:
|
|
27
|
+
- The most important element?
|
|
28
|
+
- The second most important?
|
|
29
|
+
- Clear groupings?
|
|
30
|
+
|
|
31
|
+
If everything looks the same weight blurred, you have a hierarchy problem.
|
|
32
|
+
|
|
33
|
+
### Hierarchy Through Multiple Dimensions
|
|
34
|
+
|
|
35
|
+
Don't rely on size alone. Combine:
|
|
36
|
+
|
|
37
|
+
| Tool | Strong Hierarchy | Weak Hierarchy |
|
|
38
|
+
|------|------------------|----------------|
|
|
39
|
+
| **Size** | 3:1 ratio or more | <2:1 ratio |
|
|
40
|
+
| **Weight** | Bold vs Regular | Medium vs Regular |
|
|
41
|
+
| **Color** | High contrast | Similar tones |
|
|
42
|
+
| **Position** | Top/left (primary) | Bottom/right |
|
|
43
|
+
| **Space** | Surrounded by white space | Crowded |
|
|
44
|
+
|
|
45
|
+
**The best hierarchy uses 2-3 dimensions at once**: A heading that's larger, bolder, AND has more space above it.
|
|
46
|
+
|
|
47
|
+
### Cards Are Not Required
|
|
48
|
+
|
|
49
|
+
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.
|
|
50
|
+
|
|
51
|
+
## Container Queries
|
|
52
|
+
|
|
53
|
+
Viewport queries are for page layouts. **Container queries are for components**:
|
|
54
|
+
|
|
55
|
+
```css
|
|
56
|
+
.card-container {
|
|
57
|
+
container-type: inline-size;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.card {
|
|
61
|
+
display: grid;
|
|
62
|
+
gap: var(--space-md);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Card layout changes based on its container, not viewport */
|
|
66
|
+
@container (min-width: 400px) {
|
|
67
|
+
.card {
|
|
68
|
+
grid-template-columns: 120px 1fr;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**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.
|
|
74
|
+
|
|
75
|
+
## Optical Adjustments
|
|
76
|
+
|
|
77
|
+
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.
|
|
78
|
+
|
|
79
|
+
### Touch Targets vs Visual Size
|
|
80
|
+
|
|
81
|
+
Buttons can look small but need large touch targets (44px minimum). Use padding or pseudo-elements:
|
|
82
|
+
|
|
83
|
+
```css
|
|
84
|
+
.icon-button {
|
|
85
|
+
width: 24px; /* Visual size */
|
|
86
|
+
height: 24px;
|
|
87
|
+
position: relative;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.icon-button::before {
|
|
91
|
+
content: '';
|
|
92
|
+
position: absolute;
|
|
93
|
+
inset: -10px; /* Expand tap target to 44px */
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Depth & Elevation
|
|
98
|
+
|
|
99
|
+
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.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
**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,118 @@
|
|
|
1
|
+
# Typography Rules
|
|
2
|
+
|
|
3
|
+
> Reference for the `frontend-design` skill. Covers type systems, font pairing, modular scales, and OpenType features.
|
|
4
|
+
> Adapted from [pbakaus/impeccable](https://github.com/pbakaus/impeccable) (Apache 2.0).
|
|
5
|
+
|
|
6
|
+
## Vertical Rhythm
|
|
7
|
+
|
|
8
|
+
Line-height is 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.
|
|
9
|
+
|
|
10
|
+
## Modular Scale & Hierarchy
|
|
11
|
+
|
|
12
|
+
Avoid too many font sizes that are too close together (14px, 15px, 16px, 18px). Use fewer sizes with more contrast. A 5-size system covers most needs:
|
|
13
|
+
|
|
14
|
+
| Role | Typical Ratio | Use Case |
|
|
15
|
+
|------|---------------|----------|
|
|
16
|
+
| xs | 0.75rem | Captions, legal |
|
|
17
|
+
| sm | 0.875rem | Secondary UI, metadata |
|
|
18
|
+
| base | 1rem | Body text |
|
|
19
|
+
| lg | 1.25-1.5rem | Subheadings, lead text |
|
|
20
|
+
| xl+ | 2-4rem | Headlines, hero text |
|
|
21
|
+
|
|
22
|
+
Popular ratios: 1.25 (major third), 1.333 (perfect fourth), 1.5 (perfect fifth). Pick one and commit.
|
|
23
|
+
|
|
24
|
+
## Readability & Measure
|
|
25
|
+
|
|
26
|
+
Use `ch` units for character-based measure (`max-width: 65ch`). Line-height scales inversely with line length. Increase line-height for light text on dark backgrounds (add 0.05-0.1 to normal line-height).
|
|
27
|
+
|
|
28
|
+
## Font Selection
|
|
29
|
+
|
|
30
|
+
**Avoid the invisible defaults**: Inter, Roboto, Open Sans, Lato, Montserrat. They make designs feel generic.
|
|
31
|
+
|
|
32
|
+
**Better Google Fonts alternatives**:
|
|
33
|
+
- Instead of Inter: **Instrument Sans**, **Plus Jakarta Sans**, **Outfit**
|
|
34
|
+
- Instead of Roboto: **Onest**, **Figtree**, **Urbanist**
|
|
35
|
+
- Instead of Open Sans: **Source Sans 3**, **Nunito Sans**, **DM Sans**
|
|
36
|
+
- For editorial/premium feel: **Fraunces**, **Newsreader**, **Lora**
|
|
37
|
+
|
|
38
|
+
**System fonts are underrated**: `-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui` looks native and loads instantly.
|
|
39
|
+
|
|
40
|
+
## Pairing Principles
|
|
41
|
+
|
|
42
|
+
You often don't need a second font. One well-chosen family in multiple weights creates cleaner hierarchy. Only add a second font when you need genuine contrast (e.g., display headlines + body serif).
|
|
43
|
+
|
|
44
|
+
When pairing, contrast on multiple axes:
|
|
45
|
+
- Serif + Sans (structure contrast)
|
|
46
|
+
- Geometric + Humanist (personality contrast)
|
|
47
|
+
- Condensed display + Wide body (proportion contrast)
|
|
48
|
+
|
|
49
|
+
**Never pair fonts that are similar but not identical** (e.g., two geometric sans-serifs).
|
|
50
|
+
|
|
51
|
+
## Web Font Loading
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
/* 1. Use font-display: swap for visibility */
|
|
55
|
+
@font-face {
|
|
56
|
+
font-family: 'CustomFont';
|
|
57
|
+
src: url('font.woff2') format('woff2');
|
|
58
|
+
font-display: swap;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* 2. Match fallback metrics to minimize shift */
|
|
62
|
+
@font-face {
|
|
63
|
+
font-family: 'CustomFont-Fallback';
|
|
64
|
+
src: local('Arial');
|
|
65
|
+
size-adjust: 105%;
|
|
66
|
+
ascent-override: 90%;
|
|
67
|
+
descent-override: 20%;
|
|
68
|
+
line-gap-override: 10%;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
body {
|
|
72
|
+
font-family: 'CustomFont', 'CustomFont-Fallback', sans-serif;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Tools like [Fontaine](https://github.com/unjs/fontaine) calculate these overrides automatically.
|
|
77
|
+
|
|
78
|
+
## Fluid Type
|
|
79
|
+
|
|
80
|
+
Use `clamp(min, preferred, max)` for fluid typography. The middle value (e.g., `5vw + 1rem`) controls scaling rate. Add a rem offset so it doesn't collapse to 0 on small screens.
|
|
81
|
+
|
|
82
|
+
**When NOT to use fluid type**: Button text, labels, UI elements (should be consistent), very short text, or when you need precise breakpoint control.
|
|
83
|
+
|
|
84
|
+
## OpenType Features
|
|
85
|
+
|
|
86
|
+
```css
|
|
87
|
+
/* Tabular numbers for data alignment */
|
|
88
|
+
.data-table { font-variant-numeric: tabular-nums; }
|
|
89
|
+
|
|
90
|
+
/* Proper fractions */
|
|
91
|
+
.recipe-amount { font-variant-numeric: diagonal-fractions; }
|
|
92
|
+
|
|
93
|
+
/* Small caps for abbreviations */
|
|
94
|
+
abbr { font-variant-caps: all-small-caps; }
|
|
95
|
+
|
|
96
|
+
/* Disable ligatures in code */
|
|
97
|
+
code { font-variant-ligatures: none; }
|
|
98
|
+
|
|
99
|
+
/* Enable kerning */
|
|
100
|
+
body { font-kerning: normal; }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Check font feature support at [Wakamai Fondue](https://wakamaifondue.com/).
|
|
104
|
+
|
|
105
|
+
## Token Architecture
|
|
106
|
+
|
|
107
|
+
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.
|
|
108
|
+
|
|
109
|
+
## Accessibility
|
|
110
|
+
|
|
111
|
+
- **Never disable zoom**: `user-scalable=no` breaks accessibility.
|
|
112
|
+
- **Use rem/em for font sizes**: Respects user browser settings.
|
|
113
|
+
- **Minimum 16px body text**: Smaller strains eyes and fails WCAG on mobile.
|
|
114
|
+
- **Adequate touch targets**: Text links need padding or line-height that creates 44px+ tap targets.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
**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.
|