All Projects → alesgenova → Split Me

alesgenova / Split Me

Licence: mit
Universal web component to create resizable split layouts

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Split Me

Beverage Starter Flow
Simple Example Web Application for Vaadin Flow
Stars: ✭ 24 (-65.22%)
Mutual labels:  webcomponents
Masonry Layout
An efficient and fast web component that gives you a beautiful masonry layout
Stars: ✭ 43 (-37.68%)
Mutual labels:  webcomponents
Custom Element
A base class for Web Components (Custom Elements) which provides simple data binding.
Stars: ✭ 60 (-13.04%)
Mutual labels:  webcomponents
Reactshadow
🔰 Utilise Shadow DOM in React with all the benefits of style encapsulation.
Stars: ✭ 948 (+1273.91%)
Mutual labels:  webcomponents
Egghead Typescript Vuejs Apps
Stars: ✭ 41 (-40.58%)
Mutual labels:  webcomponents
Svelte Custom Elements
Turn Svelte components into web components
Stars: ✭ 45 (-34.78%)
Mutual labels:  webcomponents
Blazor.fast
A tiny wrapper around Fast and Fluent Web Components to integrate with Blazor and easily use the EditForm components
Stars: ✭ 23 (-66.67%)
Mutual labels:  webcomponents
Web Components Angular React
Multiple apps as components POC
Stars: ✭ 64 (-7.25%)
Mutual labels:  webcomponents
Osagai
🀄️A tiny library for creating WebComponents in a Functional way
Stars: ✭ 42 (-39.13%)
Mutual labels:  webcomponents
Login Fire
An element that allows simple configuration of multiple provider login for firebase
Stars: ✭ 58 (-15.94%)
Mutual labels:  webcomponents
Codeparadise
Web based platform for kids to learn to program using Object Oriented principles in Smalltalk
Stars: ✭ 35 (-49.28%)
Mutual labels:  webcomponents
Lwc
⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
Stars: ✭ 974 (+1311.59%)
Mutual labels:  webcomponents
Polymer Quill
Polymer Quill Rich Text Editor
Stars: ✭ 48 (-30.43%)
Mutual labels:  webcomponents
Vaadin Form Layout
The Web Component providing configurable responsive layout for form elements. Part of the Vaadin components.
Stars: ✭ 15 (-78.26%)
Mutual labels:  webcomponents
Deckdeckgo
The web open source editor for presentations
Stars: ✭ 1,117 (+1518.84%)
Mutual labels:  webcomponents
Nice Anim
An animate on scroll Web Component built with StencilJS
Stars: ✭ 23 (-66.67%)
Mutual labels:  webcomponents
Html Modules Toolkit
Transforming HTML standards of the future into JavaScript standards of the past
Stars: ✭ 45 (-34.78%)
Mutual labels:  webcomponents
Onsenui
Mobile app development framework and SDK using HTML5 and JavaScript. Create beautiful and performant cross-platform mobile apps. Based on Web Components, and provides bindings for Angular 1, 2, React and Vue.js.
Stars: ✭ 8,518 (+12244.93%)
Mutual labels:  webcomponents
Patterns Library
AXA CH UI components library. Please share, comment, create issues and work with us!
Stars: ✭ 63 (-8.7%)
Mutual labels:  webcomponents
Gwt Api Generator
Generator for creating GWT JSInterop clients from Polymer Web Components
Stars: ✭ 49 (-28.99%)
Mutual labels:  webcomponents

npm package workflow status Published on webcomponents.org Built With Stencil

SplitMe - Universal Splitter

SplitMe is a universal splitter built with Stencil. It can be embedded in projects using any framework or even plain HTML.

See a Live Demo.

demo

Table of Contents

Setup

Option 1 (HTML)

Add the SplitMe script tag to your index.html:

<script src="https://unpkg.com/split-me/dist/split-me.js"></script>

Option 2 (React / Angular / Vue)

Add SplitMe to your project:

npm install --save split-me

Import SplitMe in your index.js:

import { defineCustomElements as defineSplitMe } from 'split-me/loader';

defineSplitMe(window);

Basic Usage

Use the split-me tag anywhere you like. Set the number of slots in the splitter through the n attribute. Set the order the inner elements through the slot attribute:

<split-me n="2">
  <div slot="0" class="fill red"></div>
  <div slot="1" class="fill green"></div>
</split-me>

<style>
  .fill {
    height: 100%;
    width: 100%;
  }
</style>

Splitters can be arbitrarily nested into each other to achieve any layout.

<split-me n="3" sizes="0.3, 0.3, 0.4" min-sizes="0.2, 0.0, 0.0">
  <div slot="0" class="fill red"></div>
  <div slot="1" class="fill green"></div>
  <split-me slot="2" n="2" d="vertical" fixed>
    <div slot="0" class="fill blue"></div>
    <div slot="1" class="fill magenta"></div>
  </split-me>
</split-me>

Advanced Usage

Properties

Property Attribute Description Type
d d The direction of the splitter. "horizontal" | "vertical"
fixed fixed Prevent the splitter from being resized. boolean
maxSizes max-sizes The maximum sizes of the slots. Same format as sizes number[] | string
minSizes min-sizes The minimum sizes of the slots. Same format as sizes number[] | string
n n The number of slots in the splitter. number
sizes sizes The initial sizes of the slots. Acceptable formats are: sizes="0.33, 0.67" or sizes="50%, 25%, 25%" number[] | string
throttle throttle The minimum time (in ms) between resize events while dragging. number

Events

Event Detail Description
slotResized IResizeEvent Emitted every time dragging causes the slots to resize
interface IResizeEvent {
  sizes: number[]; // [0.25, 0.75]
  divider: number; // internal divider index
  originalEvent: MouseEvent | TouchEvent; // event that triggered resize
}

Saving State

function handle(event) {
  // extrapolate details
  const { sizes, divider, originalEvent } = event.detail;
  const sourceElement = event.target;

  console.log(sourceElement, originalEvent);
  console.dir({ divider, sizes });

  // store state
  localStorage.setItem('split-sizes', sizes);
}

const el = document.querySelector('split-me');

// loads sizes, but only if they have not been set yet.
el.sizes = el.sizes || localStorage.getItem('split-sizes');

// listen on changes
el.addEventListener('slotResized', handle);

Styling

SplitMe exposes a few CSS variables that can be overridden in order to adjust the styling of the dividers (gutters) to your liking.

This is the list of variables and their default values:

:host {
  --divider-length: 100%; /* Length of the divider along the principal axis */
  --divider-thickness: 0.15rem; /* Thickness of the divider */
  --divider-color: #eeeeee; /* Background color of the divider */
  --divider-shadow: 0 0 0.3rem black; /* Shadow of the divider */
  --divider-image-h: none; /* Background image of the divider when d="horizontal" */
  --divider-image-v: none; /* Background image of the divider when d="vertical" */
  --divider-background-repeat: no-repeat; /* Repeat rule of the background image */
  --divider-background-position: center; /* Position of the background image */
  --phantom-divider-thickness: 2rem; /* Thickness of the phantom divider used to grab mouse events */
}

Any of these variables can be overridden when using SplitMe in your app. For example, to make the dividers thicker and change their color to yellow:

<split-me n="2">
  <div slot="0" class="fill red"></div>
  <div slot="1" class="fill green"></div>
</split-me>

<style>
  :root split-me {
    --divider-thickness: 0.75rem;
    --divider-color: yellow;
  }
</style>

TODO

  • Prevent resizing
  • Specify initial sizes
  • Specify minimum and maximum sizes
  • Customizable splitter style
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].