@terjeballestad/bob
v2.2.0
Published
Bob: a design system and component library for productivity tools
Readme
Bob
Bob is a design system and component library for productivity tools: React components, the CSS tokens they read, and a Tailwind entry that builds Bob's classes in your app. One dark theme. The Storybook at https://bob.godstemning.dev documents every component.
npm i @terjeballestad/bobAdd one line after your Tailwind v4 import (DD-031):
@import "tailwindcss";
@import "@terjeballestad/bob/tailwind.css";import { Button, Chip, StatusDot } from '@terjeballestad/bob';
<Button variant="primary" size="sm" onClick={save}>Save</Button>
<Chip mono tone="green">admin</Chip>
<StatusDot state="live" color="var(--bg-green)" size={7} />Your Tailwind build then writes Bob's component classes (btn, chip, card, ...) in its
utilities layer, and only the ones in use. They take variants (md:btn-sm) and mix with your
utilities: <Button className="px-8"> gets 32px of side padding over Bob's. The theme maps Bob's
tokens, so bg-card, text-secondary, border-subtle, rounded-btn and font-mono work. The
component import also loads Bob's webfonts.
Type is a class too: one text style sets the size, the line height, the letter spacing and the
weight (DD-038). Write text-label text-muted, not text-caption font-medium and not
text-[12px]. The styles are text-micro, text-tiny, text-id, text-label,
text-caption, text-note, text-figure, text-body, text-subhead, text-item,
text-base, text-heading, text-prose, text-title, text-headline and text-display;
TOKENS.md says what each sets and is for. They sit on DD-039's ramp (11 to 24px, whole pixels),
and none is 700. A style sets no family, so an id adds font-mono. Labels are sentence case.
text-base is Bob's 13px body size, not Tailwind's 1rem.
Bob 2.0 applies DD-039's design principles: four surface levels, cards edged by a soft shadow and not a border, one accent, 13px UI text, and the motion rules. docs/migration-2.0.md lists what an app changes. Bob 2.1 takes DD-041's component choices (CHANGELOG.md).
Preflight. Bob's components and Storybook assume Bob's own reset, not Tailwind's preflight. With preflight, text sits at line-height 1.5. To keep Bob's look, import the theme and the utilities only:
@layer theme, base, components, utilities; @import "tailwindcss/theme.css" layer(theme); @import "tailwindcss/utilities.css" layer(utilities); @import "@terjeballestad/bob/tailwind.css";Your element rules go in
@layer base. An unlayeredbutton { color: inherit }beats every class in a layer, Bob's too.
react, react-dom and @types/react 18.3 or later are peer dependencies. The types are a
required peer, because Bob's declarations import React's types, and npm must place them where
Bob can see them.
Layout
src/
index.ts barrel: every component and its prop types
types.ts DSOption / DSOptionInput, for SegToggle
styles.css the precompiled stylesheet (dist/bob.css), in the base layer
tailwind.css the Tailwind entry (dist/tailwind.css): tokens, theme, @utility classes
tailwind/ theme.css (@theme over the tokens), components.css and one file of
@utility classes per group: core, forms, feedback, lists
tokens/ colors, typography, layout, fonts, base (reset + focus ring)
components/ clickable.ts: the keyboard props for a clickable div (Card, ListRow)
core/ Avatar Button Card Chip IconButton Kbd ProgressBar SegToggle StatusDot
forms/ FormRow Input SearchInput Select (and its parts) Textarea
feedback/ Modal Toast (ToastStack, createToastManager, useToastManager)
lists/ ListRow NavRow SectionLabel
TOKENS.md what each CSS custom property meansConventions
- Each component renders Bob's component classes, in the daisyUI style:
btn btn-md btn-primary,chip chip-green,card card-action. Each class is a Tailwind@utilityinsrc/tailwind/<group>.css. The rules read the tokens asvar(--token), never a generated class. TOKENS.md lists every token. Hover is a CSS:hoverrule. No component keeps state, except what Base UI keeps for Select and ToastStack. - Class names have no prefix. A component writes each class name whole in its source, so
Tailwind finds it when it scans
dist/index.js. Tailwind sorts utilities by the properties they set, sotest/tailwind.test.tsxchecks that a modifier (btn-primary) comes after its base (btn). - Overrides. Components that wrap a native element (
Button,IconButton,Chip,Input,Textarea,SearchInput) takeclassNameand forward every other attribute of that element. Select's parts takeclassNameand Base UI's props. The other components take astyleprop. - One dark theme. There is no light mode and no theme switcher yet.
- Icons come from the app (DD-042). The app installs lucide-react and passes its icons to
Icon, Button's and NavRow'siconand IconButton'sicon; Bob draws them at 14 or 16px, stroke 2, in the text's colour. Bob does not depend on lucide-react. Bob draws the status shapes itself (StatusDot shape), and its own glyphs (search, chevron, check, close) follow Lucide's geometry; LICENSE-lucide.txt holds Lucide's notice. - Fonts come from Google Fonts through an
@importintokens/fonts.css: Schibsted Grotesk and JetBrains Mono.
Develop
npm install
npm test # builds dist/, then runs the export and render tests
npm run typecheck # also checks every exported type through the package namenpm test checks the built package, not the source: the exports match Bob's original
barrel, every class a component renders is defined in bob.css, and dist/index.js imports
bob.css. test/tailwind.test.tsx builds a Tailwind app with dist/tailwind.css and checks that
it writes every class the components render.
Storybook and screenshot tests
npm run storybook # http://localhost:6106 (6006 is Godot's debug adapter port)
npm run build-storybook # static build in storybook-static/
npm run test:visual:docker # one screenshot per story, in the Playwright Linux imageEach component has a docs page (stories/<group>/<Component>.mdx): purpose, when to use it and
when not, props, states and accessibility, with its stories in <Component>.stories.tsx. The
blocks the pages share are in stories/docs/blocks.tsx. .storybook/theme.ts gives Storybook
Bob's look, from the tokens.
Write a story as an app writes the component: plain JSX, one element per variant, and Tailwind
utilities on layout wrappers (<div className="flex gap-2.5">). .storybook/tailwind.css builds
those utilities from the story files. "Show code" prints the rendered JSX. A story with state sets
parameters.docs.source.code to its usage instead.
Stories with a play function are interaction tests. visual/play.visual.ts plays each one in the
built Storybook and fails when Storybook reports an error; it runs with the screenshot tests.
The screenshot test opens every story in the built Storybook and compares it with a baseline in
visual/__screenshots__/, with no pixel tolerance. Baselines come from the Playwright Linux image,
never from macOS, because fonts render differently. CI uses the same image. Build the Storybook
first.
When you change how a component looks on purpose, take new baselines and commit them with the change, so the review shows the before and after:
npm run build-storybook && npm run test:visual:docker -- --update-snapshotsA new story fails until it has a baseline. The image version in package.json and ci.yml must
match the installed @playwright/test.
Release
Bump the version in a commit, then push a tag v<version>. GitHub Actions runs the tests and
publishes to npm with trusted publishing, so no one types an OTP. A change to a prop or a token
name is a major version.
Provenance
Bob 0.1.0 is client/src/ds/ from Time Turtle at commit bb93eea, moved with no change to a
component, a style or a token. Only this README is new: the old one said that styling was inline
and that hover was component state, which was no longer true of the code.
Before that, the components were unpacked from _ds_bundle.js, a prebuilt IIFE that read
window.React and exported through a window.PMBoardDesignSystem_cdbc5e namespace (Time Turtle
SB-006). Behavior and every style value carried over unchanged. The ui_kits/pm-board demo app in
the bundle was dropped, because nothing imported it.
