10.0.1 • Published 4 years ago

depay-react-dialog v10.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

Quickstart

yarn add depay-react-dialog

or

npm install --save depay-react-dialog
import { ReactDialog } from 'depay-react-dialog'

  /*...*/

  close() {
    if(this.state == something) {
      this.setState({ showDialog: false })
    }
  }

  /*...*/

  <ReactDialog close={this.close} open={this.state.showDialog}>
    <div className="ReactDialogAnimation MyDialogStyle">
      <h1>I am a dialog</h1>
      <button onclick={this.close}>Close Dialog</button>
    </div>
  </ReactDialog>

Functionalities

Render

import { ReactDialog } from 'depay-react-dialog'

render() {
  return(
    ...
    <ReactDialog close={this.close} open={this.state.showDialog}>
      <div className="ReactDialogAnimation MyDialogStyle">
        <h1>I am a dialog</h1>
        <button onclick={this.close}>Close Dialog</button>
      </div>
    </ReactDialog>
  )
}

Please apply the ReactDialogAnimation class to the child element that you want to be animated as part of the dialog opening animation.

Props

close (function): A function living in the dialog parent that is called from the ReactDialog on a close attempt. The parent has to take care if a dialog is closable, and needs to set it's own state accordingly.

  close() {
    if(this.state == something) {
      this.setState({ showDialog: false })
    }
  }

  /*...*/

  <ReactDialog close={this.close} open={this.state.showDialog}>
    <h1>I am a dialog</h1>
    <button onclick={this.close}>Close Dialog</button>
  </ReactDialog>

background (string): Background passed as CSS to the ReactDialogBackground.

  <ReactDialog background={'rgba(255,255,255,0.6)'} close={this.close} open={this.state.showDialog}>
    <h1>I am a dialog with white background.</h1>
  </ReactDialog>

document (Document): Allows to forward a different document where the dialog is supposed to live in.

  <ReactDialog document={someIframe.document}>
    <h1>I am a dialog</h1>
    <button onclick={this.close}>Close Dialog</button>
  </ReactDialog>

container (HTMLElement): Allows to provide a explicit container where the dialog is supposed to be rendered into.

  <ReactDialog container={document.getElementById('app')}>
    <h1>I am a dialog</h1>
    <button onclick={this.close}>Close Dialog</button>
  </ReactDialog>

Development

Get started

yarn install
yarn start

Release

npm publish
10.0.1

4 years ago

10.0.0

4 years ago

9.1.0

4 years ago

9.0.1

4 years ago

9.0.0

4 years ago

7.0.0

4 years ago

6.1.2

4 years ago

6.1.1

4 years ago

5.0.1

4 years ago

6.1.0

4 years ago

6.0.1

4 years ago

6.0.0

4 years ago

6.0.2

4 years ago

4.0.0

4 years ago

5.0.0

4 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.0.5

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago