1.0.2 • Published 3 years ago

shapla-react-modal v1.0.2

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

React Modal

A classic modal overlay for React, in which you can include any content you want.

Table of contents

Installation

npm install --save shapla-react-modal

Usage

Styles

with Sass:

import 'shapla-react-modal/src/index.scss';

with CSS:

import 'shapla-react-modal/dist/modal.css';

Javascript Instantiation

import React from 'react';
import Modal from 'shapla-react-modal';
 
class MyApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = { showBoxModal: false }
    this.openBoxModal = this.openBoxModal.bind(this);
    this.closeBoxModal = this.closeBoxModal.bind(this);
  }

  openBoxModal() {
    this.setState(state => state.showBoxModal = true);
  }

  closeBoxModal() {
    this.setState(state => state.showBoxModal = false);
  }

  render() {
    return (
      <div>
        <button onClick={this.openBoxModal}>Open Box Modal</button>

        <Modal active={this.state.showBoxModal} type='box' onClose={this.closeBoxModal}>
          Box modal only have white background, border radius and 1rem padding
        </Modal>
      </div>
    );
  }
}

Props

PropertyTypeRequiredDefaultDescription
activeBooleanyes
titleStringnoUntitledtitle will not show if you set type other than card
typeStringnocardCurrently card and box design available. Use any name to get blank modal
closeOnBackgroundClickBooleannotrueIf set true, clicking outside content area will trigger close event.
showCloseIconBooleannotrueIf set false, no closing icon will be shown
contentSizeStringnomediumValue can be small, medium, large or full. small has content width 320px, medium has content width 640px, large has content width 960px and full will take full browser width
classNameStringno | Custom CSS class
childrenStringno | Modal content
footerStringno | Modal footer content when using card design.