npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flexisplit

v1.0.5

Published

**FlexiSplit** is a flexible, framework-agnostic splitter component for building resizable and collapsible panels in web applications. It can be used with **vanilla JavaScript**, **jQuery**, **React**, and **Angular**. This splitter makes it easy to creat

Downloads

307

Readme

FlexiSplit

FlexiSplit is a flexible, framework-agnostic splitter component for building resizable and collapsible panels in web applications. It can be used with vanilla JavaScript, jQuery, React, and Angular. This splitter makes it easy to create dynamic layouts with adjustable panels and customizable gutters.

Features

  • Vertical and Horizontal Splits: Easily split content either horizontally or vertically.
  • Resizable Panels: Users can drag the gutter to resize the panels.
  • Collapsible Panels: Option to collapse and expand panels with a button in the gutter.
  • Framework Agnostic: Works with vanilla JS, jQuery, React, and Angular.
  • Configurable: Highly customizable options like panel sizes, gutter size, and minimum panel size.
  • Auto CSS Class Assignment: Automatically adds required CSS classes to the container and panels.
  • Global or Module Support: FlexiSplit can be used both with module imports (React, Angular) and global script inclusions (vanilla JS, jQuery).

Installation

Install FlexiSplit via npm:

npm install flexisplit

After installation, make sure to include the CSS file for proper styling:

HTML (Vanilla JS or jQuery)

<link rel="stylesheet" href="node_modules/flexisplit/css/flexisplit.css">

For React or Angular, import the CSS:

import 'flexisplit/css/flexisplit.css';

Usage

Vanilla JavaScript or jQuery Example

  1. HTML Structure:

    <div id="container">
        <div id="panel1">Panel 1</div>
        <div id="panel2">Panel 2</div>
    </div>
  2. Include Split.js via CDN:

    <script src="https://cdn.jsdelivr.net/npm/split.js/dist/split.min.js"></script>
  3. JavaScript Initialization (for jQuery):

    <script>
    $(document).ready(function() {
        const splitter = new FlexiSplit($('#panel1')[0], $('#panel2')[0], {
            direction: 'horizontal',  // Use 'vertical' for vertical split
            percentage1: 70,          // 70% width for panel1
            percentage2: 30,          // 30% width for panel2
            gutterSize: 10,           // 10px gutter size
            minSize1: 100,            // Minimum size for panel1
            minSize2: 100,            // Minimum size for panel2
            collapseButtonVisible: true  // Show collapse button
        });
    });
    </script>

React Example

  1. React Component:

    import React, { useEffect, useRef } from 'react';
    import FlexiSplit from 'flexisplit';
    import 'flexisplit/css/flexisplit.css';
    
    const FlexiSplitReact = ({ id1, id2, options }) => {
        const panel1Ref = useRef(null);
        const panel2Ref = useRef(null);
    
        useEffect(() => {
            new FlexiSplit(panel1Ref.current, panel2Ref.current, options);
        }, []);
    
        return (
            <div>
                <div id={id1} ref={panel1Ref}>Panel 1</div>
                <div id={id2} ref={panel2Ref}>Panel 2</div>
            </div>
        );
    };
    
    export default FlexiSplitReact;
  2. Usage in Parent Component:

    import React from 'react';
    import FlexiSplitReact from './FlexiSplitReact';
    
    const App = () => {
        return (
            <div>
                <FlexiSplitReact id1="left-panel" id2="right-panel" options={{ direction: 'horizontal' }} />
            </div>
        );
    };
    
    export default App;

Angular Example

  1. Angular Component:

    import { Component, ElementRef, AfterViewInit } from '@angular/core';
    import FlexiSplit from 'flexisplit';
    import 'flexisplit/css/flexisplit.css';
    
    @Component({
      selector: 'app-flexisplit',
      template: `
        <div id="panel1">Panel 1</div>
        <div id="panel2">Panel 2</div>
      `,
      styles: []
    })
    export class FlexiSplitComponent implements AfterViewInit {
    
      constructor(private elRef: ElementRef) {}
    
      ngAfterViewInit() {
        const panel1 = this.elRef.nativeElement.querySelector('#panel1');
        const panel2 = this.elRef.nativeElement.querySelector('#panel2');
        new FlexiSplit(panel1, panel2, { direction: 'horizontal' });
      }
    }
  2. Usage in Parent Component:

    import { Component } from '@angular/core';
    
    @Component({
      selector: 'app-root',
      template: `
        <app-flexisplit></app-flexisplit>
      `,
      styles: []
    })
    export class AppComponent {}

Options

| Option | Description | Default Value | |------------------------|-----------------------------------------------------------------------------|---------------| | percentage1 | The initial size percentage of the first panel (left or top). | 50 | | percentage2 | The initial size percentage of the second panel (right or bottom). | 50 | | minSize1 | Minimum size (in pixels) of the first panel. | 100 | | minSize2 | Minimum size (in pixels) of the second panel. | 100 | | gutterSize | Size of the gutter (the draggable area between the panels). | 10 | | direction | Direction of the splitter: 'vertical' or 'horizontal'. | 'vertical' | | collapseButtonVisible | Whether or not to show a collapse button inside the gutter. | true | | initiallyCollapsed | Whether the second panel should be collapsed initially. | false |

Methods

  • collapse(): Programmatically collapses the second panel.
  • expand(): Programmatically expands the second panel to its initial size.
  • toggle(): Toggles between collapsing and expanding the second panel.

License

MIT License