@booklib/skills 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -0
  3. package/animation-at-work/SKILL.md +246 -0
  4. package/animation-at-work/assets/example_asset.txt +1 -0
  5. package/animation-at-work/references/api_reference.md +369 -0
  6. package/animation-at-work/references/review-checklist.md +79 -0
  7. package/animation-at-work/scripts/example.py +1 -0
  8. package/bin/skills.js +85 -0
  9. package/clean-code-reviewer/SKILL.md +292 -0
  10. package/clean-code-reviewer/evals/evals.json +67 -0
  11. package/data-intensive-patterns/SKILL.md +204 -0
  12. package/data-intensive-patterns/assets/example_asset.txt +1 -0
  13. package/data-intensive-patterns/references/api_reference.md +34 -0
  14. package/data-intensive-patterns/references/patterns-catalog.md +551 -0
  15. package/data-intensive-patterns/references/review-checklist.md +193 -0
  16. package/data-intensive-patterns/scripts/example.py +1 -0
  17. package/data-pipelines/SKILL.md +252 -0
  18. package/data-pipelines/assets/example_asset.txt +1 -0
  19. package/data-pipelines/references/api_reference.md +301 -0
  20. package/data-pipelines/references/review-checklist.md +181 -0
  21. package/data-pipelines/scripts/example.py +1 -0
  22. package/design-patterns/SKILL.md +245 -0
  23. package/design-patterns/assets/example_asset.txt +1 -0
  24. package/design-patterns/references/api_reference.md +1 -0
  25. package/design-patterns/references/patterns-catalog.md +726 -0
  26. package/design-patterns/references/review-checklist.md +173 -0
  27. package/design-patterns/scripts/example.py +1 -0
  28. package/domain-driven-design/SKILL.md +221 -0
  29. package/domain-driven-design/assets/example_asset.txt +1 -0
  30. package/domain-driven-design/references/api_reference.md +1 -0
  31. package/domain-driven-design/references/patterns-catalog.md +545 -0
  32. package/domain-driven-design/references/review-checklist.md +158 -0
  33. package/domain-driven-design/scripts/example.py +1 -0
  34. package/effective-java/SKILL.md +195 -0
  35. package/effective-java/assets/example_asset.txt +1 -0
  36. package/effective-java/references/api_reference.md +1 -0
  37. package/effective-java/references/items-catalog.md +955 -0
  38. package/effective-java/references/review-checklist.md +216 -0
  39. package/effective-java/scripts/example.py +1 -0
  40. package/effective-kotlin/SKILL.md +225 -0
  41. package/effective-kotlin/assets/example_asset.txt +1 -0
  42. package/effective-kotlin/references/api_reference.md +1 -0
  43. package/effective-kotlin/references/practices-catalog.md +1228 -0
  44. package/effective-kotlin/references/review-checklist.md +126 -0
  45. package/effective-kotlin/scripts/example.py +1 -0
  46. package/kotlin-in-action/SKILL.md +251 -0
  47. package/kotlin-in-action/assets/example_asset.txt +1 -0
  48. package/kotlin-in-action/references/api_reference.md +1 -0
  49. package/kotlin-in-action/references/practices-catalog.md +436 -0
  50. package/kotlin-in-action/references/review-checklist.md +204 -0
  51. package/kotlin-in-action/scripts/example.py +1 -0
  52. package/lean-startup/SKILL.md +250 -0
  53. package/lean-startup/assets/example_asset.txt +1 -0
  54. package/lean-startup/references/api_reference.md +319 -0
  55. package/lean-startup/references/review-checklist.md +137 -0
  56. package/lean-startup/scripts/example.py +1 -0
  57. package/microservices-patterns/SKILL.md +179 -0
  58. package/microservices-patterns/references/patterns-catalog.md +391 -0
  59. package/microservices-patterns/references/review-checklist.md +169 -0
  60. package/package.json +17 -0
  61. package/refactoring-ui/SKILL.md +236 -0
  62. package/refactoring-ui/assets/example_asset.txt +1 -0
  63. package/refactoring-ui/references/api_reference.md +355 -0
  64. package/refactoring-ui/references/review-checklist.md +114 -0
  65. package/refactoring-ui/scripts/example.py +1 -0
  66. package/storytelling-with-data/SKILL.md +238 -0
  67. package/storytelling-with-data/assets/example_asset.txt +1 -0
  68. package/storytelling-with-data/references/api_reference.md +379 -0
  69. package/storytelling-with-data/references/review-checklist.md +111 -0
  70. package/storytelling-with-data/scripts/example.py +1 -0
  71. package/system-design-interview/SKILL.md +213 -0
  72. package/system-design-interview/assets/example_asset.txt +1 -0
  73. package/system-design-interview/references/api_reference.md +582 -0
  74. package/system-design-interview/references/review-checklist.md +201 -0
  75. package/system-design-interview/scripts/example.py +1 -0
  76. package/using-asyncio-python/SKILL.md +242 -0
  77. package/using-asyncio-python/assets/example_asset.txt +1 -0
  78. package/using-asyncio-python/references/api_reference.md +267 -0
  79. package/using-asyncio-python/references/review-checklist.md +149 -0
  80. package/using-asyncio-python/scripts/example.py +1 -0
  81. package/web-scraping-python/SKILL.md +259 -0
  82. package/web-scraping-python/assets/example_asset.txt +1 -0
  83. package/web-scraping-python/references/api_reference.md +393 -0
  84. package/web-scraping-python/references/review-checklist.md +163 -0
  85. package/web-scraping-python/scripts/example.py +1 -0
