connore 0.1.1 → 0.2.1
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 +13 -8
- package/bin/ctxkit.js +5 -5
- package/package.json +2 -1
- package/packs/base/planning/START.md +29 -28
- package/packs/base/planning/blueprint-template.md +46 -46
- package/packs/base/planning/plan-template.md +46 -45
- package/packs/base/rules/anti-patterns.md +19 -16
- package/packs/base/rules/code-style.md +19 -16
- package/packs/base/rules/dependency-policy.md +19 -16
- package/packs/base/rules/error-handling.md +19 -16
- package/packs/base/rules/security-audit.md +47 -0
- package/packs/base/rules/security-baseline.md +19 -16
- package/packs/base/templates/bug-report.md +19 -16
- package/packs/base/templates/feature-spec.md +19 -16
- package/packs/base/templates/handoff.md +19 -16
- package/packs/base/templates/project-brief.md +19 -16
- package/packs/base/workflow/code-review.md +19 -16
- package/packs/base/workflow/debugging.md +18 -14
- package/packs/base/workflow/git-and-commits.md +19 -16
- package/packs/base/workflow/idea-to-spec.md +19 -16
- package/packs/base/workflow/session-handoff.md +19 -16
- package/packs/base/workflow/spec-to-plan.md +19 -16
- package/packs/knowledge/backend/api/conventions.md +21 -0
- package/packs/knowledge/backend/architecture/local-sqlite.md +20 -0
- package/packs/knowledge/backend/authentication/session-and-engine.md +24 -0
- package/packs/knowledge/backend/database/schema.md +21 -0
- package/packs/knowledge/components/custom/ambient-background.md +26 -0
- package/packs/knowledge/components/custom/ambient-background.tsx +12 -0
- package/packs/knowledge/components/custom/corner-frame.md +26 -0
- package/packs/knowledge/components/custom/corner-frame.tsx +48 -0
- package/packs/knowledge/components/custom/cta-button.md +26 -0
- package/packs/knowledge/components/custom/cta-button.tsx +10 -0
- package/packs/knowledge/components/custom/page-transition.md +26 -0
- package/packs/knowledge/components/custom/page-transition.tsx +10 -0
- package/packs/knowledge/components/custom/smooth-scroll.md +26 -0
- package/packs/knowledge/components/custom/smooth-scroll.tsx +32 -0
- package/packs/knowledge/components/motion-effects/README.md +30 -0
- package/packs/knowledge/components/ui-primitives/LICENSE +21 -0
- package/packs/knowledge/components/ui-primitives/README.md +22 -0
- package/packs/knowledge/components/ui-primitives/badge.md +26 -0
- package/packs/knowledge/components/ui-primitives/badge.tsx +48 -0
- package/packs/knowledge/components/ui-primitives/button.md +27 -0
- package/packs/knowledge/components/ui-primitives/button.tsx +66 -0
- package/packs/knowledge/components/ui-primitives/card.md +26 -0
- package/packs/knowledge/components/ui-primitives/card.tsx +102 -0
- package/packs/knowledge/components/ui-primitives/checkbox.md +26 -0
- package/packs/knowledge/components/ui-primitives/checkbox.tsx +32 -0
- package/packs/knowledge/components/ui-primitives/dialog.md +26 -0
- package/packs/knowledge/components/ui-primitives/dialog.tsx +168 -0
- package/packs/knowledge/components/ui-primitives/dropdown-menu.md +26 -0
- package/packs/knowledge/components/ui-primitives/dropdown-menu.tsx +268 -0
- package/packs/knowledge/components/ui-primitives/input.md +27 -0
- package/packs/knowledge/components/ui-primitives/input.tsx +18 -0
- package/packs/knowledge/components/ui-primitives/label.md +26 -0
- package/packs/knowledge/components/ui-primitives/label.tsx +23 -0
- package/packs/knowledge/components/ui-primitives/progress.md +26 -0
- package/packs/knowledge/components/ui-primitives/progress.tsx +30 -0
- package/packs/knowledge/components/ui-primitives/scroll-area.md +26 -0
- package/packs/knowledge/components/ui-primitives/scroll-area.tsx +54 -0
- package/packs/knowledge/components/ui-primitives/select.md +26 -0
- package/packs/knowledge/components/ui-primitives/select.tsx +191 -0
- package/packs/knowledge/components/ui-primitives/separator.md +26 -0
- package/packs/knowledge/components/ui-primitives/separator.tsx +27 -0
- package/packs/knowledge/components/ui-primitives/sonner.md +26 -0
- package/packs/knowledge/components/ui-primitives/sonner.tsx +49 -0
- package/packs/knowledge/components/ui-primitives/switch.md +26 -0
- package/packs/knowledge/components/ui-primitives/switch.tsx +32 -0
- package/packs/knowledge/components/ui-primitives/tabs.md +26 -0
- package/packs/knowledge/components/ui-primitives/tabs.tsx +89 -0
- package/packs/knowledge/components/ui-primitives/textarea.md +26 -0
- package/packs/knowledge/components/ui-primitives/textarea.tsx +17 -0
- package/packs/knowledge/components/ui-primitives/tooltip.md +26 -0
- package/packs/knowledge/components/ui-primitives/tooltip.tsx +56 -0
- package/packs/knowledge/design/aesthetics/app-shell.md +41 -0
- package/packs/knowledge/design/aesthetics/code-neutral.md +40 -0
- package/packs/knowledge/design/aesthetics/match.md +46 -0
- package/packs/knowledge/design/aesthetics/ruled-outline.md +40 -0
- package/packs/knowledge/design/aesthetics/solid-accent.md +43 -0
- package/packs/knowledge/design/animations/motion.md +40 -0
- package/packs/knowledge/design/project-style.md +50 -0
- package/packs/knowledge/design/references/benefit-card-grid.md +27 -0
- package/packs/knowledge/design/references/benefit-card-grid.png +0 -0
- package/packs/knowledge/design/references/cta-centered.md +27 -0
- package/packs/knowledge/design/references/cta-centered.png +0 -0
- package/packs/knowledge/design/references/cta-split-media.md +27 -0
- package/packs/knowledge/design/references/cta-split-media.png +0 -0
- package/packs/knowledge/design/references/dashboard-overview.md +31 -0
- package/packs/knowledge/design/references/dashboard-overview.png +0 -0
- package/packs/knowledge/design/references/faq-split-accordion.md +27 -0
- package/packs/knowledge/design/references/faq-split-accordion.png +0 -0
- package/packs/knowledge/design/references/feature-split-checklist.md +27 -0
- package/packs/knowledge/design/references/feature-split-checklist.png +0 -0
- package/packs/knowledge/design/references/footer-four-column.md +27 -0
- package/packs/knowledge/design/references/footer-four-column.png +0 -0
- package/packs/knowledge/design/references/footer-two-column.md +27 -0
- package/packs/knowledge/design/references/footer-two-column.png +0 -0
- package/packs/knowledge/design/references/hero-accent-curtain.md +27 -0
- package/packs/knowledge/design/references/hero-accent-curtain.png +0 -0
- package/packs/knowledge/design/references/hero-split-media.md +27 -0
- package/packs/knowledge/design/references/hero-split-media.png +0 -0
- package/packs/knowledge/design/references/logo-cloud-grid.md +27 -0
- package/packs/knowledge/design/references/logo-cloud-grid.png +0 -0
- package/packs/knowledge/design/references/logo-row-ruled.md +27 -0
- package/packs/knowledge/design/references/logo-row-ruled.png +0 -0
- package/packs/knowledge/design/references/pricing-three-card.md +27 -0
- package/packs/knowledge/design/references/pricing-three-card.png +0 -0
- package/packs/knowledge/design/references/steps-ruled-grid.md +27 -0
- package/packs/knowledge/design/references/steps-ruled-grid.png +0 -0
- package/packs/knowledge/design/rules.md +35 -0
- package/packs/knowledge/design/token-structure.md +46 -0
- package/packs/knowledge/design/tokens.md +55 -0
- package/packs/knowledge/frontend/README.md +50 -0
- package/packs/knowledge/frontend/SOURCES.md +40 -0
- package/packs/knowledge/frontend/accessibility/focus-and-dialogs.md +47 -0
- package/packs/knowledge/frontend/accessibility/semantics-and-keyboard.md +45 -0
- package/packs/knowledge/frontend/accessibility/wcag-targets.md +43 -0
- package/packs/knowledge/frontend/architecture/agent-context-files.md +43 -0
- package/packs/knowledge/frontend/architecture/app-foundations.md +43 -0
- package/packs/knowledge/frontend/architecture/error-handling.md +47 -0
- package/packs/knowledge/frontend/architecture/feature-modules.md +49 -0
- package/packs/knowledge/frontend/architecture/import-boundaries.md +44 -0
- package/packs/knowledge/frontend/architecture/naming.md +43 -0
- package/packs/knowledge/frontend/architecture/project-structure.md +48 -0
- package/packs/knowledge/frontend/architecture/routing.md +45 -0
- package/packs/knowledge/frontend/architecture/security.md +44 -0
- package/packs/knowledge/frontend/architecture/typescript.md +44 -0
- package/packs/knowledge/frontend/components/composition.md +45 -0
- package/packs/knowledge/frontend/components/data-display.md +47 -0
- package/packs/knowledge/frontend/components/library-choice.md +45 -0
- package/packs/knowledge/frontend/components/variants.md +44 -0
- package/packs/knowledge/frontend/forms/form-architecture.md +49 -0
- package/packs/knowledge/frontend/forms/multi-step.md +43 -0
- package/packs/knowledge/frontend/forms/validation.md +47 -0
- package/packs/knowledge/frontend/layout/responsive.md +41 -0
- package/packs/knowledge/frontend/page-blueprints/app-shell.md +16 -0
- package/packs/knowledge/frontend/page-blueprints/faq-footer.md +22 -0
- package/packs/knowledge/frontend/page-blueprints/feature-grid.md +22 -0
- package/packs/knowledge/frontend/page-blueprints/pricing.md +16 -0
- package/packs/knowledge/frontend/page-blueprints/saas-hero.md +24 -0
- package/packs/knowledge/frontend/patterns/dark-marketing.md +18 -0
- package/packs/knowledge/frontend/patterns/status-pill.md +19 -0
- package/packs/knowledge/frontend/performance/code-splitting.md +47 -0
- package/packs/knowledge/frontend/performance/images-and-vitals.md +44 -0
- package/packs/knowledge/frontend/performance/rendering.md +40 -0
- package/packs/knowledge/frontend/rendering/server-and-client.md +50 -0
- package/packs/knowledge/frontend/state/api-layer.md +49 -0
- package/packs/knowledge/frontend/state/async-ui-states.md +43 -0
- package/packs/knowledge/frontend/state/client-store.md +46 -0
- package/packs/knowledge/frontend/state/server-cache.md +42 -0
- package/packs/knowledge/frontend/state/state-categories.md +50 -0
- package/packs/knowledge/frontend/testing/component-tests.md +44 -0
- package/packs/knowledge/frontend/testing/strategy.md +46 -0
- package/packs/knowledge/inbox/README.md +14 -0
- package/packs/knowledge/workflows/authentication.md +18 -0
- package/packs/knowledge/workflows/crud.md +20 -0
- package/packs/knowledge/workflows/dashboard.md +22 -0
- package/packs/nextjs-fullstack/backend/auth-and-roles.md +19 -16
- package/packs/nextjs-fullstack/backend/background-jobs.md +19 -16
- package/packs/nextjs-fullstack/backend/caching.md +17 -14
- package/packs/nextjs-fullstack/backend/database.md +19 -16
- package/packs/nextjs-fullstack/backend/file-uploads.md +19 -16
- package/packs/nextjs-fullstack/backend/logging.md +17 -14
- package/packs/nextjs-fullstack/backend/migrations.md +17 -14
- package/packs/nextjs-fullstack/backend/rate-limiting.md +19 -16
- package/packs/nextjs-fullstack/backend/secrets-and-env.md +19 -16
- package/packs/nextjs-fullstack/backend/validation.md +19 -16
- package/packs/nextjs-fullstack/blueprints/ai-app.md +1 -1
- package/packs/nextjs-fullstack/blueprints/internal-tool.md +1 -1
- package/packs/nextjs-fullstack/blueprints/saas-app.md +1 -1
- package/packs/nextjs-fullstack/build-deploy/ci.md +18 -16
- package/packs/nextjs-fullstack/build-deploy/deploy.md +19 -16
- package/packs/nextjs-fullstack/build-deploy/monitoring.md +16 -14
- package/packs/nextjs-fullstack/build-deploy/performance.md +17 -14
- package/packs/nextjs-fullstack/build-deploy/project-structure.md +18 -16
- package/packs/nextjs-fullstack/build-deploy/release-checklist.md +20 -16
- package/packs/nextjs-fullstack/build-deploy/testing.md +19 -16
- package/packs/nextjs-fullstack/evals/README.md +18 -15
- package/packs/nextjs-fullstack/examples/golden-app/README.md +18 -16
- package/packs/nextjs-fullstack/frontend/accessibility.md +17 -14
- package/packs/nextjs-fullstack/frontend/components.md +19 -16
- package/packs/nextjs-fullstack/frontend/copy.md +46 -0
- package/packs/nextjs-fullstack/frontend/data-fetching.md +46 -0
- package/packs/nextjs-fullstack/frontend/forms.md +17 -14
- package/packs/nextjs-fullstack/frontend/layout.md +19 -16
- package/packs/nextjs-fullstack/frontend/loading-empty-error.md +19 -16
- package/packs/nextjs-fullstack/frontend/motion.md +17 -14
- package/packs/nextjs-fullstack/frontend/responsive.md +19 -16
- package/packs/nextjs-fullstack/frontend/seo.md +20 -16
- package/packs/nextjs-fullstack/frontend/tables.md +17 -14
- package/packs/nextjs-fullstack/frontend/tokens.md +18 -16
- package/packs/nextjs-fullstack/integrations/analytics.md +17 -14
- package/packs/nextjs-fullstack/integrations/email.md +17 -14
- package/packs/nextjs-fullstack/integrations/llm-apis.md +19 -16
- package/packs/nextjs-fullstack/integrations/oauth.md +19 -16
- package/packs/nextjs-fullstack/integrations/object-storage.md +19 -16
- package/packs/nextjs-fullstack/integrations/payments.md +17 -14
- package/packs/nextjs-fullstack/integrations/queues.md +17 -14
- package/packs/nextjs-fullstack/integrations/search.md +19 -16
- package/packs/nextjs-fullstack/integrations/webhooks.md +17 -14
- package/packs/nextjs-fullstack/playbooks/add-ai-feature.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-auth.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-crud.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-email.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-file-upload.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-webhook.md +19 -16
- package/packs/nextjs-fullstack/playbooks/ship-to-prod.md +20 -16
- package/plugins/connore/.claude-plugin/plugin.json +10 -0
- package/plugins/connore/hooks/hooks.json +16 -0
- package/plugins/connore/skills/connore-backend/SKILL.md +32 -0
- package/plugins/connore/skills/connore-handoff/SKILL.md +15 -0
- package/plugins/connore/skills/connore-routes/SKILL.md +16 -0
- package/plugins/connore/skills/connore-validate/SKILL.md +15 -0
- package/src/cli.js +110 -21
- package/src/commands/doctor.js +2 -0
- package/src/commands/edit.js +88 -0
- package/src/commands/graph.js +20 -0
- package/src/commands/handoff.js +45 -0
- package/src/commands/init.js +8 -3
- package/src/commands/lint.js +13 -5
- package/src/commands/log.js +49 -25
- package/src/commands/packs.js +21 -0
- package/src/commands/routes.js +13 -0
- package/src/commands/search.js +7 -2
- package/src/commands/update.js +5 -1
- package/src/lib/config.js +67 -64
- package/src/lib/graph.js +96 -0
- package/src/lib/index.js +88 -72
- package/src/lib/lessons.js +173 -173
- package/src/lib/lint.js +185 -67
- package/src/lib/mutate.js +26 -24
- package/src/lib/packs.js +25 -10
- package/src/lib/paths.js +1 -1
- package/src/lib/prompts.js +66 -0
- package/src/lib/report.js +41 -33
- package/src/lib/routes.js +59 -0
- package/src/lib/run.js +116 -73
- package/src/lib/search.js +24 -0
- package/src/lib/tokens.js +8 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WCAG thresholds
|
|
3
|
+
type: rule
|
|
4
|
+
tags: [accessibility, wcag, contrast, target-size]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when checking contrast, hit areas or zoom against a conformance level.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# WCAG thresholds
|
|
11
|
+
|
|
12
|
+
Numbers from WCAG 2.2. Each is a minimum, not a target. Cited criteria are named so they can be checked against the specification.
|
|
13
|
+
|
|
14
|
+
## Contrast
|
|
15
|
+
|
|
16
|
+
- Body text: at least 4.5:1 against its background (1.4.3 Contrast Minimum, AA).
|
|
17
|
+
- Large text: at least 3:1 (same criterion). Large means roughly 18pt, or 14pt bold.
|
|
18
|
+
- AAA raises these to 7:1 for body text and 4.5:1 for large text (1.4.6).
|
|
19
|
+
- Incidental text, disabled controls, logos and pure decoration are exempt.
|
|
20
|
+
|
|
21
|
+
Dark themes fail this most often on muted grey body copy. Measure it; do not judge by eye.
|
|
22
|
+
|
|
23
|
+
## Target size
|
|
24
|
+
|
|
25
|
+
- Pointer targets are at least 24 by 24 CSS pixels (2.5.8 Target Size Minimum, AA).
|
|
26
|
+
- A smaller target passes only if a 24 pixel circle centred on it does not overlap the circle of any neighbouring target, or if an equivalent larger control exists elsewhere.
|
|
27
|
+
- Inline links in a sentence are exempt.
|
|
28
|
+
|
|
29
|
+
## Reflow and zoom
|
|
30
|
+
|
|
31
|
+
- Content reflows at 320 CSS pixels wide without horizontal scrolling. That width is a 1280 pixel viewport at 400% zoom.
|
|
32
|
+
|
|
33
|
+
## Focus
|
|
34
|
+
|
|
35
|
+
- Focused elements must not be entirely hidden by other content (2.4.11 Focus Not Obscured Minimum, AA).
|
|
36
|
+
|
|
37
|
+
## How to use this
|
|
38
|
+
|
|
39
|
+
Treat these as gates before a screen ships. Record the measured values rather than asserting the screen passes. If a brand colour cannot meet contrast, record the conflict in `design/tokens.md` instead of averaging toward something that fails.
|
|
40
|
+
|
|
41
|
+
## Source
|
|
42
|
+
|
|
43
|
+
WCAG 2.2, W3C Recommendation 12 December 2024. Copyright 2020-2024 World Wide Web Consortium; W3C document use rules apply. Thresholds and criterion numbers are quoted as facts; wording is ours. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Agent context files
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [architecture, agents, context, conventions]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when deciding where project instructions for an agent should live.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Agent context files
|
|
11
|
+
|
|
12
|
+
Put an `AGENTS.md` at the repo root, and one in any subfolder that needs extra context. Many agents read this filename on their own.
|
|
13
|
+
|
|
14
|
+
Each file answers two things: where the agent is, and where it can go next.
|
|
15
|
+
|
|
16
|
+
## Shape
|
|
17
|
+
|
|
18
|
+
- Root: stack, conventions, what to never touch, and pointers to the folders that have their own file.
|
|
19
|
+
- Module, such as `backend/auth`: the rules that apply inside that module only.
|
|
20
|
+
- Keep each file short. It is read on every task, so every line costs context.
|
|
21
|
+
|
|
22
|
+
## Reading order for an agent
|
|
23
|
+
|
|
24
|
+
1. Root `AGENTS.md` for project-level context.
|
|
25
|
+
2. Locate the files or folder for the task.
|
|
26
|
+
3. The module `AGENTS.md`, if one exists.
|
|
27
|
+
4. The parent folder's `AGENTS.md`, for the layer above the module.
|
|
28
|
+
|
|
29
|
+
## Rules
|
|
30
|
+
|
|
31
|
+
- Record decisions and their reasons as they are made, and never delete earlier entries. The next session starts from them.
|
|
32
|
+
- State the stack, the component source and the icon set explicitly, so the agent does not guess.
|
|
33
|
+
- Say which existing components must be reused before new ones are written.
|
|
34
|
+
- Scope each rule to where it applies. A root file full of module details stops being read.
|
|
35
|
+
|
|
36
|
+
## Common mistakes
|
|
37
|
+
|
|
38
|
+
- One enormous root file that repeats every module's rules.
|
|
39
|
+
- Instructions that conflict with the code, which teach the agent to ignore the file.
|
|
40
|
+
|
|
41
|
+
## Source
|
|
42
|
+
|
|
43
|
+
The owner's own project note and project-context template from the raw frontend set.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Build tool and rendering strategy
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [architecture, build, vite, rendering, ssr]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when starting an app or choosing between SPA, SSR, SSG and RSC.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Build tool and rendering strategy
|
|
11
|
+
|
|
12
|
+
Starting from scratch means building your own framework over time. That is a valid choice, but make it deliberately.
|
|
13
|
+
|
|
14
|
+
## Build tools
|
|
15
|
+
|
|
16
|
+
Vite, Parcel and Rsbuild all give a dev server, a production build, fast refresh, JSX and TypeScript. Each starts you with a client-only single-page app. Metro is the bundler for React Native and lacks much of what these offer, so use it only when the project targets native.
|
|
17
|
+
|
|
18
|
+
A build tool does not give you routing, data fetching, styling or a rendering strategy. Those are separate decisions.
|
|
19
|
+
|
|
20
|
+
## Rendering strategies
|
|
21
|
+
|
|
22
|
+
- **SPA** loads one HTML page and updates it as the user interacts. Simplest to start, slowest first load. This is the default for every build tool above.
|
|
23
|
+
- **Streaming SSR** renders on the server and sends rendered HTML. Faster, substantially more to set up and maintain.
|
|
24
|
+
- **SSG** generates HTML at build time. Fast, but more moving parts than SSR for content that changes.
|
|
25
|
+
- **RSC** mixes build-time, server-only and interactive components in one tree. Currently needs deep expertise.
|
|
26
|
+
|
|
27
|
+
Choose per route, not per app. A marketing page suits SSG while a feed suits SSR, and the router is what makes that possible, so pick a router that supports it.
|
|
28
|
+
|
|
29
|
+
## Waterfalls
|
|
30
|
+
|
|
31
|
+
Fetching data inside a component after it renders creates a waterfall: the code loads, then the data loads, in sequence. Prefetch in a route loader or on the server so both happen at once. This is the most common reason a technically correct page feels slow.
|
|
32
|
+
|
|
33
|
+
## When to use a framework instead
|
|
34
|
+
|
|
35
|
+
If the app will plausibly need SSR, SSG or RSC, a framework already solves it. Rolling your own also makes help harder to find, because your routing and fetching are unique to you.
|
|
36
|
+
|
|
37
|
+
## Related
|
|
38
|
+
|
|
39
|
+
`frontend/performance/code-splitting.md`, `frontend/rendering/server-and-client.md`.
|
|
40
|
+
|
|
41
|
+
## Source
|
|
42
|
+
|
|
43
|
+
react.dev, "Build a React app from Scratch". The saved file carries no licence header; attribute react.dev and keep wording original. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Error handling
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [errors, boundaries, api, tracking]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when handling a failed request, adding a boundary, or reporting a crash.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Error handling
|
|
11
|
+
|
|
12
|
+
Three layers, each with a different job: the request, the render tree, and production reporting.
|
|
13
|
+
|
|
14
|
+
## API errors
|
|
15
|
+
|
|
16
|
+
Handle them once, in an interceptor on the shared client, rather than at every call site. That one place can raise a notification, sign out a user whose session expired, and refresh a token.
|
|
17
|
+
|
|
18
|
+
- Distinguish expected failures from unexpected ones. A 422 is a form result and belongs beside the field; a 500 is an incident.
|
|
19
|
+
- Never show a raw error object to a user. Map it to a sentence they can act on.
|
|
20
|
+
- Keep the technical detail: log it, or attach it to the report, so the useful version is not lost.
|
|
21
|
+
|
|
22
|
+
## In-app errors
|
|
23
|
+
|
|
24
|
+
Use error boundaries, and use several. One boundary around the whole app turns any component fault into a blank page. A boundary per region contains the fault, so the rest of the screen keeps working.
|
|
25
|
+
|
|
26
|
+
- Put a boundary around each route, and around any panel that renders third-party or user-generated content.
|
|
27
|
+
- Give the fallback a retry and enough context to say what failed.
|
|
28
|
+
- Error boundaries have to be client components in an App Router project.
|
|
29
|
+
- A boundary does not catch errors in event handlers or async code. Handle those where they happen.
|
|
30
|
+
|
|
31
|
+
## Error tracking
|
|
32
|
+
|
|
33
|
+
Track production errors with a dedicated tool rather than a homegrown logger, so you get the platform, browser and stack with each report. Upload source maps, or every stack trace points at minified output.
|
|
34
|
+
|
|
35
|
+
## Common mistakes
|
|
36
|
+
|
|
37
|
+
- A single top-level boundary, so one bad chart blanks the dashboard.
|
|
38
|
+
- Swallowing an error in a `catch` that only logs, leaving the UI stuck in loading.
|
|
39
|
+
- Treating every failure as a toast, so the user sees a flash and no longer has any idea what state the page is in.
|
|
40
|
+
|
|
41
|
+
## Related
|
|
42
|
+
|
|
43
|
+
`frontend/state/async-ui-states.md` covers what the user sees while a request is in flight or has failed.
|
|
44
|
+
|
|
45
|
+
## Source
|
|
46
|
+
|
|
47
|
+
Bulletproof React `docs/error-handling.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Feature modules
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [architecture, features, modules, react]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when adding a feature or deciding what belongs inside one.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Feature modules
|
|
11
|
+
|
|
12
|
+
A feature is a vertical slice of the product, such as auth, billing or discussions. It owns its own code.
|
|
13
|
+
|
|
14
|
+
A feature folder may contain:
|
|
15
|
+
|
|
16
|
+
- `api/` request declarations and the hooks that consume them
|
|
17
|
+
- `components/` components used only by this feature
|
|
18
|
+
- `hooks/` hooks scoped to this feature
|
|
19
|
+
- `stores/` state for this feature
|
|
20
|
+
- `types/` types used inside this feature
|
|
21
|
+
- `utils/` helpers for this feature
|
|
22
|
+
- `assets/` static files for this feature
|
|
23
|
+
|
|
24
|
+
Include only the folders the feature actually needs.
|
|
25
|
+
|
|
26
|
+
## When
|
|
27
|
+
|
|
28
|
+
Use for anything a user would name as a capability. Do not create a feature for a single shared button.
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
- Do not import from one feature into another. Compose features at the application layer instead.
|
|
33
|
+
- A feature that needs another feature's data should receive it as props or read it from a shared store.
|
|
34
|
+
- Export what the app needs from explicit file paths. Barrel files that re-export a whole feature break tree shaking in Vite and are not recommended.
|
|
35
|
+
- When two features keep needing the same code, move that code to the shared layer rather than importing sideways.
|
|
36
|
+
|
|
37
|
+
## Common mistakes
|
|
38
|
+
|
|
39
|
+
- Treating `features/` as a second `components/` folder.
|
|
40
|
+
- One giant feature that covers half the product.
|
|
41
|
+
- Cross-feature imports that quietly couple two slices, so neither can be deleted.
|
|
42
|
+
|
|
43
|
+
## Related
|
|
44
|
+
|
|
45
|
+
`frontend/architecture/import-boundaries.md` has the lint rules that enforce this.
|
|
46
|
+
|
|
47
|
+
## Source
|
|
48
|
+
|
|
49
|
+
Bulletproof React `docs/project-structure.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Import boundaries
|
|
3
|
+
type: rule
|
|
4
|
+
tags: [architecture, imports, eslint, boundaries]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when wiring imports between app, features and shared code.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Import boundaries
|
|
11
|
+
|
|
12
|
+
Code flows one way: shared → features → app.
|
|
13
|
+
|
|
14
|
+
- Shared code (`components`, `hooks`, `lib`, `types`, `utils`) may be imported by anything.
|
|
15
|
+
- A feature may import shared code.
|
|
16
|
+
- `app/` may import features and shared code.
|
|
17
|
+
- Nothing imports from `app/`. Features do not import each other.
|
|
18
|
+
|
|
19
|
+
## Always
|
|
20
|
+
|
|
21
|
+
1. Import files directly by path.
|
|
22
|
+
2. Keep the direction one-way, so deleting a feature cannot break another feature.
|
|
23
|
+
3. Enforce the boundary with a lint rule rather than a convention in a README.
|
|
24
|
+
|
|
25
|
+
## Never
|
|
26
|
+
|
|
27
|
+
1. Never import from `app/` inside a feature.
|
|
28
|
+
2. Never import feature A from feature B.
|
|
29
|
+
3. Never add a barrel file that re-exports a whole feature.
|
|
30
|
+
|
|
31
|
+
## Enforcing it
|
|
32
|
+
|
|
33
|
+
ESLint `import/no-restricted-paths` takes a list of zones. Give each feature a zone whose `target` is that feature and whose `from` is the features directory, with the feature itself in `except`. Add one zone with `target: './src/features'` and `from: './src/app'` for the one-way rule, and one whose `target` is the shared folders and whose `from` is features plus app.
|
|
34
|
+
|
|
35
|
+
Verify by running the linter, not by reading the config.
|
|
36
|
+
|
|
37
|
+
## Common mistakes
|
|
38
|
+
|
|
39
|
+
- Adding the zones but leaving the feature out of its own `except` list, which blocks every internal import.
|
|
40
|
+
- Enforcing the rule only in CI, so local work drifts for a week before it fails.
|
|
41
|
+
|
|
42
|
+
## Source
|
|
43
|
+
|
|
44
|
+
Bulletproof React `docs/project-structure.md`, MIT. Rule names are from ESLint's `import` plugin. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Naming and imports
|
|
3
|
+
type: rule
|
|
4
|
+
tags: [naming, conventions, imports, files]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load before creating a file, naming a symbol, or writing an import path.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Naming and imports
|
|
11
|
+
|
|
12
|
+
Consistency here costs nothing and saves every later search.
|
|
13
|
+
|
|
14
|
+
## Files and folders
|
|
15
|
+
|
|
16
|
+
- Name files and folders in `kebab-case`. One convention, enforced, beats a tasteful mix.
|
|
17
|
+
- Name the file after what it exports: `user-profile.tsx` exports `UserProfile`.
|
|
18
|
+
- Keep test folders as `__tests__` beside the code they cover.
|
|
19
|
+
- This is lintable. A filename and folder naming rule in ESLint catches drift before review does.
|
|
20
|
+
|
|
21
|
+
## Symbols
|
|
22
|
+
|
|
23
|
+
- Components in `PascalCase`, hooks as `useThing`, everything else in `camelCase`.
|
|
24
|
+
- Constants that are genuinely fixed go in `SCREAMING_SNAKE_CASE`; a value computed once does not.
|
|
25
|
+
- Booleans read as assertions: `isLoading`, `hasAccess`, `canEdit`. Not `loading` on a prop that might be a string.
|
|
26
|
+
- Event handlers are `handleX` in the component and `onX` as the prop.
|
|
27
|
+
|
|
28
|
+
## Imports
|
|
29
|
+
|
|
30
|
+
- Configure an absolute import alias and use it. `@/components/button` survives a file move; `../../../components/button` does not.
|
|
31
|
+
- One alias, `@/*` mapped to `src/*`, is enough. Several aliases invite confusion about what came from `node_modules`.
|
|
32
|
+
- Set it in `tsconfig.json` under `compilerOptions.paths`, and make the bundler agree, or imports resolve in the editor and fail at build.
|
|
33
|
+
- Use a relative import only inside the same feature folder, where the files move together.
|
|
34
|
+
|
|
35
|
+
## Never
|
|
36
|
+
|
|
37
|
+
1. Never mix naming conventions within one folder because an existing file got it wrong. Fix the file.
|
|
38
|
+
2. Never alias so deeply that the import hides which layer it crossed. See `frontend/architecture/import-boundaries.md`.
|
|
39
|
+
3. Never name a file `index.ts` purely to shorten an import. It makes every tab say `index`.
|
|
40
|
+
|
|
41
|
+
## Source
|
|
42
|
+
|
|
43
|
+
Bulletproof React `docs/project-standards.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Project structure
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [architecture, structure, folders, react]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load before creating folders or deciding where a new file belongs.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Project structure
|
|
11
|
+
|
|
12
|
+
Framework-independent. The same shape works for React, Next.js and React Native.
|
|
13
|
+
|
|
14
|
+
Keep most code under `src/`, split by role:
|
|
15
|
+
|
|
16
|
+
- `app/` routes, root component, providers, router config
|
|
17
|
+
- `components/` shared components used by more than one feature
|
|
18
|
+
- `features/` one folder per feature, where most code lives
|
|
19
|
+
- `hooks/` `lib/` `utils/` `types/` shared and reusable, with no feature knowledge
|
|
20
|
+
- `config/` env vars and global config
|
|
21
|
+
- `stores/` global state
|
|
22
|
+
- `testing/` test utilities and mocks
|
|
23
|
+
- `assets/` static files
|
|
24
|
+
|
|
25
|
+
## When
|
|
26
|
+
|
|
27
|
+
Use at the start of a project, and whenever a file has no obvious home.
|
|
28
|
+
|
|
29
|
+
## Rules
|
|
30
|
+
|
|
31
|
+
- Put new code in a feature folder first. Promote it to `components/` or `hooks/` only once a second feature needs it.
|
|
32
|
+
- Add a folder when it has a second file, not before.
|
|
33
|
+
- Keep a dedicated top-level `api/` folder only when many features share the same requests. Otherwise requests live in the feature.
|
|
34
|
+
- The layout survives a framework change because only `app/` is framework-shaped.
|
|
35
|
+
|
|
36
|
+
## Common mistakes
|
|
37
|
+
|
|
38
|
+
- A flat `components/` folder holding eighty unrelated files. That is the failure this layout prevents.
|
|
39
|
+
- Creating all nine folders in an empty repo, so the structure says nothing about the code.
|
|
40
|
+
- Mixing feature code into the shared folders, which makes the shared layer depend on features.
|
|
41
|
+
|
|
42
|
+
## Related
|
|
43
|
+
|
|
44
|
+
`frontend/architecture/feature-modules.md`, `frontend/architecture/import-boundaries.md`.
|
|
45
|
+
|
|
46
|
+
## Source
|
|
47
|
+
|
|
48
|
+
Bulletproof React `docs/project-structure.md`, MIT. Summarised in our own words. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Routing
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [routing, routes, navigation, lazy, guards]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when adding a route, a nested layout, or a protected area.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Routing
|
|
11
|
+
|
|
12
|
+
Routes are the application's public shape. Keep them in one place and keep them thin.
|
|
13
|
+
|
|
14
|
+
## Structure
|
|
15
|
+
|
|
16
|
+
- Declare routes in `app/routes/`, mirroring the URL. A reader should map a path to a file without searching.
|
|
17
|
+
- A route file wires things together: it reads params, calls a feature's hook, and renders a feature component. Business logic lives in the feature, not the route.
|
|
18
|
+
- Nest layouts for shared chrome. A sidebar, a header, or an auth shell is a parent route, not a wrapper repeated in every child.
|
|
19
|
+
- Group protected routes under one parent so the check exists once.
|
|
20
|
+
|
|
21
|
+
## Params and data
|
|
22
|
+
|
|
23
|
+
- Validate params. An id from the URL is user input, not a guarantee.
|
|
24
|
+
- Prefetch in the route rather than in the component when the router supports it. Fetching after render creates a waterfall; see `frontend/architecture/app-foundations.md`.
|
|
25
|
+
- Keep filter and sort state in the URL when the user would expect to share or reload it. Keep transient UI state out of it.
|
|
26
|
+
|
|
27
|
+
## Code splitting
|
|
28
|
+
|
|
29
|
+
Split at the route boundary, not below it, unless a specific component is heavy. Give each lazy route a fallback that holds the layout. See `frontend/performance/code-splitting.md`.
|
|
30
|
+
|
|
31
|
+
## Guards
|
|
32
|
+
|
|
33
|
+
- A route guard decides whether to render, redirect, or show a forbidden state. It is not a security boundary; the server enforces access. See `frontend/architecture/security.md`.
|
|
34
|
+
- Redirect unauthenticated users to sign-in with a return path, so they land where they intended.
|
|
35
|
+
- Render a real forbidden state for a signed-in user without permission. Redirecting them to the dashboard looks like a bug.
|
|
36
|
+
|
|
37
|
+
## Common mistakes
|
|
38
|
+
|
|
39
|
+
- Fetching and rendering a 404 for a valid id because the param was read before the loader resolved.
|
|
40
|
+
- A guard duplicated in every child route, so adding a route silently leaves it open.
|
|
41
|
+
- Route components that grow into feature components, which makes them impossible to test or reuse.
|
|
42
|
+
|
|
43
|
+
## Source
|
|
44
|
+
|
|
45
|
+
Bulletproof React `docs/project-structure.md` and `docs/performance.md`, MIT, plus the router guidance in react.dev. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Frontend security
|
|
3
|
+
type: rule
|
|
4
|
+
tags: [security, auth, authorization, xss, tokens]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when handling tokens, user identity, permissions, or user-supplied content.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Frontend security
|
|
11
|
+
|
|
12
|
+
Client-side checks improve the experience. They protect nothing. The server enforces access; assume every client check can be bypassed.
|
|
13
|
+
|
|
14
|
+
## Tokens
|
|
15
|
+
|
|
16
|
+
- Storing a token in `localStorage` exposes it to any cross-site scripting flaw on the page, which means token theft.
|
|
17
|
+
- A cookie with `HttpOnly` set cannot be read by client JavaScript, which removes that path. This is the safer default, and it requires the API to set the attribute.
|
|
18
|
+
- Holding the token only in application state is the most secure option and loses the session on refresh, which is usually unacceptable.
|
|
19
|
+
- Never log a token, put one in a URL, or commit one. Use obvious placeholders in examples.
|
|
20
|
+
|
|
21
|
+
## Identity
|
|
22
|
+
|
|
23
|
+
Treat the signed-in user as one piece of global state, readable anywhere. Derive "is authenticated" from the presence of a user object rather than tracking a separate boolean that can disagree with it.
|
|
24
|
+
|
|
25
|
+
## Authorization
|
|
26
|
+
|
|
27
|
+
- Role-based control maps roles to permissions: a role grants a fixed set of rights. It covers most screens.
|
|
28
|
+
- Permission-based control answers finer questions, such as whether this user owns this specific comment. Use it where ownership, not role, decides.
|
|
29
|
+
- Express the check as a component or hook used consistently, so a new screen cannot forget it.
|
|
30
|
+
- Hiding a button is not authorization. The endpoint behind it must refuse the call.
|
|
31
|
+
|
|
32
|
+
## User content
|
|
33
|
+
|
|
34
|
+
Sanitise anything a user supplied before rendering it, especially Markdown and HTML. Unsanitised user content is the most common route to cross-site scripting.
|
|
35
|
+
|
|
36
|
+
## Never
|
|
37
|
+
|
|
38
|
+
1. Never trust a value from the URL, local storage, or a form without validating it.
|
|
39
|
+
2. Never put a secret in client code or a public environment variable. Anything shipped to the browser is public.
|
|
40
|
+
3. Never rely on a hidden route to keep data private.
|
|
41
|
+
|
|
42
|
+
## Source
|
|
43
|
+
|
|
44
|
+
Bulletproof React `docs/security.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TypeScript conventions
|
|
3
|
+
type: rule
|
|
4
|
+
tags: [typescript, types, props, safety]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when typing props, API payloads, or a shared utility.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# TypeScript conventions
|
|
11
|
+
|
|
12
|
+
TypeScript catches issues during refactors that nothing else will. It checks at build time and prevents no runtime failure, so treat it as a refactoring tool, not a guarantee.
|
|
13
|
+
|
|
14
|
+
## Always
|
|
15
|
+
|
|
16
|
+
1. Infer types from one source of truth. Derive API types from the response schema; derive form types from the validation schema. Do not maintain a parallel interface.
|
|
17
|
+
2. Type props as an explicit interface or type next to the component, and export it when the component is shared.
|
|
18
|
+
3. Model mutually exclusive states as a discriminated union, not as several optional fields. A union makes the impossible state uncompilable.
|
|
19
|
+
4. Give functions a return type when they are exported. Inference inside a file is fine; across a boundary it drifts silently.
|
|
20
|
+
5. When refactoring, update the type declarations first, then work through the errors. That is the whole value of having them.
|
|
21
|
+
|
|
22
|
+
## Never
|
|
23
|
+
|
|
24
|
+
1. Never use `any` to move on. If the shape is genuinely unknown, use `unknown` and narrow it.
|
|
25
|
+
2. Never cast with `as` to silence an error. A cast asserts you know better than the compiler, which is rarely true at that moment.
|
|
26
|
+
3. Never use a non-null assertion on data that came from the network.
|
|
27
|
+
4. Never type a prop as `string` when it is one of four values. Use the union.
|
|
28
|
+
|
|
29
|
+
## Enums and unions
|
|
30
|
+
|
|
31
|
+
Prefer a union of string literals to an enum. It is simpler, erases at build, and compares against plain strings without conversion.
|
|
32
|
+
|
|
33
|
+
## Strictness
|
|
34
|
+
|
|
35
|
+
Turn `strict` on at the start. Adding it to a mature codebase is a project; starting with it is free.
|
|
36
|
+
|
|
37
|
+
## Common mistakes
|
|
38
|
+
|
|
39
|
+
- A shared type defined in the component that needs it, then imported upward, inverting the dependency.
|
|
40
|
+
- Optional props that are actually required in half the call sites, discovered only at runtime.
|
|
41
|
+
|
|
42
|
+
## Source
|
|
43
|
+
|
|
44
|
+
Bulletproof React `docs/project-standards.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Component composition
|
|
3
|
+
type: rule
|
|
4
|
+
tags: [components, composition, props, children]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load before building a component or adding another prop to one.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Component composition
|
|
11
|
+
|
|
12
|
+
Prefer composition over configuration. A component with twelve boolean props should have been three components.
|
|
13
|
+
|
|
14
|
+
## Primitives and composites
|
|
15
|
+
|
|
16
|
+
- A primitive renders one thing and owns no data: button, input, card surface.
|
|
17
|
+
- A composite arranges primitives and may own layout: a form row, a toolbar, a page section.
|
|
18
|
+
- Only feature components know about requests and domain types. Primitives never do.
|
|
19
|
+
|
|
20
|
+
## Children
|
|
21
|
+
|
|
22
|
+
Pass content as `children` instead of as props whenever the parent does not need to inspect it. JSX passed as `children` is created by the parent of the stateful component, so it is not re-rendered when that component's state changes. This is the cheapest render optimisation available and it needs no memo.
|
|
23
|
+
|
|
24
|
+
Use the same idea for slots: `header`, `footer` and `actions` as nodes rather than as strings plus flags.
|
|
25
|
+
|
|
26
|
+
## Rules
|
|
27
|
+
|
|
28
|
+
- Keep the data-fetching component separate from the presentational one. The presentational component takes props and can be rendered in isolation.
|
|
29
|
+
- A prop that only switches which element is rendered usually means two components.
|
|
30
|
+
- Do not reach into a child's internals from the parent. Give the child what it needs.
|
|
31
|
+
- Keep props serialisable where possible, so a component can move across the server boundary.
|
|
32
|
+
|
|
33
|
+
## Common mistakes
|
|
34
|
+
|
|
35
|
+
- Passing a render flag down three levels instead of passing the node.
|
|
36
|
+
- A component that takes both the data and the request hook, so it cannot be reused.
|
|
37
|
+
- Wrapping everything in memo instead of fixing where the state lives.
|
|
38
|
+
|
|
39
|
+
## Related
|
|
40
|
+
|
|
41
|
+
`frontend/performance/rendering.md`, `frontend/components/variants.md`.
|
|
42
|
+
|
|
43
|
+
## Source
|
|
44
|
+
|
|
45
|
+
Bulletproof React `docs/components-and-styling.md` and `docs/performance.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Lists, tables and pagination
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [lists, tables, pagination, data-display]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when rendering a collection, a table, or a paged result.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Lists, tables and pagination
|
|
11
|
+
|
|
12
|
+
Most product screens are a collection with actions. Get the mechanics right and the screen is most of the way there.
|
|
13
|
+
|
|
14
|
+
## Choosing
|
|
15
|
+
|
|
16
|
+
- A list for items read one at a time, or on narrow screens.
|
|
17
|
+
- A table when the user compares values across rows. Tabular data needs a real `table`, so screen readers can announce row and column.
|
|
18
|
+
- A grid of cards when the item has an image or needs more than two lines.
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- Give every row a stable key from the data, never the array index. An index key corrupts state when the list reorders.
|
|
23
|
+
- Render all four states: loading, error, empty, loaded. See `frontend/state/async-ui-states.md`.
|
|
24
|
+
- Keep row actions reachable by keyboard. A control that appears only on hover is invisible to a keyboard and a touch user.
|
|
25
|
+
- Put sort and filter state in the URL so a view can be shared and survives reload.
|
|
26
|
+
- Right-align numbers, left-align text, and keep a consistent number format down a column.
|
|
27
|
+
|
|
28
|
+
## Pagination
|
|
29
|
+
|
|
30
|
+
- Prefer pages when the user needs position and totals; prefer infinite scroll for browsing. Infinite scroll makes the footer unreachable, so do not use it on a page that has one.
|
|
31
|
+
- Keep the page in the URL. A reader who refreshes should not jump to page one.
|
|
32
|
+
- Preserve the scroll position and the loaded pages when the user navigates back into the list.
|
|
33
|
+
- Prefetch the next page on intent rather than after the click.
|
|
34
|
+
|
|
35
|
+
## Large lists
|
|
36
|
+
|
|
37
|
+
Virtualise only when the row count genuinely hurts, and measure first. Virtualisation breaks find-in-page and complicates keyboard navigation, so it is a cost, not a free win.
|
|
38
|
+
|
|
39
|
+
## Common mistakes
|
|
40
|
+
|
|
41
|
+
- An empty state that is just a blank area, so the user cannot tell it from a failure.
|
|
42
|
+
- A table that becomes a horizontally scrolling wall on a phone instead of collapsing to rows.
|
|
43
|
+
- Selection state lost on page change, so a bulk action silently applies to the wrong items.
|
|
44
|
+
|
|
45
|
+
## Source
|
|
46
|
+
|
|
47
|
+
This project's conventions, with the state rules from Bulletproof React `docs/state-management.md`, MIT, and the markup requirements from WCAG 2.2. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Choosing a component source
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [components, headless, copy-in, libraries, styling]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load before installing a component library or writing a custom component.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Choosing a component source
|
|
11
|
+
|
|
12
|
+
Three kinds of source, with different costs.
|
|
13
|
+
|
|
14
|
+
## Styled libraries
|
|
15
|
+
|
|
16
|
+
MUI, Ant Design and Mantine ship components with their own design language. Fast when the product can look like the library. Expensive when it cannot, because overriding a full design system fights the library on every screen. Ant Design in particular suits admin dashboards.
|
|
17
|
+
|
|
18
|
+
## Headless libraries
|
|
19
|
+
|
|
20
|
+
Radix UI, Base UI, Headless UI, React Aria and Ark UI ship behaviour and accessibility with no styling. Correct choice when the product has its own design. You write every style yourself.
|
|
21
|
+
|
|
22
|
+
## Copy-in components
|
|
23
|
+
|
|
24
|
+
shadcn/ui and Park UI give you the code rather than a dependency. You own the files and edit them directly. Upgrades are manual, which is the trade for full control.
|
|
25
|
+
|
|
26
|
+
## Order to try
|
|
27
|
+
|
|
28
|
+
1. Use a component already in `components/ui-primitives`. Those files list their real props beside them.
|
|
29
|
+
2. Add a missing one with the project's install command rather than hand-writing a copy.
|
|
30
|
+
3. Write a custom component in `components/custom` only when nothing fits, with a short note of its props and one example.
|
|
31
|
+
|
|
32
|
+
Never vendor an effects library whose licence forbids redistributing the components. Install it into the app instead, as `components/motion-effects/README.md` explains.
|
|
33
|
+
|
|
34
|
+
## Styling note
|
|
35
|
+
|
|
36
|
+
Runtime styling such as styled-components or Emotion generates styles during render. Build-time approaches, Tailwind, CSS modules and vanilla-extract, do not. React Server Components require a zero-runtime solution, so this choice constrains the architecture.
|
|
37
|
+
|
|
38
|
+
## Common mistakes
|
|
39
|
+
|
|
40
|
+
- Installing a second component library for one missing component.
|
|
41
|
+
- Rebuilding a dialog or menu by hand and losing focus trapping and keyboard support.
|
|
42
|
+
|
|
43
|
+
## Source
|
|
44
|
+
|
|
45
|
+
Bulletproof React `docs/components-and-styling.md`, MIT, and this project's existing component conventions. Summarised. See `frontend/SOURCES.md`.
|