Decisions
0006 · Design system and Storybook
An in-repo design system with typed tokens, documented in Storybook; Bricolage Grotesque replaces the serif display face.
A documentação técnica está em inglês.
Status: Accepted · 2026-11
Context
The first 2.0 drafts styled the app with a global token stylesheet (styles/globals.scss) and a shared bag of utility classes (components/ui.module.scss: btn, input, chip…). It worked, but:
- Nothing documented the components. Variants lived in whoever wrote the last screen, and features overrode each other's styles.
- Tokens existed only as CSS, so contrast couldn't be checked and a misspelled
var(--space-25)failed silently. - The display face was Abril Fatface, a high-contrast serif. Next to the logo — a heavy sans "S" cut by a slash — it read as a different brand, and it pushed the tone toward "editorial" when the product is a relaxed thing you use at a bar table.
Decision
- A design system inside the repository at
src/design-system/, with one public entry point (@/design-system). It may not importnext/*, the store or feature code. - Tokens as typed TypeScript data in two tiers (raw palette → semantic roles with light and dark values).
tokensToCss()generates the custom properties; the app inlines them in the root layout and Storybook installs the same string. Tests check WCAG contrast for every declared color pair, mirror breakpoints into Sass, and verify everyvar(--token)used in a stylesheet exists. - Storybook (React + Vite builder) as the workbench and catalogue: stories for every component and state, props tables from TSDoc, Foundations pages rendered from the token objects, a11y and theme addons. Pinned to 9.1 while the project supports Node 20.11; Storybook 10 needs Node ≥ 20.19.
- Typography: Bricolage Grotesque (variable, with an optical-size axis) for all words, Chivo Mono for numbers, the receipt and labels. No serif.
- The app is rebuilt on top of it: every screen composes design-system components; feature stylesheets only lay them out.
We considered a third-party component library (Radix Themes, MUI, shadcn/ui). The app needs about two dozen small components with a very specific look (receipts, stamps, paper surfaces); adopting a library would mean fighting its defaults for every one of them, and its visual language is exactly the generic look the product wants to avoid.
Consequences
- One place to look and one way to build UI; new screens start in Storybook.
- Color and token mistakes fail
npm run checkinstead of shipping. - The design system has no Next.js dependency, so a link styled as a button uses
buttonClassName()on the app's<Link>instead of a polymorphic component. Slightly more verbose, much simpler typing. - Storybook adds development dependencies and its own build; none of it reaches the production bundle.
- Two variable font families instead of three faces.