@shavin/skills 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +193 -0
- package/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +48 -2
- package/bin/hex-policy.mjs +157 -0
- package/bin/install.mjs +219 -0
- package/bin/lint-tokens.mjs +178 -0
- package/build.mjs +540 -0
- package/commands/add-composition.md +14 -0
- package/commands/apply-theme.md +59 -0
- package/commands/audit-layout.md +15 -0
- package/commands/audit-ui.md +42 -0
- package/commands/compose-page.md +16 -0
- package/commands/create-block.md +79 -0
- package/commands/create-primitive.md +40 -0
- package/commands/create-screen.md +45 -0
- package/commands/create-theme.md +41 -0
- package/cursor/shavin.mdc +14 -0
- package/package.json +66 -4
- package/posix-path.mjs +7 -0
- package/skills/core-rules.md +294 -0
- package/skills/layout-choreography/SKILL.md +102 -0
- package/skills/layout-choreography/references/fallbacks-and-accessibility.md +76 -0
- package/skills/layout-choreography/references/scenes.md +113 -0
- package/skills/layout-choreography/references/shavin-timelines.md +100 -0
- package/skills/layout-choreography/references/tech-and-performance.md +147 -0
- package/skills/layout-compositions/SKILL.md +149 -0
- package/skills/layout-compositions/references/adapters/shavin-ui.md +122 -0
- package/skills/layout-compositions/references/adapters/tailwind-html.md +100 -0
- package/skills/layout-compositions/references/component-language.md +105 -0
- package/skills/layout-compositions/references/compositions/conversion.md +286 -0
- package/skills/layout-compositions/references/compositions/documentation.md +125 -0
- package/skills/layout-compositions/references/compositions/editorial.md +126 -0
- package/skills/layout-compositions/references/compositions/expressive.md +151 -0
- package/skills/layout-compositions/references/compositions/features.md +262 -0
- package/skills/layout-compositions/references/compositions/gallery.md +172 -0
- package/skills/layout-compositions/references/compositions/hero.md +184 -0
- package/skills/layout-compositions/references/compositions/proof.md +194 -0
- package/skills/layout-compositions/references/compositions/structural.md +173 -0
- package/skills/layout-compositions/references/distinctiveness.md +65 -0
- package/skills/layout-compositions/references/foundations.md +119 -0
- package/skills/layout-compositions/references/metadata-schema.md +64 -0
- package/skills/layout-compositions/references/page-recipes.md +143 -0
- package/skills/layout-compositions/references/selection-guide.md +207 -0
- package/skills/layout-compositions/references/treatments.md +60 -0
- package/skills/layout-compositions/references/unsection-source-examples.md +92 -0
- package/skills/layout-compositions/references/visual-review.md +40 -0
- package/skills/layout-compositions/scripts/render_wireframes.py +138 -0
- package/skills/layout-compositions/scripts/validate_library.py +165 -0
- package/skills/layout-motion/SKILL.md +83 -0
- package/skills/layout-motion/references/composition-motion-map.md +69 -0
- package/skills/layout-motion/references/presets.md +209 -0
- package/skills/layout-motion/references/tokens.md +100 -0
- package/skills/shavin-app/SKILL.md +242 -0
- package/skills/shavin-app/patterns.md +35 -0
- package/skills/shavin-studio/SKILL.md +97 -0
- package/skills/shavin-webpage/SKILL.md +210 -0
- package/skills/shavin-webpage/editorial-craft.md +117 -0
- package/skills/shavin-webpage/page-architecture.md +137 -0
- package/skills/shavin-webpage/style-recipes.md +107 -0
- package/skills/visual-compositor/SKILL.md +200 -0
- package/skills/visual-compositor/anti-patterns.md +109 -0
- package/skills/visual-compositor/audit-checklist.md +162 -0
- package/skills/visual-compositor/cognitive-layer.md +287 -0
- package/skills/visual-compositor/composition-motion-map.md +167 -0
- package/skills/visual-compositor/concentric-laws.md +147 -0
- package/skills/visual-compositor/docs-mode.md +32 -0
- package/skills/visual-compositor/editorial-mode.md +48 -0
- package/skills/visual-compositor/font-pairings.md +224 -0
- package/skills/visual-compositor/graphics-and-assets.md +128 -0
- package/skills/visual-compositor/interface-polish.md +125 -0
- package/skills/visual-compositor/layout-restraint.md +80 -0
- package/skills/visual-compositor/motion-and-physics.md +257 -0
- package/skills/visual-compositor/page-motion-presets.md +246 -0
- package/skills/visual-compositor/references/EDITORIAL_EXPRESSIVE.md +163 -0
- package/skills/visual-compositor/spacing-core.md +386 -0
- package/skills/visual-compositor/spacing-dense.md +63 -0
- package/skills/visual-compositor/spacing-marketing.md +192 -0
- package/skills/visual-compositor/typography-rules.md +114 -0
- package/token-budget.json +86 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
# Spacing Core — Universal Spatial Composition Rules
|
|
2
|
+
|
|
3
|
+
> **Load priority:** CORE: load for any section, flex or grid structure (alongside `concentric-laws.md` and `cognitive-layer.md`).
|
|
4
|
+
> **Token cost:** ~3.4K tokens.
|
|
5
|
+
> **Depends on:** `concentric-laws.md` for the two concentric laws.
|
|
6
|
+
|
|
7
|
+
This file covers the spatial rules every layout needs — section architecture, flex/grid, hierarchy within components, alignment, containment, nesting, responsive, repeating units, and the spatial scale reference. Mode-specific rules (marketing hierarchy, density framework) are in `spacing-marketing.md` and `spacing-dense.md`.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Section Architecture
|
|
12
|
+
|
|
13
|
+
### Full-Bleed vs Contained
|
|
14
|
+
|
|
15
|
+
Every `<section>` falls into one of two shapes. Choose deliberately before writing any markup.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
// Full-bleed (background fills viewport width)
|
|
19
|
+
<Section size="body" className="bg-surface border-y border-hairline">
|
|
20
|
+
<Container size="lg" className="px-6 md:px-10">
|
|
21
|
+
{/* content */}
|
|
22
|
+
</Container>
|
|
23
|
+
</Section>
|
|
24
|
+
|
|
25
|
+
// Contained (no background, whitespace section)
|
|
26
|
+
<Section size="body">
|
|
27
|
+
<Container size="lg" className="px-6 md:px-10">
|
|
28
|
+
{/* content */}
|
|
29
|
+
</Container>
|
|
30
|
+
</Section>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Rule:** Never put `px-*` on a `<section>`. The section is full-bleed. The `Container` is the gutter. Padding on the section produces misaligned content against other sections' containers.
|
|
34
|
+
|
|
35
|
+
### Section Header Block (Heading + Subtext)
|
|
36
|
+
|
|
37
|
+
Every section that introduces content before it gets a consistent header block structure:
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
<Flex direction="column" align="center" gap="3" className="text-center max-w-3xl mx-auto mb-10 md:mb-12">
|
|
41
|
+
<Text size="xs" className="uppercase tracking-wider text-fg-subtle font-medium">
|
|
42
|
+
Section Label
|
|
43
|
+
</Text>
|
|
44
|
+
<Heading as="h2" size="2xl" className="font-display font-bold text-fg">
|
|
45
|
+
One clear declarative statement.
|
|
46
|
+
</Heading>
|
|
47
|
+
<Text color="subtle" size="md" className="max-w-2xl">
|
|
48
|
+
Supporting context in one or two sentences. Never more.
|
|
49
|
+
</Text>
|
|
50
|
+
</Flex>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Rules:**
|
|
54
|
+
|
|
55
|
+
- When a section has a label: Label → Heading → Text, in that order, never reversed. Many sections have no label.
|
|
56
|
+
- When a label is warranted, prefer plain overline text (`<Text size="xs" className="uppercase tracking-wider text-fg-subtle">`) over `<Badge>`: a badge's fill, border and pill shape compete with the headline. See `anti-patterns.md` AP-04 (Badge Soup).
|
|
57
|
+
- Use `<Badge>` only for stateful labels (version tags, success/error states, notification counts), not for marketing adjectives or category markers.
|
|
58
|
+
- `max-w-3xl` on the wrapper, `max-w-2xl` on the Text. The heading is wider than the body.
|
|
59
|
+
- `mb-10 md:mb-12` separates the header from content below. Never less than `mb-8`.
|
|
60
|
+
- Do not add a fourth element (button, link) to the section header. Actions live below the content, not above it.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Flex Layout Rules
|
|
65
|
+
|
|
66
|
+
### Gap vs Padding
|
|
67
|
+
|
|
68
|
+
These are not interchangeable. They communicate different things.
|
|
69
|
+
|
|
70
|
+
| Decision | Use | Why |
|
|
71
|
+
| -------------------------------------- | ----------------------- | --------------------------------------------- |
|
|
72
|
+
| Space **between** sibling elements | `gap-*` | Communicates separation of independent items |
|
|
73
|
+
| Space **inside** a container wall | `p-*` / `px-*` / `py-*` | Communicates containment |
|
|
74
|
+
| Space **between grouped text lines** | `space-y-*` | Communicates relationship within a text block |
|
|
75
|
+
| Space **between independent sections** | `mt-*` or `mb-*` | Communicates page-level separation |
|
|
76
|
+
|
|
77
|
+
**Never substitute** `gap` for `p`. They produce identical pixel outputs in some cases but communicate entirely different structures.
|
|
78
|
+
|
|
79
|
+
### Flex Direction × Gap Reference
|
|
80
|
+
|
|
81
|
+
```jsx
|
|
82
|
+
// Horizontal row — icon + label, button group, nav items
|
|
83
|
+
<Flex direction="row" align="center" gap="2"> // tight (8px) — same conceptual unit
|
|
84
|
+
<Flex direction="row" align="center" gap="3"> // standard (12px) — related but distinct
|
|
85
|
+
<Flex direction="row" align="center" gap="4"> // loose (16px) — clearly separate items
|
|
86
|
+
<Flex direction="row" align="center" gap="6"> // very loose — action groups in toolbars
|
|
87
|
+
|
|
88
|
+
// Vertical stack — heading + text + button
|
|
89
|
+
<Flex direction="column" gap="1"> // within a single element (label + hint)
|
|
90
|
+
<Flex direction="column" gap="2"> // tight related items (form field internals)
|
|
91
|
+
<Flex direction="column" gap="3"> // standard vertical group (card body)
|
|
92
|
+
<Flex direction="column" gap="4"> // section sub-groups
|
|
93
|
+
<Flex direction="column" gap="6"> // major content blocks
|
|
94
|
+
<Flex direction="column" gap="8"> // section-level stacking (page builder)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Align + Justify Semantics
|
|
98
|
+
|
|
99
|
+
| Pattern | Use for |
|
|
100
|
+
| ---------------------------------- | -------------------------------------- |
|
|
101
|
+
| `align="center" justify="between"` | Header rows (logo left, actions right) |
|
|
102
|
+
| `align="center" justify="center"` | Hero content, centered section content |
|
|
103
|
+
| `align="center" justify="start"` | List rows, sidebar items |
|
|
104
|
+
| `align="start" justify="start"` | Text-heavy blocks, card bodies |
|
|
105
|
+
| `align="center" justify="end"` | Action footers (Cancel / Confirm) |
|
|
106
|
+
|
|
107
|
+
**Never use `justify="between"` for fewer than 2 elements.** It collapses to `justify="start"` and looks identical but communicates broken intent.
|
|
108
|
+
|
|
109
|
+
### Optical Centering — Three-Column TopBar Rule
|
|
110
|
+
|
|
111
|
+
> **Problem:** `justify-between` on a flex row containing 3 children (logo | nav | actions) does NOT optically center the middle element.
|
|
112
|
+
|
|
113
|
+
**The fix — three equal-width columns:**
|
|
114
|
+
|
|
115
|
+
```jsx
|
|
116
|
+
// ✓ center column is ALWAYS optically centered regardless of side widths
|
|
117
|
+
<Flex as="header" align="center" className="h-14 px-6">
|
|
118
|
+
<Flex align="center" justify="start" className="flex-1">
|
|
119
|
+
<Logo />
|
|
120
|
+
</Flex>
|
|
121
|
+
<Flex align="center" justify="center" className="flex-1">
|
|
122
|
+
<Flex as="nav" align="center" gap="6">
|
|
123
|
+
<Link href="/docs">Docs</Link>
|
|
124
|
+
<Link href="/components">Components</Link>
|
|
125
|
+
<Link href="/blocks">Blocks</Link>
|
|
126
|
+
</Flex>
|
|
127
|
+
</Flex>
|
|
128
|
+
<Flex align="center" justify="end" gap="2" className="flex-1">
|
|
129
|
+
<IconButton aria-label="Toggle theme"><Icon name="Moon" size="md" /></IconButton>
|
|
130
|
+
<Button>Get started</Button>
|
|
131
|
+
</Flex>
|
|
132
|
+
</Flex>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**The rule:** Any horizontal bar where visual center matters — top navigation, modal header, toolbar — **MUST** use three `flex-1` children rather than `justify-between`. `justify-between` is only correct when there are exactly two children.
|
|
136
|
+
|
|
137
|
+
| Layout | Use three-col `flex-1` | Use `justify-between` |
|
|
138
|
+
| -------------------------------------------- | --------------------------- | --------------------------------- |
|
|
139
|
+
| Top navigation (logo + nav links + actions) | ✅ Always | ✗ Never |
|
|
140
|
+
| Modal / dialog header (title + close button) | ✅ When content is centered | ✓ When title is left-aligned |
|
|
141
|
+
| Toolbar with centered tool group | ✅ Yes | ✗ No |
|
|
142
|
+
| Card header (label + action) | — | ✅ Two children, no center needed |
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Grid Layout Rules
|
|
147
|
+
|
|
148
|
+
### Column Count by Context
|
|
149
|
+
|
|
150
|
+
```jsx
|
|
151
|
+
// Feature/card grids
|
|
152
|
+
<Grid columns="3" className="grid-cols-1 sm:grid-cols-2 lg:grid-cols-3"> // 3-up feature grid
|
|
153
|
+
<Grid columns="2" className="grid-cols-1 md:grid-cols-2"> // 2-up comparison
|
|
154
|
+
<Grid columns="4" className="grid-cols-2 lg:grid-cols-4"> // stat/metric row
|
|
155
|
+
|
|
156
|
+
// App sidebar + content
|
|
157
|
+
className="grid grid-cols-[240px_1fr]" // fixed sidebar
|
|
158
|
+
className="grid grid-cols-[1fr_320px]" // main + aside panel
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Grid Gap Reference
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
gap-4 (16px) ← form fields, dense card grids
|
|
165
|
+
gap-5 (20px) ← standard card grids (compact)
|
|
166
|
+
gap-6 (24px) ← standard card grids (comfortable)
|
|
167
|
+
gap-8 (32px) ← feature grids, large showcase cards
|
|
168
|
+
gap-10 (40px) ← hero split layouts, large editorial
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Rule:** Match gap size to card padding. If a card has `p-6`, the grid gap should be `gap-6`. Visual rhythm = gap ≈ card padding.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Container Nesting Depth
|
|
176
|
+
|
|
177
|
+
Every nesting level adds cognitive weight. Limit depth deliberately.
|
|
178
|
+
|
|
179
|
+
### Maximum Nesting Rules
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
Page depth 0 — <main>, <body>
|
|
183
|
+
Section depth 1 — <section>
|
|
184
|
+
Container depth 2 — <Container size="lg">
|
|
185
|
+
Content block depth 3 — <div> or grid row
|
|
186
|
+
Card / panel depth 4 — <Card> or surface div
|
|
187
|
+
Card internal group depth 5 — <div className="space-y-3">
|
|
188
|
+
Element depth 6 — <Button>, <Text>, <Input>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Hard rules:**
|
|
192
|
+
|
|
193
|
+
- **Maximum 6 nesting levels** from `<main>` to a leaf element.
|
|
194
|
+
- **Never nest a card inside a card** without a clear semantic reason (exception: inset code block, terminal preview).
|
|
195
|
+
- **Never wrap a single child** in a div whose sole purpose is adding margin. Use `mt-*` on the child directly or `gap-*` on the parent.
|
|
196
|
+
- **`<section>` is never a layout div.** A section communicates document structure. Use `<div>` for purely presentational groupings.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Typography Spacing Within Components
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
Heading → immediately following subheading: gap-1 / space-y-1
|
|
204
|
+
Heading → following body text: gap-2 / space-y-2
|
|
205
|
+
Label → Input: space-y-1 or space-y-1.5
|
|
206
|
+
Input → helper text / error: mt-1
|
|
207
|
+
Form field → next form field: space-y-4 or space-y-5
|
|
208
|
+
Section heading → body text: gap-3 / space-y-3
|
|
209
|
+
Section body → CTA button: mt-6 or mt-8
|
|
210
|
+
Label (if any) → heading (section header): gap-3 (label above heading)
|
|
211
|
+
Heading → description (card): space-y-2
|
|
212
|
+
Card body → card footer divider: pt-3 border-t border-hairline
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Rule:** Heading and its direct supporting text always have less space between them (`gap-2`) than the space between the heading+text group and the next sibling group (`gap-6`). If sibling distance ≤ internal distance, the grouping breaks.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Responsive Breakpoint Rules
|
|
220
|
+
|
|
221
|
+
### Breakpoint Ladder
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
Default (mobile, <640px): single column, full-width, compressed padding
|
|
225
|
+
sm (>=640px): 2-column grids begin, padding grows slightly
|
|
226
|
+
md (>=768px): desktop layout kicks in fully, full nav visible
|
|
227
|
+
lg (>=1024px): 3-column grids, sidebar layouts
|
|
228
|
+
xl (>=1280px): max-width containers stop growing, content centers
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Responsive Padding Pattern
|
|
232
|
+
|
|
233
|
+
```jsx
|
|
234
|
+
// Section
|
|
235
|
+
className = "py-12 md:py-16 lg:py-24";
|
|
236
|
+
|
|
237
|
+
// Container horizontal gutter
|
|
238
|
+
className = "px-4 sm:px-6 md:px-8 lg:px-10";
|
|
239
|
+
|
|
240
|
+
// Card (stays consistent — card padding doesn't need to grow)
|
|
241
|
+
className = "p-4 md:p-5";
|
|
242
|
+
|
|
243
|
+
// Hero vertical breathing
|
|
244
|
+
className = "pt-12 pb-16 md:pt-20 md:pb-24";
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Rule:** Never reduce padding at larger breakpoints. Spacing only grows or stays the same as viewport expands.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Alignment Rules
|
|
252
|
+
|
|
253
|
+
### The Three Alignment Contexts
|
|
254
|
+
|
|
255
|
+
| Alignment | When to use | Hard limits |
|
|
256
|
+
| ---------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
|
|
257
|
+
| **Left** | Body text, list content, form labels, card body, sidebar nav, data tables, any content > 2 lines | No limit — default for all prose and data |
|
|
258
|
+
| **Center** | Hero headings, section headers, empty states, standalone CTAs | Max **3 lines** of text. Never center a paragraph. Never center form fields. |
|
|
259
|
+
| **Right** | Numeric data in table cells, trailing actions in a row, timestamps in chat | Only in contexts where right-to-left reading makes sense (amounts, timestamps) |
|
|
260
|
+
|
|
261
|
+
### Reading Path Rules
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
Marketing page (F-pattern):
|
|
265
|
+
Logo (top-left) → Nav (horizontal) → Hero heading → CTA → Sections scroll downward
|
|
266
|
+
|
|
267
|
+
App dashboard (Z-pattern):
|
|
268
|
+
Page title (top-left) → Actions (top-right) → Primary metric (top-left of content)
|
|
269
|
+
→ Supporting content (right / below)
|
|
270
|
+
|
|
271
|
+
Form (single-column downward):
|
|
272
|
+
Label → Input → Hint → Next label → Next input
|
|
273
|
+
Never: 2-column forms on mobile
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Alignment must be consistent within a section.** If one card has `text-left`, all cards in that grid have `text-left`.
|
|
277
|
+
|
|
278
|
+
### Ruled-List / Divider Layout Alignment
|
|
279
|
+
|
|
280
|
+
When building horizontal-divider layouts (ruled lists, definition rows, feature matrices) where each row has a **label column + description column**, the label column MUST use a **fixed width** so all descriptions start at the same x position across rows.
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
// ✓ Correct — label column has fixed width, descriptions align
|
|
284
|
+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-[260px_1fr] sm:items-center">
|
|
285
|
+
<div className="shrink-0">Label A</div>
|
|
286
|
+
<div>Description for A starts here</div>
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
// ✗ Wrong — label width varies per row, descriptions misalign
|
|
290
|
+
<div className="grid grid-cols-2 gap-4">
|
|
291
|
+
<div>Label A</div> {/* different width */}
|
|
292
|
+
<div>Description for A</div>
|
|
293
|
+
</div>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Key rules:**
|
|
297
|
+
- Use `sm:grid-cols-[Wpx_1fr]` (or `sm:grid-cols-[Wrem_1fr]`) with a fixed first column
|
|
298
|
+
- Add `shrink-0` to the label to prevent flex compression
|
|
299
|
+
- Common widths: `w-44` (11rem) for short labels, `sm:w-72` (18rem) for longer labels
|
|
300
|
+
- On mobile, stack vertically (`grid-cols-1`) — the fixed width only applies at `sm:` and up
|
|
301
|
+
- This applies to ALL ruled/divider layouts: lineage lists, feature matrices, tool descriptions, cognitive skills grids
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Repeating Unit Consistency
|
|
306
|
+
|
|
307
|
+
Every element that appears in a set (cards in a grid, items in a list, tabs in a tab bar) must have **identical spatial structure** at any given viewport: same padding, same gap, same border treatment, same radius.
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
✓ Correct — identical structure:
|
|
311
|
+
Card 1: p-5, space-y-3, border border-hairline, rounded-[var(--radius-panel)]
|
|
312
|
+
Card 2: p-5, space-y-3, border border-hairline, rounded-[var(--radius-panel)]
|
|
313
|
+
|
|
314
|
+
✗ Wrong — structure varies:
|
|
315
|
+
Card 1: p-5, space-y-3, border, rounded-[var(--radius-panel)]
|
|
316
|
+
Card 2: p-4, space-y-4, no border, rounded-[var(--radius-lg)] ← different
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**Content varies. Structure does not.**
|
|
320
|
+
|
|
321
|
+
### When Intentional Variation Is Valid
|
|
322
|
+
|
|
323
|
+
Maximum **1** variant item per repeating set. Must be visually heavier, positioned first or last — never in the middle.
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## False Containment Rule
|
|
328
|
+
|
|
329
|
+
### What Is False Containment
|
|
330
|
+
|
|
331
|
+
False containment occurs when a visual boundary (border, background, shadow, rounded corners) is applied for aesthetic reasons without a semantic reason.
|
|
332
|
+
|
|
333
|
+
### The Containment Test
|
|
334
|
+
|
|
335
|
+
Before adding any `border`, `bg-*`, `shadow-*`, or `rounded-*` to a div, answer:
|
|
336
|
+
|
|
337
|
+
> **What conceptual group does this boundary define, and what is outside it?**
|
|
338
|
+
|
|
339
|
+
If you cannot answer clearly, the boundary is false. Remove it.
|
|
340
|
+
|
|
341
|
+
```
|
|
342
|
+
✓ Valid containment:
|
|
343
|
+
Card with border border-hairline — groups: "this card's content" vs "the grid around it"
|
|
344
|
+
Sidebar with bg-surface — groups: "navigation" vs "main content"
|
|
345
|
+
|
|
346
|
+
✗ False containment:
|
|
347
|
+
Div with border around a heading and its subtext
|
|
348
|
+
bg-surface on a div that is just vertically stacking two paragraphs
|
|
349
|
+
Card inside a card with a different background
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Containment Hierarchy Must Match Semantic Hierarchy
|
|
353
|
+
|
|
354
|
+
```
|
|
355
|
+
Correct hierarchy:
|
|
356
|
+
Page background: bg-canvas (no shadow, no border)
|
|
357
|
+
Section: bg-surface border-y border-hairline (light boundary)
|
|
358
|
+
Card: shadow-card border border-hairline rounded-[var(--radius-panel)] (medium boundary)
|
|
359
|
+
Badge: bg-brand/15 rounded-[var(--radius-lg)] (light inner signal)
|
|
360
|
+
|
|
361
|
+
Inverted (wrong):
|
|
362
|
+
Card: shadow-sm border (lighter than its inner element)
|
|
363
|
+
Inner callout: shadow-panel (heavier — visually overrides the parent) ✗
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## Quick Reference — Spatial Scale
|
|
369
|
+
|
|
370
|
+
| Scale | px | Common use |
|
|
371
|
+
| ------------------------- | -------- | ------------------------------------------- |
|
|
372
|
+
| `space-y-1` / `gap-1` | 4px | Label → hint, icon → label |
|
|
373
|
+
| `space-y-1.5` / `gap-1.5` | 6px | Dense list item internals |
|
|
374
|
+
| `space-y-2` / `gap-2` | 8px | Heading → subtext, tight sibling rows |
|
|
375
|
+
| `space-y-3` / `gap-3` | 12px | Card body groups, nav item gaps |
|
|
376
|
+
| `space-y-4` / `gap-4` | 16px | Form field gap, card grid (dense) |
|
|
377
|
+
| `space-y-5` / `gap-5` | 20px | Card grid (compact) |
|
|
378
|
+
| `space-y-6` / `gap-6` | 24px | Standard card grid, section sub-blocks |
|
|
379
|
+
| `space-y-8` / `gap-8` | 32px | Feature grids, page content blocks |
|
|
380
|
+
| `space-y-10` / `gap-10` | 40px | Hero splits, large editorial layouts |
|
|
381
|
+
| `py-12` | 48px | Compact section / mobile standard |
|
|
382
|
+
| `py-16` | 64px | Standard marketing section |
|
|
383
|
+
| `py-20` | 80px | Prominent section |
|
|
384
|
+
| `py-24` | 96px | Hero / major landmark section |
|
|
385
|
+
| `py-32` | 128px | Extra-large hero / editorial breath section |
|
|
386
|
+
| `min-h-screen` / `100dvh` | viewport | Editorial full-screen hero |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Spacing Dense — Density Framework & Monospace Restraint
|
|
2
|
+
|
|
3
|
+
> **Load priority:** STRUCTURAL mode (dashboards, admin panels, data tables, apps). Skip for MARKETING.
|
|
4
|
+
> **Token cost:** ~850 tokens.
|
|
5
|
+
> **Depends on:** `spacing-core.md` for section architecture, flex/grid, and the spatial scale reference.
|
|
6
|
+
|
|
7
|
+
This file covers two rules that only apply to dense, data-heavy interfaces — the density framework (how compressed spacing should be by interface type) and monospace font restraint (where `font-mono` is and isn't allowed).
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Density Framework
|
|
12
|
+
|
|
13
|
+
### Density Levels
|
|
14
|
+
|
|
15
|
+
| Level | Description | Padding scale | Gap scale | Line height |
|
|
16
|
+
| --------------- | ---------------------------------------------------- | ---------------------------------------------- | ---------------- | ------------------------------------- |
|
|
17
|
+
| **Airy** | Marketing, editorial, hero sections | `p-6`–`p-8` surfaces, `py-20`+ sections | `gap-6`–`gap-10` | `leading-relaxed` or `leading-loose` |
|
|
18
|
+
| **Comfortable** | Standard web app, settings panels, documentation | `p-4`–`p-6` surfaces, `py-12`–`py-16` sections | `gap-4`–`gap-6` | `leading-normal` or `leading-relaxed` |
|
|
19
|
+
| **Compact** | Dashboards, data tables, sidebars, admin tools | `p-3`–`p-4` surfaces, `py-8`–`py-12` sections | `gap-2`–`gap-4` | `leading-tight` or `leading-normal` |
|
|
20
|
+
| **Dense** | Command palettes, terminal output, log viewers, code | `p-2`–`p-3` surfaces, `py-4`–`py-8` sections | `gap-1`–`gap-2` | `leading-tight` |
|
|
21
|
+
|
|
22
|
+
### Density Decision by Interface Type
|
|
23
|
+
|
|
24
|
+
| Interface type | Correct density | Never use |
|
|
25
|
+
| --------------------------- | --------------------------------------- | -------------------------- |
|
|
26
|
+
| Marketing landing page | Airy | Compact or Dense |
|
|
27
|
+
| Documentation portal | Comfortable | Dense |
|
|
28
|
+
| SaaS product (general) | Comfortable | Airy (wastes screen space) |
|
|
29
|
+
| Analytics / dashboard | Compact | Airy |
|
|
30
|
+
| Admin / data table | Compact–Dense | Airy |
|
|
31
|
+
| Command palette / spotlight | Dense | Airy or Comfortable |
|
|
32
|
+
| Mobile app (any) | Comfortable (one level up from desktop) | Dense on mobile |
|
|
33
|
+
|
|
34
|
+
**Rule:** Never mix density levels within a single view.
|
|
35
|
+
|
|
36
|
+
### Responsive Density
|
|
37
|
+
|
|
38
|
+
Mobile is always **one density level more compressed** than desktop.
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Desktop marketing page: Airy → py-24, p-8 cards, gap-8
|
|
42
|
+
Mobile marketing page: Comfortable → py-16, p-5 cards, gap-6
|
|
43
|
+
|
|
44
|
+
Desktop dashboard: Compact → py-12, p-4 cards, gap-4
|
|
45
|
+
Mobile dashboard: Dense → py-8, p-3 cards, gap-3
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Monospace Typography Restraint (`font-mono` Usage)
|
|
51
|
+
|
|
52
|
+
`font-mono` must be reserved strictly for code representations (code blocks, inline `<code>` snippets, CLI commands, raw token keys, hashes/IDs). Use it very sparingly in regular UI unless the project's font preset is explicitly monospace.
|
|
53
|
+
|
|
54
|
+
### What NOT to Use `font-mono` On
|
|
55
|
+
- ❌ Standard UI labels, form field labels, dropdown labels
|
|
56
|
+
- ❌ Filter popovers & headers, popover titles, action triggers
|
|
57
|
+
- ❌ Component & asset names in galleries/catalogs
|
|
58
|
+
- ❌ Metric units & status labels
|
|
59
|
+
|
|
60
|
+
### What `font-mono` IS Intended For
|
|
61
|
+
- ✅ Code snippets & representations, inline `<code>` tags, JSX prop syntax
|
|
62
|
+
- ✅ Developer syntax & keys: raw token keys, CSS variables, hex color strings, git SHAs
|
|
63
|
+
- ✅ Explicit Monospace Design Modes (Brutalist / Developer Terminal theme)
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Spacing Marketing — Hierarchy, Weight & Negative Space
|
|
2
|
+
|
|
3
|
+
> **Load priority:** MARKETING and EDITORIAL modes. Skip for STRUCTURAL.
|
|
4
|
+
> **Token cost:** ~2.5K tokens.
|
|
5
|
+
> **Depends on:** `spacing-core.md` for section architecture, flex/grid, alignment, and the spatial scale reference.
|
|
6
|
+
|
|
7
|
+
This file covers the spatial rules that govern marketing pages, landing pages, and editorial layouts — visual dominance hierarchy, weight balance, negative space budgets, the first-3-seconds perception rule, and gradient blending. These rules are about controlling attention and breathing room, not structural composition.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Hierarchy Stack — Making Exactly One Element Dominant
|
|
12
|
+
|
|
13
|
+
The three levers that create visual dominance are **size**, **weight**, and **surrounding space**. They must all point to the same element.
|
|
14
|
+
|
|
15
|
+
### The Three Dominance Levels
|
|
16
|
+
|
|
17
|
+
| Level | Role | Size | Weight | Surrounding space |
|
|
18
|
+
| ------------- | ------------------------------------- | --------------------------------------- | ------------------------------- | ------------------------------------------ |
|
|
19
|
+
| **Primary** | The one thing users must notice first | `text-4xl`–`text-7xl` / largest graphic | `font-bold` or `font-extrabold` | `mt-0 mb-4`+ on desktop; always above fold |
|
|
20
|
+
| **Secondary** | Supports the primary; labels actions | `text-lg`–`text-2xl` | `font-semibold` | `mb-2`–`mb-3` |
|
|
21
|
+
| **Tertiary** | Body copy, captions, hints, metadata | `text-sm`–`text-base` | `font-normal` or `font-medium` | `mb-1`–`mb-2` |
|
|
22
|
+
|
|
23
|
+
**Rules:**
|
|
24
|
+
|
|
25
|
+
- Exactly **one** primary element per screen or logical view. Never two.
|
|
26
|
+
- Primary element must be **at least 2× the font-size** of the nearest secondary element.
|
|
27
|
+
- Never apply `font-bold` or `shadow-panel` to a tertiary element — it creates false primacy.
|
|
28
|
+
- Color alone does not create hierarchy. `text-brand-text` on body-sized text is emphasis, not primary level.
|
|
29
|
+
|
|
30
|
+
### Responsive Hierarchy
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Desktop primary: text-5xl md:text-7xl (48px → 72px)
|
|
34
|
+
Desktop secondary: text-xl md:text-2xl (20px → 24px)
|
|
35
|
+
Desktop tertiary: text-sm md:text-base (14px → 16px)
|
|
36
|
+
|
|
37
|
+
Mobile primary: text-4xl (36px) — still 2× secondary ✓
|
|
38
|
+
Mobile secondary: text-lg (18px)
|
|
39
|
+
Mobile tertiary: text-sm (14px)
|
|
40
|
+
|
|
41
|
+
Ratio check: 36 / 18 = 2.0 — minimum maintained ✓
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Visual Weight Balance
|
|
47
|
+
|
|
48
|
+
### What Creates Weight
|
|
49
|
+
|
|
50
|
+
| Property | Weight added | Rule |
|
|
51
|
+
| ------------------------------------------ | ------------ | ----------------------------------------- |
|
|
52
|
+
| Large size (`text-5xl+`, full-width image) | Very high | Must be the primary element |
|
|
53
|
+
| `shadow-panel` or `shadow-card` | High | Requires `p-5`+ inside the surface |
|
|
54
|
+
| `bg-brand` or high-saturation background | High | Max 1 brand-bg element per view |
|
|
55
|
+
| `font-bold` + large size | High | Only on primary / secondary elements |
|
|
56
|
+
| `border border-hairline` | Low-medium | Adds containment weight; use deliberately |
|
|
57
|
+
| `text-fg` vs `text-fg-muted` | Low | Dark text is heavier than muted |
|
|
58
|
+
| Dense content (many elements, small gap) | Medium | Counter with surrounding whitespace |
|
|
59
|
+
|
|
60
|
+
### Balancing Heavy Elements
|
|
61
|
+
|
|
62
|
+
When a heavy element exists, it must be balanced by **increased surrounding whitespace**, not by adding more heavy elements.
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
Heavy card (shadow-panel):
|
|
66
|
+
Needs: min p-5 internal, min gap-6 in surrounding grid
|
|
67
|
+
|
|
68
|
+
Brand-background badge or callout:
|
|
69
|
+
Needs: py-1.5+ vertical padding, surrounded by text-fg-muted elements
|
|
70
|
+
|
|
71
|
+
Large hero heading (text-6xl+):
|
|
72
|
+
Needs: mb-4+ below it before the next element, pb-16+ section padding
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**The balance rule:** If you add a `shadow-*` class, increase `p-*` by one step. If you add `bg-brand`, surround with `text-fg-muted` elements and increase gap.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Negative Space Budget
|
|
80
|
+
|
|
81
|
+
### Content Width Budget
|
|
82
|
+
|
|
83
|
+
| Interface type | Target content width | Minimum | Maximum |
|
|
84
|
+
| ----------------------------- | ---------------------------------- | ---------- | ----------- |
|
|
85
|
+
| Marketing page body text | 60–70% of container | 50% | 75% |
|
|
86
|
+
| App main content area | 70–85% of viewport (minus sidebar) | 60% | 90% |
|
|
87
|
+
| Reading / documentation prose | 65ch–80ch max-width | 45ch | 90ch |
|
|
88
|
+
| Modal / dialog | 40–60% of viewport width | `max-w-sm` | `max-w-3xl` |
|
|
89
|
+
|
|
90
|
+
### Vertical Whitespace Budget
|
|
91
|
+
|
|
92
|
+
- Marketing pages: whitespace ≥ **25% of total page height**
|
|
93
|
+
- Apps: whitespace ≥ **15% of total screen height**
|
|
94
|
+
|
|
95
|
+
### Negative Space is Not Waste
|
|
96
|
+
|
|
97
|
+
| Gap location | What it signals | Rule |
|
|
98
|
+
| ------------------------------------------------ | ---------------------------------------------------- | ------------------------------------------------------- |
|
|
99
|
+
| `mb-10 md:mb-12` between section header and grid | "This header introduces what follows" | Never reduce below `mb-8` |
|
|
100
|
+
| `py-16` section padding | "This section is a complete, contained idea" | Never reduce below `py-12` for marketing |
|
|
101
|
+
| `gap-6` between cards | "These cards are independent but related" | Never use `gap-2` between cards |
|
|
102
|
+
| `mt-8` above a standalone CTA | "This action is separate from the preceding content" | Never place a CTA immediately adjacent with `mt-2` |
|
|
103
|
+
|
|
104
|
+
**Never remove a gap entirely on mobile.** `gap-0` or `space-y-0` between conceptually separate items destroys their relationship signal.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## First-3-Seconds Rule
|
|
109
|
+
|
|
110
|
+
### What Users See Before They Read
|
|
111
|
+
|
|
112
|
+
In the first 3 seconds, users perceive: the dominant element's size and position, the rough density, whether there is a clear action, and whether the page feels "safe". They do not yet read the heading.
|
|
113
|
+
|
|
114
|
+
### Spatial Rules for the First 3 Seconds
|
|
115
|
+
|
|
116
|
+
**1. Primary element above the fold — always.**
|
|
117
|
+
```
|
|
118
|
+
Desktop fold: ~700px–900px from top of viewport
|
|
119
|
+
Mobile fold: ~550px–700px from top of viewport
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**2. CTA within reach of the primary message.**
|
|
123
|
+
```
|
|
124
|
+
Desktop: CTA must be within 320px vertically of the h1 bottom edge.
|
|
125
|
+
Mobile: CTA must be within 240px vertically of the h1 bottom edge.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**3. Maximum 3 focal elements in any hero or primary view.**
|
|
129
|
+
```
|
|
130
|
+
Focal element = anything with shadow-panel, bg-brand, text-5xl+, or a primary Button.
|
|
131
|
+
On mobile, reduce to 2 focal elements if possible.
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**4. Navigation must not compete with the primary element.**
|
|
135
|
+
```
|
|
136
|
+
Header height: h-14 (56px) standard, h-16 (64px) max.
|
|
137
|
+
Header background: bg-canvas/80 backdrop-blur — semi-transparent.
|
|
138
|
+
Never: a header taller than 72px.
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Animated / Static Gradient Blending
|
|
144
|
+
|
|
145
|
+
Use this when placing animated mesh gradients as page-level decorative backgrounds that should dissolve cleanly into the canvas color.
|
|
146
|
+
|
|
147
|
+
### The Page-Level Backdrop Pattern
|
|
148
|
+
|
|
149
|
+
Gradient backgrounds spanning multiple sections must be owned at the **page level**, not inside any individual section component.
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
// In page.tsx — outside <Header> and <main>
|
|
153
|
+
<div
|
|
154
|
+
className="pointer-events-none absolute inset-x-0 top-0 z-0 overflow-hidden"
|
|
155
|
+
aria-hidden
|
|
156
|
+
style={{
|
|
157
|
+
height: "calc(64px + 92svh + 160px)",
|
|
158
|
+
maskImage: "linear-gradient(to bottom, black 0%, black 65%, transparent 100%)",
|
|
159
|
+
WebkitMaskImage: "linear-gradient(to bottom, black 0%, black 65%, transparent 100%)",
|
|
160
|
+
}}
|
|
161
|
+
>
|
|
162
|
+
<div className="hero-gradient-light absolute inset-0 opacity-70 dark:hidden" />
|
|
163
|
+
<div className="hero-gradient-dark absolute inset-0 hidden opacity-80 dark:block" />
|
|
164
|
+
</div>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Key rules:**
|
|
168
|
+
- **z-index**: gradient `z-0`, Header `z-50`, main content `z-10`
|
|
169
|
+
- **`pointer-events-none`**: gradient must never intercept clicks
|
|
170
|
+
- **`aria-hidden`**: purely decorative
|
|
171
|
+
- **Header transparency**: `bg-canvas/40 backdrop-blur-xl` (not `bg-canvas/90`)
|
|
172
|
+
- **`position: absolute`**: scrolls with the page (not `fixed`)
|
|
173
|
+
|
|
174
|
+
### Fading: CSS `mask-image` vs Overlay Div
|
|
175
|
+
|
|
176
|
+
**Use `mask-image`, not an overlay div:**
|
|
177
|
+
|
|
178
|
+
| Method | Works | Problem |
|
|
179
|
+
| ---------------------------------------------------------------- | ---------------------- | --------------------------------------------------------- |
|
|
180
|
+
| Overlay div `bg-linear-gradient(transparent → var(--bg-canvas))` | ❌ Broken | Color-interpolation bug across themes |
|
|
181
|
+
| Overlay div `bg-linear-gradient(transparent → #ffffff)` | ❌ Broken in dark mode | Hardcodes a color |
|
|
182
|
+
| `maskImage: linear-gradient(black → transparent)` | ✅ Correct | Uses mask alpha channel — fully color-agnostic |
|
|
183
|
+
|
|
184
|
+
### Sections Below the Gradient Must Be Opaque
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
// ✓ Correct — blocks any residual gradient bleed
|
|
188
|
+
<section className="relative border-t border-hairline bg-canvas py-16 md:py-24">
|
|
189
|
+
|
|
190
|
+
// ✗ Wrong — transparent section shows gradient underneath
|
|
191
|
+
<section className="relative border-t border-hairline py-16 md:py-24">
|
|
192
|
+
```
|