A Catalog You Can Turn the Knobs On
GRAIN's catalog showed every component and let you copy its code, but you could not change anything and watch it respond. I borrowed the part of Storybook that matters and kept the catalog a single page with no dependencies.
The catalog was always the most honest page on the site. It is built from the same markdown that documents each component, so it cannot drift from what ships. But it was a page you read, not one you used. To see a panel in its stale state you had to find the example someone had written for it, and if nobody had, you could not see it at all.
Storybook solved this years ago with Controls: a panel of inputs beside the preview, one per argument, so you change a prop and watch the component answer. Storybook infers those controls from component types. GRAIN components are markup and CSS, so there is nothing to infer from. Ladle's controls showed the way round that: a short, fixed list of control kinds that the author declares next to the story.
Three kinds of control
A component doc may now end a section with a controls block. Each line is one control: a select of attribute values, a toggle that adds or removes an attribute, or a text box that edits one element's text. The catalog renders the doc's first example as a live preview beside that form.
The source under the preview is read back from the live markup after every change, so the code you copy is the component you are looking at, not the example as it was first written.
Accessible first, then attractive
A section titled Accessibility now renders as its own block above the examples rather than as one more heading, so the note on how a component behaves for a keyboard or a screen reader is the first thing after the description. Search matches the opening prose as well as the name, opens with the slash key, clears with Escape, and announces how many components match. A skip link leads past the sidebar, the arrow keys move through it, and the sidebar marks the entry in view.
The tracked capitals on every label are gone. grain-lint now flags them as a tell of machine-made design, and the catalog was the worst offender in the system. Sentence case and weight do the same job and read better.
The new surfaces pass axe at WCAG 2.2 AA. The older components in the catalog still carry three findings of their own, which are next.
What stayed the same
The catalog is still one URL and every component still lives at its own anchor, so no link into it broke. It is still one page with no dependencies, and a doc without a controls block renders exactly as before. Only the five new dashboard components carry controls so far; the rest will get them one layer at a time.
Sources
- Storybook, Controls, for changing a component's inputs beside a live preview.
- Ladle, Controls, for the small fixed set of control kinds declared next to the example.
The judgment is human. The typing, by design, is not.