npm.io
1.0.10 • Published 5 years ago

react-subwindow

Licence
MIT
Version
1.0.10
Deps
0
Size
5.7 MB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

react-subwindow

A react way to create modals and some useful utility functions

NPM JavaScript Style Guide

Install

npm install --save react-subwindow

Usage

import React from 'react'

import { createSubwindow } from 'react-subwindow'
import 'react-subwindow/dist/index.css'

const App = () => {
  return (
    <div>
      <button
        onClick={() => createSubwindow(
          <div>
            <h1>Saying hello from modal</h1>
          </div>
        )}
      >Open Modal</button>
      <br/>
      <button
        onClick={
          () => {
            onConfirmationPopup("Are you sure", function confirm() {
              window.alert("This will show up if you click on 'Confirm'")
            })
          }
        }
      >
        Do something after confirmation
      </button>
    </div>
  )
}

export default App
API
import { createSubwindow, onConfirmationPopup, getZIndex, releaseZIndex } from 'react-subwindow'
createSubwindow(reactElement)

Example

createSubwindow(
  <div>
    <h1>Saying hello from modal</h1>
  </div>
)
onConfirmationPopup(title, onConfirm)

Example

onConfirmationPopup(
  "Are you sure", 
  function confirm() {
    window.alert("This will show up if you click on 'Confirm'")
  }
)
getZIndex()

Returns number lowest available z index

Use this method to book a z-index value

releaseZIndex()

Release the last z index returned by getZIndex()

License

MIT Raufoon