New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-common-modal

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-common-modal

React Modal Dialog

latest
Source
npmnpm
Version
0.0.14
Version published
Weekly downloads
3
-62.5%
Maintainers
1
Weekly downloads
 
Created
Source

react-common-modal

Simple Modal Dialog

Installation

With npm

npm i react-common-modal --save --save-exact

With yarn

yarn add react-common-modal -E

Usage

./Dialog.js

import React from "react";
import {
  DialogTitle,
  DialogContent,
  DialogActions,
  Dialog as UIDialog,
} from "react-common-modal";

Dialog.propTypes = {
  open: PropTypes.bool,
  onRequestClose: PropTypes.func,

  title: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
  showCloseButton: PropTypes.bool,
  children: PropTypes.node.isRequired,
  position: PropTypes.string,
  alignActions: PropTypes.string
};

export default function Dialog(props) {
  return(
    <UIDialog open={props.open} position={props.position}>
      <DialogTitle
        title={props.title}
        onClose={props.showCloseButton ? props.onRequestClose : null}
      />

      <DialogContent>{props.children}</DialogContent>

      <DialogActions align={props.alignActions}>
        <Button onClick={props.onRequestClose}>Close</Button>
      </DialogActions>
    </UIDialog>
  )
}

./App.js

import React from "react";
import Dialog from "./Dialog";

export default class App extends React.Component {
  constructor() {
    super();

    this.state = {
      showModal: false
    }
  }

  render() {
    <div>
      <button
        onClick={() => this.setState({ showModal: true })}
      >
        Open Modal
      </button>

      <Dialog
        title="Dialog Title"
        alignActions="center"
        position="top-center"
        showCloseButton={true}
        open={this.state.showModal}
        onRequestClose={this.setState({ showModal: false })}
      >
        <h5>Dialog Content</h5>
      </Dialog>
    </div>
  }
}

Props

Dialog
NameTypeDefaultDescription
openBooleanfalseIf true the Modal Dialog is open
positionString:
top-left | top-center | top-right
center-left | center | center-right
bottom-left | bottom-center | bottom-right
centerPosition Modal Dialog on the page
childrenNodeModal Dialog children, usually the included sub-components
classNameStringThe className to add to the content container
backdropClassNameStringThe className to add to the overlay container
DialogTitle
NameTypeDefaultDescription
titleString | NodeThe title to display on the Modal Dialog
onCloseFuncFired when to be click on the close button
classNameStringThe className to add to the content container
titleClassNameStringThe className to add to the title container
DialogContent
NameTypeDefaultDescription
childrenNodeContent children, usually the included sub-components
classNameStringThe className to add to the content container
DialogActions
NameTypeDefaultDescription
alignString:
start | center | end
endAlign actions content
childrenNodeActions children, usually the included sub-components
classNameStringThe className to add to the content container

Live Example

https://react-common-modal.firebaseapp.com/

Licence

MIT

Keywords

react

FAQs

Package last updated on 17 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts