@champpaba/claude-agent-kit 3.0.2 → 3.2.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/.claude/CHANGELOG.md +707 -0
- package/.claude/CLAUDE.md +128 -613
- package/.claude/agents/_shared/pre-work-checklist.md +108 -7
- package/.claude/commands/cdev.md +36 -0
- package/.claude/commands/csetup.md +292 -1791
- package/.claude/commands/cview.md +364 -364
- package/.claude/contexts/design/accessibility.md +611 -611
- package/.claude/contexts/design/layout.md +400 -400
- package/.claude/contexts/design/responsive.md +551 -551
- package/.claude/contexts/design/shadows.md +522 -522
- package/.claude/contexts/design/typography.md +465 -465
- package/.claude/contexts/domain/README.md +164 -164
- package/.claude/contexts/patterns/agent-coordination.md +388 -388
- package/.claude/contexts/patterns/development-principles.md +513 -513
- package/.claude/contexts/patterns/error-handling.md +478 -478
- package/.claude/contexts/patterns/logging.md +424 -424
- package/.claude/contexts/patterns/tdd-classification.md +516 -516
- package/.claude/contexts/patterns/testing.md +413 -413
- package/.claude/lib/README.md +3 -3
- package/.claude/lib/detailed-guides/taskmaster-analysis.md +1 -1
- package/.claude/lib/task-analyzer.md +144 -0
- package/.claude/lib/tdd-workflow.md +2 -1
- package/.claude/lib/validation-gates.md +484 -484
- package/.claude/settings.local.json +42 -42
- package/.claude/templates/PROJECT_STATUS.template.yml +16 -41
- package/.claude/templates/context-template.md +45 -45
- package/.claude/templates/flags-template.json +42 -42
- package/.claude/templates/phases-sections/accessibility-test.md +17 -17
- package/.claude/templates/phases-sections/api-design.md +37 -37
- package/.claude/templates/phases-sections/backend-tests.md +16 -16
- package/.claude/templates/phases-sections/backend.md +37 -37
- package/.claude/templates/phases-sections/business-logic-validation.md +16 -16
- package/.claude/templates/phases-sections/component-tests.md +17 -17
- package/.claude/templates/phases-sections/contract-backend.md +16 -16
- package/.claude/templates/phases-sections/contract-frontend.md +16 -16
- package/.claude/templates/phases-sections/database.md +35 -35
- package/.claude/templates/phases-sections/e2e-tests.md +16 -16
- package/.claude/templates/phases-sections/fix-implementation.md +17 -17
- package/.claude/templates/phases-sections/frontend-integration.md +18 -18
- package/.claude/templates/phases-sections/manual-flow-test.md +15 -15
- package/.claude/templates/phases-sections/manual-ux-test.md +16 -16
- package/.claude/templates/phases-sections/refactor-implementation.md +17 -17
- package/.claude/templates/phases-sections/refactor.md +16 -16
- package/.claude/templates/phases-sections/regression-tests.md +15 -15
- package/.claude/templates/phases-sections/responsive-test.md +16 -16
- package/.claude/templates/phases-sections/script-implementation.md +43 -43
- package/.claude/templates/phases-sections/test-coverage.md +16 -16
- package/.claude/templates/phases-sections/user-approval.md +14 -14
- package/LICENSE +21 -21
- package/package.json +1 -1
- package/.claude/lib/tdd-classifier.md +0 -345
|
@@ -1,400 +1,400 @@
|
|
|
1
|
-
# Layout Patterns
|
|
2
|
-
|
|
3
|
-
> **Purpose:** Common layout structures and alignment strategies
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Core Layout Principles
|
|
8
|
-
|
|
9
|
-
1. **Box Model First** - Understand all elements as boxes (see `box-thinking.md`)
|
|
10
|
-
2. **Flex for 1D** - Use flexbox for single-axis layouts (rows or columns)
|
|
11
|
-
3. **Grid for 2D** - Use CSS Grid for multi-axis layouts (rows AND columns)
|
|
12
|
-
4. **Responsive by Default** - Design mobile-first, enhance for larger screens
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## Common Layout Patterns
|
|
17
|
-
|
|
18
|
-
### 1. Stack (Vertical)
|
|
19
|
-
|
|
20
|
-
**Use for:** Form fields, article content, vertical lists
|
|
21
|
-
|
|
22
|
-
```css
|
|
23
|
-
.stack {
|
|
24
|
-
display: flex;
|
|
25
|
-
flex-direction: column;
|
|
26
|
-
gap: var(--spacing-4); /* 16px */
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Variants */
|
|
30
|
-
.stack-tight {
|
|
31
|
-
gap: var(--spacing-2); /* 8px */
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.stack-loose {
|
|
35
|
-
gap: var(--spacing-8); /* 32px */
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**HTML:**
|
|
40
|
-
```html
|
|
41
|
-
<div class="stack">
|
|
42
|
-
<div>Item 1</div>
|
|
43
|
-
<div>Item 2</div>
|
|
44
|
-
<div>Item 3</div>
|
|
45
|
-
</div>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
### 2. Inline (Horizontal)
|
|
51
|
-
|
|
52
|
-
**Use for:** Button groups, breadcrumbs, navigation
|
|
53
|
-
|
|
54
|
-
```css
|
|
55
|
-
.inline {
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: row;
|
|
58
|
-
gap: var(--spacing-4); /* 16px */
|
|
59
|
-
align-items: center; /* Vertical centering */
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/* Variants */
|
|
63
|
-
.inline-start {
|
|
64
|
-
justify-content: flex-start; /* Left-aligned */
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.inline-center {
|
|
68
|
-
justify-content: center; /* Centered */
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.inline-end {
|
|
72
|
-
justify-content: flex-end; /* Right-aligned */
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.inline-between {
|
|
76
|
-
justify-content: space-between; /* Space between items */
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
### 3. Sidebar Layout
|
|
83
|
-
|
|
84
|
-
**Use for:** Dashboard, admin panels, documentation
|
|
85
|
-
|
|
86
|
-
```css
|
|
87
|
-
.sidebar-layout {
|
|
88
|
-
display: grid;
|
|
89
|
-
grid-template-columns: 250px 1fr; /* Fixed sidebar + fluid main */
|
|
90
|
-
gap: var(--spacing-6); /* 24px */
|
|
91
|
-
min-height: 100vh;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@media (max-width: 768px) {
|
|
95
|
-
.sidebar-layout {
|
|
96
|
-
grid-template-columns: 1fr; /* Stack on mobile */
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
**HTML:**
|
|
102
|
-
```html
|
|
103
|
-
<div class="sidebar-layout">
|
|
104
|
-
<aside class="sidebar">Sidebar</aside>
|
|
105
|
-
<main class="main-content">Main Content</main>
|
|
106
|
-
</div>
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
### 4. Holy Grail Layout
|
|
112
|
-
|
|
113
|
-
**Use for:** Classic web pages (header, sidebar, content, footer)
|
|
114
|
-
|
|
115
|
-
```css
|
|
116
|
-
.holy-grail {
|
|
117
|
-
display: grid;
|
|
118
|
-
grid-template-areas:
|
|
119
|
-
"header header header"
|
|
120
|
-
"sidebar main aside"
|
|
121
|
-
"footer footer footer";
|
|
122
|
-
grid-template-columns: 200px 1fr 200px;
|
|
123
|
-
grid-template-rows: auto 1fr auto;
|
|
124
|
-
min-height: 100vh;
|
|
125
|
-
gap: var(--spacing-4);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.header { grid-area: header; }
|
|
129
|
-
.sidebar { grid-area: sidebar; }
|
|
130
|
-
.main { grid-area: main; }
|
|
131
|
-
.aside { grid-area: aside; }
|
|
132
|
-
.footer { grid-area: footer; }
|
|
133
|
-
|
|
134
|
-
@media (max-width: 1024px) {
|
|
135
|
-
.holy-grail {
|
|
136
|
-
grid-template-areas:
|
|
137
|
-
"header"
|
|
138
|
-
"main"
|
|
139
|
-
"sidebar"
|
|
140
|
-
"aside"
|
|
141
|
-
"footer";
|
|
142
|
-
grid-template-columns: 1fr;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
### 5. Card Grid
|
|
150
|
-
|
|
151
|
-
**Use for:** Product listings, portfolios, image galleries
|
|
152
|
-
|
|
153
|
-
```css
|
|
154
|
-
.card-grid {
|
|
155
|
-
display: grid;
|
|
156
|
-
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
|
157
|
-
gap: var(--spacing-6); /* 24px */
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/* Auto-fill: Creates as many columns as fit */
|
|
161
|
-
/* minmax(300px, 1fr): Min 300px, max equal width */
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
**Responsive Behavior:**
|
|
165
|
-
- Mobile: 1 column
|
|
166
|
-
- Tablet: 2 columns
|
|
167
|
-
- Desktop: 3-4 columns (auto-adjusts)
|
|
168
|
-
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
### 6. Center Element
|
|
172
|
-
|
|
173
|
-
**Use for:** Modals, empty states, landing hero sections
|
|
174
|
-
|
|
175
|
-
```css
|
|
176
|
-
/* Flexbox method */
|
|
177
|
-
.center-flex {
|
|
178
|
-
display: flex;
|
|
179
|
-
justify-content: center;
|
|
180
|
-
align-items: center;
|
|
181
|
-
min-height: 100vh;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/* Grid method */
|
|
185
|
-
.center-grid {
|
|
186
|
-
display: grid;
|
|
187
|
-
place-items: center; /* Shorthand for center both axes */
|
|
188
|
-
min-height: 100vh;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/* Absolute positioning (legacy) */
|
|
192
|
-
.center-absolute {
|
|
193
|
-
position: absolute;
|
|
194
|
-
top: 50%;
|
|
195
|
-
left: 50%;
|
|
196
|
-
transform: translate(-50%, -50%);
|
|
197
|
-
}
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
---
|
|
201
|
-
|
|
202
|
-
### 7. Header with Navigation
|
|
203
|
-
|
|
204
|
-
**Use for:** Site headers, app nav bars
|
|
205
|
-
|
|
206
|
-
```css
|
|
207
|
-
.header {
|
|
208
|
-
display: flex;
|
|
209
|
-
justify-content: space-between;
|
|
210
|
-
align-items: center;
|
|
211
|
-
padding: var(--spacing-4) var(--spacing-6);
|
|
212
|
-
background: white;
|
|
213
|
-
box-shadow: var(--shadow-sm);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.nav {
|
|
217
|
-
display: flex;
|
|
218
|
-
gap: var(--spacing-6);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
@media (max-width: 768px) {
|
|
222
|
-
.nav {
|
|
223
|
-
display: none; /* Hide on mobile (use hamburger menu) */
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
### 8. Container (Max-Width)
|
|
231
|
-
|
|
232
|
-
**Use for:** Constraining content width for readability
|
|
233
|
-
|
|
234
|
-
```css
|
|
235
|
-
.container {
|
|
236
|
-
max-width: 1280px; /* Desktop max width */
|
|
237
|
-
margin-left: auto;
|
|
238
|
-
margin-right: auto;
|
|
239
|
-
padding-left: var(--spacing-6); /* 24px */
|
|
240
|
-
padding-right: var(--spacing-6);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/* Variants */
|
|
244
|
-
.container-narrow {
|
|
245
|
-
max-width: 768px; /* Blog posts, forms */
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.container-wide {
|
|
249
|
-
max-width: 1536px; /* Dashboards, wide layouts */
|
|
250
|
-
}
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
**Optimal Reading Widths:**
|
|
254
|
-
- Text content: 65-75 characters per line (~768px)
|
|
255
|
-
- Dashboard: 1280-1536px
|
|
256
|
-
- Full-width: No max-width (use sparingly)
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
## Alignment Strategies
|
|
261
|
-
|
|
262
|
-
### Flexbox Alignment
|
|
263
|
-
|
|
264
|
-
**Main Axis (justify-content):**
|
|
265
|
-
```css
|
|
266
|
-
.flex-start { justify-content: flex-start; } /* Left/Top */
|
|
267
|
-
.flex-center { justify-content: center; } /* Center */
|
|
268
|
-
.flex-end { justify-content: flex-end; } /* Right/Bottom */
|
|
269
|
-
.flex-between { justify-content: space-between; } /* Space between */
|
|
270
|
-
.flex-around { justify-content: space-around; } /* Space around */
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
**Cross Axis (align-items):**
|
|
274
|
-
```css
|
|
275
|
-
.items-start { align-items: flex-start; } /* Top/Left */
|
|
276
|
-
.items-center { align-items: center; } /* Center */
|
|
277
|
-
.items-end { align-items: flex-end; } /* Bottom/Right */
|
|
278
|
-
.items-stretch { align-items: stretch; } /* Stretch to fill */
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Grid Alignment
|
|
282
|
-
|
|
283
|
-
```css
|
|
284
|
-
/* Place items (both axes) */
|
|
285
|
-
.place-center { place-items: center; }
|
|
286
|
-
.place-start { place-items: start; }
|
|
287
|
-
.place-end { place-items: end; }
|
|
288
|
-
|
|
289
|
-
/* Justify/align individual item */
|
|
290
|
-
.justify-self-center { justify-self: center; }
|
|
291
|
-
.align-self-center { align-self: center; }
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
|
-
## Z-Index Layering
|
|
297
|
-
|
|
298
|
-
**Standard Z-Index Scale:**
|
|
299
|
-
|
|
300
|
-
```css
|
|
301
|
-
:root {
|
|
302
|
-
--z-base: 1; /* Base content */
|
|
303
|
-
--z-dropdown: 10; /* Dropdowns, popovers */
|
|
304
|
-
--z-sticky: 20; /* Sticky headers */
|
|
305
|
-
--z-modal-backdrop: 100; /* Modal overlays */
|
|
306
|
-
--z-modal: 110; /* Modal content */
|
|
307
|
-
--z-popover: 200; /* Tooltips, toasts */
|
|
308
|
-
--z-notification: 1000; /* Notifications (top layer) */
|
|
309
|
-
}
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
**Usage:**
|
|
313
|
-
```css
|
|
314
|
-
.content { z-index: var(--z-base); }
|
|
315
|
-
.dropdown { z-index: var(--z-dropdown); }
|
|
316
|
-
.modal-backdrop { z-index: var(--z-modal-backdrop); }
|
|
317
|
-
.modal { z-index: var(--z-modal); }
|
|
318
|
-
.toast { z-index: var(--z-notification); }
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
---
|
|
322
|
-
|
|
323
|
-
## Aspect Ratios
|
|
324
|
-
|
|
325
|
-
**Use for:** Images, videos, cards with consistent proportions
|
|
326
|
-
|
|
327
|
-
```css
|
|
328
|
-
/* Modern approach (aspect-ratio property) */
|
|
329
|
-
.aspect-square { aspect-ratio: 1 / 1; } /* 1:1 */
|
|
330
|
-
.aspect-video { aspect-ratio: 16 / 9; } /* 16:9 */
|
|
331
|
-
.aspect-portrait { aspect-ratio: 3 / 4; } /* 3:4 */
|
|
332
|
-
|
|
333
|
-
/* Legacy approach (padding-bottom hack) */
|
|
334
|
-
.aspect-ratio-16-9 {
|
|
335
|
-
position: relative;
|
|
336
|
-
padding-bottom: 56.25%; /* 9/16 = 0.5625 */
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
.aspect-ratio-16-9 > * {
|
|
340
|
-
position: absolute;
|
|
341
|
-
top: 0;
|
|
342
|
-
left: 0;
|
|
343
|
-
width: 100%;
|
|
344
|
-
height: 100%;
|
|
345
|
-
}
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
---
|
|
349
|
-
|
|
350
|
-
## Best Practices
|
|
351
|
-
|
|
352
|
-
### DO:
|
|
353
|
-
- ✅ Use flexbox for 1D layouts
|
|
354
|
-
- ✅ Use grid for 2D layouts
|
|
355
|
-
- ✅ Design mobile-first (stack by default)
|
|
356
|
-
- ✅ Use semantic HTML (header, main, aside, footer)
|
|
357
|
-
- ✅ Constrain content width for readability
|
|
358
|
-
- ✅ Use CSS custom properties for spacing
|
|
359
|
-
- ✅ Test on all screen sizes
|
|
360
|
-
|
|
361
|
-
### DON'T:
|
|
362
|
-
- ❌ Use floats for layouts (legacy technique)
|
|
363
|
-
- ❌ Use fixed pixel widths (not responsive)
|
|
364
|
-
- ❌ Nest too many layout containers (keep it flat)
|
|
365
|
-
- ❌ Forget semantic HTML
|
|
366
|
-
- ❌ Use arbitrary z-index values (100, 9999)
|
|
367
|
-
- ❌ Overcomplicate layouts (KISS principle)
|
|
368
|
-
|
|
369
|
-
---
|
|
370
|
-
|
|
371
|
-
## Quick Reference
|
|
372
|
-
|
|
373
|
-
**Layout Techniques:**
|
|
374
|
-
| Pattern | Technique | Use Case |
|
|
375
|
-
|---------|-----------|----------|
|
|
376
|
-
| Stack | Flexbox (column) | Vertical lists, forms |
|
|
377
|
-
| Inline | Flexbox (row) | Horizontal groups, nav |
|
|
378
|
-
| Sidebar | Grid (2 columns) | Admin panels, docs |
|
|
379
|
-
| Card Grid | Grid (auto-fill) | Products, galleries |
|
|
380
|
-
| Center | Flexbox/Grid | Modals, empty states |
|
|
381
|
-
|
|
382
|
-
**Container Widths:**
|
|
383
|
-
| Type | Max Width | Use Case |
|
|
384
|
-
|------|-----------|----------|
|
|
385
|
-
| Narrow | 768px | Blog posts, forms |
|
|
386
|
-
| Default | 1280px | Standard pages |
|
|
387
|
-
| Wide | 1536px | Dashboards |
|
|
388
|
-
| Full | none | Landing pages |
|
|
389
|
-
|
|
390
|
-
**Z-Index Layers:**
|
|
391
|
-
| Layer | Z-Index | Element Type |
|
|
392
|
-
|-------|---------|--------------|
|
|
393
|
-
| Base | 1 | Content |
|
|
394
|
-
| Dropdown | 10 | Dropdowns, popovers |
|
|
395
|
-
| Modal | 100-110 | Modals, overlays |
|
|
396
|
-
| Notification | 1000 | Toasts, alerts |
|
|
397
|
-
|
|
398
|
-
---
|
|
399
|
-
|
|
400
|
-
**💡 Remember:** Good layout is invisible. Users should focus on content, not structure!
|
|
1
|
+
# Layout Patterns
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Common layout structures and alignment strategies
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Core Layout Principles
|
|
8
|
+
|
|
9
|
+
1. **Box Model First** - Understand all elements as boxes (see `box-thinking.md`)
|
|
10
|
+
2. **Flex for 1D** - Use flexbox for single-axis layouts (rows or columns)
|
|
11
|
+
3. **Grid for 2D** - Use CSS Grid for multi-axis layouts (rows AND columns)
|
|
12
|
+
4. **Responsive by Default** - Design mobile-first, enhance for larger screens
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Common Layout Patterns
|
|
17
|
+
|
|
18
|
+
### 1. Stack (Vertical)
|
|
19
|
+
|
|
20
|
+
**Use for:** Form fields, article content, vertical lists
|
|
21
|
+
|
|
22
|
+
```css
|
|
23
|
+
.stack {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: var(--spacing-4); /* 16px */
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Variants */
|
|
30
|
+
.stack-tight {
|
|
31
|
+
gap: var(--spacing-2); /* 8px */
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.stack-loose {
|
|
35
|
+
gap: var(--spacing-8); /* 32px */
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**HTML:**
|
|
40
|
+
```html
|
|
41
|
+
<div class="stack">
|
|
42
|
+
<div>Item 1</div>
|
|
43
|
+
<div>Item 2</div>
|
|
44
|
+
<div>Item 3</div>
|
|
45
|
+
</div>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### 2. Inline (Horizontal)
|
|
51
|
+
|
|
52
|
+
**Use for:** Button groups, breadcrumbs, navigation
|
|
53
|
+
|
|
54
|
+
```css
|
|
55
|
+
.inline {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: row;
|
|
58
|
+
gap: var(--spacing-4); /* 16px */
|
|
59
|
+
align-items: center; /* Vertical centering */
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Variants */
|
|
63
|
+
.inline-start {
|
|
64
|
+
justify-content: flex-start; /* Left-aligned */
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.inline-center {
|
|
68
|
+
justify-content: center; /* Centered */
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.inline-end {
|
|
72
|
+
justify-content: flex-end; /* Right-aligned */
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.inline-between {
|
|
76
|
+
justify-content: space-between; /* Space between items */
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
### 3. Sidebar Layout
|
|
83
|
+
|
|
84
|
+
**Use for:** Dashboard, admin panels, documentation
|
|
85
|
+
|
|
86
|
+
```css
|
|
87
|
+
.sidebar-layout {
|
|
88
|
+
display: grid;
|
|
89
|
+
grid-template-columns: 250px 1fr; /* Fixed sidebar + fluid main */
|
|
90
|
+
gap: var(--spacing-6); /* 24px */
|
|
91
|
+
min-height: 100vh;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@media (max-width: 768px) {
|
|
95
|
+
.sidebar-layout {
|
|
96
|
+
grid-template-columns: 1fr; /* Stack on mobile */
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**HTML:**
|
|
102
|
+
```html
|
|
103
|
+
<div class="sidebar-layout">
|
|
104
|
+
<aside class="sidebar">Sidebar</aside>
|
|
105
|
+
<main class="main-content">Main Content</main>
|
|
106
|
+
</div>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### 4. Holy Grail Layout
|
|
112
|
+
|
|
113
|
+
**Use for:** Classic web pages (header, sidebar, content, footer)
|
|
114
|
+
|
|
115
|
+
```css
|
|
116
|
+
.holy-grail {
|
|
117
|
+
display: grid;
|
|
118
|
+
grid-template-areas:
|
|
119
|
+
"header header header"
|
|
120
|
+
"sidebar main aside"
|
|
121
|
+
"footer footer footer";
|
|
122
|
+
grid-template-columns: 200px 1fr 200px;
|
|
123
|
+
grid-template-rows: auto 1fr auto;
|
|
124
|
+
min-height: 100vh;
|
|
125
|
+
gap: var(--spacing-4);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.header { grid-area: header; }
|
|
129
|
+
.sidebar { grid-area: sidebar; }
|
|
130
|
+
.main { grid-area: main; }
|
|
131
|
+
.aside { grid-area: aside; }
|
|
132
|
+
.footer { grid-area: footer; }
|
|
133
|
+
|
|
134
|
+
@media (max-width: 1024px) {
|
|
135
|
+
.holy-grail {
|
|
136
|
+
grid-template-areas:
|
|
137
|
+
"header"
|
|
138
|
+
"main"
|
|
139
|
+
"sidebar"
|
|
140
|
+
"aside"
|
|
141
|
+
"footer";
|
|
142
|
+
grid-template-columns: 1fr;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### 5. Card Grid
|
|
150
|
+
|
|
151
|
+
**Use for:** Product listings, portfolios, image galleries
|
|
152
|
+
|
|
153
|
+
```css
|
|
154
|
+
.card-grid {
|
|
155
|
+
display: grid;
|
|
156
|
+
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
|
157
|
+
gap: var(--spacing-6); /* 24px */
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* Auto-fill: Creates as many columns as fit */
|
|
161
|
+
/* minmax(300px, 1fr): Min 300px, max equal width */
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Responsive Behavior:**
|
|
165
|
+
- Mobile: 1 column
|
|
166
|
+
- Tablet: 2 columns
|
|
167
|
+
- Desktop: 3-4 columns (auto-adjusts)
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### 6. Center Element
|
|
172
|
+
|
|
173
|
+
**Use for:** Modals, empty states, landing hero sections
|
|
174
|
+
|
|
175
|
+
```css
|
|
176
|
+
/* Flexbox method */
|
|
177
|
+
.center-flex {
|
|
178
|
+
display: flex;
|
|
179
|
+
justify-content: center;
|
|
180
|
+
align-items: center;
|
|
181
|
+
min-height: 100vh;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Grid method */
|
|
185
|
+
.center-grid {
|
|
186
|
+
display: grid;
|
|
187
|
+
place-items: center; /* Shorthand for center both axes */
|
|
188
|
+
min-height: 100vh;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Absolute positioning (legacy) */
|
|
192
|
+
.center-absolute {
|
|
193
|
+
position: absolute;
|
|
194
|
+
top: 50%;
|
|
195
|
+
left: 50%;
|
|
196
|
+
transform: translate(-50%, -50%);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### 7. Header with Navigation
|
|
203
|
+
|
|
204
|
+
**Use for:** Site headers, app nav bars
|
|
205
|
+
|
|
206
|
+
```css
|
|
207
|
+
.header {
|
|
208
|
+
display: flex;
|
|
209
|
+
justify-content: space-between;
|
|
210
|
+
align-items: center;
|
|
211
|
+
padding: var(--spacing-4) var(--spacing-6);
|
|
212
|
+
background: white;
|
|
213
|
+
box-shadow: var(--shadow-sm);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.nav {
|
|
217
|
+
display: flex;
|
|
218
|
+
gap: var(--spacing-6);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@media (max-width: 768px) {
|
|
222
|
+
.nav {
|
|
223
|
+
display: none; /* Hide on mobile (use hamburger menu) */
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
### 8. Container (Max-Width)
|
|
231
|
+
|
|
232
|
+
**Use for:** Constraining content width for readability
|
|
233
|
+
|
|
234
|
+
```css
|
|
235
|
+
.container {
|
|
236
|
+
max-width: 1280px; /* Desktop max width */
|
|
237
|
+
margin-left: auto;
|
|
238
|
+
margin-right: auto;
|
|
239
|
+
padding-left: var(--spacing-6); /* 24px */
|
|
240
|
+
padding-right: var(--spacing-6);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* Variants */
|
|
244
|
+
.container-narrow {
|
|
245
|
+
max-width: 768px; /* Blog posts, forms */
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.container-wide {
|
|
249
|
+
max-width: 1536px; /* Dashboards, wide layouts */
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Optimal Reading Widths:**
|
|
254
|
+
- Text content: 65-75 characters per line (~768px)
|
|
255
|
+
- Dashboard: 1280-1536px
|
|
256
|
+
- Full-width: No max-width (use sparingly)
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Alignment Strategies
|
|
261
|
+
|
|
262
|
+
### Flexbox Alignment
|
|
263
|
+
|
|
264
|
+
**Main Axis (justify-content):**
|
|
265
|
+
```css
|
|
266
|
+
.flex-start { justify-content: flex-start; } /* Left/Top */
|
|
267
|
+
.flex-center { justify-content: center; } /* Center */
|
|
268
|
+
.flex-end { justify-content: flex-end; } /* Right/Bottom */
|
|
269
|
+
.flex-between { justify-content: space-between; } /* Space between */
|
|
270
|
+
.flex-around { justify-content: space-around; } /* Space around */
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Cross Axis (align-items):**
|
|
274
|
+
```css
|
|
275
|
+
.items-start { align-items: flex-start; } /* Top/Left */
|
|
276
|
+
.items-center { align-items: center; } /* Center */
|
|
277
|
+
.items-end { align-items: flex-end; } /* Bottom/Right */
|
|
278
|
+
.items-stretch { align-items: stretch; } /* Stretch to fill */
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Grid Alignment
|
|
282
|
+
|
|
283
|
+
```css
|
|
284
|
+
/* Place items (both axes) */
|
|
285
|
+
.place-center { place-items: center; }
|
|
286
|
+
.place-start { place-items: start; }
|
|
287
|
+
.place-end { place-items: end; }
|
|
288
|
+
|
|
289
|
+
/* Justify/align individual item */
|
|
290
|
+
.justify-self-center { justify-self: center; }
|
|
291
|
+
.align-self-center { align-self: center; }
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Z-Index Layering
|
|
297
|
+
|
|
298
|
+
**Standard Z-Index Scale:**
|
|
299
|
+
|
|
300
|
+
```css
|
|
301
|
+
:root {
|
|
302
|
+
--z-base: 1; /* Base content */
|
|
303
|
+
--z-dropdown: 10; /* Dropdowns, popovers */
|
|
304
|
+
--z-sticky: 20; /* Sticky headers */
|
|
305
|
+
--z-modal-backdrop: 100; /* Modal overlays */
|
|
306
|
+
--z-modal: 110; /* Modal content */
|
|
307
|
+
--z-popover: 200; /* Tooltips, toasts */
|
|
308
|
+
--z-notification: 1000; /* Notifications (top layer) */
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Usage:**
|
|
313
|
+
```css
|
|
314
|
+
.content { z-index: var(--z-base); }
|
|
315
|
+
.dropdown { z-index: var(--z-dropdown); }
|
|
316
|
+
.modal-backdrop { z-index: var(--z-modal-backdrop); }
|
|
317
|
+
.modal { z-index: var(--z-modal); }
|
|
318
|
+
.toast { z-index: var(--z-notification); }
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Aspect Ratios
|
|
324
|
+
|
|
325
|
+
**Use for:** Images, videos, cards with consistent proportions
|
|
326
|
+
|
|
327
|
+
```css
|
|
328
|
+
/* Modern approach (aspect-ratio property) */
|
|
329
|
+
.aspect-square { aspect-ratio: 1 / 1; } /* 1:1 */
|
|
330
|
+
.aspect-video { aspect-ratio: 16 / 9; } /* 16:9 */
|
|
331
|
+
.aspect-portrait { aspect-ratio: 3 / 4; } /* 3:4 */
|
|
332
|
+
|
|
333
|
+
/* Legacy approach (padding-bottom hack) */
|
|
334
|
+
.aspect-ratio-16-9 {
|
|
335
|
+
position: relative;
|
|
336
|
+
padding-bottom: 56.25%; /* 9/16 = 0.5625 */
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.aspect-ratio-16-9 > * {
|
|
340
|
+
position: absolute;
|
|
341
|
+
top: 0;
|
|
342
|
+
left: 0;
|
|
343
|
+
width: 100%;
|
|
344
|
+
height: 100%;
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Best Practices
|
|
351
|
+
|
|
352
|
+
### DO:
|
|
353
|
+
- ✅ Use flexbox for 1D layouts
|
|
354
|
+
- ✅ Use grid for 2D layouts
|
|
355
|
+
- ✅ Design mobile-first (stack by default)
|
|
356
|
+
- ✅ Use semantic HTML (header, main, aside, footer)
|
|
357
|
+
- ✅ Constrain content width for readability
|
|
358
|
+
- ✅ Use CSS custom properties for spacing
|
|
359
|
+
- ✅ Test on all screen sizes
|
|
360
|
+
|
|
361
|
+
### DON'T:
|
|
362
|
+
- ❌ Use floats for layouts (legacy technique)
|
|
363
|
+
- ❌ Use fixed pixel widths (not responsive)
|
|
364
|
+
- ❌ Nest too many layout containers (keep it flat)
|
|
365
|
+
- ❌ Forget semantic HTML
|
|
366
|
+
- ❌ Use arbitrary z-index values (100, 9999)
|
|
367
|
+
- ❌ Overcomplicate layouts (KISS principle)
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## Quick Reference
|
|
372
|
+
|
|
373
|
+
**Layout Techniques:**
|
|
374
|
+
| Pattern | Technique | Use Case |
|
|
375
|
+
|---------|-----------|----------|
|
|
376
|
+
| Stack | Flexbox (column) | Vertical lists, forms |
|
|
377
|
+
| Inline | Flexbox (row) | Horizontal groups, nav |
|
|
378
|
+
| Sidebar | Grid (2 columns) | Admin panels, docs |
|
|
379
|
+
| Card Grid | Grid (auto-fill) | Products, galleries |
|
|
380
|
+
| Center | Flexbox/Grid | Modals, empty states |
|
|
381
|
+
|
|
382
|
+
**Container Widths:**
|
|
383
|
+
| Type | Max Width | Use Case |
|
|
384
|
+
|------|-----------|----------|
|
|
385
|
+
| Narrow | 768px | Blog posts, forms |
|
|
386
|
+
| Default | 1280px | Standard pages |
|
|
387
|
+
| Wide | 1536px | Dashboards |
|
|
388
|
+
| Full | none | Landing pages |
|
|
389
|
+
|
|
390
|
+
**Z-Index Layers:**
|
|
391
|
+
| Layer | Z-Index | Element Type |
|
|
392
|
+
|-------|---------|--------------|
|
|
393
|
+
| Base | 1 | Content |
|
|
394
|
+
| Dropdown | 10 | Dropdowns, popovers |
|
|
395
|
+
| Modal | 100-110 | Modals, overlays |
|
|
396
|
+
| Notification | 1000 | Toasts, alerts |
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
**💡 Remember:** Good layout is invisible. Users should focus on content, not structure!
|