Package detail

@ijsto/react-slideout

ijsto35ISC1.4.0

Lightweight & Accessible React Slideout Component

react, react-component, drawer, navigation

readme


react-slideout

Accessible SlideOut component for React.JS


📖 Table of Contents


📦 Installation

To install, you can use npm:

$ npm install @ijsto/react-slideout

or yarn:

$ yarn add @ijsto/react-slideout

🔨 How to Use

Here is a simple example of react-modal being used in an app with some custom styles and focusable input elements within the modal content:

import React, { useState } from "react";
import SlideOut from "@ijsto/react-slideout";

const MySlideOut = () => {
  const [slideOutIsOpen, setSlideOutIsOpen] = useState(false);

  const openSlideOut = () => {
    setSlideOutIsOpen(true);
  };

  const closeSlideOut = () => {
    setSlideOutIsOpen(false);
  };

  return (
    <div>
      <button onClick={openSlideOut}>Open Modal</button>
      <SlideOut isOpen={slideOutIsOpen} onClose={closeSlideOut}>
        <h2>My Slide Out</h2>

        <div>This is the content inside React Slide Out component.</div>
        <button onClick={closeSlideOut}>Close slide-out</button>
      </SlideOut>
    </div>
  );
};

More examples are coming soon.


📜 API documentation


Props

The following propertiess are available:

Property name Type Default Description
bg CSS Color "white" Any legal CSS color value component
children A React component - Any React component - this will appear in the slideout
classNamePrefix string - Namespace - will be applied to all SlideOut components
closeComponent React Component or html element - Custom close button component
hideClose boolean false Use this to hide close button. You can use parent component to handle state and toggle
isOpen boolean - Controls whether the slideout is visible
max-width CSS unit 100% Custom max-width of the the Slideout container.

offsetTop | CSS Unit | 0 | Offset slideout from top. Useful to account for the header height. | | onClose | function | internal state toggle | A function that will close the Slideout | | onCloseComponentKeyDown | function | - | Accessibility handler | | onCloseComponentKeyPress | function | - | Accessibility handler | | onCloseComponentKeyUp | function | - | Accessibility handler | | onOverlayKeyPress | function | - | Accessibility handler | | overflowShouldLock | Boolean | true | Locks the document body overflow-y | | overlayColor | HEX Color code | "#000000" (black) | Changes overlay color must be in HEX format (example: "#ffffff") | | overlayOpacity | integer from 0 to 1 | 0.5 | Changes default opacity of the overlay | | padding | CSS unit | - | Applied to the inner SlideOut container | | shouldCloseOnOverlayClick | boolean | true | To disable closing, when user clicks on overlay set shouldCloseOnOverlayClick={false} | | slideFrom | string | "left" | Determines the location from where slideout will appear | | speed | integer | 0.3s | Controls the speed of the slideout animation | | width | CSS unit | 350px | Custom width of the the Slideout | | zIndexIncrement | integer | 0 | Increments all zIndexes by the provided value. See default zIndexes below. |


Stacking (zIndexes)

By default Slideout components have the following zIndexes:

Here are the available classNames:

  • wrapper // 7
  • close-overlay // 8
  • body // 9

Styling

We provide more fine-grained control over all React-Slideout components via CSS class names.

Here are the available classNames:

  • wrapper // the top-level Slideout component
  • body // the Slideout component content
  • close-button //
  • close-component // wrapper that wrapper your custom close component
  • close-overlay // style overlay background, opacity, z-index etc.

🎬 Demos

Coming soon.


🗺️ Roadmap

  • Add entry from other sides
  • Add focus management system
  • Improve accessibility

🙆‍♂️ Contributions

Please feel free to submit PRs for the above (Roadmap) goals or otherwise

iJS.to

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[0.1.1] - 2020-11-08

Added

  • @ijsto/eslint-config (@scottagirs / Montreal)

Changed

  • Reverted 0.1.0

[0.1.0] - 2020-11-08

Added

  • Updated container element tags (@scottagirs / Montreal)

[0.0.15] - 2020-07-31

Added

  • build of version 0.0.14

[0.0.14] - 2020-07-31

Fixed

  • vertical overflow issue which prevented content from being scrollable

[0.0.13] - 2020-04-10

Added

  • style // prop - Passes CSS style object to Slideout wrapper
  • a11y click // handles accessibility interaction

[0.0.12] - 2020-03-28

Push latest build

[0.0.11] - 2020-03-28

Bugfix

  • import React

[0.0.10] - 2020-03-28

Added

  • slideFrom // prop - Determines the location from where slideout will appear

Update

  • API README docs related to available props

Removed

  • right prop in favour of slideFrom

[0.0.9] - 2020-03-11

Added

  • padding prop // padding is applied to the inner SlideOut container
  • overlayColor prop // change default color to overlay takes in HEX color code (example: "#ffffff")
  • overlayOpacity prop // change defauly opacity to overlay

Fixed

  • noOverlay

[0.0.8] - 2020-03-10

Added

  • speed prop // controls the speed of the slideout animation

[0.0.7] - 2020-03-05

Added

  • noOverlay // disable overlay, when slideout is open
  • styled-components to manage styles
  • keywords to package.json

Fix

  • width and offsetTop

[0.0.6] - 2020-01-21

Fix

  • default overlay position

[0.0.5] - 2020-01-20

Added

  • .npmignore file to ignore assets

[0.0.4] - 2020-01-20

Refactored

  • logo file was added to repository and referenced in README

[0.0.3] - 2020-01-20

No changes

[0.0.2] - 2020-01-20

Added

  • Branding/Logo

[0.0.1] - 2020-01-18

Initial Commit

The following props/functionality is already available:

  • closeComponent // custom close button component
  • noCloseComponent // hide/disable default close button
  • isOpen // open state, control should be within parent component, or state store
  • onClose // close Slideout callback for close button
  • offsetTop // offset sidebar from top, default is 64px
  • onCloseComponentKeyDown // custom keyboard logic for close button
  • onCloseComponentKeyPress // custom keyboard logic for close button
  • onCloseComponentKeyUp // custom keyboard logic for close button
  • onOverlayKeyPress // add custom logic for keyboard interaction with layout
  • shouldCloseOnOverlayClick = true // to disable closing the Slideout on overlay click use shouldCloseOnOverlayClick={false}
  • width // provide custom width to the Slideout, default is 350px

-

  • ignore no-array-index-key
  • ignore require-default-props
  • ignore no-unescaped-entities