1.1.1 • Published 10 months ago

sly-svelte-pane v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Svelte Pane

A lightweight, flexible Svelte library for creating resizable pane layouts in your web applications, leveraging CSS variables and grid for flexible layouts.

Features

  • Create draggable and resizable panes using CSS Grid
  • Utilizes CSS variables for dynamic sizing
  • Customizable drag handles
  • Responsive design
  • TypeScript support

Installation

pnpm add sly-svelte-pane

Usage

1. Import the components

<script>
  import { DraggableEdge } from 'sly-svelte-pane';
</script>

2. Create a resizable pane layout

<main class="pane-grid-container">
    <div class="pane">
        <h1>Pane 1</h1>
        <DraggableEdge
            options={{
                property: "--center-scale",
                anchor: "right",
                gridSelector: ".pane-grid-container",
            }}
        />
    </div>
    <div class="pane">
        <h1>Pane 2</h1>
        <DraggableEdge
            options={{
                property: "--center-scale-2",
                anchor: "right",
                gridSelector: ".pane-grid-container",
            }}
        />
    </div>
    <div class="pane">
        <h1>Pane 3</h1>
    </div>
</main>

3. Set up CSS variables and grid layout

<style>
    :root {
        --center-scale: 50%;
        --center-scale-max: 90%;
        --center-scale-min: 10%;
        --center-scale-2: 50%;
        --center-scale-2-max: 90%;
        --center-scale-2-min: 10%;
    }

    main {
        display: grid;
        grid-template-columns: var(--center-scale) var(--center-scale-2) 1fr;
    }
</style>

Styling

The package includes default styles for the draggable edge. You can customize these styles by overriding the following CSS classes:

  • .sly-draggable-edge-root: Styles the root container of the draggable edge.
  • .sly-draggable-edge-touchable: Styles the touchable area of the draggable edge.

Example of custom styling:

.sly-draggable-edge-root {
  background: #007bff;
}

.sly-draggable-edge-touchable {
   cursor: col-resize;
}

API

DraggableEdge

A Svelte component that creates a draggable edge for resizing panes. Place it inside the grid element you want to resize.

Props:

  • options: DraggableOptions (required)

DraggableOptions

{
  property: string;       // CSS variable to update (e.g., "--center-scale")
  anchor: "left" | "right" | "top" | "bottom";  // Edge anchor position
  gridSelector: string;   // Selector for the parent grid container
}

License

MIT

1.1.1

10 months ago

1.1.0

10 months ago

1.0.33

10 months ago

1.0.32

10 months ago

1.0.31

10 months ago

1.0.30

10 months ago

1.0.29

10 months ago

1.0.28

10 months ago

1.0.27

10 months ago

1.0.26

10 months ago

1.0.25

10 months ago

1.0.24

10 months ago

1.0.23

10 months ago

1.0.22

10 months ago

1.0.21

10 months ago

1.0.20

10 months ago

1.0.19

10 months ago

1.0.18

10 months ago

1.0.17

10 months ago

1.0.16

10 months ago

1.0.15

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago