Adds project documentation: MIT license file, README with package overview/usage/development guide, and CLAUDE.md with maintenance guidelines covering feature parity, testing strategy, and CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5.1 KiB
5.1 KiB
CLAUDE.md — DT Design System
Project Overview
Monorepo for the Dangerous Things design system. Three npm packages publish under @dangerousthings/*:
- tokens — canonical design tokens in TypeScript, compiled to JS and auto-generated as CSS custom properties
- web — CSS themes (bevels, glows, elevation, forms) consumed by web apps
- react-native — React Native components built on React Native Paper
Three brand themes: dt (neon cyberpunk / beveled), classic (dark navy / magenta), supra (MD3 / blue).
Build & Tooling
- Turbo orchestrates builds;
packages/tokensmust build first (dependency for web and react-native). - Build everything:
npm run build - Typecheck everything:
npm run typecheck - Tokens build:
tscthennode dist/scripts/generate-css.js - Web build:
node scripts/build.js(copies CSS, assembles brand token CSS, copies fonts) - React Native build:
tsc - Versioning: Changesets (
npx changeset,npm run version-packages,npm run release)
Architecture Rules
- Tokens are the single source of truth. Never hard-code color, typography, or shape values in web or react-native packages — always reference the tokens package.
- Web package is pure CSS — no JavaScript runtime except the optional
theme-registrymodule. - React Native components wrap React Native Paper and must list it (and react, react-native, react-native-svg, react-native-safe-area-context) as peer dependencies, never bundled dependencies.
Feature Parity
When adding or modifying a design token, component, or visual behavior, keep all three layers in sync:
- Tokens — add/update the value in every brand file (
packages/tokens/src/brands/{dt,classic,supra}.ts) and in the shared type (packages/tokens/src/types.ts). - Web — if the token maps to a CSS component, update the relevant CSS file under
packages/web/src/components/. Ensure the CSS custom property name matches the token path (e.g.,--dt-color-brand-primary). - React Native — update the corresponding component(s) under
packages/react-native/src/components/and ensure the theme provider maps the new token.
Parity Checklist (use before closing any PR)
- New tokens exist in all three brand files with correct values
- Token types are updated if the shape of the token object changed
- CSS generation script produces the expected custom properties (
npm run build:tokensthen inspectdist/css/) - Web CSS files reference the new/changed custom properties
- React Native components consume the new tokens via the theme
- All three packages build cleanly (
npm run build) - TypeScript typechecks pass (
npm run typecheck)
Testing
No test framework is configured yet. When adding tests, follow the guidance below.
Strategy
- Tokens: unit tests for token value correctness and CSS generation output. Verify every brand file satisfies the shared type. Snapshot the generated CSS files.
- Web: visual regression tests or snapshot tests for the compiled CSS. Ensure each brand's generated stylesheet contains expected custom properties.
- React Native: component rendering tests with React Native Testing Library. Test that each component renders without errors under every brand theme. Test interactive behaviors (press, toggle, expand).
Conventions (apply once a framework is added)
- Place test files next to source:
foo.ts→foo.test.ts,DTButton.tsx→DTButton.test.tsx. - Name test blocks clearly:
describe("DTButton"),it("renders in contained mode"). - Run tests via Turbo: add a
testtask toturbo.jsonand per-packagetestscripts. - CI should run
turbo run testalongsidebuildandtypecheck.
Maintenance
Adding a New Component
- Create the React Native component in
packages/react-native/src/components/DTFoo.tsx. - Re-export it from
packages/react-native/src/index.ts. - If it needs new tokens, add them to all brand files and types first.
- If there is a web equivalent (CSS-only), add a CSS file in
packages/web/src/components/. - Create a changeset:
npx changeset— select affected packages and describe the change.
Adding a New Brand
- Create
packages/tokens/src/brands/newbrand.tsimplementing the fullBrandTokenstype. - Re-export it from
packages/tokens/src/index.ts. - The CSS generation script will pick it up automatically.
- Add the brand to the React Native
DTThemeProviderbrand union. - Update this file and the README.
Modifying Tokens
- Always start in
packages/tokens/src/types.tsif the token shape changes. - Update every brand file — the TypeScript compiler will flag missing properties.
- Rebuild tokens (
npm run build:tokens) and verify the generated CSS before touching downstream packages.
CI
GitHub Actions runs on push to main and on PRs:
- Builds across Node 18, 20, 22
- Runs typecheck
- Validates changesets on PRs (
npx changeset status)
Code Style
- TypeScript strict mode.
- CSS uses BEM-ish class names prefixed with
dt-(e.g.,.dt-bevel-card). - React Native components are prefixed
DT(e.g.,DTButton). - Keep files focused — one component per file, one brand per file.