Giter Club home page Giter Club logo

reboron's Introduction

Reboron

A collection of dialog animations with React.js.

About

This is a fork of http://yuanyan.github.io/boron/ that has fixes for the deprecation warnings in React 15.*. I will be working on updating this package to use es6 as well as fixing some of the issues in the main package. PRs welcome!

Installation

The easiest way to use reboron is to install it from NPM and include it in your own React build process

npm install reboron --save

Usage

import React, { Component } from 'react';
import Modal from 'reboron/DropModal';

class Example extends Component {
  constructor(props) {
    super(props);
  }

  showModal() {
    this.refs.modal.show();
  }

  hideModal() {
    this.refs.modal.hide();
  }

  callback(evt) {
    console.log(evt);
  }

  render() {
    return (
      <div>
        <button onClick={ () => this.showModal() }>Open</button>
        <Modal ref={ 'modal' } keyboard={ () => this.callback() }>
          <h2>I am a dialog</h2>
          <button onClick={ () => this.hideModal() }>Close</button>
        </Modal>
      </div>
    );
  }
}

export default Example;

Props

  • className - Add custom class name.
  • keyboard - Receive a callback function or a boolean to choose to close the modal when escape key is pressed.
  • backdrop - Includes a backdrop element.
  • closeOnClick - Close the backdrop element when clicked.
  • duration - duration in milliseconds before the modal is hidden
  • onShow - Show callback.
  • onHide - Hide callback. Argument is the source of the hide action, one of:
    • hide - hide() method is the cause of the hide.
    • toggle - toggle() method is the cause of the hide
    • keyboard - keyboard (escape key) is the cause of the hide
    • backdrop - backdrop click is the cause of the hide
    • timeout - timeout is the cause of the hide
    • [any] - custom argument passed by invoking code into the hide() method when called directly.
  • modalStyle - CSS styles to apply to the modal
  • backdropStyle - CSS styles to apply to the backdrop
  • contentStyle - CSS styles to apply to the modal's content
  • rectStyle - CSS styles to apply to the modal's rectangle (OutlineModal only)

Note: If the hide() method is called directly, a custom source string can be passed as the argument, as noted above. For example, this might be useful if if multiple actions could cause the hide and it was desirable to know which of those actions was the trigger for the given onHide callback).

Custom Styles

Objects consisting of CSS properties/values can be passed as props to the Modal component. The values for the CSS properties will either add new properties or override the default property value set for that Modal type.

Modal with 80% width:

import React, { Component } from 'react';
import Modal from 'reboron/ScaleModal';

// Style object
const modalStyle = {
  width: '80%',
};

class Example extends Component {
  showModal() {
    this.refs.modal.show();
  }

  hideModal() {
      this.refs.modal.hide();
  }

  render() {
    return (
      <div>
        <button onClick={ () => this.showModal() }>Open</button>
        <Modal ref={ 'modal' } modalStyle={ modalStyle }>
          <h2>I am a dialog</h2>
          <button onClick={ () => this.hideModal() }>Close</button>
        </Modal>
      </div>
    );
  }
}

export default Example;

Red backdrop with a blue modal, rotated at 45 degrees:

import React, { Component } from 'react';
import Modal from 'reboron/FlyModal';

// Individual styles for the modal, modal content, and backdrop
const modalStyle = {
  transform: 'rotate(45deg) translateX(-50%)',
};

const backdropStyle = {
  backgroundColor: 'red',
};

const contentStyle = {
  backgroundColor: 'blue',
  height: '100%',
};

class Example extends Component {
  showModal() {
    this.refs.modal.show();
  }

  hideModal() {
    this.refs.modal.hide();
  }

  render() {
    return (
      <div>
        <button onClick={ () => this.showModal() }>Open</button>
        <Modal ref={ 'modal' } modalStyle={ modalStyle } backdropStyle={ backdropStyle } contentStyle={ contentStyle }>
          <h2>I am a dialog</h2>
          <button onClick={ () => this.hideModal() }>Close</button>
        </Modal>
      </div>
    );
  }
}

export default Example;

Modals

  • DropModal
  • FadeModal
  • FlyModal
  • OutlineModal
  • ScaleModal
  • WaveModal

License

Reboron is MIT licensed.

reboron's People

Contributors

brandonwade avatar bsbates avatar dimaksid-zz avatar jaywaa avatar jerairrest avatar jesusoterogomez avatar kennyt avatar krmannix avatar madalosso avatar matthewhorst avatar morenoh149 avatar qvist avatar rickywiens avatar sour-dev avatar yuanyan 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

Watchers

 avatar  avatar  avatar  avatar  avatar

reboron's Issues

In Modal on click Enter

Hi, @jerairrest! How to implementing onEnter in modal becouse keyboard is bool and I can't override this func. Is possible to do without override library ?

keyboard={ () => this.callback() } // return invalid propTypes

onHide source is not implemented

The onHide function is passed a source argument to identify which source caused the modal to close. This is stated in the README and also implemented in the boron repo here. I think it would be good for this repo to also implement such logic.

Animation problem in Safari

In Safari 11, on Mac (via BrowserStack). On first animation, the display of the inputs is out of line with the rest of the modal. They can be selected, but only by clicking above the element. Perhaps a problem with webkit-animation? Or missing off an animation-fill-mode: forwards; somewhere?

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.