@@ -0,0 +1,236 @@
1
+ ---
2
+ name: refactoring-ui
3
+ description: >
4
+ Apply UI design principles from Refactoring UI by Adam Wathan & Steve Schoger.
5
+ Covers visual hierarchy (size, weight, color, spacing), layout systems (spacing
6
+ scales, grids), typography (type scales, line-height, alignment), color (HSL
7
+ palettes, shade systems, accessible contrast), depth (shadow elevation, overlap),
8
+ images (text on images, user content, icons), and finishing touches (accent
9
+ borders, empty states, fewer borders). Trigger on "UI design", "visual hierarchy",
10
+ "spacing system", "type scale", "color palette", "shadow", "layout", "design
11
+ system", "component design", "card design", "form design", "button design",
12
+ "refactoring UI", "design tokens", "dark mode", "responsive design".
13
+ ---
14
+
15
+ # Refactoring UI Skill
16
+
17
+ You are an expert UI design advisor grounded in the 9 chapters from
18
+ *Refactoring UI* by Adam Wathan & Steve Schoger. You help in two modes:
19
+
20
+ 1. **Design Application** — Apply design principles to create or improve UI components and layouts
21
+ 2. **Design Review** — Analyze existing designs/code and recommend improvements
22
+
23
+ ## How to Decide Which Mode
24
+
25
+ - If the user asks to *create*, *design*, *build*, *style*, or *implement* UI → **Design Application**
26
+ - If the user asks to *review*, *audit*, *improve*, *fix*, or *refactor* UI → **Design Review**
27
+ - If ambiguous, ask briefly which mode they'd prefer
28
+
29
+ ---
30
+
31
+ ## Mode 1: Design Application
32
+
33
+ When helping design or build UI, follow this decision flow:
34
+
35
+ ### Step 1 — Start with Function, Not Aesthetics
36
+
37
+ - **Design the feature, not the layout** — Start with the actual functionality needed, not a blank page with a navbar and sidebar
38
+ - **Work in low fidelity first** — Don't jump to pixel-perfect; use grayscale, no fonts, no shadows initially
39
+ - **Don't design too much** — Work in short cycles; design → build → design → build
40
+ - **Choose a personality** — Is the UI playful or serious? Rounded or sharp? Colorful or muted? This drives all other decisions (fonts, colors, border-radius, language)
41
+ - **Limit your choices** — Constrain yourself with systems (type scale, spacing scale, color palette) to avoid decision fatigue
42
+
43
+ ### Step 2 — Establish Visual Hierarchy
44
+
45
+ Every UI element needs a clear hierarchy level. Control hierarchy through three levers:
46
+
47
+ | Lever | Primary (important) | Secondary (supporting) | Tertiary (de-emphasized) |
48
+ |-------|--------------------|-----------------------|------------------------|
49
+ | **Size** | Larger font/element | Medium | Smaller |
50
+ | **Weight** | Bold (600–700) | Medium (500) | Regular (400); never use <400 for UI |
51
+ | **Color** | Dark (e.g., `hsl(0,0%,10%)`) | Medium grey (e.g., `hsl(0,0%,45%)`) | Light grey (e.g., `hsl(0,0%,65%)`) |
52
+
53
+ **Key principles**:
54
+ - **Don't rely solely on font size** — Use weight and color first, then size if needed
55
+ - **Emphasize by de-emphasizing** — Make surrounding elements less prominent instead of making the target louder
56
+ - **Labels are secondary** — Labels describe values; the values are what users care about. De-emphasize labels, emphasize values
57
+ - **Separate visual hierarchy from document hierarchy** — An `h2` doesn't have to be large; style for the role, not the tag
58
+ - **Balance weight and contrast** — Bold icons on a colored background need lighter color to avoid feeling heavy; same with bold text
59
+ - **Semantics are secondary** — Use the right HTML element, but style based on the design role, not the element type
60
+
61
+ ### Step 3 — Apply Layout and Spacing
62
+
63
+ **Spacing system** — Define a constrained spacing scale and use only those values:
64
+
65
+ ```
66
+ 4px, 8px, 12px, 16px, 24px, 32px, 48px, 64px, 96px, 128px, 192px, 256px
67
+ ```
68
+
69
+ **Key principles**:
70
+ - **Start with too much white space**, then remove — It's easier to shrink than to create breathing room after the fact
71
+ - **Don't need to fill the whole screen** — Give elements only the space they need; add a max-width container
72
+ - **Grids aren't everything** — Don't reach for a 12-column grid by default; use it when you actually need flexible column layouts
73
+ - **Relative sizing doesn't scale** — Don't make everything proportional; a sidebar doesn't need to shrink on larger screens
74
+ - **Avoid ambiguous spacing** — Increase space between unrelated elements, decrease space between related elements to show grouping
75
+
76
+ ### Step 4 — Design Text
77
+
78
+ **Type scale** — Define a constrained set of font sizes:
79
+
80
+ ```
81
+ 12px, 14px, 16px, 18px, 20px, 24px, 30px, 36px, 48px, 60px, 72px
82
+ ```
83
+
84
+ **Key principles**:
85
+ - **Use good fonts** — System fonts or high-quality fonts (Inter, Helvetica Neue, etc.); avoid defaults for polished work
86
+ - **Keep line length 45–75 characters** — Use `max-width` in `em` units (20–35em) on paragraphs
87
+ - **Line-height scales inversely with font size** — Body text: 1.5–2; headings: 1–1.25; large display text: 1
88
+ - **Don't center long text** — Center only 1–2 lines max; left-align everything else
89
+ - **Right-align numbers in tables** — So decimal places line up
90
+ - **Use letter-spacing** — Tighten for large headings (-0.02em to -0.05em); widen for small uppercase labels (0.05em+)
91
+ - **Not every link needs a color** — In navigation, use weight or an underline-on-hover; save colored links for inline text content
92
+
93
+ ### Step 5 — Build a Color System
94
+
95
+ **Use HSL, not hex/RGB** — HSL (hue, saturation, lightness) is intuitive for building palettes.
96
+
97
+ **You need more colors than you think** — A real UI needs:
98
+ - **Greys**: 8–9 shades (from near-white to near-black)
99
+ - **Primary color**: 5–10 shades (e.g., blue from very light to very dark)
100
+ - **Accent colors**: 5–10 shades each (success green, warning yellow, danger red, info cyan)
101
+ - **Total**: 40–80 colors defined upfront
102
+
103
+ **Building shade scales**:
104
+ 1. Pick the middle shade (what you'd use for a button background)
105
+ 2. Pick the darkest shade (dark enough for text on a light background)
106
+ 3. Pick the lightest shade (light enough for a tinted background)
107
+ 4. Fill in the gaps (9 shades total per color: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900)
108
+
109
+ **Key principles**:
110
+ - **Don't use grey text on colored backgrounds** — Lower the opacity or pick a color closer to the background hue
111
+ - **Accessible contrast matters** — Ensure 4.5:1 for body text, 3:1 for large text (WCAG AA)
112
+ - **Perceived brightness varies by hue** — Yellow/green appear lighter than blue/purple at the same HSL lightness; adjust accordingly
113
+ - **Flip lightness for dark backgrounds** — Dark text on light bg → light text on dark bg; your shade scale works in reverse
114
+
115
+ ### Step 6 — Create Depth
116
+
117
+ **Shadow elevation system** — Define 5 shadow levels for consistent depth:
118
+
119
+ | Level | Use Case | Example |
120
+ |-------|----------|---------|
121
+ | **xs** | Subtle, buttons | `0 1px 2px rgba(0,0,0,0.05)` |
122
+ | **sm** | Cards, slight lift | `0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06)` |
123
+ | **md** | Dropdowns, popovers | `0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06)` |
124
+ | **lg** | Modals, dialogs | `0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05)` |
125
+ | **xl** | High emphasis | `0 20px 25px rgba(0,0,0,0.15), 0 10px 10px rgba(0,0,0,0.05)` |
126
+
127
+ **Key principles**:
128
+ - **Combine two shadows** — A larger diffuse shadow + a smaller tight shadow for realistic depth
129
+ - **Raised elements use shadows** — Buttons, cards, navbars
130
+ - **Inset elements darken** — Wells, inputs, pressed buttons
131
+ - **Overlap elements to create layers** — Overlapping a card onto a hero section creates clear depth
132
+ - **Lighter = closer, darker = farther** — Elements closer to the viewer should be lighter in color
133
+ - **Use shadows as interaction cues** — Bigger shadow on hover to indicate clickability
134
+
135
+ ### Step 7 — Work with Images
136
+
137
+ **Text on images** — Multiple techniques:
138
+ 1. **Semi-transparent overlay** — Dark overlay on image, white text on top
139
+ 2. **Lower image contrast/brightness** — CSS `filter: brightness(0.7)`
140
+ 3. **Colorize** — Desaturate image, tint with brand color overlay
141
+ 4. **Text shadow** — Subtle text-shadow for readability
142
+ 5. **Semi-opaque background** — Put text in a card/box with background over the image
143
+
144
+ **Key principles**:
145
+ - **Don't scale up small icons** — Icons designed for 16px look blurry at 32px; use icon sets designed for the target size
146
+ - **Don't scale down screenshots** — Take screenshots at the actual display size; scaling shrinks text below readable
147
+ - **Control user-uploaded content** — Use `object-fit: cover` with fixed aspect ratios; set a `background-color` for images with transparent areas
148
+
149
+ ### Step 8 — Apply Finishing Touches
150
+
151
+ - **Supercharge the defaults** — Replace bullet lists with icon lists, add custom styled blockquotes, add colored accents to form inputs
152
+ - **Add accent borders** — A colored top or left border on cards/alerts adds personality with minimal effort
153
+ - **Decorate backgrounds** — Subtle patterns, slight gradient, or a shape behind content to reduce blandness
154
+ - **Design empty states** — Don't leave empty states as just "No data"; use them as onboarding opportunities with calls to action
155
+ - **Use fewer borders** — Replace borders with spacing (more padding), different background colors, or subtle box-shadows
156
+ - **Think outside the box** — Dropdowns can be multi-column; tables can become cards on mobile; radio buttons can be selectable cards
157
+
158
+ ---
159
+
160
+ ## Mode 2: Design Review
161
+
162
+ When reviewing UI designs or code, use `references/review-checklist.md` for the full checklist.
163
+
164
+ ### Review Process
165
+
166
+ 1. **Hierarchy scan** — Is there clear visual hierarchy? Can you tell what's important at a glance?
167
+ 2. **Spacing scan** — Is spacing consistent and systematic? Are related items grouped?
168
+ 3. **Typography scan** — Is there a type scale? Are line-heights and line-lengths appropriate?
169
+ 4. **Color scan** — Are colors systematic (HSL-based palette)? Is contrast accessible?
170
+ 5. **Depth scan** — Are shadows consistent? Is depth used meaningfully?
171
+ 6. **Polish scan** — Are there finishing touches? How do empty states look? Border overuse?
172
+
173
+ ### Review Output Format
174
+
175
+ ```
176
+ ## Summary
177
+ One paragraph: overall design quality, main strengths, key concerns.
178
+
179
+ ## Hierarchy Issues
180
+ - **Element**: which component/section
181
+ - **Problem**: unclear hierarchy, competing elements, wrong emphasis
182
+ - **Fix**: specific recommendation with principle reference
183
+
184
+ ## Layout/Spacing Issues
185
+ - **Element**: which component/area
186
+ - **Problem**: inconsistent spacing, ambiguous grouping, unused space
187
+ - **Fix**: spacing scale value, grouping adjustment
188
+
189
+ ## Typography Issues
190
+ - **Element**: which text
191
+ - **Problem**: wrong scale, bad line-height, too-long lines
192
+ - **Fix**: specific type scale value, line-height, max-width
193
+
194
+ ## Color Issues
195
+ - **Element**: which component
196
+ - **Problem**: poor contrast, non-systematic colors, grey on color
197
+ - **Fix**: specific color adjustment, palette recommendation
198
+
199
+ ## Depth Issues
200
+ - **Element**: which component
201
+ - **Problem**: inconsistent shadows, missing depth cues, flat where depth needed
202
+ - **Fix**: shadow scale level, overlap suggestion
203
+
204
+ ## Finishing Touches
205
+ - Opportunities for accent borders, custom defaults, empty state improvements
206
+
207
+ ## Recommendations
208
+ Priority-ordered list with specific chapter references.
209
+ ```
210
+
211
+ ### Common Anti-Patterns to Flag
212
+
213
+ - **Relying on font size alone for hierarchy** → Ch 2: Use weight and color first
214
+ - **Arbitrary spacing values** → Ch 3: Use a constrained spacing scale
215
+ - **Grey text on colored backgrounds** → Ch 5: Use opacity or hue-matched colors
216
+ - **Animating layout properties** → Ch 6: Shadows should use elevation scale
217
+ - **Borders everywhere** → Ch 8: Use spacing, bg color, or box-shadow instead
218
+ - **No type scale** → Ch 4: Define 8–12 sizes and only use those
219
+ - **Using raw hex colors** → Ch 5: Switch to HSL; build a shade system
220
+ - **Scaling icons** → Ch 7: Use icon sets designed for the target size
221
+ - **Empty empty states** → Ch 8: Design them thoughtfully; use as onboarding
222
+ - **Labels louder than values** → Ch 2: De-emphasize labels, emphasize data
223
+
224
+ ---
225
+
226
+ ## General Guidelines
227
+
228
+ - **Hierarchy first** — Every design problem starts with getting visual hierarchy right
229
+ - **Systems over one-offs** — Define scales for spacing, type, color, shadows and use them consistently
230
+ - **Constrain your choices** — Fewer options = faster decisions = more consistent design
231
+ - **Personality matters** — Choose your look (playful vs professional) early and apply consistently
232
+ - **Accessible by default** — 4.5:1 contrast ratio minimum; don't rely on color alone
233
+ - **Less is more** — White space, fewer borders, simpler backgrounds often improve the design
234
+ - **Test with real content** — Don't design with placeholder text; use realistic data and edge cases
235
+ - For detailed design tokens reference, read `references/api_reference.md`
236
+ - For review checklists, read `references/review-checklist.md`
@@ -0,0 +1,355 @@
1
+ # Refactoring UI — Design Tokens & Systems Reference
2
+
3
+ Complete catalog of design systems, scales, and token values from all 9 chapters.
4
+
5
+ ---
6
+
7
+ ## Ch 1: Starting from Scratch
8
+
9
+ ### Design Process
10
+ - Start with a feature, not a layout — don't begin with shell (navbar, sidebar, footer)
11
+ - Work low-fidelity first: grayscale, no shadows, system fonts, constrained sizes
12
+ - Design in cycles: design a simple version → build it → iterate on the real thing
13
+ - Hold the detail — don't waste time on perfect icons or color when the layout isn't right
14
+ - Don't over-design: only design the next thing you're going to build
15
+
16
+ ### Choosing a Personality
17
+ Personality should be decided before picking any specific design values:
18
+
19
+ | Attribute | Elegant/Formal | Neutral/Safe | Playful/Fun |
20
+ |-----------|---------------|-------------|-------------|
21
+ | **Font** | Serif, thin sans-serif | System fonts, clean sans | Rounded sans, display fonts |
22
+ | **Color** | Muted, few hues, gold/navy | Blue, grey, safe palette | Bright, saturated, many hues |
23
+ | **Border-radius** | None or minimal (0–2px) | Small (4px) | Large (8px–full) |
24
+ | **Language** | Formal, professional | Neutral, clear | Casual, friendly, fun |
25
+
26
+ ### Limiting Your Choices
27
+ - **Define systems in advance**: type scale, spacing scale, color palette, shadow scale, font weights, border-radius, width, opacity
28
+ - **Design by choosing from constrained options**, not by picking arbitrary values
29
+ - Systems provide speed (fewer decisions) and consistency (same values everywhere)
30
+
31
+ ---
32
+
33
+ ## Ch 2: Hierarchy is Everything
34
+
35
+ ### The Three Levers of Hierarchy
36
+ 1. **Size** — Larger = more important
37
+ 2. **Weight** — Bolder = more important (use 600–700 for emphasis, 400–500 for normal; never go below 400 for UI text)
38
+ 3. **Color** — Darker = more important
39
+
40
+ ### Text Color System (Light Background)
41
+ | Role | Description | Example Value |
42
+ |------|-------------|---------------|
43
+ | **Primary** | Main content, headings, important text | `hsl(0, 0%, 10%)` — near-black |
44
+ | **Secondary** | Supporting text, descriptions, meta | `hsl(0, 0%, 45%)` — medium grey |
45
+ | **Tertiary** | Placeholders, disabled, timestamps | `hsl(0, 0%, 65%)` — light grey |
46
+
47
+ ### Emphasis Techniques
48
+ - **Don't just make things bigger** — Try weight and color changes first
49
+ - **Emphasize by de-emphasizing surroundings** — Make competing elements less prominent
50
+ - **Labels as supporting cast** — Labels describe data; the data itself should be emphasized
51
+ - **Visual hierarchy ≠ document hierarchy** — An `<h1>` can be small if it's not the focal point
52
+ - **Bold icons need softer color** — Heavy visual weight + high contrast = too loud
53
+
54
+ ### Icon Sizing in Context
55
+ - Icons next to text: match the font size or slightly smaller
56
+ - Icons as primary elements: can be larger, but tone down color/weight to balance
57
+ - Avoid scaling icons beyond their designed size — use different icon sets for different sizes
58
+
59
+ ---
60
+
61
+ ## Ch 3: Layout and Spacing
62
+
63
+ ### Spacing Scale
64
+ A limited set of spacing values to use everywhere:
65
+
66
+ ```
67
+ 4px — Tight: icon-to-label gap, inline element spacing
68
+ 8px — Compact: tight form fields, dense lists
69
+ 12px — Default small: label-to-input, list item padding
70
+ 16px — Default: standard padding, gaps between small elements
71
+ 24px — Comfortable: card padding, section gaps within a component
72
+ 32px — Roomy: between components in a group
73
+ 48px — Spacious: between distinct sections
74
+ 64px — Section: major section separators
75
+ 96px — Large: between page sections
76
+ 128px — Extra large: hero/header padding
77
+ 192px — Maximum padding for very large screens
78
+ 256px — Full-width section padding on desktops
79
+ ```
80
+
81
+ ### Layout Principles
82
+ - **Start with too much white space, then remove** — Easier to tighten than to create breathing room
83
+ - **Don't fill the screen** — Use max-width (e.g., 600–800px for content, 1200px for full layouts)
84
+ - **Grids are a tool, not a rule** — Use them when you need proportional columns; many layouts don't need a grid
85
+ - **Relative sizing doesn't scale** — A 250px sidebar is fine at all widths; don't make it 20% of viewport
86
+ - **Dense UIs need smaller spacing** — Dashboards and data-heavy UIs can use tighter spacing from the scale
87
+ - **Generous UIs need larger spacing** — Marketing pages and hero sections use wider spacing
88
+
89
+ ### Grouping with Spacing
90
+ - **Close = related** — Elements that belong together should have less space between them
91
+ - **Far = unrelated** — Use larger spacing to separate distinct groups
92
+ - **Ambiguous spacing is the enemy** — If spacing between items is uniform, the grouping is unclear
93
+
94
+ ---
95
+
96
+ ## Ch 4: Designing Text
97
+
98
+ ### Type Scale
99
+ A limited set of font sizes to use everywhere:
100
+
101
+ ```
102
+ 12px — Fine print, captions, badges
103
+ 14px — Secondary text, meta information, labels
104
+ 16px — Body text (base size for most interfaces)
105
+ 18px — Slightly emphasized body, lead paragraphs
106
+ 20px — Large body, small headings, subheadings
107
+ 24px — Section headings (h3 equivalent)
108
+ 30px — Page section headings (h2 equivalent)
109
+ 36px — Page titles, hero subheadings
110
+ 48px — Display headings, hero titles
111
+ 60px — Large display, landing page headlines
112
+ 72px — Extra-large display, maximum emphasis
113
+ ```
114
+
115
+ ### Font Weight Scale
116
+ | Weight | Use |
117
+ |--------|-----|
118
+ | 400 (Regular) | Body text, descriptions, de-emphasized content |
119
+ | 500 (Medium) | Slightly emphasized body, labels, navigation |
120
+ | 600 (Semi-bold) | Headings, buttons, emphasized text |
121
+ | 700 (Bold) | Strong emphasis, primary headings |
122
+
123
+ **Never use weights below 400** for UI text — they're too hard to read.
124
+
125
+ ### Line-Height Guidelines
126
+ | Font Size | Recommended Line-Height |
127
+ |-----------|------------------------|
128
+ | 12–14px | 1.5–1.75 (more leading for small text) |
129
+ | 16–18px | 1.5 (standard reading comfort) |
130
+ | 20–24px | 1.25–1.4 (can tighten slightly) |
131
+ | 30–48px | 1.1–1.25 (headings need less) |
132
+ | 48px+ | 1–1.1 (display text: nearly solid) |
133
+
134
+ ### Line Length
135
+ - **Optimal**: 45–75 characters per line
136
+ - **Implementation**: `max-width: 20em` to `35em` on text containers
137
+ - **Centered text**: Only for 1–2 lines maximum; left-align everything else
138
+
139
+ ### Letter-Spacing
140
+ | Context | Letter-Spacing |
141
+ |---------|---------------|
142
+ | Large headings (36px+) | -0.02em to -0.05em (tighten) |
143
+ | Normal body text | 0 (default) |
144
+ | Small uppercase labels | +0.05em to +0.1em (widen) |
145
+ | All-caps text | +0.05em (widen for readability) |
146
+
147
+ ### Link Styling
148
+ - **In body text**: Colored + underlined (or underlined on hover)
149
+ - **In navigation**: No special color; use weight, underline-on-hover, or active indicator
150
+ - **In cards**: The whole card can be clickable; no link styling needed
151
+
152
+ ---
153
+
154
+ ## Ch 5: Working with Color
155
+
156
+ ### HSL Color Model
157
+ ```
158
+ hsl(hue, saturation%, lightness%)
159
+ ```
160
+ - **Hue**: 0–360 (color wheel: 0=red, 120=green, 240=blue)
161
+ - **Saturation**: 0%=grey, 100%=vivid
162
+ - **Lightness**: 0%=black, 50%=pure color, 100%=white
163
+
164
+ ### Building a Complete Palette
165
+
166
+ **Greys (8–9 shades)**:
167
+ | Shade | Lightness Range | Use |
168
+ |-------|----------------|-----|
169
+ | 50 | 97–98% | Page backgrounds, subtle tints |
170
+ | 100 | 93–95% | Card backgrounds, alternate rows |
171
+ | 200 | 85–90% | Borders, dividers |
172
+ | 300 | 75–80% | Disabled text, placeholder icons |
173
+ | 400 | 60–65% | Placeholder text |
174
+ | 500 | 45–50% | Secondary text |
175
+ | 600 | 35–40% | Icons, labels |
176
+ | 700 | 25–30% | Secondary headings |
177
+ | 800 | 15–20% | Primary text, headings |
178
+ | 900 | 5–10% | Maximum emphasis text |
179
+
180
+ **Primary/Accent colors (5–10 shades each)**:
181
+ Follow same pattern: pick middle (button bg), darkest (text), lightest (tinted bg), fill in between.
182
+
183
+ ### Color Accessibility
184
+ | Standard | Ratio | When |
185
+ |----------|-------|------|
186
+ | WCAG AA (normal text) | 4.5:1 | Body text, labels, inputs |
187
+ | WCAG AA (large text) | 3:1 | Headings 18px+ bold, or 24px+ |
188
+ | WCAG AAA (normal) | 7:1 | Enhanced accessibility |
189
+
190
+ ### Grey on Colored Backgrounds
191
+ **Problem**: Pure grey (`hsl(0, 0%, X%)`) looks washed out on colored backgrounds.
192
+
193
+ **Solutions**:
194
+ 1. **Reduce opacity**: `rgba(255,255,255,0.8)` on dark bg; `rgba(0,0,0,0.5)` on light bg
195
+ 2. **Hand-pick**: Choose a color with same hue as background but adjusted saturation/lightness
196
+
197
+ ### Perceived Brightness by Hue
198
+ Hues have different apparent brightness at same HSL lightness:
199
+ - **Brightest** (feel lighter): Yellow (60°), Cyan (180°), Green (120°)
200
+ - **Darkest** (feel darker): Blue (240°), Red (0°), Magenta (300°)
201
+ - Adjust lightness values to compensate when building palettes across hues
202
+
203
+ ### Dark Mode Adaptation
204
+ - Reverse the shade scale: shade-900 becomes background, shade-50 becomes text
205
+ - Reduce saturation slightly (vivid colors are harsh on dark backgrounds)
206
+ - Shadows are less visible on dark — use subtle glows or border accents instead
207
+ - Test carefully: contrast requirements still apply
208
+
209
+ ---
210
+
211
+ ## Ch 6: Creating Depth
212
+
213
+ ### Shadow Elevation Scale
214
+
215
+ ```css
216
+ --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
217
+ --shadow-sm: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
218
+ --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
219
+ --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
220
+ --shadow-xl: 0 20px 25px rgba(0,0,0,0.15), 0 10px 10px rgba(0,0,0,0.05);
221
+ ```
222
+
223
+ ### Shadow Best Practices
224
+ - **Two shadows per level**: Large diffuse + small tight for realism
225
+ - **Raised elements**: Buttons, cards, navbars, floating action buttons
226
+ - **Inset elements**: Input fields, wells, pressed button states
227
+ - **Interactive shadows**: Increase shadow on hover (sm → md) to show clickability
228
+ - **Don't overdo flat design**: Some depth helps users understand interactive affordances
229
+ - **Keep it consistent**: Use only the defined scale; no random shadow values
230
+
231
+ ### Depth Through Overlap
232
+ - Offset an element (e.g., card) so it overlaps a background section
233
+ - Creates visual layering without shadows
234
+ - Negative margins or absolute positioning to achieve the overlap
235
+
236
+ ### Color and Depth
237
+ - **Lighter elements appear closer** to the viewer
238
+ - **Darker elements appear farther** away
239
+ - Use this with shadows: elevated elements can also be slightly lighter in bg color
240
+
241
+ ---
242
+
243
+ ## Ch 7: Working with Images
244
+
245
+ ### Text on Images
246
+
247
+ | Technique | CSS | Best For |
248
+ |-----------|-----|----------|
249
+ | Dark overlay | `background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url(...)` | Hero sections |
250
+ | Lower brightness | `filter: brightness(0.7)` | Subtle dimming |
251
+ | Colorize | `filter: grayscale(100%); mix-blend-mode: multiply` + color overlay | Brand consistency |
252
+ | Text shadow | `text-shadow: 0 2px 4px rgba(0,0,0,0.5)` | Quick fix |
253
+ | Scrim/card | Semi-opaque `background-color` on text container | Readable blocks |
254
+
255
+ ### Image Sizing
256
+
257
+ | Scenario | Approach |
258
+ |----------|----------|
259
+ | Icons at different sizes | Use different icon sets (16px, 24px, 32px) — don't scale |
260
+ | Screenshots in marketing | Capture at display size; don't scale down |
261
+ | User-uploaded avatars | `object-fit: cover` + fixed aspect ratio + bg color fallback |
262
+ | User-uploaded hero images | `object-fit: cover` + fixed height + handle extremes (panoramic, portrait) |
263
+
264
+ ### Object-Fit Values
265
+ ```css
266
+ object-fit: cover; /* Crop to fill — best for avatars, hero images */
267
+ object-fit: contain; /* Fit inside — best for product images, logos */
268
+ object-fit: fill; /* Stretch — avoid for most UI use cases */
269
+ ```
270
+
271
+ ---
272
+
273
+ ## Ch 8: Finishing Touches
274
+
275
+ ### Accent Borders
276
+ ```css
277
+ /* Top accent on card */
278
+ .card { border-top: 4px solid var(--primary-500); }
279
+
280
+ /* Left accent on alert */
281
+ .alert { border-left: 4px solid var(--warning-500); }
282
+
283
+ /* Color-code by type */
284
+ .alert-success { border-left-color: var(--success-500); }
285
+ .alert-danger { border-left-color: var(--danger-500); }
286
+ ```
287
+
288
+ ### Replacing Borders
289
+ | Instead of Border | Try |
290
+ |-------------------|-----|
291
+ | Between list items | More padding/spacing between items |
292
+ | Around cards | Box-shadow (subtle shadow creates implied boundary) |
293
+ | Between sections | Different background color |
294
+ | Around inputs | Background color difference + subtle shadow |
295
+
296
+ ### Empty States
297
+ - **Don't**: Show just "No items found" in grey text
298
+ - **Do**: Show an illustration + explanation + primary call to action
299
+ - **Example**: "No projects yet — Create your first project" with a big button
300
+ - Empty states are onboarding opportunities
301
+
302
+ ### Custom Defaults
303
+ | Default Element | Upgrade |
304
+ |----------------|---------|
305
+ | Bullet lists | Icon lists (checkmarks, arrows, custom icons) |
306
+ | Blockquotes | Large border-left + background tint + italic |
307
+ | Form inputs | Colored focus ring, custom checkbox/radio |
308
+ | Tables | Alternating rows, sticky headers, row hover |
309
+ | Links | Custom underline color/thickness |
310
+
311
+ ---
312
+
313
+ ## Ch 9: Leveling Up
314
+
315
+ ### Learning Approach
316
+ - **Steal from good designs** — Rebuild UIs you admire to understand why they work
317
+ - **Analyze decisions** — Ask "why does this work?" not just "what does it look like?"
318
+ - **Think in systems** — Every decision should fit into a reusable system
319
+ - **Look outside your domain** — SaaS, e-commerce, media, dashboards — all have lessons
320
+ - **Rebuild for practice** — Pick a well-designed app and recreate a page pixel-by-pixel
321
+
322
+ ### Design System Assembly
323
+ Collect all your scales into one system:
324
+
325
+ ```css
326
+ :root {
327
+ /* Spacing */
328
+ --space-1: 4px; --space-2: 8px; --space-3: 12px;
329
+ --space-4: 16px; --space-5: 24px; --space-6: 32px;
330
+ --space-8: 48px; --space-10: 64px; --space-12: 96px;
331
+ --space-16: 128px;
332
+
333
+ /* Type */
334
+ --text-xs: 12px; --text-sm: 14px; --text-base: 16px;
335
+ --text-lg: 18px; --text-xl: 20px; --text-2xl: 24px;
336
+ --text-3xl: 30px; --text-4xl: 36px; --text-5xl: 48px;
337
+
338
+ /* Font Weight */
339
+ --font-normal: 400; --font-medium: 500;
340
+ --font-semibold: 600; --font-bold: 700;
341
+
342
+ /* Shadows */
343
+ --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
344
+ --shadow-sm: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
345
+ --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
346
+ --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
347
+ --shadow-xl: 0 20px 25px rgba(0,0,0,0.15), 0 10px 10px rgba(0,0,0,0.05);
348
+
349
+ /* Border Radius */
350
+ --radius-sm: 2px; --radius-md: 4px;
351
+ --radius-lg: 8px; --radius-full: 9999px;
352
+
353
+ /* Colors: define full shade scales for grey, primary, accent, etc. */
354
+ }
355
+ ```