-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
205 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,23 @@ | ||
# create-svelte | ||
# PaneForge | ||
|
||
Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte). | ||
Resizable pane components for Svelte. | ||
|
||
Read more about creating a library [in the docs](https://kit.svelte.dev/docs/packaging). | ||
|
||
## Creating a project | ||
|
||
If you're seeing this, you've probably already done this step. Congrats! | ||
|
||
```bash | ||
# create a new project in the current directory | ||
npm create svelte@latest | ||
|
||
# create a new project in my-app | ||
npm create svelte@latest my-app | ||
``` | ||
|
||
## Developing | ||
|
||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: | ||
## Installation | ||
|
||
```bash | ||
npm run dev | ||
|
||
# or start the server and open the app in a new browser tab | ||
npm run dev -- --open | ||
npm install paneforge | ||
``` | ||
|
||
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app. | ||
## Usage | ||
|
||
## Building | ||
```svelte | ||
<script lang="ts"> | ||
import { PaneGroup, Pane, PaneResizer } from "paneforge"; | ||
</script> | ||
To build your library: | ||
|
||
```bash | ||
npm run package | ||
``` | ||
|
||
To create a production version of your showcase app: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
You can preview the production build with `npm run preview`. | ||
|
||
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. | ||
## Publishing | ||
|
||
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/)). | ||
|
||
To publish your library to [npm](https://www.npmjs.com): | ||
|
||
```bash | ||
npm publish | ||
<PaneGroup direction="horizontal"> | ||
<Pane defaultSize={50}>Pane 1</Pane> | ||
<PaneResizer /> | ||
<Pane defaultSize={50}>Pane 2</Pane> | ||
</PaneGroup> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
title: Persistent Layouts | ||
description: Examples of persisting layouts across page loads. | ||
--- | ||
|
||
<script> | ||
import { StorageDemo, CookieDemo } from '$lib/components/demos' | ||
export let data; | ||
</script> | ||
|
||
## Local Storage | ||
|
||
The `PaneGroup` component has an `autoSaveId` prop that can be used to uniquely identify the layout of the panes within the group. When provided, the layout of the panes will be saved to local storage and restored when the page is reloaded. | ||
|
||
<StorageDemo /> | ||
|
||
### Anatomy | ||
|
||
Here's the high-level structure of the example above: | ||
|
||
```svelte title="+page.svelte" | ||
<script lang="ts"> | ||
import { PaneGroup, Pane, PaneResizer } from "paneforge"; | ||
</script> | ||
<PaneGroup direction="horizontal" autoSaveId="someGroupId"> | ||
<Pane defaultSize={50} /> | ||
<PaneResizer /> | ||
<Pane defaultSize={50} /> | ||
</PaneGroup> | ||
``` | ||
|
||
## Cookies (SSR-friendly) | ||
|
||
Local storage is not available on the server, so you can use cookies to persist the layout of the panes across page loads, ensuring no layout flicker when the page is first loaded. | ||
|
||
<CookieDemo layout={data.layout} /> | ||
|
||
### Anatomy | ||
|
||
Here's the high-level structure of the example above: | ||
|
||
```ts title="+page.server.ts" | ||
import type { PageServerLoad } from "./$types"; | ||
|
||
export const load: PageServerLoad = async (event) => { | ||
let layout = event.cookies.get("PaneForge:layout"); | ||
if (layout) { | ||
layout = JSON.parse(layout); | ||
} | ||
|
||
return { | ||
layout, | ||
}; | ||
}; | ||
``` | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { PaneGroup, Pane, PaneResizer } from "paneforge"; | ||
export let layout: number[] | undefined = undefined; | ||
function onLayoutChange(sizes: number[]) { | ||
document.cookie = `PaneForge:layout=${JSON.stringify(sizes)}`; | ||
} | ||
</script> | ||
<PaneGroup direction="horizontal" {onLayoutChange}> | ||
<Pane defaultSize={layout ? layout[0] : 50} /> | ||
<PaneResizer /> | ||
<Pane defaultSize={layout ? layout[1] : 50} /> | ||
</PaneGroup> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: Getting Started | ||
description: Learn how to install and use Paneforge in your projects. | ||
--- | ||
|
||
## Installation | ||
|
||
Install Paneforge using your favorite package manager: | ||
|
||
```bash | ||
npm install paneforge | ||
``` | ||
|
||
## Basic Usage | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import { PaneGroup, Pane, PaneResizer } from "paneforge"; | ||
</script> | ||
<PaneGroup direction="horizontal"> | ||
<Pane defaultSize={50}>Pane 1</Pane> | ||
<PaneResizer /> | ||
<Pane defaultSize={50}>Pane 2</Pane> | ||
</PaneGroup> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.