Code Monkey home page Code Monkey logo

react-drawer's Introduction

react-drawer (1.3.4)

Simple HTML5 drawer menu for React.js.

NPM

996.ICU Travis CI Quality dependencies devdependencies semantic-release

Installation

The easiest way to use react-drawer is to install it from npm and include it in your React build process (using Webpack, Browserify, etc).

npm install --save react-drawer

Create a standalone module using WebPack:

> npm install
> webpack

Demo

https://jmfrancois.github.io/react-drawer/

Run on your local & development

// 1. keep monitor changes to /src/*
> npm run build:watch

// 2. open dev server
> npm start

// 3. visit http://localhost:3000/example/

Example

import React from 'react';
import ReactDOM from 'react-dom';
import ReactDrawer from 'react-drawer';
import 'react-drawer/lib/react-drawer.css';

class Main extends React.Component {
  constructor() {
    super();
    this.state = {
      open: false,
      position: 'right',
      noOverlay: false
    };
    this.toggleDrawer = this.toggleDrawer.bind(this);
    this.closeDrawer = this.closeDrawer.bind(this);
    this.onDrawerClose = this.onDrawerClose.bind(this);
    this.setPosition = this.setPosition.bind(this);
    this.setNoOverlay = this.setNoOverlay.bind(this);
  }
  setPosition(e) {
    this.setState({position: e.target.value});
  }
  setNoOverlay(e) {
    this.setState({noOverlay: e.target.checked});
  }
  toggleDrawer() {
    this.setState({open: !this.state.open});
  }
  closeDrawer() {
    this.setState({open: false});
  }
  onDrawerClose() {
    this.setState({open: false});
  }
  render() {
    return (
      <div>
        <div style={{margin: 200}}>
          <h1>React Drawer configuration</h1>
          <div style={{margin: 20}}>
            <label>Position</label>
            <select value={this.state.position} onChange={this.setPosition}>
              <option value="top">top</option>
              <option value="bottom">bottom</option>
              <option value="left">left</option>
              <option value="right">right</option>
            </select>
          </div>
          <div style={{margin: 20}}>
            <input type="checkbox"
              checked={this.state.noOverlay}
              onChange={this.setNoOverlay}
            />
            <label>No overlay</label>
            <small>(The overlay lets you close the drawer on click)</small>
          </div>
          <button
            style={{margin: 20}}
            onClick={this.toggleDrawer}
            disabled={this.state.open && !this.state.noOverlay}
            >
            {!this.state.open ? <span>show drawer</span>: <span>close drawer</span>}
          </button>
        </div>
        <ReactDrawer
          open={this.state.open}
          position={this.state.position}
          onClose={this.onDrawerClose}
          noOverlay={this.state.noOverlay}>
          <i onClick={this.closeDrawer} className="icono-cross"></i>
          <h2>What a nice drawer !</h2>
        </ReactDrawer>
      </div>
    );
  }
}

ReactDOM.render(<Main />, document.getElementById('app'));

Todo

  • basic features
  • open position option
  • drawer open method
  • themes

License

MIT

react-drawer's People

Contributors

atom2ueki avatar jmfrancois avatar jonstuebe avatar npmcdn-to-unpkg-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-drawer's Issues

React Drawer not showing

I have the following situation where even when the open property is toggle to true the drawer stays hidden.
As in the hiddenDrawer state does not change.

how close the drawer if it opens another

Hello,

I have several drawer in the menu (for example: notifications, visitors etc. ..).
I can run the componants but I would like when I open one, it closes the other if already open

Any idea ?

Best regards,

Need help on maintaining this library

Because of job scope changes, now I'm not active working on react.js, need volunteers who familiar with react.js and semantic-release, pm me if you keen for it !

developer change the world !!

Is there an install to just use the component?

Having this as an example is convoluted. I could not get this to work as just an import of react-drawer and add the drawer component into my project. Basically I want to skip this step:

npm install
webpack

It kept asking me for animate.css and I could not figure out how to reference it. I installed animate.css, but it kept saying it could not located it.

