|
| 1 | +# Contributing to Tiny UI |
| 2 | + |
| 3 | +Thanks for your interest in contributing to Tiny UI! This guide will help you get started. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Node.js >= 22 |
| 10 | +- pnpm (see `packageManager` in `package.json` for the exact version) |
| 11 | + |
| 12 | +### Getting Started |
| 13 | + |
| 14 | +```bash |
| 15 | +# Clone the repo |
| 16 | +git clone https://github.com/wangdicoder/tiny-ui.git |
| 17 | +cd tiny-ui |
| 18 | + |
| 19 | +# Install dependencies |
| 20 | +pnpm install |
| 21 | + |
| 22 | +# Start the docs site (dev server) |
| 23 | +pnpm dev |
| 24 | + |
| 25 | +# Run tests |
| 26 | +pnpm test |
| 27 | + |
| 28 | +# Build the component library |
| 29 | +pnpm build |
| 30 | +``` |
| 31 | + |
| 32 | +## Project Structure |
| 33 | + |
| 34 | +``` |
| 35 | +tiny-ui/ |
| 36 | +├── packages/react/ # @tiny-ui/react — component library |
| 37 | +│ ├── src/ # Component source code |
| 38 | +│ ├── scripts/ # Build scripts |
| 39 | +│ └── package.json |
| 40 | +├── apps/docs/ # Documentation site |
| 41 | +│ ├── src/ # Site source |
| 42 | +│ ├── guides/ # Guide markdown files |
| 43 | +│ └── package.json |
| 44 | +├── turbo.json # Turborepo config |
| 45 | +└── package.json # Workspace root |
| 46 | +``` |
| 47 | + |
| 48 | +## Adding a New Component |
| 49 | + |
| 50 | +1. Create a new directory under `packages/react/src/your-component/` |
| 51 | +2. Follow the existing component structure: |
| 52 | + |
| 53 | +``` |
| 54 | +your-component/ |
| 55 | +├── your-component.tsx # Component implementation |
| 56 | +├── types.ts # TypeScript interfaces |
| 57 | +├── index.tsx # Barrel export |
| 58 | +├── index.md # English documentation |
| 59 | +├── index.zh_CN.md # Chinese documentation |
| 60 | +├── style/ |
| 61 | +│ ├── _index.scss # Component styles |
| 62 | +│ └── index.tsx # Style entry (imports) |
| 63 | +├── demo/ |
| 64 | +│ └── basic.md # Usage demos |
| 65 | +└── __tests__/ |
| 66 | + └── your-component.test.tsx |
| 67 | +``` |
| 68 | + |
| 69 | +3. Export the component from `packages/react/src/index.ts` |
| 70 | +4. Add the route in `apps/docs/src/routers.tsx` |
| 71 | + |
| 72 | +## Code Style |
| 73 | + |
| 74 | +- TypeScript strict mode is enabled |
| 75 | +- Components use `React.forwardRef` for ref forwarding |
| 76 | +- CSS class names follow the `ty-component-name` convention |
| 77 | +- SCSS variables are in `packages/react/src/style/_variables.scss` |
| 78 | + |
| 79 | +## Running Tests |
| 80 | + |
| 81 | +```bash |
| 82 | +# Run all tests |
| 83 | +pnpm test |
| 84 | + |
| 85 | +# Run tests for a specific component |
| 86 | +pnpm --filter @tiny-ui/react test -- --testPathPattern=button |
| 87 | + |
| 88 | +# Update snapshots |
| 89 | +pnpm --filter @tiny-ui/react test:update |
| 90 | + |
| 91 | +# Run with coverage |
| 92 | +pnpm --filter @tiny-ui/react test:coverage |
| 93 | +``` |
| 94 | + |
| 95 | +## Commit Convention |
| 96 | + |
| 97 | +We use [Conventional Commits](https://www.conventionalcommits.org/). Each commit message should be structured as: |
| 98 | + |
| 99 | +``` |
| 100 | +<type>(<scope>): <description> |
| 101 | +``` |
| 102 | + |
| 103 | +Types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `chore`, `revert` |
| 104 | + |
| 105 | +Examples: |
| 106 | +- `feat(button): add loading state` |
| 107 | +- `fix(modal): prevent scroll when open` |
| 108 | +- `docs(input): update API documentation` |
| 109 | + |
| 110 | +## Adding a Changeset |
| 111 | + |
| 112 | +We use [Changesets](https://github.com/changesets/changesets) to manage versioning and changelogs. If your PR includes user-facing changes to `@tiny-ui/react`, add a changeset: |
| 113 | + |
| 114 | +```bash |
| 115 | +pnpm changeset |
| 116 | +``` |
| 117 | + |
| 118 | +You'll be prompted to: |
| 119 | +1. Select the package(s) affected (`@tiny-ui/react`) |
| 120 | +2. Choose the semver bump type (patch / minor / major) |
| 121 | +3. Write a short summary of your change |
| 122 | + |
| 123 | +This creates a markdown file in `.changeset/` — commit it with your PR. When the PR merges, a "Version Packages" PR is automatically opened. Merging that PR publishes to npm and updates the changelog. |
| 124 | + |
| 125 | +## Pull Requests |
| 126 | + |
| 127 | +1. Fork the repo and create a branch from `master` |
| 128 | +2. If you've added code, add tests |
| 129 | +3. Ensure the test suite passes (`pnpm test`) |
| 130 | +4. Ensure your code lints (`pnpm lint`) |
| 131 | +5. Add a changeset if your change affects published packages (`pnpm changeset`) |
| 132 | +6. Create a pull request with a clear description |
| 133 | + |
| 134 | +## Reporting Bugs |
| 135 | + |
| 136 | +Use [GitHub Issues](https://github.com/wangdicoder/tiny-ui/issues) with the bug report template. Include: |
| 137 | +- Steps to reproduce |
| 138 | +- Expected vs actual behavior |
| 139 | +- Browser and OS information |
| 140 | +- A minimal reproduction if possible |
| 141 | + |
| 142 | +## License |
| 143 | + |
| 144 | +By contributing, you agree that your contributions will be licensed under the [MIT License](./LICENSE). |
0 commit comments