|
1 | | -[Bug Reports](#bugs) | [Features Requests](#features) | [Submitting Pull Requests](#pull-requests) | [Running Local Demo](#running-local-demo) | [Running Tests](#running-tests) |
| 1 | +# Contributing to React Split Pane |
2 | 2 |
|
3 | | -# Contributing to this project |
| 3 | +[Bug Reports](#bugs) | [Feature Requests](#features) | [Pull Requests](#pull-requests) | [Development Setup](#development-setup) | [Running Tests](#running-tests) |
4 | 4 |
|
5 | | -Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved. |
| 5 | +Thank you for considering contributing to React Split Pane! Please take a moment to review this document to make the contribution process easy and effective. |
6 | 6 |
|
7 | | -Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. |
8 | | -In return, they should reciprocate that respect in addressing your issue or assessing patches and features. |
| 7 | +## Using the Issue Tracker |
9 | 8 |
|
10 | | -## Using the issue tracker |
| 9 | +The issue tracker is the preferred channel for bug reports and feature requests. Please respect these guidelines: |
11 | 10 |
|
12 | | -The issue tracker is the preferred channel for bug reports but please respect the following restrictions: |
13 | | - |
14 | | -- Please **do not** use the issue tracker for personal support requests. |
15 | | -- Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others. |
| 11 | +- **Do not** use the issue tracker for personal support requests. |
| 12 | +- **Do not** derail or troll issues. Keep discussions on topic. |
16 | 13 |
|
17 | 14 | <a name="bugs"></a> |
18 | 15 |
|
19 | | -## Bug reports |
| 16 | +## Bug Reports |
20 | 17 |
|
21 | | -A bug is a _demonstrable problem_ that is caused by the code in the repository. |
22 | | -Good bug reports are extremely helpful - thank you! |
| 18 | +A bug is a _demonstrable problem_ caused by the code in the repository. Good bug reports are extremely helpful! |
23 | 19 |
|
24 | 20 | Guidelines for bug reports: |
25 | 21 |
|
26 | | -1. **Use the GitHub issue search** — check if the issue has already been reported. |
27 | | -2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or development branch in the repository. |
28 | | -3. **Isolate the problem** — create a [reduced test case](http://css-tricks.com/reduced-test-cases/) and a live example (using a site like [CodeSandbox](https://codesandbox.io/)). |
29 | | - |
30 | | -A good bug report shouldn't leave others needing to chase you up for more information. |
31 | | -Please try to be as detailed as possible in your report. |
32 | | -Which versions of react-virtualized and react are you using? |
33 | | -What steps will reproduce the issue? What browser(s) and OS experience the problem? |
34 | | -What would you expect to be the outcome? |
35 | | -All these details will help people to fix any potential bugs. |
| 22 | +1. **Search first** — Check if the issue has already been reported. |
| 23 | +2. **Test latest** — Try to reproduce it using the latest `v3` branch. |
| 24 | +3. **Isolate** — Create a minimal reproduction using [CodeSandbox](https://codesandbox.io/) or [StackBlitz](https://stackblitz.com/). |
36 | 25 |
|
37 | | -Example: |
| 26 | +A good bug report includes: |
38 | 27 |
|
39 | | -> Short and descriptive example bug report title |
40 | | -> |
41 | | -> A summary of the issue and the browser/OS environment in which it occurs. |
42 | | -> If suitable, include the steps required to reproduce the bug. |
43 | | -> |
44 | | -> 1. This is the first step |
45 | | -> 2. This is the second step |
46 | | -> 3. Further steps, etc. |
47 | | -> |
48 | | -> `<url>` - a link to the reduced test case |
49 | | -> |
50 | | -> Any other information you want to share that is relevant to the issue being reported. |
51 | | -> This might include the lines of code that you have identified as causing the bug, |
52 | | -> and potential solutions (and your opinions on their merits). |
| 28 | +- React Split Pane version |
| 29 | +- React version |
| 30 | +- Browser and OS |
| 31 | +- Steps to reproduce |
| 32 | +- Expected vs actual behavior |
| 33 | +- Link to reproduction |
53 | 34 |
|
54 | 35 | <a name="features"></a> |
55 | 36 |
|
56 | | -## Feature requests |
| 37 | +## Feature Requests |
57 | 38 |
|
58 | | -Feature requests are welcome. |
59 | | -But take a moment to find out whether your idea fits with the scope and aims of the project. |
60 | | -It's up to _you_ to make a strong case to convince the project's developers of the merits of this feature. |
61 | | -Please provide as much detail and context as possible. |
| 39 | +Feature requests are welcome! Please provide: |
62 | 40 |
|
63 | | -<a name="pull-requests"></a> |
| 41 | +- Clear use case |
| 42 | +- Why existing features don't solve your problem |
| 43 | +- API suggestions (if applicable) |
| 44 | +- Examples from similar libraries (if applicable) |
64 | 45 |
|
65 | | -## Pull requests |
| 46 | +<a name="pull-requests"></a> |
66 | 47 |
|
67 | | -Good pull requests - patches, improvements, new features - are a fantastic help. |
68 | | -They should remain focused in scope and avoid containing unrelated commits. |
| 48 | +## Pull Requests |
69 | 49 |
|
70 | | -**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language), |
71 | | -otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project. |
| 50 | +Good pull requests are a fantastic help! They should remain focused and avoid unrelated changes. |
72 | 51 |
|
73 | | -Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). |
| 52 | +**Please ask first** before starting significant work (new features, major refactoring). Open an issue to discuss your idea. |
74 | 53 |
|
75 | | -Follow this process if you'd like your work considered for inclusion in the project: |
| 54 | +### Pull Request Process |
76 | 55 |
|
77 | | -1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes: |
| 56 | +1. Fork and clone the repository: |
78 | 57 |
|
79 | 58 | ```bash |
80 | | - # Clone your fork of the repo into the current directory |
81 | 59 | git clone https://github.com/<your-username>/react-split-pane |
82 | | - # Navigate to the newly cloned directory |
83 | 60 | cd react-split-pane |
84 | | - # Assign the original repo to a remote called "upstream" |
85 | 61 | git remote add upstream https://github.com/tomkp/react-split-pane |
86 | 62 | ``` |
87 | 63 |
|
88 | | -2. If you cloned a while ago, get the latest changes from upstream: |
| 64 | +2. Create a branch from `v3`: |
89 | 65 |
|
90 | 66 | ```bash |
91 | | - git checkout master |
92 | | - git pull upstream master |
| 67 | + git checkout v3 |
| 68 | + git pull upstream v3 |
| 69 | + git checkout -b my-feature |
93 | 70 | ``` |
94 | 71 |
|
95 | | -3. Install/update dependencies: |
| 72 | +3. Install dependencies: |
96 | 73 |
|
97 | 74 | ```bash |
98 | | - yarn install |
| 75 | + npm install |
99 | 76 | ``` |
100 | 77 |
|
101 | | -4. Create a new topic branch (off the main project development branch) to |
102 | | - contain your feature, change, or fix: |
| 78 | +4. Make your changes, following the [code style](#code-style). |
| 79 | + |
| 80 | +5. Add tests for new functionality. |
| 81 | + |
| 82 | +6. Ensure all tests pass: |
103 | 83 |
|
104 | 84 | ```bash |
105 | | - git checkout -b <topic-branch-name> |
| 85 | + npm test |
106 | 86 | ``` |
107 | 87 |
|
108 | | -5. Commit your changes in logical chunks. |
109 | | - Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) |
110 | | - or your code is unlikely be merged into the main project. |
111 | | - Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) |
112 | | - feature to tidy up your commits before making them public. |
| 88 | +7. Ensure code passes linting: |
113 | 89 |
|
114 | | -6. Locally merge (or rebase) the upstream development branch into your topic branch: |
| 90 | + ```bash |
| 91 | + npm run lint |
| 92 | + ``` |
| 93 | + |
| 94 | +8. Commit with a clear message: |
115 | 95 |
|
116 | 96 | ```bash |
117 | | - git pull [--rebase] upstream master |
| 97 | + git commit -m "feat: add new feature" |
118 | 98 | ``` |
119 | 99 |
|
120 | | -7. Push your topic branch up to your fork: |
| 100 | +9. Push and open a pull request against `v3`: |
121 | 101 |
|
122 | 102 | ```bash |
123 | | - git push origin <topic-branch-name> |
| 103 | + git push origin my-feature |
124 | 104 | ``` |
125 | 105 |
|
126 | | -8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) |
127 | | - with a clear title and description. |
| 106 | +### Commit Message Format |
| 107 | + |
| 108 | +We follow [Conventional Commits](https://www.conventionalcommits.org/): |
| 109 | + |
| 110 | +- `feat:` — New feature |
| 111 | +- `fix:` — Bug fix |
| 112 | +- `docs:` — Documentation only |
| 113 | +- `style:` — Formatting, no code change |
| 114 | +- `refactor:` — Code change that neither fixes a bug nor adds a feature |
| 115 | +- `test:` — Adding or fixing tests |
| 116 | +- `chore:` — Build process or auxiliary tools |
| 117 | + |
| 118 | +<a name="development-setup"></a> |
128 | 119 |
|
129 | | -**IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by this project (MIT). |
| 120 | +## Development Setup |
130 | 121 |
|
131 | | -<a name="running-local-demo"></a> |
| 122 | +### Prerequisites |
132 | 123 |
|
133 | | -## Running Local Demo |
| 124 | +- Node.js 18+ |
| 125 | +- npm 9+ |
134 | 126 |
|
135 | | -You can run the local demo with yarn like so: |
| 127 | +### Setup |
136 | 128 |
|
137 | 129 | ```bash |
138 | | -cd <root> |
139 | | -yarn build |
140 | | -yarn website:start |
| 130 | +# Clone the repository |
| 131 | +git clone https://github.com/tomkp/react-split-pane |
| 132 | +cd react-split-pane |
| 133 | + |
| 134 | +# Install dependencies |
| 135 | +npm install |
| 136 | + |
| 137 | +# Start the development server (examples) |
| 138 | +npm run dev |
141 | 139 | ``` |
142 | 140 |
|
143 | | -The local app will then be available at http://localhost:3000 |
| 141 | +The examples will be available at http://localhost:5173 |
| 142 | + |
| 143 | +### Project Structure |
| 144 | + |
| 145 | +``` |
| 146 | +src/ |
| 147 | +├── components/ # React components (SplitPane, Pane, Divider) |
| 148 | +├── hooks/ # React hooks (useResizer, useKeyboardResize) |
| 149 | +├── types/ # TypeScript type definitions |
| 150 | +├── utils/ # Utility functions |
| 151 | +├── test/ # Test setup |
| 152 | +└── index.ts # Main entry point |
| 153 | +
|
| 154 | +examples/ # Example applications |
| 155 | +``` |
| 156 | + |
| 157 | +### Available Scripts |
| 158 | + |
| 159 | +| Command | Description | |
| 160 | +|---------|-------------| |
| 161 | +| `npm run dev` | Start examples dev server | |
| 162 | +| `npm test` | Run tests | |
| 163 | +| `npm run test:watch` | Run tests in watch mode | |
| 164 | +| `npm run lint` | Run ESLint | |
| 165 | +| `npm run build` | Build for production | |
| 166 | +| `npm run typecheck` | Run TypeScript type checking | |
144 | 167 |
|
145 | 168 | <a name="running-tests"></a> |
146 | 169 |
|
147 | 170 | ## Running Tests |
148 | 171 |
|
149 | | -All unit tests must pass before a pull request will be approved. |
150 | | -You can run unit tests with yarn like so: |
| 172 | +All tests must pass before a pull request will be merged. |
151 | 173 |
|
152 | 174 | ```bash |
153 | | -cd <root> |
154 | | -yarn test |
| 175 | +# Run all tests |
| 176 | +npm test |
| 177 | + |
| 178 | +# Run tests in watch mode |
| 179 | +npm run test:watch |
| 180 | + |
| 181 | +# Run tests with coverage |
| 182 | +npm run test:coverage |
| 183 | +``` |
| 184 | + |
| 185 | +### Writing Tests |
| 186 | + |
| 187 | +- Place tests next to the code they test (e.g., `useResizer.test.ts`) |
| 188 | +- Use descriptive test names |
| 189 | +- Test both success and error cases |
| 190 | +- For hooks, use `@testing-library/react` and `renderHook` |
| 191 | + |
| 192 | +Example: |
| 193 | + |
| 194 | +```typescript |
| 195 | +import { describe, it, expect } from 'vitest'; |
| 196 | +import { renderHook } from '@testing-library/react'; |
| 197 | +import { useResizer } from './useResizer'; |
| 198 | + |
| 199 | +describe('useResizer', () => { |
| 200 | + it('initializes with provided sizes', () => { |
| 201 | + const { result } = renderHook(() => |
| 202 | + useResizer({ |
| 203 | + direction: 'horizontal', |
| 204 | + sizes: [300, 700], |
| 205 | + minSizes: [100, 100], |
| 206 | + maxSizes: [500, 900], |
| 207 | + }) |
| 208 | + ); |
| 209 | + |
| 210 | + expect(result.current.currentSizes).toEqual([300, 700]); |
| 211 | + }); |
| 212 | +}); |
155 | 213 | ``` |
| 214 | + |
| 215 | +<a name="code-style"></a> |
| 216 | + |
| 217 | +## Code Style |
| 218 | + |
| 219 | +- **TypeScript** — All code must be typed |
| 220 | +- **ESLint** — Run `npm run lint` before committing |
| 221 | +- **Prettier** — Code is auto-formatted |
| 222 | +- **No `any`** — Avoid `any` types; use `unknown` if necessary |
| 223 | +- **Functional** — Prefer functional components and hooks |
| 224 | +- **Comments** — Add JSDoc comments to exported functions |
| 225 | + |
| 226 | +### Example Component |
| 227 | + |
| 228 | +```typescript |
| 229 | +import type { CSSProperties } from 'react'; |
| 230 | + |
| 231 | +interface MyComponentProps { |
| 232 | + /** Description of the prop */ |
| 233 | + value: string; |
| 234 | + /** Optional prop with default */ |
| 235 | + size?: number; |
| 236 | +} |
| 237 | + |
| 238 | +/** |
| 239 | + * Description of the component. |
| 240 | + * |
| 241 | + * @example |
| 242 | + * ```tsx |
| 243 | + * <MyComponent value="hello" /> |
| 244 | + * ``` |
| 245 | + */ |
| 246 | +export function MyComponent({ value, size = 10 }: MyComponentProps) { |
| 247 | + // Implementation |
| 248 | +} |
| 249 | +``` |
| 250 | + |
| 251 | +## License |
| 252 | + |
| 253 | +By contributing, you agree to license your work under the [MIT License](./LICENSE). |
0 commit comments