Module not found: Can't resolve 'React' in react-drawer/lib

I tried creating a simple example app using create-react-scripts and react-drawer but it fails when I run npm start with the following error:

./node_modules/react-drawer/lib/react-drawer.js
Module not found: Can't resolve 'React' in '..../react-drawer-test/node_modules/react-drawer/lib'

I also tried to clone the source repo, build it and run the example app but got the same error. I'm on Ubuntu 16.04 with npm 5.7.1.

Pin or dock the drawer (for larger screens)

I'm looking for a drawer solution that allows the user to pin/dock the drawer into an open position so it's always visible, on larger screens. Is this difficult to implement with your current solution? It doesn't seem to have any specific hooks for that, but is it possible with what is exposed currently?

Module with equal name if case ignored

So I found an issue when I use this with webpack and other react packages because your require statements use a require('React') with a capital letter and everything else uses require('react') with a lower case letter. I was able to fix all the warnings by changing your code to:

(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react")); else if(typeof define === 'function' && define.amd) define(["react"], factory); else if(typeof exports === 'object') exports["ReactDrawer"] = factory(require("react")); else root["ReactDrawer"] = factory(root["react"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_3__) {

Otherwise this looks like a really nice component.

input box in drawer - can't add space

I have an input box inside of a drawer component that will not accept spaces in its input. Is there anything in react-drawer that could be causing this behavior?

React-drawer not rendering in Safari (MacOS)

Hi,

React-Drawer isn't rendering in Safari (MacOS) on state change,

I have followed the functions though with a series of console logs and each command is being called and state is being changed when the button calling the function to open the draw is clicked but the the drawer is not appearing. Working is all other browser (Chrome, IE, Edge, FF) but not Safari (MacOS).

No error output is being displayed either.

thanks for your help.

Paul

semantic release

Hi,

I'm using semantic release process on all addons I'm writing.
I would like to setup this on react-drawer.
The only constraints for you is to follow guidelines on the commit messages

  • starts with feat -> trigger a feature release
  • starts with fix -> trigger a minor release
  • BREAKING CHANGE in the body -> trigger a major release

MAJOR dot FEATURE dot MINOR is what semver propose.

the idea behind semantic release is to add a semantic to the commit message.

Are you OK with this ?

Look at commits of thoses addons (the CONTRIBUTING.md file explains this in details):

https://github.com/talend/react-cmf/commits
https://github.com/talend/react-talend-components/commits
https://github.com/talend/react-talend-containers/commits
https://github.com/talend/bootstrap-theme/commits
https://github.com/jmfrancois/react-storybook-cmf/commits

Once we merge a pull request, the release is done by the CI

If you said yes, I can do the setup for you @atom2ueki

QA (unit tests, CI), documentation

I plan to use react-drawer but I need the following changes so I will do theses.
Because I like opensource and I hate doing things alone, I would like to know if you are ok with theses changes:

  • add tests
  • add linters
  • add documentation
  • use animate.css as a dependency
  • provide examples throw github pages (not in the master branch)
  • make it works in my current project

No ability to easily edit styles for drawer

I really hope I'm missing something here, but it doesn't look like there's any way for me to easily style this component. I'm stuck with a ugly green sidebar hidden behind my svg canvas because I cannot adjust the z-index or background color. I can't even override the styles easily with these extremely long class names. I'm using webpack and importing the styles above, but no changes are applied to the ReactDrawer when I set className. I'm sure I'm missing something here because I can't imagine anyone would find a lime green drawer element to be useful in their application.

css style not attached with webpack

Hi, I was trying to get this module work with my webpack project, it rendered successfully but without any CSS attached to the elements:

image

The way I used this module:

import Drawer from 'react-drawer';

...

<Drawer
    open={this.state.openMenu}
    onClose={this.handleMenuCloseRequest} >...</Drawer>)
  • react-drawer: 1.2.5
  • react: 15.4.1

Add more prop touch to use on mobile

It's nice, but maybe you can add props {touch:true/false} to use on mobile, and class to custom drawer (as speed, overlay opacity, shadow ...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.