Contributing
How to add to the system so the compiler picks it up and consumers can use it. After any change, run the gates CI runs (node scripts/check-tokens.js, check-classes.js, check-card-coverage.js, check-registry.js, check-bundle-exports.js, check-dts.js; the full list is in .github/workflows/ds-validate.yml) and fix what they report.
How the compiler sees the project
- Global CSS is
styles.css(an@importmanifest). Tokens and@font-faceare read from its closure. - A component = a
Name.d.ts(PascalCase) plus a siblingName.jsxin the same folder. It compiles into_ds_bundle.jsand is exposed atwindow.PrismDesignSystem_39d121.Name. - A specimen / doc card = an
.htmlwhose first line is<!-- @dsCard group="…" viewport="WxH" name="…" subtitle="…" -->. It renders in the visual guide, the docs site and Storybook, grouped bygroup. - Never hand-edit
_ds_bundle.js,_ds_manifest.jsonor_adherence.oxlintrc.json. After a.jsxchange, rebuild the bundle withnode scripts/build-bundle.mjs.
Add a component
- Create
components/<group>/<Name>.jsx. Plain React. Styling = tokens-only, applied via aprism-*className. - Add its CSS to
components/<group>/<group>.cssand ensure that file is@imported incomponents/components.css. - Write
components/<group>/<Name>.d.ts— exact prop types (this is the contract). - Write
components/<group>/<Name>.prompt.md— what it's for, when to use it, when not to, and a code example. - Add or update the group's
.card.htmlspecimen (load../../_ds_bundle.js, read from the namespace). - Add the component to the index in
docs/COMPONENTS.md. - Rebuild the bundle (
node scripts/build-bundle.mjs) and regenerate the registry, docs and Storybook (./update-ds.sh --regen, ornpm run geninprism-docs/). - Run the gates → fix → repeat until clean.
Naming: PascalCase exports; prism-<component> / prism-<component>-<part> classes. Only capitalised exports reach the window namespace.
Add a token
- Put it in the right
tokens/*.cssfile (colour →colors.css, etc.). Define both light and dark values if it's a semantic colour. - Reference existing primitives (
var(--brand-500)) rather than new raw values; introduce a new palette ramp only when no existing hue fits, and define it in OKLCH. - If you rename a token, alias the old name for one minor cycle (see MATURITY).
- Document it (token card and/or README token index). Validate contrast for any text/border colour.
Add a pattern
A pattern is a composition (a workflow, a form layout, a permission flow). Build it from existing components; if you find yourself writing one-off markup twice, promote it to a component first. Document the recipe in PATTERNS.md (or the relevant docs/ guide) with a @dsCard if it warrants a visual.
Add a product signature
Signatures live in tokens/signatures.css and re-skin a subtree via data-signature="…".
- Add a canonical hue to the
--domain-*set incolors.css. - Add
[data-signature="<name>"] { --sig: var(--domain-<name>); }— the shared[data-signature]block derives the rest and adapts to light/dark automatically. - If the hue is light (e.g. amber), override
--accent-onto a dark value so on-accent text passes contrast. - Note the recommended
data-densityin a comment and add the signature to the signatures card.
Add a template
Templates are starting folders consumers copy. Create templates/<slug>/<Slug>.dc.html with <!-- @template name="…" description="…" --> as the first line of the body and <helmet><script src="./ds-base.js"></script></helmet>. Keep every file the template needs inside templates/<slug>/.
Demo data & assets
- Real photos in kits are reference-only (Pexels), declared in
assets/demo/and excluded from the package. Never depend on them in a shipped component. - Prefer CSS gradient/placeholder fallbacks so a component looks intentional even if an image 404s.
Keep the docs true
A change is not finished until the pages that describe it are right. Update the hand-written docs in the same change as the code: the site pages under prism-docs/website/docs/ (all but the generated components/ and about/changelog.md), docs/*.md, readme.md, the package READMEs and the component *.prompt.md.
- If you rename or remove something, add the old name to
retiredinscripts/docs-facts.config.json; the gate then lists every page that still mentions it. - Run
node scripts/check-docs-facts.js. It fails on a token name, theme value, component count, package version or retired term that no longer matches the code. - Run
cd prism-docs && npm run gen && npm run docs:build. The build fails on a broken link.
Review expectations
- Passes all applicable QA gates.
- Tokens-only styling; correct maturity status; docs updated in the same change, and
check-docs-factspasses. - The
ds-validategates pass. - Semver-appropriate (see MATURITY); breaking changes carry a migration note.