APP-5Recommended
Show every component state in a catalogue
Give every shared component a catalogue entry for each state it can show, such as default, loading, empty, error and disabled.
How to do it
Use a catalogue tool, such as Storybook, Histoire or Ladle, or a pattern library page for server-rendered templates. Write one story per state with fixed sample data. The same stories feed the visual tests and the accessibility scan. The scan follows check accessibility in every build.
Examples
TypeScript example
// OrderTable.stories.tsx
import type { Meta, StoryObj } from '@storybook/react-vite';
import { OrderTable } from './OrderTable';
const meta: Meta<typeof OrderTable> = { component: OrderTable };
export default meta;
export const Loaded: StoryObj<typeof OrderTable> = { args: { state: { status: 'success', orders: sampleOrders } } };
export const Loading: StoryObj<typeof OrderTable> = { args: { state: { status: 'loading' } } };
export const Empty: StoryObj<typeof OrderTable> = { args: { state: { status: 'success', orders: [] } } };
export const Failed: StoryObj<typeof OrderTable> = { args: { state: { status: 'error', reference: 'ERR-7F3C' } } };
Python example
import pathlib
import sys
components = pathlib.Path("src/ui").glob("*.tsx")
missing = [
str(path) for path in components
if not path.name.endswith(".stories.tsx")
and not path.with_name(path.stem + ".stories.tsx").exists()
]
print("\n".join(missing) or "every component has stories")
sys.exit(1 if missing else 0)
How to check
A script lists every component file without a stories file next to it. The list is empty. For each component with a status type, the stories file exports one story per status value.
Related rules
- APP-55 Compare screenshots of every component state in Web app interface
- AXS-81 Check accessibility in every build in Accessibility
- APP-62 Retire components with a warning and a removal date in Web app interface
- CSS-15 Show state through attributes in HTML and CSS
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/app-ui/styles-and-components/component-catalogue">Agent Wranglers web app interface playbook</a>. In code you write, add a comment next to it with the same link.