* refactor(storybook): add design tokens doc & improve menu organization * fix(turbo): generate components using new structure * refactor(sidebar): change from experimental to old components
3.1 KiB
Contributing to Signoz Components
Getting Started
-
Clone the repository:
git clone [email protected]:SigNoz/components.git -
Install dependencies:
pnpm install -
Build the packages:
pnpm build -
Start Storybook:
pnpm run dev
Useful Commands
pnpm build- Build all packages, including the Storybook sitepnpm dev- Run all packages locally and preview with Storybookpnpm lint- Lint all packagespnpm clean- Clean up allnode_modulesanddistfolders
Adding a New Component
All components live in the single package @signozhq/ui under packages/ui.
Using the Generator (Recommended)
The easiest way to add a new component is using the turbo generator:
-
Create a new branch:
git checkout -b feature/new-component-name -
Run the generator:
pnpm turbo gen -
Select
new-componentand follow the prompts:- Enter the component name in kebab-case (e.g.,
my-component) - Provide a brief description
- Choose whether to import from shadcn or create from scratch
The generator will automatically:
- Create the component folder at
packages/ui/src/{name}/ - Add the export to
packages/ui/src/index.ts - Add the build entry to
packages/ui/vite.config.ts - Create a Storybook story at
apps/docs/stories/{name}.stories.tsx - Run
pnpm install
- Enter the component name in kebab-case (e.g.,
-
Build and verify:
pnpm build pnpm dev -
Commit and push:
git add . git commit -m "Add new component: my-component" git push origin feature/new-component-name -
Open a pull request.
Manual Setup
If you prefer to add a component manually:
-
Create a new branch:
git checkout -b feature/new-component-name -
Add the component under
packages/ui/src/:- Create a folder named after the component (e.g.,
packages/ui/src/my-component/) - Add the component file (e.g.,
my-component.tsx) and anindex.tsthat re-exports the public API - Add an
index.cssfor component styles - Follow the structure of existing components (e.g.,
packages/ui/src/badge/)
- Create a folder named after the component (e.g.,
-
Register the new export in
packages/ui/src/index.ts:export * from './my-component/index.js'; -
Register the new entry in
packages/ui/vite.config.ts:const entries: Record<string, string> = { // ... existing entries 'my-component/index': 'src/my-component/index.ts', }; -
Add a Storybook story in
apps/docs/stories/:- Create
apps/docs/stories/my-component.stories.tsx - Import from
@signozhq/uiand use the same story/doc pattern as other stories (see e.g.,badge.stories.tsx)
- Create
-
Build and verify:
pnpm build pnpm dev -
Commit and push:
git add . git commit -m "Add new component: my-component" git push origin feature/new-component-name -
Open a pull request.
Releasing
Releases are driven by Release Please. Create a pull request with your changes and the Release Please bot will create a release draft with generated notes.