qualia-framework 2.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/README.md +50 -0
- package/bin/cli.js +519 -0
- package/framework/agents/architecture-strategist.md +53 -0
- package/framework/agents/backend-agent.md +150 -0
- package/framework/agents/code-simplicity-reviewer.md +86 -0
- package/framework/agents/frontend-agent.md +111 -0
- package/framework/agents/kieran-typescript-reviewer.md +96 -0
- package/framework/agents/performance-oracle.md +111 -0
- package/framework/agents/qualia-codebase-mapper.md +760 -0
- package/framework/agents/qualia-debugger.md +1203 -0
- package/framework/agents/qualia-executor.md +881 -0
- package/framework/agents/qualia-integration-checker.md +423 -0
- package/framework/agents/qualia-phase-researcher.md +453 -0
- package/framework/agents/qualia-plan-checker.md +699 -0
- package/framework/agents/qualia-planner.md +1241 -0
- package/framework/agents/qualia-project-researcher.md +602 -0
- package/framework/agents/qualia-research-synthesizer.md +236 -0
- package/framework/agents/qualia-roadmapper.md +605 -0
- package/framework/agents/qualia-verifier.md +685 -0
- package/framework/agents/team-orchestrator.md +228 -0
- package/framework/agents/teams/full-stack-team.md +48 -0
- package/framework/agents/teams/optimize-team.md +53 -0
- package/framework/agents/teams/review-team.md +62 -0
- package/framework/agents/teams/ship-team.md +86 -0
- package/framework/agents/test-agent.md +182 -0
- package/framework/askpass.sh +2 -0
- package/framework/commands/design.md +53 -0
- package/framework/commands/quick-db.md +22 -0
- package/framework/config/retention.json +35 -0
- package/framework/core/PRINCIPLES.md +77 -0
- package/framework/hooks/auto-format.sh +45 -0
- package/framework/hooks/block-env-edit.sh +42 -0
- package/framework/hooks/branch-guard.sh +46 -0
- package/framework/hooks/confirm-delete.sh +56 -0
- package/framework/hooks/migration-validate.sh +68 -0
- package/framework/hooks/notification-speak.sh +15 -0
- package/framework/hooks/pre-commit.sh +80 -0
- package/framework/hooks/pre-compact.sh +55 -0
- package/framework/hooks/pre-deploy-gate.sh +151 -0
- package/framework/hooks/qualia-colors.sh +32 -0
- package/framework/hooks/retention-cleanup.sh +43 -0
- package/framework/hooks/save-session-state.sh +153 -0
- package/framework/hooks/session-context-loader.sh +28 -0
- package/framework/hooks/session-learn.sh +30 -0
- package/framework/knowledge/claudecode-bible.md +1384 -0
- package/framework/knowledge/client-prefs.md +22 -0
- package/framework/knowledge/common-fixes.md +25 -0
- package/framework/knowledge/deployment-map.md +35 -0
- package/framework/knowledge/email-signature.html +1 -0
- package/framework/knowledge/employees.md +8 -0
- package/framework/knowledge/learned-patterns.md +51 -0
- package/framework/knowledge/optimization-research-2026.md +137 -0
- package/framework/knowledge/qualia-context.md +67 -0
- package/framework/knowledge/supabase-patterns.md +50 -0
- package/framework/knowledge/voice-agent-patterns.md +46 -0
- package/framework/qualia-engine/VERSION +1 -0
- package/framework/qualia-engine/bin/qualia-tools.js +2160 -0
- package/framework/qualia-engine/bin/qualia-tools.test.js +1054 -0
- package/framework/qualia-engine/references/checkpoints.md +775 -0
- package/framework/qualia-engine/references/continuation-format.md +249 -0
- package/framework/qualia-engine/references/decimal-phase-calculation.md +65 -0
- package/framework/qualia-engine/references/design-quality.md +56 -0
- package/framework/qualia-engine/references/git-integration.md +254 -0
- package/framework/qualia-engine/references/git-planning-commit.md +50 -0
- package/framework/qualia-engine/references/model-profile-resolution.md +32 -0
- package/framework/qualia-engine/references/model-profiles.md +73 -0
- package/framework/qualia-engine/references/phase-argument-parsing.md +61 -0
- package/framework/qualia-engine/references/planning-config.md +195 -0
- package/framework/qualia-engine/references/questioning.md +141 -0
- package/framework/qualia-engine/references/tdd.md +263 -0
- package/framework/qualia-engine/references/ui-brand.md +160 -0
- package/framework/qualia-engine/references/verification-patterns.md +612 -0
- package/framework/qualia-engine/templates/DEBUG.md +159 -0
- package/framework/qualia-engine/templates/DESIGN.md +81 -0
- package/framework/qualia-engine/templates/UAT.md +247 -0
- package/framework/qualia-engine/templates/codebase/architecture.md +255 -0
- package/framework/qualia-engine/templates/codebase/concerns.md +310 -0
- package/framework/qualia-engine/templates/codebase/conventions.md +307 -0
- package/framework/qualia-engine/templates/codebase/integrations.md +280 -0
- package/framework/qualia-engine/templates/codebase/stack.md +186 -0
- package/framework/qualia-engine/templates/codebase/structure.md +285 -0
- package/framework/qualia-engine/templates/codebase/testing.md +480 -0
- package/framework/qualia-engine/templates/config.json +35 -0
- package/framework/qualia-engine/templates/context.md +283 -0
- package/framework/qualia-engine/templates/continue-here.md +78 -0
- package/framework/qualia-engine/templates/debug-subagent-prompt.md +91 -0
- package/framework/qualia-engine/templates/discovery.md +146 -0
- package/framework/qualia-engine/templates/milestone-archive.md +123 -0
- package/framework/qualia-engine/templates/milestone.md +115 -0
- package/framework/qualia-engine/templates/phase-prompt.md +567 -0
- package/framework/qualia-engine/templates/planner-subagent-prompt.md +117 -0
- package/framework/qualia-engine/templates/project.md +184 -0
- package/framework/qualia-engine/templates/projects/ai-agent.md +156 -0
- package/framework/qualia-engine/templates/projects/mobile-app.md +181 -0
- package/framework/qualia-engine/templates/projects/voice-agent.md +134 -0
- package/framework/qualia-engine/templates/projects/website.md +137 -0
- package/framework/qualia-engine/templates/requirements.md +231 -0
- package/framework/qualia-engine/templates/research-project/ARCHITECTURE.md +204 -0
- package/framework/qualia-engine/templates/research-project/FEATURES.md +147 -0
- package/framework/qualia-engine/templates/research-project/PITFALLS.md +200 -0
- package/framework/qualia-engine/templates/research-project/STACK.md +120 -0
- package/framework/qualia-engine/templates/research-project/SUMMARY.md +170 -0
- package/framework/qualia-engine/templates/research.md +552 -0
- package/framework/qualia-engine/templates/roadmap.md +202 -0
- package/framework/qualia-engine/templates/state.md +176 -0
- package/framework/qualia-engine/templates/summary-complex.md +59 -0
- package/framework/qualia-engine/templates/summary-minimal.md +41 -0
- package/framework/qualia-engine/templates/summary-standard.md +48 -0
- package/framework/qualia-engine/templates/summary.md +246 -0
- package/framework/qualia-engine/templates/user-setup.md +311 -0
- package/framework/qualia-engine/templates/verification-report.md +322 -0
- package/framework/qualia-engine/workflows/add-phase.md +179 -0
- package/framework/qualia-engine/workflows/add-todo.md +157 -0
- package/framework/qualia-engine/workflows/audit-milestone.md +241 -0
- package/framework/qualia-engine/workflows/check-todos.md +176 -0
- package/framework/qualia-engine/workflows/complete-milestone.md +858 -0
- package/framework/qualia-engine/workflows/diagnose-issues.md +219 -0
- package/framework/qualia-engine/workflows/discovery-phase.md +289 -0
- package/framework/qualia-engine/workflows/discuss-phase.md +534 -0
- package/framework/qualia-engine/workflows/execute-phase.md +559 -0
- package/framework/qualia-engine/workflows/execute-plan.md +438 -0
- package/framework/qualia-engine/workflows/help.md +470 -0
- package/framework/qualia-engine/workflows/insert-phase.md +220 -0
- package/framework/qualia-engine/workflows/list-phase-assumptions.md +178 -0
- package/framework/qualia-engine/workflows/map-codebase.md +327 -0
- package/framework/qualia-engine/workflows/new-milestone.md +363 -0
- package/framework/qualia-engine/workflows/new-project.md +1037 -0
- package/framework/qualia-engine/workflows/pause-work.md +122 -0
- package/framework/qualia-engine/workflows/plan-milestone-gaps.md +256 -0
- package/framework/qualia-engine/workflows/plan-phase.md +422 -0
- package/framework/qualia-engine/workflows/progress.md +354 -0
- package/framework/qualia-engine/workflows/quick.md +252 -0
- package/framework/qualia-engine/workflows/remove-phase.md +326 -0
- package/framework/qualia-engine/workflows/research-phase.md +74 -0
- package/framework/qualia-engine/workflows/resume-project.md +306 -0
- package/framework/qualia-engine/workflows/set-profile.md +80 -0
- package/framework/qualia-engine/workflows/settings.md +145 -0
- package/framework/qualia-engine/workflows/transition.md +556 -0
- package/framework/qualia-engine/workflows/update.md +197 -0
- package/framework/qualia-engine/workflows/verify-phase.md +195 -0
- package/framework/qualia-engine/workflows/verify-work.md +625 -0
- package/framework/rules/context7.md +11 -0
- package/framework/rules/deployment.md +29 -0
- package/framework/rules/frontend.md +33 -0
- package/framework/rules/security.md +12 -0
- package/framework/rules/speed.md +20 -0
- package/framework/scripts/__pycache__/say.cpython-314.pyc +0 -0
- package/framework/scripts/apply-retention.sh +120 -0
- package/framework/scripts/bootstrap-pop-os.sh +354 -0
- package/framework/scripts/claude-voice +13 -0
- package/framework/scripts/cleanup.sh +131 -0
- package/framework/scripts/cowork-mode.sh +141 -0
- package/framework/scripts/generate-project-claude-md.sh +153 -0
- package/framework/scripts/load-test-webhook.js +172 -0
- package/framework/scripts/say.py +236 -0
- package/framework/scripts/showcase-video-recorder/ffmpeg-builder.js +167 -0
- package/framework/scripts/showcase-video-recorder/playwright-helpers.js +216 -0
- package/framework/scripts/speak.py +55 -0
- package/framework/scripts/speak.sh +18 -0
- package/framework/scripts/status.sh +138 -0
- package/framework/scripts/sync-to-framework.sh +65 -0
- package/framework/scripts/voice-hotkey.py +227 -0
- package/framework/scripts/voice-input.sh +51 -0
- package/framework/skills/animate/SKILL.md +202 -0
- package/framework/skills/bolder/SKILL.md +144 -0
- package/framework/skills/browser-qa/SKILL.md +536 -0
- package/framework/skills/clarify/SKILL.md +179 -0
- package/framework/skills/colorize/SKILL.md +170 -0
- package/framework/skills/critique/SKILL.md +126 -0
- package/framework/skills/deep-research/SKILL.md +271 -0
- package/framework/skills/delight/SKILL.md +329 -0
- package/framework/skills/deploy/SKILL.md +261 -0
- package/framework/skills/deploy-verify/SKILL.md +377 -0
- package/framework/skills/deploy-verify/scripts/canary-check.sh +206 -0
- package/framework/skills/deploy-verify/scripts/check-console-errors.js +147 -0
- package/framework/skills/deploy-verify/scripts/check-cwv.js +139 -0
- package/framework/skills/deploy-verify/scripts/project-detect.sh +84 -0
- package/framework/skills/deploy-verify/scripts/verify.sh +548 -0
- package/framework/skills/design-quieter/SKILL.md +130 -0
- package/framework/skills/distill/SKILL.md +149 -0
- package/framework/skills/docs-lookup/SKILL.md +78 -0
- package/framework/skills/fcm-notifications/SKILL.md +125 -0
- package/framework/skills/financial-ledger/SKILL.md +1039 -0
- package/framework/skills/frontend-master/NOTICE.md +4 -0
- package/framework/skills/frontend-master/SKILL.md +127 -0
- package/framework/skills/frontend-master/reference/color-and-contrast.md +132 -0
- package/framework/skills/frontend-master/reference/interaction-design.md +123 -0
- package/framework/skills/frontend-master/reference/motion-design.md +99 -0
- package/framework/skills/frontend-master/reference/responsive-design.md +114 -0
- package/framework/skills/frontend-master/reference/spatial-design.md +100 -0
- package/framework/skills/frontend-master/reference/typography.md +131 -0
- package/framework/skills/frontend-master/reference/ux-writing.md +107 -0
- package/framework/skills/harden/SKILL.md +357 -0
- package/framework/skills/i18n-rtl/SKILL.md +752 -0
- package/framework/skills/learn/SKILL.md +71 -0
- package/framework/skills/memory/SKILL.md +50 -0
- package/framework/skills/mobile-expo/SKILL.md +864 -0
- package/framework/skills/mobile-expo/references/store-checklist.md +550 -0
- package/framework/skills/nestjs-backend/README.md +73 -0
- package/framework/skills/nestjs-backend/SKILL.md +446 -0
- package/framework/skills/nestjs-backend/references/templates.md +1173 -0
- package/framework/skills/normalize/SKILL.md +79 -0
- package/framework/skills/onboard/SKILL.md +242 -0
- package/framework/skills/polish/SKILL.md +209 -0
- package/framework/skills/pr/SKILL.md +66 -0
- package/framework/skills/qualia/SKILL.md +153 -0
- package/framework/skills/qualia-add-todo/SKILL.md +68 -0
- package/framework/skills/qualia-audit-milestone/SKILL.md +92 -0
- package/framework/skills/qualia-check-todos/SKILL.md +55 -0
- package/framework/skills/qualia-complete-milestone/SKILL.md +108 -0
- package/framework/skills/qualia-debug/SKILL.md +149 -0
- package/framework/skills/qualia-design/SKILL.md +203 -0
- package/framework/skills/qualia-discuss-phase/SKILL.md +72 -0
- package/framework/skills/qualia-execute-phase/SKILL.md +86 -0
- package/framework/skills/qualia-help/SKILL.md +67 -0
- package/framework/skills/qualia-idk/SKILL.md +352 -0
- package/framework/skills/qualia-list-phase-assumptions/SKILL.md +67 -0
- package/framework/skills/qualia-new-milestone/SKILL.md +72 -0
- package/framework/skills/qualia-new-project/SKILL.md +92 -0
- package/framework/skills/qualia-optimize/SKILL.md +417 -0
- package/framework/skills/qualia-pause-work/SKILL.md +96 -0
- package/framework/skills/qualia-plan-milestone-gaps/SKILL.md +57 -0
- package/framework/skills/qualia-plan-phase/SKILL.md +101 -0
- package/framework/skills/qualia-progress/SKILL.md +53 -0
- package/framework/skills/qualia-quick/SKILL.md +89 -0
- package/framework/skills/qualia-research-phase/SKILL.md +88 -0
- package/framework/skills/qualia-resume-work/SKILL.md +62 -0
- package/framework/skills/qualia-review/SKILL.md +263 -0
- package/framework/skills/qualia-start/SKILL.md +182 -0
- package/framework/skills/qualia-verify-work/SKILL.md +105 -0
- package/framework/skills/qualia-workflow/SKILL.md +130 -0
- package/framework/skills/rag/SKILL.md +750 -0
- package/framework/skills/responsive/SKILL.md +231 -0
- package/framework/skills/retro/SKILL.md +284 -0
- package/framework/skills/sakani-conventions/SKILL.md +136 -0
- package/framework/skills/sakani-conventions/evals/evals.json +23 -0
- package/framework/skills/sakani-conventions/references/entities.md +365 -0
- package/framework/skills/sakani-conventions/references/error-codes.md +95 -0
- package/framework/skills/seo-master/SKILL.md +490 -0
- package/framework/skills/seo-master/references/checklist.md +199 -0
- package/framework/skills/seo-master/references/structured-data.md +609 -0
- package/framework/skills/ship/SKILL.md +202 -0
- package/framework/skills/stack-researcher/SKILL.md +215 -0
- package/framework/skills/status/SKILL.md +154 -0
- package/framework/skills/status/scripts/health-check.sh +562 -0
- package/framework/skills/subscription-payments/SKILL.md +250 -0
- package/framework/skills/supabase/SKILL.md +973 -0
- package/framework/skills/supabase/references/templates.md +159 -0
- package/framework/skills/team/SKILL.md +67 -0
- package/framework/skills/test-runner/SKILL.md +202 -0
- package/framework/skills/voice-agent/SKILL.md +407 -0
- package/framework/skills/zoho-workflow/SKILL.md +51 -0
- package/framework/statusline-command.sh +117 -0
- package/package.json +24 -0
- package/profiles/fawzi.json +16 -0
- package/profiles/hasan.json +16 -0
- package/profiles/moayad.json +16 -0
- package/templates/CLAUDE-owner.md +52 -0
- package/templates/CLAUDE.md.hbs +58 -0
- package/templates/env.claude.template +12 -0
- package/templates/settings.json +141 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Spatial Design
|
|
2
|
+
|
|
3
|
+
## Spacing Systems
|
|
4
|
+
|
|
5
|
+
### Use 4pt Base, Not 8pt
|
|
6
|
+
|
|
7
|
+
8pt systems are too coarse—you'll frequently need 12px (between 8 and 16). Use 4pt for granularity: 4, 8, 12, 16, 24, 32, 48, 64, 96px.
|
|
8
|
+
|
|
9
|
+
### Name Tokens Semantically
|
|
10
|
+
|
|
11
|
+
Name by relationship (`--space-sm`, `--space-lg`), not value (`--spacing-8`). Use `gap` instead of margins for sibling spacing—it eliminates margin collapse and cleanup hacks.
|
|
12
|
+
|
|
13
|
+
## Grid Systems
|
|
14
|
+
|
|
15
|
+
### The Self-Adjusting Grid
|
|
16
|
+
|
|
17
|
+
Use `repeat(auto-fit, minmax(280px, 1fr))` for responsive grids without breakpoints. Columns are at least 280px, as many as fit per row, leftovers stretch. For complex layouts, use named grid areas (`grid-template-areas`) and redefine them at breakpoints.
|
|
18
|
+
|
|
19
|
+
## Visual Hierarchy
|
|
20
|
+
|
|
21
|
+
### The Squint Test
|
|
22
|
+
|
|
23
|
+
Blur your eyes (or screenshot and blur). Can you still identify:
|
|
24
|
+
- The most important element?
|
|
25
|
+
- The second most important?
|
|
26
|
+
- Clear groupings?
|
|
27
|
+
|
|
28
|
+
If everything looks the same weight blurred, you have a hierarchy problem.
|
|
29
|
+
|
|
30
|
+
### Hierarchy Through Multiple Dimensions
|
|
31
|
+
|
|
32
|
+
Don't rely on size alone. Combine:
|
|
33
|
+
|
|
34
|
+
| Tool | Strong Hierarchy | Weak Hierarchy |
|
|
35
|
+
|------|------------------|----------------|
|
|
36
|
+
| **Size** | 3:1 ratio or more | <2:1 ratio |
|
|
37
|
+
| **Weight** | Bold vs Regular | Medium vs Regular |
|
|
38
|
+
| **Color** | High contrast | Similar tones |
|
|
39
|
+
| **Position** | Top/left (primary) | Bottom/right |
|
|
40
|
+
| **Space** | Surrounded by white space | Crowded |
|
|
41
|
+
|
|
42
|
+
**The best hierarchy uses 2-3 dimensions at once**: A heading that's larger, bolder, AND has more space above it.
|
|
43
|
+
|
|
44
|
+
### Cards Are Not Required
|
|
45
|
+
|
|
46
|
+
Cards are overused. Spacing and alignment create visual grouping naturally. Use cards only when content is truly distinct and actionable, items need visual comparison in a grid, or content needs clear interaction boundaries. **Never nest cards inside cards**—use spacing, typography, and subtle dividers for hierarchy within a card.
|
|
47
|
+
|
|
48
|
+
## Container Queries
|
|
49
|
+
|
|
50
|
+
Viewport queries are for page layouts. **Container queries are for components**:
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
.card-container {
|
|
54
|
+
container-type: inline-size;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.card {
|
|
58
|
+
display: grid;
|
|
59
|
+
gap: var(--space-md);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Card layout changes based on its container, not viewport */
|
|
63
|
+
@container (min-width: 400px) {
|
|
64
|
+
.card {
|
|
65
|
+
grid-template-columns: 120px 1fr;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Why this matters**: A card in a narrow sidebar stays compact, while the same card in a main content area expands—automatically, without viewport hacks.
|
|
71
|
+
|
|
72
|
+
## Optical Adjustments
|
|
73
|
+
|
|
74
|
+
Text at `margin-left: 0` looks indented due to letterform whitespace—use negative margin (`-0.05em`) to optically align. Geometrically centered icons often look off-center; play icons need to shift right, arrows shift toward their direction.
|
|
75
|
+
|
|
76
|
+
### Touch Targets vs Visual Size
|
|
77
|
+
|
|
78
|
+
Buttons can look small but need large touch targets (44px minimum). Use padding or pseudo-elements:
|
|
79
|
+
|
|
80
|
+
```css
|
|
81
|
+
.icon-button {
|
|
82
|
+
width: 24px; /* Visual size */
|
|
83
|
+
height: 24px;
|
|
84
|
+
position: relative;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.icon-button::before {
|
|
88
|
+
content: '';
|
|
89
|
+
position: absolute;
|
|
90
|
+
inset: -10px; /* Expand tap target to 44px */
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Depth & Elevation
|
|
95
|
+
|
|
96
|
+
Create semantic z-index scales (dropdown → sticky → modal-backdrop → modal → toast → tooltip) instead of arbitrary numbers. For shadows, create a consistent elevation scale (sm → md → lg → xl). **Key insight**: Shadows should be subtle—if you can clearly see it, it's probably too strong.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
**Avoid**: Arbitrary spacing values outside your scale. Making all spacing equal (variety creates hierarchy). Creating hierarchy through size alone - combine size, weight, color, and space.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Typography
|
|
2
|
+
|
|
3
|
+
## Classic Typography Principles
|
|
4
|
+
|
|
5
|
+
### Vertical Rhythm
|
|
6
|
+
|
|
7
|
+
Your line-height should be the base unit for ALL vertical spacing. If body text has `line-height: 1.5` on `16px` type (= 24px), spacing values should be multiples of 24px. This creates subconscious harmony—text and space share a mathematical foundation.
|
|
8
|
+
|
|
9
|
+
### Modular Scale & Hierarchy
|
|
10
|
+
|
|
11
|
+
The common mistake: too many font sizes that are too close together (14px, 15px, 16px, 18px...). This creates muddy hierarchy.
|
|
12
|
+
|
|
13
|
+
**Use fewer sizes with more contrast.** A 5-size system covers most needs:
|
|
14
|
+
|
|
15
|
+
| Role | Typical Ratio | Use Case |
|
|
16
|
+
|------|---------------|----------|
|
|
17
|
+
| xs | 0.75rem | Captions, legal |
|
|
18
|
+
| sm | 0.875rem | Secondary UI, metadata |
|
|
19
|
+
| base | 1rem | Body text |
|
|
20
|
+
| lg | 1.25-1.5rem | Subheadings, lead text |
|
|
21
|
+
| xl+ | 2-4rem | Headlines, hero text |
|
|
22
|
+
|
|
23
|
+
Popular ratios: 1.25 (major third), 1.333 (perfect fourth), 1.5 (perfect fifth). Pick one and commit.
|
|
24
|
+
|
|
25
|
+
### Readability & Measure
|
|
26
|
+
|
|
27
|
+
Use `ch` units for character-based measure (`max-width: 65ch`). Line-height scales inversely with line length—narrow columns need tighter leading, wide columns need more.
|
|
28
|
+
|
|
29
|
+
**Non-obvious**: Increase line-height for light text on dark backgrounds. The perceived weight is lighter, so text needs more breathing room. Add 0.05-0.1 to your normal line-height.
|
|
30
|
+
|
|
31
|
+
## Font Selection & Pairing
|
|
32
|
+
|
|
33
|
+
### Choosing Distinctive Fonts
|
|
34
|
+
|
|
35
|
+
**Avoid the invisible defaults**: Inter, Roboto, Open Sans, Lato, Montserrat. These are everywhere, making your design feel generic. They're fine for documentation or tools where personality isn't the goal—but if you want distinctive design, look elsewhere.
|
|
36
|
+
|
|
37
|
+
**Better Google Fonts alternatives**:
|
|
38
|
+
- Instead of Inter → **Instrument Sans**, **Plus Jakarta Sans**, **Outfit**
|
|
39
|
+
- Instead of Roboto → **Onest**, **Figtree**, **Urbanist**
|
|
40
|
+
- Instead of Open Sans → **Source Sans 3**, **Nunito Sans**, **DM Sans**
|
|
41
|
+
- For editorial/premium feel → **Fraunces**, **Newsreader**, **Lora**
|
|
42
|
+
|
|
43
|
+
**System fonts are underrated**: `-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui` looks native, loads instantly, and is highly readable. Consider this for apps where performance > personality.
|
|
44
|
+
|
|
45
|
+
### Pairing Principles
|
|
46
|
+
|
|
47
|
+
**The non-obvious truth**: You often don't need a second font. One well-chosen font family in multiple weights creates cleaner hierarchy than two competing typefaces. Only add a second font when you need genuine contrast (e.g., display headlines + body serif).
|
|
48
|
+
|
|
49
|
+
When pairing, contrast on multiple axes:
|
|
50
|
+
- Serif + Sans (structure contrast)
|
|
51
|
+
- Geometric + Humanist (personality contrast)
|
|
52
|
+
- Condensed display + Wide body (proportion contrast)
|
|
53
|
+
|
|
54
|
+
**Never pair fonts that are similar but not identical** (e.g., two geometric sans-serifs). They create visual tension without clear hierarchy.
|
|
55
|
+
|
|
56
|
+
### Web Font Loading
|
|
57
|
+
|
|
58
|
+
The layout shift problem: fonts load late, text reflows, and users see content jump. Here's the fix:
|
|
59
|
+
|
|
60
|
+
```css
|
|
61
|
+
/* 1. Use font-display: swap for visibility */
|
|
62
|
+
@font-face {
|
|
63
|
+
font-family: 'CustomFont';
|
|
64
|
+
src: url('font.woff2') format('woff2');
|
|
65
|
+
font-display: swap;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* 2. Match fallback metrics to minimize shift */
|
|
69
|
+
@font-face {
|
|
70
|
+
font-family: 'CustomFont-Fallback';
|
|
71
|
+
src: local('Arial');
|
|
72
|
+
size-adjust: 105%; /* Scale to match x-height */
|
|
73
|
+
ascent-override: 90%; /* Match ascender height */
|
|
74
|
+
descent-override: 20%; /* Match descender depth */
|
|
75
|
+
line-gap-override: 10%; /* Match line spacing */
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
body {
|
|
79
|
+
font-family: 'CustomFont', 'CustomFont-Fallback', sans-serif;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Tools like [Fontaine](https://github.com/unjs/fontaine) calculate these overrides automatically.
|
|
84
|
+
|
|
85
|
+
## Modern Web Typography
|
|
86
|
+
|
|
87
|
+
### Fluid Type
|
|
88
|
+
|
|
89
|
+
Use `clamp(min, preferred, max)` for fluid typography. The middle value (e.g., `5vw + 1rem`) controls scaling rate—higher vw = faster scaling. Add a rem offset so it doesn't collapse to 0 on small screens.
|
|
90
|
+
|
|
91
|
+
**When NOT to use fluid type**: Button text, labels, UI elements (should be consistent), very short text, or when you need precise breakpoint control.
|
|
92
|
+
|
|
93
|
+
### OpenType Features
|
|
94
|
+
|
|
95
|
+
Most developers don't know these exist. Use them for polish:
|
|
96
|
+
|
|
97
|
+
```css
|
|
98
|
+
/* Tabular numbers for data alignment */
|
|
99
|
+
.data-table { font-variant-numeric: tabular-nums; }
|
|
100
|
+
|
|
101
|
+
/* Proper fractions */
|
|
102
|
+
.recipe-amount { font-variant-numeric: diagonal-fractions; }
|
|
103
|
+
|
|
104
|
+
/* Small caps for abbreviations */
|
|
105
|
+
abbr { font-variant-caps: all-small-caps; }
|
|
106
|
+
|
|
107
|
+
/* Disable ligatures in code */
|
|
108
|
+
code { font-variant-ligatures: none; }
|
|
109
|
+
|
|
110
|
+
/* Enable kerning (usually on by default, but be explicit) */
|
|
111
|
+
body { font-kerning: normal; }
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Check what features your font supports at [Wakamai Fondue](https://wakamaifondue.com/).
|
|
115
|
+
|
|
116
|
+
## Typography System Architecture
|
|
117
|
+
|
|
118
|
+
Name tokens semantically (`--text-body`, `--text-heading`), not by value (`--font-size-16`). Include font stacks, size scale, weights, line-heights, and letter-spacing in your token system.
|
|
119
|
+
|
|
120
|
+
## Accessibility Considerations
|
|
121
|
+
|
|
122
|
+
Beyond contrast ratios (which are well-documented), consider:
|
|
123
|
+
|
|
124
|
+
- **Never disable zoom**: `user-scalable=no` breaks accessibility. If your layout breaks at 200% zoom, fix the layout.
|
|
125
|
+
- **Use rem/em for font sizes**: This respects user browser settings. Never `px` for body text.
|
|
126
|
+
- **Minimum 16px body text**: Smaller than this strains eyes and fails WCAG on mobile.
|
|
127
|
+
- **Adequate touch targets**: Text links need padding or line-height that creates 44px+ tap targets.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
**Avoid**: More than 2-3 font families per project. Skipping fallback font definitions. Ignoring font loading performance (FOUT/FOIT). Using decorative fonts for body text.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# UX Writing
|
|
2
|
+
|
|
3
|
+
## The Button Label Problem
|
|
4
|
+
|
|
5
|
+
**Never use "OK", "Submit", or "Yes/No".** These are lazy and ambiguous. Use specific verb + object patterns:
|
|
6
|
+
|
|
7
|
+
| Bad | Good | Why |
|
|
8
|
+
|-----|------|-----|
|
|
9
|
+
| OK | Save changes | Says what will happen |
|
|
10
|
+
| Submit | Create account | Outcome-focused |
|
|
11
|
+
| Yes | Delete message | Confirms the action |
|
|
12
|
+
| Cancel | Keep editing | Clarifies what "cancel" means |
|
|
13
|
+
| Click here | Download PDF | Describes the destination |
|
|
14
|
+
|
|
15
|
+
**For destructive actions**, name the destruction:
|
|
16
|
+
- "Delete" not "Remove" (delete is permanent, remove implies recoverable)
|
|
17
|
+
- "Delete 5 items" not "Delete selected" (show the count)
|
|
18
|
+
|
|
19
|
+
## Error Messages: The Formula
|
|
20
|
+
|
|
21
|
+
Every error message should answer: (1) What happened? (2) Why? (3) How to fix it? Example: "Email address isn't valid. Please include an @ symbol." not "Invalid input".
|
|
22
|
+
|
|
23
|
+
### Error Message Templates
|
|
24
|
+
|
|
25
|
+
| Situation | Template |
|
|
26
|
+
|-----------|----------|
|
|
27
|
+
| **Format error** | "[Field] needs to be [format]. Example: [example]" |
|
|
28
|
+
| **Missing required** | "Please enter [what's missing]" |
|
|
29
|
+
| **Permission denied** | "You don't have access to [thing]. [What to do instead]" |
|
|
30
|
+
| **Network error** | "We couldn't reach [thing]. Check your connection and [action]." |
|
|
31
|
+
| **Server error** | "Something went wrong on our end. We're looking into it. [Alternative action]" |
|
|
32
|
+
|
|
33
|
+
### Don't Blame the User
|
|
34
|
+
|
|
35
|
+
Reframe errors: "Please enter a date in MM/DD/YYYY format" not "You entered an invalid date".
|
|
36
|
+
|
|
37
|
+
## Empty States Are Opportunities
|
|
38
|
+
|
|
39
|
+
Empty states are onboarding moments: (1) Acknowledge briefly, (2) Explain the value of filling it, (3) Provide a clear action. "No projects yet. Create your first one to get started." not just "No items".
|
|
40
|
+
|
|
41
|
+
## Voice vs Tone
|
|
42
|
+
|
|
43
|
+
**Voice** is your brand's personality—consistent everywhere.
|
|
44
|
+
**Tone** adapts to the moment.
|
|
45
|
+
|
|
46
|
+
| Moment | Tone Shift |
|
|
47
|
+
|--------|------------|
|
|
48
|
+
| Success | Celebratory, brief: "Done! Your changes are live." |
|
|
49
|
+
| Error | Empathetic, helpful: "That didn't work. Here's what to try..." |
|
|
50
|
+
| Loading | Reassuring: "Saving your work..." |
|
|
51
|
+
| Destructive confirm | Serious, clear: "Delete this project? This can't be undone." |
|
|
52
|
+
|
|
53
|
+
**Never use humor for errors.** Users are already frustrated. Be helpful, not cute.
|
|
54
|
+
|
|
55
|
+
## Writing for Accessibility
|
|
56
|
+
|
|
57
|
+
**Link text** must have standalone meaning—"View pricing plans" not "Click here". **Alt text** describes information, not the image—"Revenue increased 40% in Q4" not "Chart". Use `alt=""` for decorative images. **Icon buttons** need `aria-label` for screen reader context.
|
|
58
|
+
|
|
59
|
+
## Writing for Translation
|
|
60
|
+
|
|
61
|
+
### Plan for Expansion
|
|
62
|
+
|
|
63
|
+
German text is ~30% longer than English. Allocate space:
|
|
64
|
+
|
|
65
|
+
| Language | Expansion |
|
|
66
|
+
|----------|-----------|
|
|
67
|
+
| German | +30% |
|
|
68
|
+
| French | +20% |
|
|
69
|
+
| Finnish | +30-40% |
|
|
70
|
+
| Chinese | -30% (fewer chars, but same width) |
|
|
71
|
+
|
|
72
|
+
### Translation-Friendly Patterns
|
|
73
|
+
|
|
74
|
+
Keep numbers separate ("New messages: 3" not "You have 3 new messages"). Use full sentences as single strings (word order varies by language). Avoid abbreviations ("5 minutes ago" not "5 mins ago"). Give translators context about where strings appear.
|
|
75
|
+
|
|
76
|
+
## Consistency: The Terminology Problem
|
|
77
|
+
|
|
78
|
+
Pick one term and stick with it:
|
|
79
|
+
|
|
80
|
+
| Inconsistent | Consistent |
|
|
81
|
+
|--------------|------------|
|
|
82
|
+
| Delete / Remove / Trash | Delete |
|
|
83
|
+
| Settings / Preferences / Options | Settings |
|
|
84
|
+
| Sign in / Log in / Enter | Sign in |
|
|
85
|
+
| Create / Add / New | Create |
|
|
86
|
+
|
|
87
|
+
Build a terminology glossary and enforce it. Variety creates confusion.
|
|
88
|
+
|
|
89
|
+
## Avoid Redundant Copy
|
|
90
|
+
|
|
91
|
+
If the heading explains it, the intro is redundant. If the button is clear, don't explain it again. Say it once, say it well.
|
|
92
|
+
|
|
93
|
+
## Loading States
|
|
94
|
+
|
|
95
|
+
Be specific: "Saving your draft..." not "Loading...". For long waits, set expectations ("This usually takes 30 seconds") or show progress.
|
|
96
|
+
|
|
97
|
+
## Confirmation Dialogs: Use Sparingly
|
|
98
|
+
|
|
99
|
+
Most confirmation dialogs are design failures—consider undo instead. When you must confirm: name the action, explain consequences, use specific button labels ("Delete project" / "Keep project", not "Yes" / "No").
|
|
100
|
+
|
|
101
|
+
## Form Instructions
|
|
102
|
+
|
|
103
|
+
Show format with placeholders, not instructions. For non-obvious fields, explain why you're asking.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
**Avoid**: Jargon without explanation. Blaming users ("You made an error" → "This field is required"). Vague errors ("Something went wrong"). Varying terminology for variety. Humor for errors.
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: harden
|
|
3
|
+
description: Improve interface resilience through better error handling, i18n support, text overflow handling, and edge case management. Makes interfaces robust and production-ready.
|
|
4
|
+
user-invokable: true
|
|
5
|
+
args:
|
|
6
|
+
- name: target
|
|
7
|
+
description: The feature or area to harden (optional)
|
|
8
|
+
required: false
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Strengthen interfaces against edge cases, errors, internationalization issues, and real-world usage scenarios that break idealized designs.
|
|
12
|
+
|
|
13
|
+
## Assess Hardening Needs
|
|
14
|
+
|
|
15
|
+
Identify weaknesses and edge cases:
|
|
16
|
+
|
|
17
|
+
1. **Test with extreme inputs**:
|
|
18
|
+
- Very long text (names, descriptions, titles)
|
|
19
|
+
- Very short text (empty, single character)
|
|
20
|
+
- Special characters (emoji, RTL text, accents)
|
|
21
|
+
- Large numbers (millions, billions)
|
|
22
|
+
- Many items (1000+ list items, 50+ options)
|
|
23
|
+
- No data (empty states)
|
|
24
|
+
|
|
25
|
+
2. **Test error scenarios**:
|
|
26
|
+
- Network failures (offline, slow, timeout)
|
|
27
|
+
- API errors (400, 401, 403, 404, 500)
|
|
28
|
+
- Validation errors
|
|
29
|
+
- Permission errors
|
|
30
|
+
- Rate limiting
|
|
31
|
+
- Concurrent operations
|
|
32
|
+
|
|
33
|
+
3. **Test internationalization**:
|
|
34
|
+
- Long translations (German is often 30% longer than English)
|
|
35
|
+
- RTL languages (Arabic, Hebrew)
|
|
36
|
+
- Character sets (Chinese, Japanese, Korean, emoji)
|
|
37
|
+
- Date/time formats
|
|
38
|
+
- Number formats (1,000 vs 1.000)
|
|
39
|
+
- Currency symbols
|
|
40
|
+
|
|
41
|
+
**CRITICAL**: Designs that only work with perfect data aren't production-ready. Harden against reality.
|
|
42
|
+
|
|
43
|
+
## Hardening Dimensions
|
|
44
|
+
|
|
45
|
+
Systematically improve resilience:
|
|
46
|
+
|
|
47
|
+
### Text Overflow & Wrapping
|
|
48
|
+
|
|
49
|
+
**Long text handling**:
|
|
50
|
+
```css
|
|
51
|
+
/* Single line with ellipsis */
|
|
52
|
+
.truncate {
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Multi-line with clamp */
|
|
59
|
+
.line-clamp {
|
|
60
|
+
display: -webkit-box;
|
|
61
|
+
-webkit-line-clamp: 3;
|
|
62
|
+
-webkit-box-orient: vertical;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Allow wrapping */
|
|
67
|
+
.wrap {
|
|
68
|
+
word-wrap: break-word;
|
|
69
|
+
overflow-wrap: break-word;
|
|
70
|
+
hyphens: auto;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Flex/Grid overflow**:
|
|
75
|
+
```css
|
|
76
|
+
/* Prevent flex items from overflowing */
|
|
77
|
+
.flex-item {
|
|
78
|
+
min-width: 0; /* Allow shrinking below content size */
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Prevent grid items from overflowing */
|
|
83
|
+
.grid-item {
|
|
84
|
+
min-width: 0;
|
|
85
|
+
min-height: 0;
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Responsive text sizing**:
|
|
90
|
+
- Use `clamp()` for fluid typography
|
|
91
|
+
- Set minimum readable sizes (14px on mobile)
|
|
92
|
+
- Test text scaling (zoom to 200%)
|
|
93
|
+
- Ensure containers expand with text
|
|
94
|
+
|
|
95
|
+
### Internationalization (i18n)
|
|
96
|
+
|
|
97
|
+
**Text expansion**:
|
|
98
|
+
- Add 30-40% space budget for translations
|
|
99
|
+
- Use flexbox/grid that adapts to content
|
|
100
|
+
- Test with longest language (usually German)
|
|
101
|
+
- Avoid fixed widths on text containers
|
|
102
|
+
|
|
103
|
+
```jsx
|
|
104
|
+
// ❌ Bad: Assumes short English text
|
|
105
|
+
<button className="w-24">Submit</button>
|
|
106
|
+
|
|
107
|
+
// ✅ Good: Adapts to content
|
|
108
|
+
<button className="px-4 py-2">Submit</button>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**RTL (Right-to-Left) support**:
|
|
112
|
+
```css
|
|
113
|
+
/* Use logical properties */
|
|
114
|
+
margin-inline-start: 1rem; /* Not margin-left */
|
|
115
|
+
padding-inline: 1rem; /* Not padding-left/right */
|
|
116
|
+
border-inline-end: 1px solid; /* Not border-right */
|
|
117
|
+
|
|
118
|
+
/* Or use dir attribute */
|
|
119
|
+
[dir="rtl"] .arrow { transform: scaleX(-1); }
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Character set support**:
|
|
123
|
+
- Use UTF-8 encoding everywhere
|
|
124
|
+
- Test with Chinese/Japanese/Korean (CJK) characters
|
|
125
|
+
- Test with emoji (they can be 2-4 bytes)
|
|
126
|
+
- Handle different scripts (Latin, Cyrillic, Arabic, etc.)
|
|
127
|
+
|
|
128
|
+
**Date/Time formatting**:
|
|
129
|
+
```javascript
|
|
130
|
+
// ✅ Use Intl API for proper formatting
|
|
131
|
+
new Intl.DateTimeFormat('en-US').format(date); // 1/15/2024
|
|
132
|
+
new Intl.DateTimeFormat('de-DE').format(date); // 15.1.2024
|
|
133
|
+
|
|
134
|
+
new Intl.NumberFormat('en-US', {
|
|
135
|
+
style: 'currency',
|
|
136
|
+
currency: 'USD'
|
|
137
|
+
}).format(1234.56); // $1,234.56
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Pluralization**:
|
|
141
|
+
```javascript
|
|
142
|
+
// ❌ Bad: Assumes English pluralization
|
|
143
|
+
`${count} item${count !== 1 ? 's' : ''}`
|
|
144
|
+
|
|
145
|
+
// ✅ Good: Use proper i18n library
|
|
146
|
+
t('items', { count }) // Handles complex plural rules
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Error Handling
|
|
150
|
+
|
|
151
|
+
**Network errors**:
|
|
152
|
+
- Show clear error messages
|
|
153
|
+
- Provide retry button
|
|
154
|
+
- Explain what happened
|
|
155
|
+
- Offer offline mode (if applicable)
|
|
156
|
+
- Handle timeout scenarios
|
|
157
|
+
|
|
158
|
+
```jsx
|
|
159
|
+
// Error states with recovery
|
|
160
|
+
{error && (
|
|
161
|
+
<ErrorMessage>
|
|
162
|
+
<p>Failed to load data. {error.message}</p>
|
|
163
|
+
<button onClick={retry}>Try again</button>
|
|
164
|
+
</ErrorMessage>
|
|
165
|
+
)}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Form validation errors**:
|
|
169
|
+
- Inline errors near fields
|
|
170
|
+
- Clear, specific messages
|
|
171
|
+
- Suggest corrections
|
|
172
|
+
- Don't block submission unnecessarily
|
|
173
|
+
- Preserve user input on error
|
|
174
|
+
|
|
175
|
+
**API errors**:
|
|
176
|
+
- Handle each status code appropriately
|
|
177
|
+
- 400: Show validation errors
|
|
178
|
+
- 401: Redirect to login
|
|
179
|
+
- 403: Show permission error
|
|
180
|
+
- 404: Show not found state
|
|
181
|
+
- 429: Show rate limit message
|
|
182
|
+
- 500: Show generic error, offer support
|
|
183
|
+
|
|
184
|
+
**Graceful degradation**:
|
|
185
|
+
- Core functionality works without JavaScript
|
|
186
|
+
- Images have alt text
|
|
187
|
+
- Progressive enhancement
|
|
188
|
+
- Fallbacks for unsupported features
|
|
189
|
+
|
|
190
|
+
### Edge Cases & Boundary Conditions
|
|
191
|
+
|
|
192
|
+
**Empty states**:
|
|
193
|
+
- No items in list
|
|
194
|
+
- No search results
|
|
195
|
+
- No notifications
|
|
196
|
+
- No data to display
|
|
197
|
+
- Provide clear next action
|
|
198
|
+
|
|
199
|
+
**Loading states**:
|
|
200
|
+
- Initial load
|
|
201
|
+
- Pagination load
|
|
202
|
+
- Refresh
|
|
203
|
+
- Show what's loading ("Loading your projects...")
|
|
204
|
+
- Time estimates for long operations
|
|
205
|
+
|
|
206
|
+
**Large datasets**:
|
|
207
|
+
- Pagination or virtual scrolling
|
|
208
|
+
- Search/filter capabilities
|
|
209
|
+
- Performance optimization
|
|
210
|
+
- Don't load all 10,000 items at once
|
|
211
|
+
|
|
212
|
+
**Concurrent operations**:
|
|
213
|
+
- Prevent double-submission (disable button while loading)
|
|
214
|
+
- Handle race conditions
|
|
215
|
+
- Optimistic updates with rollback
|
|
216
|
+
- Conflict resolution
|
|
217
|
+
|
|
218
|
+
**Permission states**:
|
|
219
|
+
- No permission to view
|
|
220
|
+
- No permission to edit
|
|
221
|
+
- Read-only mode
|
|
222
|
+
- Clear explanation of why
|
|
223
|
+
|
|
224
|
+
**Browser compatibility**:
|
|
225
|
+
- Polyfills for modern features
|
|
226
|
+
- Fallbacks for unsupported CSS
|
|
227
|
+
- Feature detection (not browser detection)
|
|
228
|
+
- Test in target browsers
|
|
229
|
+
|
|
230
|
+
### Input Validation & Sanitization
|
|
231
|
+
|
|
232
|
+
**Client-side validation**:
|
|
233
|
+
- Required fields
|
|
234
|
+
- Format validation (email, phone, URL)
|
|
235
|
+
- Length limits
|
|
236
|
+
- Pattern matching
|
|
237
|
+
- Custom validation rules
|
|
238
|
+
|
|
239
|
+
**Server-side validation** (always):
|
|
240
|
+
- Never trust client-side only
|
|
241
|
+
- Validate and sanitize all inputs
|
|
242
|
+
- Protect against injection attacks
|
|
243
|
+
- Rate limiting
|
|
244
|
+
|
|
245
|
+
**Constraint handling**:
|
|
246
|
+
```html
|
|
247
|
+
<!-- Set clear constraints -->
|
|
248
|
+
<input
|
|
249
|
+
type="text"
|
|
250
|
+
maxlength="100"
|
|
251
|
+
pattern="[A-Za-z0-9]+"
|
|
252
|
+
required
|
|
253
|
+
aria-describedby="username-hint"
|
|
254
|
+
/>
|
|
255
|
+
<small id="username-hint">
|
|
256
|
+
Letters and numbers only, up to 100 characters
|
|
257
|
+
</small>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Accessibility Resilience
|
|
261
|
+
|
|
262
|
+
**Keyboard navigation**:
|
|
263
|
+
- All functionality accessible via keyboard
|
|
264
|
+
- Logical tab order
|
|
265
|
+
- Focus management in modals
|
|
266
|
+
- Skip links for long content
|
|
267
|
+
|
|
268
|
+
**Screen reader support**:
|
|
269
|
+
- Proper ARIA labels
|
|
270
|
+
- Announce dynamic changes (live regions)
|
|
271
|
+
- Descriptive alt text
|
|
272
|
+
- Semantic HTML
|
|
273
|
+
|
|
274
|
+
**Motion sensitivity**:
|
|
275
|
+
```css
|
|
276
|
+
@media (prefers-reduced-motion: reduce) {
|
|
277
|
+
* {
|
|
278
|
+
animation-duration: 0.01ms !important;
|
|
279
|
+
animation-iteration-count: 1 !important;
|
|
280
|
+
transition-duration: 0.01ms !important;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**High contrast mode**:
|
|
286
|
+
- Test in Windows high contrast mode
|
|
287
|
+
- Don't rely only on color
|
|
288
|
+
- Provide alternative visual cues
|
|
289
|
+
|
|
290
|
+
### Performance Resilience
|
|
291
|
+
|
|
292
|
+
**Slow connections**:
|
|
293
|
+
- Progressive image loading
|
|
294
|
+
- Skeleton screens
|
|
295
|
+
- Optimistic UI updates
|
|
296
|
+
- Offline support (service workers)
|
|
297
|
+
|
|
298
|
+
**Memory leaks**:
|
|
299
|
+
- Clean up event listeners
|
|
300
|
+
- Cancel subscriptions
|
|
301
|
+
- Clear timers/intervals
|
|
302
|
+
- Abort pending requests on unmount
|
|
303
|
+
|
|
304
|
+
**Throttling & Debouncing**:
|
|
305
|
+
```javascript
|
|
306
|
+
// Debounce search input
|
|
307
|
+
const debouncedSearch = debounce(handleSearch, 300);
|
|
308
|
+
|
|
309
|
+
// Throttle scroll handler
|
|
310
|
+
const throttledScroll = throttle(handleScroll, 100);
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Testing Strategies
|
|
314
|
+
|
|
315
|
+
**Manual testing**:
|
|
316
|
+
- Test with extreme data (very long, very short, empty)
|
|
317
|
+
- Test in different languages
|
|
318
|
+
- Test offline
|
|
319
|
+
- Test slow connection (throttle to 3G)
|
|
320
|
+
- Test with screen reader
|
|
321
|
+
- Test keyboard-only navigation
|
|
322
|
+
- Test on old browsers
|
|
323
|
+
|
|
324
|
+
**Automated testing**:
|
|
325
|
+
- Unit tests for edge cases
|
|
326
|
+
- Integration tests for error scenarios
|
|
327
|
+
- E2E tests for critical paths
|
|
328
|
+
- Visual regression tests
|
|
329
|
+
- Accessibility tests (axe, WAVE)
|
|
330
|
+
|
|
331
|
+
**IMPORTANT**: Hardening is about expecting the unexpected. Real users will do things you never imagined.
|
|
332
|
+
|
|
333
|
+
**NEVER**:
|
|
334
|
+
- Assume perfect input (validate everything)
|
|
335
|
+
- Ignore internationalization (design for global)
|
|
336
|
+
- Leave error messages generic ("Error occurred")
|
|
337
|
+
- Forget offline scenarios
|
|
338
|
+
- Trust client-side validation alone
|
|
339
|
+
- Use fixed widths for text
|
|
340
|
+
- Assume English-length text
|
|
341
|
+
- Block entire interface when one component errors
|
|
342
|
+
|
|
343
|
+
## Verify Hardening
|
|
344
|
+
|
|
345
|
+
Test thoroughly with edge cases:
|
|
346
|
+
|
|
347
|
+
- **Long text**: Try names with 100+ characters
|
|
348
|
+
- **Emoji**: Use emoji in all text fields
|
|
349
|
+
- **RTL**: Test with Arabic or Hebrew
|
|
350
|
+
- **CJK**: Test with Chinese/Japanese/Korean
|
|
351
|
+
- **Network issues**: Disable internet, throttle connection
|
|
352
|
+
- **Large datasets**: Test with 1000+ items
|
|
353
|
+
- **Concurrent actions**: Click submit 10 times rapidly
|
|
354
|
+
- **Errors**: Force API errors, test all error states
|
|
355
|
+
- **Empty**: Remove all data, test empty states
|
|
356
|
+
|
|
357
|
+
Remember: You're hardening for production reality, not demo perfection. Expect users to input weird data, lose connection mid-flow, and use your product in unexpected ways. Build resilience into every component.
|