Contributing
Set up the repository, run the checks and work on the docs.
Bug reports, accessibility findings, docs fixes and pull requests are all welcome. Please read the Code of Conduct first, and report security issues as described in SECURITY.md instead of opening an issue.
Setup
You need Node 22 or newer.
npm installnpx playwright install chromiumnpm run devnpm run dev starts the playground on Vite. It is the quickest way to see a change. The Playwright tests run against it too.
Workflow
- Open an issue first for anything larger than a small fix, so we can agree on the approach.
- Write the failing test first, then the change. Unit and integration tests live next to the code in
src/*.test.ts(x). Browser tests live ine2e/. - Keep the package free of runtime dependencies. Anything the site or docs need goes in
devDependencies. - Every visible string, icon, color and timing must stay replaceable through
labels,icons,renderor a--eg-*variable. - Run the checks before opening a pull request.
npm run formatnpm run lint && npm run typecheck && npm run test && npm run e2enpm run build && npm run size && npm run check:package| Script | What it does |
|---|---|
npm run dev | Playground on Vite |
npm run test | Unit and integration tests (Vitest, jsdom) |
npm run e2e | Playwright on desktop Chrome and Pixel 7 |
npm run typecheck | TypeScript, including isolated declaration checks |
npm run lint | ESLint with React Hooks and jsx-a11y |
npm run build | ESM bundle, declarations and stylesheet in dist |
npm run size | Bundle size |
npm run check:package | publint and Are the Types Wrong |
Working on the docs
This site lives in docs/, a Next.js app built with Fumadocs, rendered on the server and deployed to Vercel with docs as the root directory. proxy.ts sets a per-request Content Security Policy. It imports the library straight from src/, so the demos always run the code in your branch, and the prop tables are generated from src/types.ts.
npm install --prefix docsnpm run dev --prefix docsPages are MDX files in docs/content/docs, and the sidebar order is in meta.json there. Two components are available in every page:
<Demo />renders a live gallery. Pass plain lightbox props,set(images,mediaorplayer),count, andpresetfor props that need functions.<HashDemo prefix="..." />does the same withuseLightboxHash.<GridsDemo />renders a grid. Passlayout,switcher,filter,lightboxandcount.
Write prop tables with <auto-type-table path="src/types.ts" name="..." /> instead of by hand, so they cannot drift from the code.
Code style
- TypeScript in strict mode. Public exports have explicit types and a doc comment.
- Only documentation comments. A short comment is fine when it explains a non-obvious reason the code cannot show.
- Animations use
transformandopacityonly and respectprefers-reduced-motion. - No em dashes in prose, code comments or commit messages.
- Commit messages follow Conventional Commits (
feat:,fix:,docs:,test:,chore:).
Accessibility
Changes to the viewer must keep it usable with a keyboard and a screen reader. Check focus order, focus return, labels and announcements in a real browser, and add an end-to-end test when behavior changes.
Releases
Maintainers release by publishing a GitHub release, which runs the publish workflow and puts the version on npm.