Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zendeskgarden/container-splitter

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zendeskgarden/container-splitter

Containers relating to Splitter in the Garden Design System

  • 2.0.20
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
80K
decreased by-22.43%
Maintainers
0
Weekly downloads
 
Created
Source

@zendeskgarden/container-splitter npm version

This package includes containers relating to Splitter in the Garden Design System.

Installation

npm install @zendeskgarden/container-splitter

Usage

This container implements the window splitter design pattern and can be used to build a splitter component. Check out storybook for live examples.

useSplitter

The useSplitter hook manages positioning and required accessibility attributes for the window splitting separator.

import {
  useSplitter,
  SplitterType,
  SplitterOrientation,
  SplitterPosition
} from '@zendeskgarden/container-splitter';

const Splitter = () => {
  const { getSeparatorProps, getPrimaryPaneProps, valueNow } = useSplitter({
    label: 'primary-pane',
    type: SplitterType.VARIABLE,
    orientation: SplitterOrientation.VERTICAL,
    min: 50,
    max: 100,
    position: SplitterPosition.TRAILS,
    environment: window
  });

  const separatorProps = getSeparatorProps();
  const primaryPaneProps = getPrimaryPaneProps();

  return (
    <div style={{ display: 'flex' }}>
      <div {...primaryPaneProps} style={{ flex: `0 0 ${valueNow}px` }}>
        <p>Primary Pane</p>
      </div>
      <div style={{ flex: '0 0 5px' }} {...separatorProps} />
      <div style={{ flex: '1 1 auto' }}>
        <p>Secondary Pane</p>
      </div>
    </div>
  );
};

SplitterContainer

SplitterContainer is a render-prop wrapper for the useSplitter hook.

import {
  SplitterContainer,
  SplitterType,
  SplitterOrientation,
  SplitterPosition
} from '@zendeskgarden/container-splitter';

<SplitterContainer
  label="primary-pane"
  type={SplitterType.VARIABLE}
  orientation={SplitterOrientation.VERTICAL}
  min={50}
  max={100}
  position={SplitterPosition.TRAILS}
  environment={window}
>
  {({ getSeparatorProps, getPrimaryPaneProps, valueNow }) => {
    const separatorProps = getSeparatorProps();
    const primaryPaneProps = getPrimaryPaneProps();

    return (
      <div id="container" style={{ display: 'flex' }}>
        <div {...primaryPaneProps} style={{ flex: `0 0 ${valueNow}px` }}>
          <p>Primary Pane</p>
        </div>
        <div style={{ flex: '0 0 5px' }} {...separatorProps} />
        <div style={{ flex: '1 1 auto' }}>
          <p>Secondary Pane</p>
        </div>
      </div>
    );
  }}
</SplitterContainer>;

Keywords

FAQs

Package last updated on 25 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc