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

react-better-splitviews

v1.2.5

Published

A great react component with a simple API that mimics the way SplitViews operate in visual studio code.

Downloads

39

Readme

Handle Split Views like it's 2022

Live demo

Nowadays, split views are everywhere, and yet it looked like there wasn't a great one, with an easy-to-use API, for React -- so we made one. We've fetched great inspiration from the Visual Studio Code split views. They're discrete, and they feel great.

🐥 Tiny ~4.7kb

🐼 Written in TypeScript

🦁 Use standard CSS properties to customize the SplitView and it's views

🦄 A simple, easy-to-use API, and a beautiful SplitView! No redundancy! All hail the unicorns!

TypeScript-lovers notice: All type declarations are included in the package. No need to install @types.

Installation

npm i react-better-splitviews
// OR
yarn add react-better-splitviews

and

import { SplitView } from "react-better-splitviews";

Examples

There are 2 orientations you can use for your SplitView: rows or columns.

1. Rows (default)

import { SplitView } from "react-better-splitviews";

const CustomComponent = () => {
  return (
    <SplitView style={{ height: "500px" }}>
      <div>First View</div>
      <div>Second View</div>
      <div>Third View</div>
    </SplitView>
  );
};
import { SplitView } from "react-better-splitviews";

const CustomComponent = () => {
  return (
    <SplitView style={{ height: "500px" }}>
      {/* Width will start at 10 pixels */}
      <div style={{ width: "10px" }}>First View</div>

      {/*
        Width will start at 50% of the SplitView's 
        It can't be shrunk under 110 pixels
      */}
      <div style={{ width: "50%", minWidth: 110 }}>Second View</div>

      {/* 
        Width will take all remaining space 
        It can't be shrunk under 100 pixels
        It can't be stretched above 300 pixels
      */}
      <div style={{ minWidth: 100, maxWidth: 300 }}>Third View</div>
    </SplitView>
  );
};

2. Columns

import { SplitView } from "react-better-splitviews";

const CustomComponent = () => {
  return (
    <SplitView style={{ height: "500px" }} direction="column">
      <div>First View</div>
      <div>Second View</div>
      <div>Third View</div>
    </SplitView>
  );
};
import { SplitView } from "react-better-splitviews";

const CustomComponent = () => {
  return (
    <SplitView style={{ height: "500px" }} direction="column">
      {/* Height will start at 10 pixels */}
      <div style={{ height: "10px" }}>First View</div>

      {/*
        Height will start at 50% of the SplitView's 
        It can't be shrunk under 110 pixels
      */}
      <div style={{ height: "50%", minHeight: 110 }}>Second View</div>

      {/* 
        Height will take all remaining space 
        It can't be shrunk under 100 pixels
        It can't be stretched above 300 pixels
      */}
      <div style={{ minHeight: 100, maxHeight: 300 }}>Third View</div>
    </SplitView>
  );
};

3. Combine them

Support for various combinations of Splitviews is supported. For example, this looks a bit like the Visual Studio Code layout.

import { SplitView } from "react-better-splitviews";

const CustomComponent = () => {
  return (
    <SplitView id="container">
      <SplitView id="side-bar" style={{ width: "25%" }} direction="column">
        <Workspace style={{ minHeight: 24 }} />
        <Outline style={{ minHeight: 24 }} />
        <TimeLine style={{ minHeight: 24 }} />
      </SplitView>
      <SplitView
        id="editors_panel"
        style={{ minWidth: 100 }}
        direction="column"
      >
        <SplitView id="editors" style={{ minWidth: 100 }} direction="row">
          <Editor style={{ width: 250 }} />
          <Editor style={{ minWidth: 100 }} />
          <Editor style={{ minWidth: 100 }} />
        </SplitView>
        <Panel style={{ height: "25%" }} />
      </SplitView>
    </SplitView>
  );
};

Please let us know if you need more examples.

Contributing

While we are confident this library will work for most use cases, it is still young. We welcome any feedback, recommendations and pull requests to make it even better!

API

SplitViewProperties

| Prop | Type | Description | Default | | --------------- | ------------- | ------------------------------------------------------------------------------------------- | ----------------------------------- | | style | CSSProperties | Object with CSS Properties to be applied to the SplitView | { height: "100%", width: "100%" } | | direction | Direction | Specifies the direction of the splitview. Much like Flexboxes, it can be row or column. | "row" | | handleOptions | HandleOptions | Specified the looks and feel of the Handle. | see HandleOptions | | onGrabHandle | Function | Gets called when a handle is grabbed by the user. | undefined (is not called) | | onDragHandle | Function | Gets called when a handle is moved by the user. | undefined (is not called) | | onReleaseHandle | Function | Gets called when a handle is released by the user. | undefined (is not called) |

HandleOptions

| Prop | Type | Description | Default | | ------------ | ------ | ------------------------------------------------------------------------------------------------------------ | ------------- | | focusedColor | string | When the handle is focused (hovered, selected), this is the color it will display. Any CSS colors work here. | "#0D6EFD" | | focusedSize | number | When the handle is focused (hovered, selected), this is the size (in pixels) it will have. | 5 | | defaultColor | string | This is the default color it will display. Any CSS colors work here. | "lightgray" | | defaultSize | number | This is the default size (in pixels) it will have. | 1 |

License

MIT

Sharing is caring ❤️

Show us some love and STAR ⭐ the project if you find it useful

Send us pictures of what you did the Better SplitViews library; we can't wait to see what the community will do with it! Cheers