Skip to content

Commit 637dfc7

Browse files
committed
Add detailed JSDoc comments for SplitPane, Pane, Divider, hooks, and examples; include accessibility improvements, touch support, and new Snap Points/Tutorial examples.
1 parent 629af02 commit 637dfc7

16 files changed

Lines changed: 2222 additions & 99 deletions

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,38 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [3.0.0](https://github.com/tomkp/react-split-pane/compare/v0.1.92...v3.0.0) (2024-12-22)
6+
7+
### ⚠ BREAKING CHANGES
8+
9+
* Complete rewrite with modern React patterns
10+
* Children must now be wrapped in `<Pane>` components
11+
* `split` prop renamed to `direction` (and meanings swapped to align with CSS flex)
12+
* Size constraints (`minSize`, `maxSize`, `defaultSize`) moved to `<Pane>` component
13+
* Callback props renamed: `onDragStarted``onResizeStart`, `onChange``onResize`, `onDragFinished``onResizeEnd`
14+
* Callback signatures changed to include event metadata
15+
* `primary` prop removed (use controlled mode instead)
16+
* `allowResize` renamed to `resizable`
17+
* CSS class names changed: `SplitPane``split-pane`, `Resizer``split-pane-divider`
18+
* IE11 no longer supported
19+
20+
### Features
21+
22+
* **Hooks-based architecture**: Complete rewrite using modern React hooks
23+
* **TypeScript**: Full TypeScript support with strict mode
24+
* **Accessibility**: Full keyboard navigation (arrow keys, Home, End) and ARIA attributes
25+
* **Touch support**: Built-in touch event handling for mobile devices
26+
* **Snap points**: Optional snap-to positions during resize
27+
* **Multiple panes**: Native support for 2+ panes without nesting
28+
* **Persistence hook**: `usePersistence` hook for localStorage/sessionStorage
29+
* **Custom dividers**: Pass custom divider components via `divider` prop
30+
* **RAF-throttled**: Smooth resize performance with requestAnimationFrame throttling
31+
* **Smaller bundle**: < 5KB gzipped
32+
33+
### Migration
34+
35+
See [MIGRATION.md](./MIGRATION.md) for detailed upgrade instructions from v0.1.x.
36+
537
### [0.1.92](https://github.com/tomkp/react-split-pane/compare/v0.1.91...v0.1.92) (2020-08-10)
638

739

CONTRIBUTING.md

Lines changed: 184 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,253 @@
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
22

3-
# Contributing to this project
3+
[Bug Reports](#bugs) | [Feature Requests](#features) | [Pull Requests](#pull-requests) | [Development Setup](#development-setup) | [Running Tests](#running-tests)
44

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.
66

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
98

10-
## Using the issue tracker
9+
The issue tracker is the preferred channel for bug reports and feature requests. Please respect these guidelines:
1110

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.
1613

1714
<a name="bugs"></a>
1815

19-
## Bug reports
16+
## Bug Reports
2017

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!
2319

2420
Guidelines for bug reports:
2521

26-
1. **Use the GitHub issue search** &mdash; check if the issue has already been reported.
27-
2. **Check if the issue has been fixed** &mdash; try to reproduce it using the latest `master` or development branch in the repository.
28-
3. **Isolate the problem** &mdash; 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/).
3625

37-
Example:
26+
A good bug report includes:
3827

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
5334

5435
<a name="features"></a>
5536

56-
## Feature requests
37+
## Feature Requests
5738

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:
6240

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)
6445

65-
## Pull requests
46+
<a name="pull-requests"></a>
6647

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
6949

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.
7251

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.
7453

75-
Follow this process if you'd like your work considered for inclusion in the project:
54+
### Pull Request Process
7655

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:
7857

7958
```bash
80-
# Clone your fork of the repo into the current directory
8159
git clone https://github.com/<your-username>/react-split-pane
82-
# Navigate to the newly cloned directory
8360
cd react-split-pane
84-
# Assign the original repo to a remote called "upstream"
8561
git remote add upstream https://github.com/tomkp/react-split-pane
8662
```
8763

88-
2. If you cloned a while ago, get the latest changes from upstream:
64+
2. Create a branch from `v3`:
8965

9066
```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
9370
```
9471

95-
3. Install/update dependencies:
72+
3. Install dependencies:
9673

9774
```bash
98-
yarn install
75+
npm install
9976
```
10077

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:
10383

10484
```bash
105-
git checkout -b <topic-branch-name>
85+
npm test
10686
```
10787

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:
11389

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:
11595

11696
```bash
117-
git pull [--rebase] upstream master
97+
git commit -m "feat: add new feature"
11898
```
11999

120-
7. Push your topic branch up to your fork:
100+
9. Push and open a pull request against `v3`:
121101

122102
```bash
123-
git push origin <topic-branch-name>
103+
git push origin my-feature
124104
```
125105

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>
128119

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
130121

131-
<a name="running-local-demo"></a>
122+
### Prerequisites
132123

133-
## Running Local Demo
124+
- Node.js 18+
125+
- npm 9+
134126

135-
You can run the local demo with yarn like so:
127+
### Setup
136128

137129
```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
141139
```
142140

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 |
144167

145168
<a name="running-tests"></a>
146169

147170
## Running Tests
148171

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.
151173

152174
```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+
});
155213
```
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

Comments
 (0)