Skip to content

Commit 35e4f87

Browse files
authored
chore: cleanup and docs (#1)
1 parent 1484790 commit 35e4f87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+436
-309
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
33
"changelog": [
44
"@svitejs/changesets-changelog-github-compact",
5-
{ "repo": "huntabyte/paneforge" }
5+
{ "repo": "svecosystem/paneforge" }
66
],
77
"commit": false,
88
"fixed": [],

.changeset/old-years-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"paneforge": patch
3+
---
4+
5+
Initial release 🎉

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
11
# Paneforge
2+
3+
PaneForge provides components that make it easy to create resizable panes in your Svelte apps. It's designed to be simple to use, and to work well with other Svelte components and libraries. This project has taken a lot of inspiration and code from the work done by [Bryan Vaughn](https://github.com/bvaughn) and [react-resizable-panels](https://github.com/bvaughn/react-resizable-panels) and seeks to provide a similar experience for Svelte developers.
4+
5+
## Features
6+
7+
- **Simple API**: PaneForge is designed to be easy to use. It provides a small set of components that can be combined to create complex layouts.
8+
- **Resizable Panes**: Panes can be resized by dragging the resizer between them.
9+
- **Nested Groups**: Groups of panes can be nested inside other groups to create complex layouts.
10+
- **Customizable**: The appearance and behavior of the panes can be customized using CSS and Svelte props.
11+
- **Persistent Layouts**: PaneForge can be used with LocalStorage or cookies to persist the layout of the panes between page loads.
12+
- **Accessible**: PaneForge is designed to be accessible to all users, including those who use assistive technologies.
13+
- **Community-driven**: PaneForge is an open-source project that welcomes contributions from the community. If you have an idea for a new feature or an improvement, we'd love to hear from you!
14+
15+
## Installation
16+
17+
```bash
18+
npm install paneforge
19+
```
20+
21+
## Basic Usage
22+
23+
Here's a simple example of how to use Paneforge to create a horizontal pane group with two panes:
24+
25+
```svelte
26+
<script lang="ts">
27+
import { PaneGroup, Pane, PaneResizer } from "paneforge";
28+
</script>
29+
30+
<PaneGroup direction="horizontal">
31+
<Pane defaultSize={50}>Pane 1</Pane>
32+
<PaneResizer />
33+
<Pane defaultSize={50}>Pane 2</Pane>
34+
</PaneGroup>
35+
```
36+
37+
The `PaneGroup` component is used to initialize a pane group, and the `Pane` component is used to create a pane. The `PaneResizer` component is used to create a resizer that can be dragged to resize the panes.
38+
39+
The components ship only with the styles necessary to position the panes in the appropriate layout. The rest of the styling is up to you.
40+
41+
For more information, see the [Documentation](https://paneforge.com).

packages/paneforge/.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"singleQuote": false,
44
"trailingComma": "es5",
55
"printWidth": 100,
6-
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
6+
"plugins": ["prettier-plugin-svelte"],
77
"overrides": [
88
{
99
"files": "*.svelte",

packages/paneforge/README.md

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,41 @@
1-
# create-svelte
1+
# Paneforge
22

3-
Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
3+
PaneForge provides components that make it easy to create resizable panes in your Svelte apps. It's designed to be simple to use, and to work well with other Svelte components and libraries. This project has taken a lot of inspiration and code from the work done by [Bryan Vaughn](https://github.com/bvaughn) and [react-resizable-panels](https://github.com/bvaughn/react-resizable-panels) and seeks to provide a similar experience for Svelte developers.
44

5-
Read more about creating a library [in the docs](https://kit.svelte.dev/docs/packaging).
5+
## Features
66

7-
## Creating a project
7+
- **Simple API**: PaneForge is designed to be easy to use. It provides a small set of components that can be combined to create complex layouts.
8+
- **Resizable Panes**: Panes can be resized by dragging the resizer between them.
9+
- **Nested Groups**: Groups of panes can be nested inside other groups to create complex layouts.
10+
- **Customizable**: The appearance and behavior of the panes can be customized using CSS and Svelte props.
11+
- **Persistent Layouts**: PaneForge can be used with LocalStorage or cookies to persist the layout of the panes between page loads.
12+
- **Accessible**: PaneForge is designed to be accessible to all users, including those who use assistive technologies.
13+
- **Community-driven**: PaneForge is an open-source project that welcomes contributions from the community. If you have an idea for a new feature or an improvement, we'd love to hear from you!
814

9-
If you're seeing this, you've probably already done this step. Congrats!
15+
## Installation
1016

1117
```bash
12-
# create a new project in the current directory
13-
npm create svelte@latest
14-
15-
# create a new project in my-app
16-
npm create svelte@latest my-app
18+
npm install paneforge
1719
```
1820

19-
## Developing
21+
## Basic Usage
2022

21-
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
23+
Here's a simple example of how to use Paneforge to create a horizontal pane group with two panes:
2224

23-
```bash
24-
npm run dev
25+
```svelte
26+
<script lang="ts">
27+
import { PaneGroup, Pane, PaneResizer } from "paneforge";
28+
</script>
2529
26-
# or start the server and open the app in a new browser tab
27-
npm run dev -- --open
30+
<PaneGroup direction="horizontal">
31+
<Pane defaultSize={50}>Pane 1</Pane>
32+
<PaneResizer />
33+
<Pane defaultSize={50}>Pane 2</Pane>
34+
</PaneGroup>
2835
```
2936

30-
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31-
32-
## Building
37+
The `PaneGroup` component is used to initialize a pane group, and the `Pane` component is used to create a pane. The `PaneResizer` component is used to create a resizer that can be dragged to resize the panes.
3338

34-
To build your library:
39+
The components ship only with the styles necessary to position the panes in the appropriate layout. The rest of the styling is up to you.
3540

36-
```bash
37-
npm run package
38-
```
39-
40-
To create a production version of your showcase app:
41-
42-
```bash
43-
npm run build
44-
```
45-
46-
You can preview the production build with `npm run preview`.
47-
48-
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
49-
50-
## Publishing
51-
52-
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53-
54-
To publish your library to [npm](https://www.npmjs.com):
55-
56-
```bash
57-
npm publish
58-
```
41+
For more information, see the [Documentation](https://paneforge.com).

packages/paneforge/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
},
1313
"scripts": {
1414
"dev": "pnpm watch",
15-
"build": "vite build && npm run package",
15+
"build": "pnpm package",
1616
"preview": "vite preview",
1717
"package": "svelte-kit sync && svelte-package && publint",
18-
"prepublishOnly": "npm run package",
18+
"prepublishOnly": "pnpm run package",
1919
"test": "npm run test:integration && npm run test:unit",
2020
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
2121
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { default as PaneGroup } from "./pane-group.svelte";
22
export { default as Pane } from "./pane.svelte";
3-
export { default as PaneResizeHandle } from "./pane-resize-handle.svelte";
3+
export { default as PaneResizer } from "./pane-resizer.svelte";
44
export type * from "./types.js";

packages/paneforge/src/lib/components/pane-group.svelte

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
export let onLayoutChange: PaneGroupOnLayout | null = null;
1515
export let storage: PaneGroupStorage = defaultStorage as PaneGroupStorage;
1616
export let el: $$Props["el"] = undefined;
17-
export let api: $$Props["api"] = undefined;
17+
export let paneGroup: $$Props["paneGroup"] = undefined;
1818
1919
let styleFromProps: $$Props["style"] = undefined;
2020
export { styleFromProps as style };
2121
2222
const {
2323
states: { paneGroupStyle, paneGroupSelectors, groupId },
2424
methods: { setLayout, getLayout },
25+
updateOption,
2526
} = setCtx({
2627
autoSaveId,
2728
direction,
@@ -31,7 +32,14 @@
3132
storage,
3233
});
3334
34-
api = {
35+
$: updateOption("autoSaveId", autoSaveId);
36+
$: updateOption("direction", direction);
37+
$: updateOption("id", id);
38+
$: updateOption("keyboardResizeBy", keyboardResizeBy);
39+
$: updateOption("onLayout", onLayoutChange);
40+
$: updateOption("storage", storage);
41+
42+
paneGroup = {
3543
getLayout,
3644
setLayout,
3745
getId: () => $groupId,

packages/paneforge/src/lib/components/pane-resize-handle.svelte renamed to packages/paneforge/src/lib/components/pane-resizer.svelte

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import { getCursorStyle, generateId, styleToString } from "$lib/internal/utils/index.js";
88
import { onMount } from "svelte";
99
import { getCtx } from "./ctx.js";
10-
import { resizeHandleAction } from "./pane-resize-handle.js";
11-
import type { PaneResizeHandleProps, PaneResizeHandleAttributes } from "./types.js";
10+
import { resizeHandleAction } from "./pane-resizer.js";
11+
import type { PaneResizerProps, PaneResizerAttributes } from "./types.js";
1212
13-
type $$Props = PaneResizeHandleProps;
13+
type $$Props = PaneResizerProps;
1414
1515
export let disabled: $$Props["disabled"] = false;
1616
export let onDraggingChange: $$Props["onDraggingChange"] = undefined;
@@ -25,7 +25,7 @@
2525
const {
2626
methods: { registerResizeHandle, startDragging, stopDragging },
2727
states: { direction, dragState, groupId },
28-
} = getCtx("PaneResizeHandle");
28+
} = getCtx("PaneResizer");
2929
3030
const resizeHandleId = generateId(idFromProps);
3131
$: isDragging = $dragState?.dragHandleId === resizeHandleId;
@@ -98,12 +98,13 @@
9898
}) + styleFromProps ?? "";
9999
100100
$: attrs = {
101-
"data-pane-group-direction": $direction,
101+
"data-direction": $direction,
102102
"data-pane-group-id": $groupId,
103103
"data-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
104104
"data-enabled": !disabled,
105-
"data-pane-resize-handle-id": resizeHandleId,
106-
} satisfies PaneResizeHandleAttributes;
105+
"data-pane-resizer-id": resizeHandleId,
106+
"data-pane-resizer": "",
107+
} satisfies PaneResizerAttributes;
107108
</script>
108109

109110
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->

packages/paneforge/src/lib/components/pane-resize-handle.ts renamed to packages/paneforge/src/lib/components/pane-resizer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
import { chain } from "$lib/internal/utils/chain.js";
77
import { addEventListener } from "$lib/internal/utils/event.js";
88

9-
type ResizeHandleActionParams = {
9+
type ResizerActionParams = {
1010
disabled?: boolean;
1111
resizeHandler: ResizeHandler | null;
1212
isDragging?: boolean;
@@ -18,9 +18,9 @@ type ResizeHandleActionParams = {
1818
* A Svelte action that adds resize handle functionality to an element.
1919
* This action is used to handle the dragging of a resize handle.
2020
*/
21-
export function resizeHandleAction(node: HTMLElement, params: ResizeHandleActionParams) {
21+
export function resizeHandleAction(node: HTMLElement, params: ResizerActionParams) {
2222
let unsub = () => {};
23-
function update(params: ResizeHandleActionParams) {
23+
function update(params: ResizerActionParams) {
2424
unsub();
2525
const { disabled, resizeHandler, isDragging, stopDragging, onDragging = undefined } = params;
2626
if (disabled || resizeHandler === null || !isDragging) return;

0 commit comments

Comments
 (0)