1.0.3 • Published 3 years ago

react-drawer-wrapper v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-drawer-wrapper

NPM JavaScript Style Guide

Install

npm install --save react-drawer-wrapper

Usage

import React, { useState } from 'react'

import { DrawerWrapper } from 'react-drawer-wrapper'
import 'react-drawer-wrapper/dist/index.css'

const App = () => {
  const [open, setOpen] = useState(false)

  const handleDrawerMode = (nextMode: boolean) => {
    /*
      callback that gets the next mode of the drawer
      if the drawer is closed, nextMode will be true (open)
      else, nextMode will be false (close)
    */
    setOpen(nextMode)
  }

  return (
    <DrawerWrapper
      style={{}} // any style you want..
      direction='top'
      speed={1}
      open={open}
      onModeChange={handleDrawerMode}
    >
      <DrawerWrapper.Drawer
        className='' // class name to target the drawer
        style={{}} // any style you want related to the drawer
      >
        <h1>Here you can enter your drawer content</h1>
      </DrawerWrapper.Drawer>

      <DrawerWrapper.Content
        className='' // class name to target the content
        style={{}} // any style you want related to the content
      >
        <h1>Here you can enter your wrapped content</h1>
      </DrawerWrapper.Content>
    </DrawerWrapper>
  )
}

API

propstypedefaultdescription
classNamestringnull-
styleCSSPropertiesnullReact style props
directionstringlefttop bottom left right
heightstringtop/bottom - 30%, left/right - 100%in %, px, etc...
widthstringtop/bottom - 100%, left/right - 20%in %, px, etc...
buttonSizestringtop/bottom - long, left/right - shortlong short
speednumber0.3speed of drawer opening/closing in seconds
openbooleanfalsedrawer is open or not
onModeChangefunc() => {}func that recives the next drawer mode (open/close), (nextMode: boolean) => {}

Made with create-react-library

License

MIT © Yitzhakpro