Giter Site home page Giter Site logo

sidharthancr / react-popout-v2 Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2.78 MB

React popout is a util to handle the popout windows with ease and supports IE

HTML 6.83% JavaScript 91.57% CSS 1.60%
react popout ie11 window react-popout npm-package npm hooks

react-popout-v2's Introduction

react-popout-v2

React popout is a util to handle the popout windows with ease
Size of plugin is Just 10KB
Supports IE 11

NPM JavaScript Style Guide

Install

npm install --save react-popout-v2

Usage

import React, { useState } from 'react'
import ReactDOM from 'react-dom'
import Popout from 'react-popout-v2'

const MyComponent = () => {
  const [isOpen, setOpen] = useState(false)
  return (
    <>
      {!isOpen && <button onClick={() => setOpen(true)}>Open Popout</button>}
      {isOpen && (
        <Popout
          url={'#/popout'}
          reactDom={ReactDOM}
          children={<div>This is a content of new popout!</div>}
          onClose={() => setOpen(false)}
        />
      )}
    </>
  )
}
export default MyComponent

Props

reactDom: ReactDom [REQUIRED]

Pass react dom instance from parent component to popout. It helps to over come version discrepancy issue and reduce bundle size from 250KB to 10KB

id: String

Default value: react-popout

Unique ID to find different popouts. If you are using multiple popouts its mandatory tp provide id

url: String

Default value: about:black

Url to load in the popout, we can load another link or can be used to load the CSS.

title: String

Default value: react-popout

Title of the popout window

containerId: String

Default value: react-popout

Unique id for the popout content div.[Useful on CSS separation]

children: ReactComponents/ Function

Popout content elements or function which accepts the popout window as param

containerId: bool

Default value: false

Flag to close the popout on parent window unload event

options: object

Default value: {}

Object representing window options. See the docs for reference.

Example: <Popout options={{left: '100px', top: '200px'}} />

By default 500px wide, 400px high and centered over the window hosting the react component.

You can also specify a function with signature (options, window) => { } to perform calculations. For example top is calculated with (o, w) => ((w.innerHeight - o.height) / 2) + w.screenY

onClose: Function

Callback on popout close event

onError: Function

Callback on popout creation error event

parentWindow: Object

Default value: window

Pass window object to open from given window, it default to current window object

onCreate: Function

Callback on popout creation event with param as created popout window

Note:

Cross origin url does not support onClose callBack and content display. It opens new window and onCreate callback will be called with created popout window instance.

License

MIT © sidharthancr

react-popout-v2's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

react-popout-v2's Issues

setOpen(false) does not close the window

Your app is the only one, I found, that allows the child component to have any events inside. Thank you.

But what I found is that using the setOpen(false); does not close the popup.
Do you have a suggestion to kill the popout from the children?

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.