connore 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -8
- 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,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Component variants and props
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [components, variants, props, typescript, cva]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when giving a component sizes, styles or a typed prop interface.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Component variants and props
|
|
11
|
+
|
|
12
|
+
A variant is a named visual choice: `size`, `tone`, `intent`. Declare the set, do not accept arbitrary classes.
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- Define variants in one place per component and export the type, so callers get autocomplete and invalid values fail to compile.
|
|
17
|
+
- Give every variant a default, so the common call is short.
|
|
18
|
+
- Keep variants orthogonal. `size` should not change the colour.
|
|
19
|
+
- Accept a `className` for one-off spacing, but never let a caller restyle the component through it. If a caller needs a new look, add a variant.
|
|
20
|
+
- Forward the native element props and the ref, so the component works with forms, tooltips and focus management.
|
|
21
|
+
|
|
22
|
+
## Prop interfaces
|
|
23
|
+
|
|
24
|
+
- Name props for what they mean, not how they render: `isLoading`, not `showSpinner`.
|
|
25
|
+
- Prefer one union prop over several booleans. Three booleans allow eight states, most of which are nonsense.
|
|
26
|
+
- Keep required props to the ones with no sensible default.
|
|
27
|
+
|
|
28
|
+
## Tooling
|
|
29
|
+
|
|
30
|
+
`class-variance-authority` is the convention in this project's component set, with `cn` for merging. It is a styling helper, not a requirement of the pattern; the same rules apply with plain objects or any other approach.
|
|
31
|
+
|
|
32
|
+
## Common mistakes
|
|
33
|
+
|
|
34
|
+
- A `variant="custom"` escape hatch that ends up on half the call sites.
|
|
35
|
+
- Variants defined in the component and again in a wrapper, which drift apart.
|
|
36
|
+
- Dropping the ref, so the component cannot be focused or measured.
|
|
37
|
+
|
|
38
|
+
## Related
|
|
39
|
+
|
|
40
|
+
`components/ui-primitives/README.md` lists what each copied component actually declares. `frontend/components/library-choice.md` covers where components come from.
|
|
41
|
+
|
|
42
|
+
## Source
|
|
43
|
+
|
|
44
|
+
Bulletproof React `docs/components-and-styling.md`, MIT, and the component set already in `components/ui-primitives`. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Form architecture
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [forms, inputs, react, controlled]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load before building a form or adding a field component.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Form architecture
|
|
11
|
+
|
|
12
|
+
Wrap the form library once, then build screens against your own components. Screens should not import the library directly.
|
|
13
|
+
|
|
14
|
+
## Shape
|
|
15
|
+
|
|
16
|
+
- One `Form` component that owns submission, the schema and the error surface.
|
|
17
|
+
- One wrapper per input type: text, select, checkbox, textarea. Each takes a label, a name, and an error, and renders the project's field markup.
|
|
18
|
+
- Screens compose those wrappers. Changing form library then touches the wrappers, not every screen.
|
|
19
|
+
|
|
20
|
+
## Controlled or uncontrolled
|
|
21
|
+
|
|
22
|
+
- Uncontrolled fields keep their value in the DOM and re-render less. They suit most forms.
|
|
23
|
+
- Controlled fields keep the value in React. Use them when another part of the UI must react to each keystroke, such as a live preview or a dependent field.
|
|
24
|
+
- Do not mix the two on one field. A field with both `value` and `defaultValue` is a bug.
|
|
25
|
+
|
|
26
|
+
## Rules
|
|
27
|
+
|
|
28
|
+
- Every input has a label element bound to it. A placeholder is not a label.
|
|
29
|
+
- Keep field state in the form library, not in a global store.
|
|
30
|
+
- Disable the submit button while a submission is in flight, and keep the entered values if it fails.
|
|
31
|
+
- Report the submission result where the user is looking, not only as a toast.
|
|
32
|
+
|
|
33
|
+
## Libraries
|
|
34
|
+
|
|
35
|
+
React Hook Form, Formik and React Final Form all handle validation, errors and submission. Pick one per project.
|
|
36
|
+
|
|
37
|
+
## Common mistakes
|
|
38
|
+
|
|
39
|
+
- A field wrapper per screen, so eight forms have eight different error styles.
|
|
40
|
+
- Clearing the form on a failed submit, which throws away the user's work.
|
|
41
|
+
- Submitting on Enter in a multi-field form that has no explicit submit button.
|
|
42
|
+
|
|
43
|
+
## Related
|
|
44
|
+
|
|
45
|
+
`frontend/forms/validation.md`, `components/ui-primitives/input.md`, `components/ui-primitives/label.md`.
|
|
46
|
+
|
|
47
|
+
## Source
|
|
48
|
+
|
|
49
|
+
Bulletproof React `docs/state-management.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Multi-step forms
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [forms, wizard, steps, validation]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when a form spans more than one screen or step.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Multi-step forms
|
|
11
|
+
|
|
12
|
+
One form state across all steps. Each step is a view over that state, not its own form.
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- Hold the values in a single store for the whole flow, so going back never loses input.
|
|
17
|
+
- Validate each step against the slice of the schema it covers. Validate the whole schema once more on final submit.
|
|
18
|
+
- Block forward navigation when the current step is invalid. Always allow going back.
|
|
19
|
+
- Show where the user is and how far is left. A step count is enough.
|
|
20
|
+
- Submit once, at the end, unless a step genuinely has to persist on its own.
|
|
21
|
+
|
|
22
|
+
## When to avoid
|
|
23
|
+
|
|
24
|
+
Do not split a form that fits on one screen. Steps add navigation, state and failure modes. Three fields do not need a wizard.
|
|
25
|
+
|
|
26
|
+
## Resuming
|
|
27
|
+
|
|
28
|
+
If the flow can be abandoned and resumed, persist the values deliberately and say so in the UI. Never persist payment details or anything that belongs in a vault.
|
|
29
|
+
|
|
30
|
+
## Common mistakes
|
|
31
|
+
|
|
32
|
+
- A separate form per step, so the back button clears what was typed.
|
|
33
|
+
- Validating everything on step one, which errors on fields the user has not reached.
|
|
34
|
+
- A final submit that fails and drops the user back to step one with an empty form.
|
|
35
|
+
- A progress indicator that cannot be trusted because steps are added conditionally.
|
|
36
|
+
|
|
37
|
+
## Related
|
|
38
|
+
|
|
39
|
+
`frontend/forms/form-architecture.md`, `frontend/forms/validation.md`.
|
|
40
|
+
|
|
41
|
+
## Source
|
|
42
|
+
|
|
43
|
+
Derived from the form guidance in Bulletproof React `docs/state-management.md`, MIT, applied to multi-step flows. No step-specific source was present in the raw set. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Form validation
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [forms, validation, schema, errors]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when validating input or showing field and server errors.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Form validation
|
|
11
|
+
|
|
12
|
+
Declare one schema per form and derive both the types and the validation from it.
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- Define the schema next to the request declaration, so the client and the API agree on one shape.
|
|
17
|
+
- Infer the form's TypeScript types from the schema. Do not maintain a parallel interface.
|
|
18
|
+
- Validate on the server as well. Client validation is a convenience, never a guarantee.
|
|
19
|
+
- Map server field errors back onto the matching fields. A server error shown only as a banner leaves the user hunting.
|
|
20
|
+
|
|
21
|
+
## When to validate
|
|
22
|
+
|
|
23
|
+
- On submit, always.
|
|
24
|
+
- On blur for a field the user has already left, which is the least noisy default.
|
|
25
|
+
- While typing only after that field has errored once, so the message clears as it is fixed.
|
|
26
|
+
|
|
27
|
+
Do not validate a field the user has not touched. `touched` and `dirty` exist for this.
|
|
28
|
+
|
|
29
|
+
## Messages
|
|
30
|
+
|
|
31
|
+
- Say what is wrong and what to do: "Use at least 8 characters", not "Invalid".
|
|
32
|
+
- Put the message next to its field, and link it to the input so screen readers announce it. See `frontend/accessibility/semantics-and-keyboard.md`.
|
|
33
|
+
- Keep one summary at the top for long forms, with links to the failed fields.
|
|
34
|
+
|
|
35
|
+
## Common mistakes
|
|
36
|
+
|
|
37
|
+
- Validating on every keystroke from the first render, so a fresh form is already red.
|
|
38
|
+
- A schema that allows a shape the API rejects, moving the failure to the network tab.
|
|
39
|
+
- Showing only the first error when several fields failed.
|
|
40
|
+
|
|
41
|
+
## Version note
|
|
42
|
+
|
|
43
|
+
Zod and Yup are both common resolvers. The raw sources name schema validation without pinning a library version, so confirm what is installed.
|
|
44
|
+
|
|
45
|
+
## Source
|
|
46
|
+
|
|
47
|
+
Bulletproof React `docs/state-management.md` and `docs/api-layer.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Responsive layout
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [layout, responsive, grid, container, breakpoints]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when building a page layout, grid or container.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Responsive layout
|
|
11
|
+
|
|
12
|
+
Let the browser do the layout. Reach for a breakpoint only when the content genuinely needs a different arrangement, not to patch a number.
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- Build mobile first. Start with the single-column case and add rules upward.
|
|
17
|
+
- Prefer intrinsic sizing to fixed widths: a wrapping flex row, `minmax` grid tracks, `clamp` for type. These adapt without a media query.
|
|
18
|
+
- Define containers once as a reusable width, so pages do not each pick their own.
|
|
19
|
+
- Use breakpoints at the point where the layout breaks, not at device names. Phones and windows are arbitrary widths.
|
|
20
|
+
- Keep the reading measure bounded. Full-width body text at 1600px is unreadable regardless of the grid.
|
|
21
|
+
- Content must reflow at 320 CSS pixels wide, which is a 1280px viewport at 400% zoom, without a horizontal scrollbar.
|
|
22
|
+
|
|
23
|
+
## Grids
|
|
24
|
+
|
|
25
|
+
- A card grid is `repeat(auto-fit, minmax(<min>, 1fr))` before it is a set of breakpoints.
|
|
26
|
+
- Keep gaps on a spacing scale. Do not hand-tune each section.
|
|
27
|
+
- Do not nest grids to achieve alignment that one grid with named lines would give.
|
|
28
|
+
|
|
29
|
+
## Avoid
|
|
30
|
+
|
|
31
|
+
- Magic numbers chosen because they looked right on one screen.
|
|
32
|
+
- A breakpoint per component, which makes the page impossible to reason about.
|
|
33
|
+
- Layout that depends on an element's measured height in JavaScript.
|
|
34
|
+
|
|
35
|
+
## Measurement note
|
|
36
|
+
|
|
37
|
+
Spacing and container widths for this project's reference screens are not measured. Treat them as TODO in `design/tokens.md` rather than inventing pixel values.
|
|
38
|
+
|
|
39
|
+
## Source
|
|
40
|
+
|
|
41
|
+
The argument for algorithmic layout is general and widely held; the raw set contained only a sales page for a paid book on the topic, so nothing from that book is reproduced here. The 320 pixel figure is WCAG 2.2 Reflow. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: App shell
|
|
3
|
+
type: blueprint
|
|
4
|
+
tags: [dashboard, app-shell, sidebar]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Signed-in overview layout from the dashboard reference.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# App shell
|
|
11
|
+
|
|
12
|
+
Spec: `design/references/dashboard-overview.md`. This is a reference layout, not the Context101 schema. Data for a real dashboard is in `workflows/dashboard.md`.
|
|
13
|
+
|
|
14
|
+
Sidebar: logo, workspace, search with a shortcut, nav, then a footer with the user. Main: page title, a short toolbar, then cards. First row can be two columns. A warning banner spans the main column when a job is paused.
|
|
15
|
+
|
|
16
|
+
Colors from the sample: sidebar `#04100c`, main `#0c1010`. One white primary button. Other toolbar buttons are dark with a light border. Do not use the landing accent `#06e27a` on this shell.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: FAQ and footer
|
|
3
|
+
type: blueprint
|
|
4
|
+
tags: [faq, footer]
|
|
5
|
+
updated: 2026-11-19
|
|
6
|
+
description: Closing sections for the solid-accent and ruled reference sets.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# FAQ and footer
|
|
11
|
+
|
|
12
|
+
## FAQ
|
|
13
|
+
|
|
14
|
+
Spec: `faq-split-accordion.md`. Left column is the `[ FAQ ]` label and headline. Right column is six collapsed rows, question left, plus right. Do not open a row unless the user asks.
|
|
15
|
+
|
|
16
|
+
## Footer
|
|
17
|
+
|
|
18
|
+
Solid-accent set (`footer-two-column.md`): brand and socials on the left, two link columns on the right.
|
|
19
|
+
|
|
20
|
+
Ruled set (`footer-four-column.md`): brand cell, then four columns with small-caps labels. Hairline rules, not cards.
|
|
21
|
+
|
|
22
|
+
Closing CTA sits above the footer. The solid-accent set centers a filled button (`cta-centered.md`). The ruled set uses two bracket buttons beside an image (`cta-split-media.md`).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Feature grid
|
|
3
|
+
type: blueprint
|
|
4
|
+
tags: [features, cards, grid, steps]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Benefit cards, the feature split, and the ruled step grid.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Feature grid
|
|
11
|
+
|
|
12
|
+
## Benefit cards
|
|
13
|
+
|
|
14
|
+
Spec: `benefit-card-grid.md`. Label `[ BENEFITS ]`. 3 columns, 2 rows. Each card: one line icon, one title, two gray lines. Same padding in every cell. No buttons inside the cards.
|
|
15
|
+
|
|
16
|
+
## Feature split
|
|
17
|
+
|
|
18
|
+
Spec: `feature-split-checklist.md`. Line tabs, then a 50/50 card: checklist on the left, a product mock on the right. One filled button under the checklist.
|
|
19
|
+
|
|
20
|
+
## Ruled steps
|
|
21
|
+
|
|
22
|
+
Spec: `steps-ruled-grid.md`. A ruled 2×2 grid, not floating cards. Three numbered cells and one image cell. Numbers are 01, 02, 03.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Pricing
|
|
3
|
+
type: blueprint
|
|
4
|
+
tags: [pricing, cards, landing]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Three-column pricing row from the solid-accent reference set.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Pricing
|
|
11
|
+
|
|
12
|
+
Spec: `design/references/pricing-three-card.md`.
|
|
13
|
+
|
|
14
|
+
Section label `[ PRICING ]` in the accent green, then a two-line headline (second line gray). A monthly/yearly switch sits left, with a small "20% OFF" outline pill.
|
|
15
|
+
|
|
16
|
+
Three equal cards. Each has name, price, one sentence, one action, a Features label, and check rows. Only the middle card gets a "Popular" pill and a filled button. The other actions are text links. Do not fill all three buttons.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SaaS hero
|
|
3
|
+
type: blueprint
|
|
4
|
+
tags: [hero, landing, accent, outline]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: How to build the two hero layouts in the reference set.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# SaaS hero
|
|
11
|
+
|
|
12
|
+
Read `design/references/hero-accent-curtain.md` or `hero-split-media.md` before drawing.
|
|
13
|
+
|
|
14
|
+
## Accent curtain
|
|
15
|
+
|
|
16
|
+
Left copy, right accent curtain. Order: wordmark header, two-line headline, one sentence, one filled button (`#06e27a`), then a console card. Header links stay text. One filled button in the header, one in the hero.
|
|
17
|
+
|
|
18
|
+
## Split media
|
|
19
|
+
|
|
20
|
+
Two columns split by a vertical rule. Left: three tiny meta pills, one headline, one gray sentence (`#707070`), two corner-bracket buttons. Right: one image. No filled accent button.
|
|
21
|
+
|
|
22
|
+
## Shared
|
|
23
|
+
|
|
24
|
+
Page field `#080808`. Headline near white. Do not mix the two button styles on one hero.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Dark marketing
|
|
3
|
+
type: pattern
|
|
4
|
+
tags: [landing, color, type]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Section order for the two dark landing profiles. Load only after match.md picks one.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Dark marketing
|
|
11
|
+
|
|
12
|
+
Load only after `design/aesthetics/match.md` picks `solid-accent.md` or `ruled-outline.md`. Page field and accent come from that profile, not from this file.
|
|
13
|
+
|
|
14
|
+
Sections stack in this order in the solid-accent set: hero, logos, features, use cases, benefits, pricing, FAQ, CTA, footer. In the ruled set: hero, logos, what it does, how it works, CTA, footer. Skip a section rather than inventing one.
|
|
15
|
+
|
|
16
|
+
Header is sticky: wordmark, text links, one action. Content width is wide. Exact max-width: TODO.
|
|
17
|
+
|
|
18
|
+
Labels are either `[ WORD ]` in green (solid-accent set) or a green square plus a short phrase (ruled set).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Status pill
|
|
3
|
+
type: pattern
|
|
4
|
+
tags: [badge, status]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Small status labels as they appear in the reference layouts.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Status pill
|
|
11
|
+
|
|
12
|
+
Use a pill for a live state, not for a section title.
|
|
13
|
+
|
|
14
|
+
- Console log header: a running state in green text on a dark green chip.
|
|
15
|
+
- Pricing: an emphasis pill in green, on the middle card only.
|
|
16
|
+
- Dashboard repo card: a green dot plus a one-word index state.
|
|
17
|
+
- Hero meta row: dark chips with a green dot and a short compliance word.
|
|
18
|
+
|
|
19
|
+
Code equivalent: `components/ui-primitives/badge.md`, variant outline or a custom class. Do not invent a second green. Use the accent already chosen for that screen.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Code splitting
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [performance, code-splitting, lazy, bundle, routes]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when deciding what to lazy-load or why the bundle is large.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Code splitting
|
|
11
|
+
|
|
12
|
+
Split the production bundle so a visitor downloads the code for the page they opened, not the whole app.
|
|
13
|
+
|
|
14
|
+
## Where to split
|
|
15
|
+
|
|
16
|
+
- At the route level first. This is the highest-value boundary and usually the only one needed.
|
|
17
|
+
- Around a heavy component that most sessions never open: a chart library, a rich text editor, a map.
|
|
18
|
+
- Behind an interaction, such as a dialog whose body is only built when opened.
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- Do not split everything. Each chunk is a request, and many small chunks are slower than a few right-sized ones.
|
|
23
|
+
- Give every lazy boundary a fallback that holds the layout, so the page does not jump when the chunk lands.
|
|
24
|
+
- Keep shared dependencies out of the split so two routes do not each ship their own copy.
|
|
25
|
+
- Prefetch the next likely chunk on hover or intent rather than on click.
|
|
26
|
+
|
|
27
|
+
## When to avoid
|
|
28
|
+
|
|
29
|
+
Do not split a component that is on the first screen. Deferring something the user sees immediately makes the page slower, not faster.
|
|
30
|
+
|
|
31
|
+
## Verifying
|
|
32
|
+
|
|
33
|
+
Check the built bundle, not the source. A lazy import that is also imported statically somewhere else collapses back into the main chunk, and nothing in the code shows it.
|
|
34
|
+
|
|
35
|
+
## Common mistakes
|
|
36
|
+
|
|
37
|
+
- Splitting the component that renders above the fold.
|
|
38
|
+
- Lazy routes with no fallback, so navigation flashes an empty page.
|
|
39
|
+
- Assuming the split worked because the `import()` is there.
|
|
40
|
+
|
|
41
|
+
## Related
|
|
42
|
+
|
|
43
|
+
`frontend/performance/images-and-vitals.md` for what the user actually measures.
|
|
44
|
+
|
|
45
|
+
## Source
|
|
46
|
+
|
|
47
|
+
Bulletproof React `docs/performance.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Images and web vitals
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [performance, images, web-vitals, lcp, loading]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when adding images or checking a page against performance metrics.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Images and web vitals
|
|
11
|
+
|
|
12
|
+
Images are usually the largest thing on a page, so they decide the headline metric.
|
|
13
|
+
|
|
14
|
+
## Images
|
|
15
|
+
|
|
16
|
+
- Lazy-load anything below the fold. Load the hero image eagerly; lazy-loading it delays the metric it defines.
|
|
17
|
+
- Serve a modern format such as WebP.
|
|
18
|
+
- Provide `srcset` so the browser picks the right file for the screen instead of downloading the desktop asset on a phone.
|
|
19
|
+
- Always set width and height, or an aspect ratio. Without them the page reflows when the image arrives.
|
|
20
|
+
- Give every meaningful image real alt text, and an empty `alt` when it is decoration.
|
|
21
|
+
|
|
22
|
+
## Vitals
|
|
23
|
+
|
|
24
|
+
Core Web Vitals affect how a page is indexed, so they are worth watching:
|
|
25
|
+
|
|
26
|
+
- Largest Contentful Paint, how long until the main content appears. Usually the hero image or headline.
|
|
27
|
+
- Interaction to Next Paint, how quickly the page responds to input.
|
|
28
|
+
- Cumulative Layout Shift, how much the content moves while loading.
|
|
29
|
+
|
|
30
|
+
Measure with Lighthouse or PageSpeed Insights.
|
|
31
|
+
|
|
32
|
+
## Honest note
|
|
33
|
+
|
|
34
|
+
No measurement has been taken for this project. These are the metrics to check, not results. Record real numbers when a page is measured, rather than asserting a score.
|
|
35
|
+
|
|
36
|
+
## Common mistakes
|
|
37
|
+
|
|
38
|
+
- Lazy-loading the hero, which delays Largest Contentful Paint.
|
|
39
|
+
- A sized container whose image has no dimensions, so the shift is simply moved.
|
|
40
|
+
- Treating a local Lighthouse run as a field measurement; it reflects your machine and network.
|
|
41
|
+
|
|
42
|
+
## Source
|
|
43
|
+
|
|
44
|
+
Bulletproof React `docs/performance.md`, MIT, and the web.dev performance overview, which is a navigation page rather than detailed guidance. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Render performance
|
|
3
|
+
type: rule
|
|
4
|
+
tags: [performance, rendering, state, react, context]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when a view re-renders too often or feels slow to type in.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Render performance
|
|
11
|
+
|
|
12
|
+
Most render problems are state placement problems. Fix where state lives before reaching for memo.
|
|
13
|
+
|
|
14
|
+
## Always
|
|
15
|
+
|
|
16
|
+
1. Keep state as close as possible to where it is read. A value held three levels above its only consumer re-renders everything between.
|
|
17
|
+
2. Split a large store into several stores by usage. One object that everything subscribes to re-renders the tree on any change.
|
|
18
|
+
3. Pass isolated subtrees as `children`, so a parent's state change cannot re-render them.
|
|
19
|
+
4. Use the lazy initialiser form when the initial value is expensive: `useState(() => expensive())` runs once, while `useState(expensive())` runs on every render.
|
|
20
|
+
5. Measure before and after. A profiler run is the evidence; a hunch is not.
|
|
21
|
+
|
|
22
|
+
## Context
|
|
23
|
+
|
|
24
|
+
Context suits low-frequency data: theme, locale, the signed-in user. Every consumer re-renders when the value changes, so it is a poor fit for values that change on each keystroke or frame. For those, use a store with selectors, or `use-context-selector`.
|
|
25
|
+
|
|
26
|
+
Before adding context at all, consider lifting state up or recomposing the components. Context is often used to avoid prop drilling when composition would solve it.
|
|
27
|
+
|
|
28
|
+
## Styling
|
|
29
|
+
|
|
30
|
+
Runtime styling libraries generate styles during render. On a view that updates frequently, moving to a build-time approach such as Tailwind, CSS modules or vanilla-extract removes that work from the render path.
|
|
31
|
+
|
|
32
|
+
## Common mistakes
|
|
33
|
+
|
|
34
|
+
- Wrapping components in memo while the offending state stays at the top of the tree.
|
|
35
|
+
- A context value rebuilt inline on each render, so every consumer updates regardless of memo.
|
|
36
|
+
- Tracking many items in one state object when atomic updates were needed.
|
|
37
|
+
|
|
38
|
+
## Source
|
|
39
|
+
|
|
40
|
+
Bulletproof React `docs/performance.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Server and client components
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [nextjs, server-components, use-client, rendering]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when choosing where a Next.js App Router component runs.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Server and client components
|
|
11
|
+
|
|
12
|
+
Next.js App Router only. Nothing here applies to a React SPA or the Pages Router.
|
|
13
|
+
|
|
14
|
+
Components are server components by default. `'use client'` marks the boundary where client code starts, and everything imported below it becomes client code too.
|
|
15
|
+
|
|
16
|
+
## Use a client component when you need
|
|
17
|
+
|
|
18
|
+
- State and event handlers, such as `onClick` or `onChange`.
|
|
19
|
+
- Lifecycle effects, such as `useEffect`.
|
|
20
|
+
- Browser-only APIs: `localStorage`, `window`, `navigator`.
|
|
21
|
+
- Custom hooks that rely on any of the above.
|
|
22
|
+
|
|
23
|
+
## Use a server component when you need
|
|
24
|
+
|
|
25
|
+
- To fetch data close to the source, from a database or API.
|
|
26
|
+
- To use API keys and tokens without exposing them to the browser.
|
|
27
|
+
- To send less JavaScript to the client.
|
|
28
|
+
- To improve First Contentful Paint and stream content progressively.
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
- Push `'use client'` as far down the tree as it will go. Marking a layout client-side pulls the whole page with it.
|
|
33
|
+
- Fetch in the server component and pass the result as props to the interactive child.
|
|
34
|
+
- Keep props passed across the boundary serialisable. Functions and class instances do not cross.
|
|
35
|
+
- Error boundaries must be client components.
|
|
36
|
+
- Server components require a zero-runtime styling solution. See `frontend/components/library-choice.md`.
|
|
37
|
+
|
|
38
|
+
## Common mistakes
|
|
39
|
+
|
|
40
|
+
- A `'use client'` at the top of a page because one button needs a handler.
|
|
41
|
+
- Reading a secret in a component that is, or later becomes, client-side.
|
|
42
|
+
- Fetching in a client child with an effect when the parent could have fetched on the server.
|
|
43
|
+
|
|
44
|
+
## Version note
|
|
45
|
+
|
|
46
|
+
Describes the App Router as documented in the Next.js docs snapshot in the raw set, dated 2026-05-13 in its own frontmatter. Confirm against the installed version.
|
|
47
|
+
|
|
48
|
+
## Source
|
|
49
|
+
|
|
50
|
+
Next.js documentation, "When to use Server and Client Components?". Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: API layer
|
|
3
|
+
type: guide
|
|
4
|
+
tags: [api, data-fetching, types, architecture]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load before writing a fetch call or adding a request to a feature.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# API layer
|
|
11
|
+
|
|
12
|
+
One configured client, and request declarations that are defined once and exported.
|
|
13
|
+
|
|
14
|
+
## The client
|
|
15
|
+
|
|
16
|
+
Create a single pre-configured instance and reuse it everywhere: base URL, credentials, default headers, and one place to handle auth and errors. The native `fetch`, axios, `graphql-request` or Apollo all work. Put it in `lib/api-client`.
|
|
17
|
+
|
|
18
|
+
## A request declaration
|
|
19
|
+
|
|
20
|
+
Each request is declared next to the feature that owns it, in `features/<name>/api/`, and has three parts:
|
|
21
|
+
|
|
22
|
+
1. Types and a validation schema for the request and the response.
|
|
23
|
+
2. A fetcher function that calls one endpoint through the shared client.
|
|
24
|
+
3. A hook that wraps the fetcher with the data-fetching library, so caching lives in one place.
|
|
25
|
+
|
|
26
|
+
Infer response types from the schema and pass them down, so a shape change surfaces at compile time rather than in the UI.
|
|
27
|
+
|
|
28
|
+
## When
|
|
29
|
+
|
|
30
|
+
Use for every endpoint the app calls, including one-off requests. The cost of declaring it is one file.
|
|
31
|
+
|
|
32
|
+
## Never
|
|
33
|
+
|
|
34
|
+
1. Never build a request inline inside a component.
|
|
35
|
+
2. Never create a second client instance with its own headers.
|
|
36
|
+
3. Never return `any` from a fetcher. The types stop being load-bearing.
|
|
37
|
+
|
|
38
|
+
## Common mistakes
|
|
39
|
+
|
|
40
|
+
- Declaring the fetcher but calling it directly, so each caller invents its own caching.
|
|
41
|
+
- Putting every request in a shared `api/` folder when only one feature uses it. Share only what is shared.
|
|
42
|
+
|
|
43
|
+
## Related
|
|
44
|
+
|
|
45
|
+
`frontend/state/server-cache.md` for keys, invalidation and mutations. `backend/api/conventions.md` for the response shape this project returns.
|
|
46
|
+
|
|
47
|
+
## Source
|
|
48
|
+
|
|
49
|
+
Bulletproof React `docs/api-layer.md`, MIT. Summarised. See `frontend/SOURCES.md`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Loading, error and empty states
|
|
3
|
+
type: rule
|
|
4
|
+
tags: [state, loading, errors, empty, ux]
|
|
5
|
+
updated: 2026-12-06
|
|
6
|
+
description: Load when rendering anything that depends on a request.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Loading, error and empty states
|
|
11
|
+
|
|
12
|
+
Every screen that reads server data has four states, not one. Build all four or the screen is unfinished.
|
|
13
|
+
|
|
14
|
+
1. **Loading** the request is in flight.
|
|
15
|
+
2. **Error** the request failed.
|
|
16
|
+
3. **Empty** the request succeeded and returned nothing.
|
|
17
|
+
4. **Loaded** there is data to show.
|
|
18
|
+
|
|
19
|
+
## Always
|
|
20
|
+
|
|
21
|
+
1. Render the empty state as a deliberate design, with a sentence and usually one action. It is a normal result, not a bug.
|
|
22
|
+
2. Distinguish first load from a background refetch. A spinner over existing data loses the user's place.
|
|
23
|
+
3. Give the error state a retry, and say what failed in plain language.
|
|
24
|
+
4. Reserve the layout space the loaded state will need, so content does not jump when it arrives.
|
|
25
|
+
|
|
26
|
+
## Never
|
|
27
|
+
|
|
28
|
+
1. Never show an empty table with no explanation and call it done.
|
|
29
|
+
2. Never treat an error as empty. "No results" when the request failed is a lie the user cannot act on.
|
|
30
|
+
3. Never block a whole page on one slow panel when the rest of the data has arrived.
|
|
31
|
+
|
|
32
|
+
## Skeletons
|
|
33
|
+
|
|
34
|
+
Use a skeleton when you know the shape of what is coming. Use a spinner when you do not. A skeleton that does not match the final layout is worse than a spinner.
|
|
35
|
+
|
|
36
|
+
## Common mistakes
|
|
37
|
+
|
|
38
|
+
- Checking only `isLoading`, so the error path renders the loaded branch with undefined data.
|
|
39
|
+
- An empty state that appears for a frame before data arrives, because loading was not checked first.
|
|
40
|
+
|
|
41
|
+
## Source
|
|
42
|
+
|
|
43
|
+
Bulletproof React `docs/state-management.md` and `docs/error-handling.md`, MIT, plus the rules in `design/rules.md`. Summarised. See `frontend/SOURCES.md`.
|