Files

210 lines
6.4 KiB
Markdown
Raw Permalink Normal View History

2023-08-17 14:59:22 +04:00
# Contributing
Thanks for your interest in contributing to ui.shadcn.com. We're happy to have you here.
Please take a moment to review this document before submitting your first pull request. We also strongly recommend that you check for open issues and pull requests to see if someone else is working on something similar.
If you need any help, feel free to reach out to [@shadcn](https://twitter.com/shadcn).
## About this repository
This repository is a monorepo.
- We use [pnpm](https://pnpm.io) and [`workspaces`](https://pnpm.io/workspaces) for development.
- We use [Turborepo](https://turbo.build/repo) as our build system.
- We use [changesets](https://github.com/changesets/changesets) for managing releases.
## Structure
This repository is structured as follows:
```
apps
└── v4
2023-08-17 14:59:22 +04:00
├── app
├── components
├── content
└── registry
└── new-york-v4
2023-08-17 14:59:22 +04:00
├── example
└── ui
packages
└── shadcn
2023-08-17 14:59:22 +04:00
```
| Path | Description |
| -------------------- | ---------------------------------------- |
| `apps/v4/app` | The Next.js application for the website. |
| `apps/v4/components` | The React components for the website. |
| `apps/v4/content` | The content for the website. |
| `apps/v4/registry` | The registry for the components. |
| `packages/shadcn` | The `shadcn` package. |
2023-08-17 14:59:22 +04:00
## Development
### Fork this repo
2023-08-17 14:59:22 +04:00
You can fork this repo by clicking the fork button in the top right corner of this page.
### Clone on your local machine
```bash
git clone https://github.com/your-username/ui.git
2023-08-17 14:59:22 +04:00
```
### Navigate to project directory
```bash
cd ui
2023-08-17 14:59:22 +04:00
```
### Create a new Branch
2023-08-17 14:59:22 +04:00
```bash
git checkout -b my-new-branch
2023-08-17 14:59:22 +04:00
```
### Install dependencies
```bash
2023-08-17 14:59:22 +04:00
pnpm install
```
### Run a workspace
You can use the `pnpm --filter=[WORKSPACE]` command to start the development process for a workspace.
#### Examples
1. To run the `ui.shadcn.com` website:
```bash
pnpm --filter=v4 dev
2023-08-17 14:59:22 +04:00
```
chore(v4): stop tracking generated styles (#11190) * chore(v4): stop tracking generated styles Phase 2 of generated-output untracking (follows #11189). The compiled style sources under apps/v4/styles (base-*/radix-*, ~1,080 files) are produced by registry:build (copyUIToStyles + RTL) on every deploy, so the committed copies were redundant. Only styles/README.md stays tracked. Unlike public/r/styles, these are imported modules, so: - code-check.yml: the typecheck job now runs `registry:build --style all` (the fast targeted build) after installing Bun, since v4 typecheck imports @/styles/*. - next.config.mjs: fail fast in dev with the regeneration command when the styles are missing, instead of a module-not-found cascade. - .prettierignore: skip styles/ — targeted builds intentionally skip prettier on generated output. - turbo.json: declare public/r/styles/** and styles/** as build outputs so a turbo cache replay of v4#build restores them (also fixes a latent phase-1 gap where a cache hit could deploy without registry JSON). Fresh clones: run `pnpm --filter=v4 registry:build --style all` once (~50s) before next dev; see styles/README.md. * docs: document untracked generated styles in CONTRIBUTING * fix(v4): register gitignored styles as tailwind sources Tailwind v4's source detection skips gitignored files, so untracking styles/ dropped every utility class that only appears in the generated output — progress bars collapsed (h-1), radio indicators and bubble radii lost their styles. An explicit @source glob only overrides .gitignore when the path through the ignored level is literal: ../styles/**/*.tsx gets pruned at the ignored directory, while ../styles/base-nova/**/*.tsx is scanned. Register each generated style explicitly. When adding a new style, add a line here. Verified byte-identical CSS output against an unrestricted scan.
2026-07-16 12:02:36 +04:00
> **Fresh clone?** The generated styles are not checked into git. Run
> `pnpm --filter=v4 registry:build --style all` once before starting the dev
> server. If you forget, the dev server will fail fast and tell you exactly
> this.
2. To run the `shadcn` package:
2023-08-17 14:59:22 +04:00
```bash
pnpm --filter=shadcn dev
2023-08-17 14:59:22 +04:00
```
## Running the CLI Locally
To run the CLI locally, you can follow the workflow:
1. Start by running the dev server:
```bash
pnpm dev
```
2. In another terminal tab, test the CLI by running:
```bash
pnpm shadcn
```
To test the CLI in a specific app, use a command like:
```bash
pnpm shadcn <init | add | ...> -c ~/Desktop/my-app
```
This workflow ensures that you are running the most recent version of the registry and testing the CLI properly in your local environment.
2023-08-17 14:59:22 +04:00
## Documentation
The documentation for this project is located in the `v4` workspace. You can run the documentation locally by running the following command:
2023-08-17 14:59:22 +04:00
```bash
pnpm --filter=v4 dev
2023-08-17 14:59:22 +04:00
```
Documentation is written using [MDX](https://mdxjs.com). You can find the documentation files in the `apps/v4/content/docs` directory.
2023-08-17 14:59:22 +04:00
## Components
We use a registry system for developing components. You can find the source code for the components under `apps/v4/registry`. The components are organized by styles.
2023-08-17 14:59:22 +04:00
```bash
apps
└── v4
2023-08-17 15:00:08 +04:00
└── registry
└── new-york-v4
2023-08-17 15:00:08 +04:00
├── example
└── ui
2023-08-17 14:59:22 +04:00
```
When adding or modifying components, please ensure that:
1. You make the changes for every style.
2. You update the documentation.
3. You run `pnpm registry:build` to update the registry.
2023-08-17 14:59:22 +04:00
See [`apps/v4/registry/README.md`](apps/v4/registry/README.md) for how the
registry pipeline is structured and for the faster targeted build modes
(`--style`, `--registry`, `--examples`, `--indexes`) you can use while
iterating locally. Always run the full `pnpm registry:build` before committing.
chore(v4): stop tracking generated styles (#11190) * chore(v4): stop tracking generated styles Phase 2 of generated-output untracking (follows #11189). The compiled style sources under apps/v4/styles (base-*/radix-*, ~1,080 files) are produced by registry:build (copyUIToStyles + RTL) on every deploy, so the committed copies were redundant. Only styles/README.md stays tracked. Unlike public/r/styles, these are imported modules, so: - code-check.yml: the typecheck job now runs `registry:build --style all` (the fast targeted build) after installing Bun, since v4 typecheck imports @/styles/*. - next.config.mjs: fail fast in dev with the regeneration command when the styles are missing, instead of a module-not-found cascade. - .prettierignore: skip styles/ — targeted builds intentionally skip prettier on generated output. - turbo.json: declare public/r/styles/** and styles/** as build outputs so a turbo cache replay of v4#build restores them (also fixes a latent phase-1 gap where a cache hit could deploy without registry JSON). Fresh clones: run `pnpm --filter=v4 registry:build --style all` once (~50s) before next dev; see styles/README.md. * docs: document untracked generated styles in CONTRIBUTING * fix(v4): register gitignored styles as tailwind sources Tailwind v4's source detection skips gitignored files, so untracking styles/ dropped every utility class that only appears in the generated output — progress bars collapsed (h-1), radio indicators and bubble radii lost their styles. An explicit @source glob only overrides .gitignore when the path through the ignored level is literal: ../styles/**/*.tsx gets pruned at the ignored directory, while ../styles/base-nova/**/*.tsx is scanned. Register each generated style explicitly. When adding a new style, add a line here. Verified byte-identical CSS output against an unrestricted scan.
2026-07-16 12:02:36 +04:00
Note that most generated output is not tracked in git: the installable JSON
under `apps/v4/public/r/styles` and the compiled styles under `apps/v4/styles`
are gitignored and rebuilt on every deploy. Running `registry:build` will not
dirty your working tree with generated files — only changes to the authored
sources (e.g. `registry/bases`) and the tracked indexes are committed.
## Commit Convention
Before you create a Pull Request, please check whether your commits comply with
the commit conventions used in this repository.
When you create a commit we kindly ask you to follow the convention
`category(scope or module): message` in your commit message while using one of
the following categories:
- `feat / feature`: all changes that introduce completely new code or new
features
- `fix`: changes that fix a bug (ideally you will additionally reference an
issue if present)
- `refactor`: any code related change that is not a fix nor a feature
- `docs`: changing existing or creating new documentation (i.e. README, docs for
usage of a lib or cli usage)
- `build`: all changes regarding the build of the software, changes to
dependencies or the addition of new dependencies
- `test`: all changes regarding tests (adding new tests or changing existing
ones)
- `ci`: all changes regarding the configuration of continuous integration (i.e.
github actions, ci system)
- `chore`: all changes to the repository that do not fit into any of the above
categories
e.g. `feat(components): add new prop to the avatar component`
If you are interested in the detailed specification you can visit
https://www.conventionalcommits.org/ or check out the
[Angular Commit Message Guidelines](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines).
2023-08-17 14:59:22 +04:00
## Requests for new components
If you have a request for a new component, please open a discussion on GitHub. We'll be happy to help you out.
## CLI
The `shadcn` package is a CLI for adding components to your project. You can find the documentation for the CLI [here](https://ui.shadcn.com/docs/cli).
2023-08-17 14:59:22 +04:00
Any changes to the CLI should be made in the `packages/shadcn` directory. If you can, it would be great if you could add tests for your changes.
2023-08-17 14:59:22 +04:00
## Testing
Tests are written using [Vitest](https://vitest.dev). You can run all the tests from the root of the repository.
```bash
2023-08-18 02:39:49 +09:00
pnpm test
2023-08-17 14:59:22 +04:00
```
Please ensure that the tests are passing when submitting a pull request. If you're adding new features, please include tests.