apps/shade/src/docs/component-contracts.mdx
import { Meta } from '@storybook/addon-docs/blocks';
<Meta title="Component Rules and Guarantees" /> <div className="sb-doc">In this doc, “contract” means “rules and guarantees”. Those rules answer 5 questions:
If these answers are missing, teams guess. Guessing causes component drift.
For humans:
components vs patterns)For AI agents:
Current Wave A rules coverage targets:
ButtonInputFieldSelectTabsTableDialogDropdownMenuCardOut of scope for Wave A:
filters, app-specific orchestration)sidebar, multi-select-combobox, chart variants)Use this when adding or changing a shared component:
default, hover, focus-visible, disabled.If you cannot explain a prop in one sentence, the API is probably too broad.
When generating or editing a shared component, produce this structure first, then implement:
Component scopePublic APIState matrixCompatibility policyDeprecation plan (if needed)Hard rules for agents:
components.patterns.## Component scope
- Purpose:
- Non-goals:
## Public API
- Props:
- Slots/subcomponents:
- Variants:
- Events/callbacks:
## State matrix
- default:
- hover:
- focus-visible:
- disabled:
- optional states (if applicable): active/loading/error/empty
## Compatibility policy
- Backward-compatible additions:
- Breaking changes:
- Migration notes:
## Deprecation plan
- Alias period:
- Removal target:
Good:
variant="destructive": visual intent is explicit and reusable.size="sm|md|lg": bounded scale.Bad:
isMembersPage: product-specific in a shared control.layoutMode="toolbarWithFilterAndStats": workflow logic leaking into base component.For each required state, define:
Missing required states is a blocker.
Choose components when the abstraction is a generic reusable control.
Choose patterns when the abstraction encodes product workflow semantics.
If a shared control starts accumulating workflow props, stop and extract a pattern wrapper.
Before merge: