项目作者: eetay

项目描述 :
Wrap a react component and make it and its children detachable from current browser frame into a popup
高级语言: JavaScript
项目地址: git://github.com/eetay/react-detachable-window.git
创建时间: 2018-07-23T10:26:27Z
项目社区:https://github.com/eetay/react-detachable-window

开源协议:

下载


react-detachable-window

ReactDetachableWindow wraps a portion of the DOM or a group of react components and make it detachable from current window frame into a new window
it takes care to copy the stylesheets and title from the original frame into the new window or you can define your own

[See a live example]

Install:

  1. npm i react-detachable-window

Use:

  1. import ReactDetachableWindow from 'react-detachable-window'
  1. <ReactDetachableWindow title='I am detached!' windowOptions={{width: 800, height: 600}}>
  2. <!-- DOM defined here can be detached to a new popup window and re-attached-->
  3. </ReactDetachableWindow>
  1. var reattachButton = (<button type='button'>Close!</button>)
  2. var detachButton = (<button type='button'>Detach!</button>)
  3. <ReactDetachableWindow
  4. windowOptions={{ width: 800, height: 600 }}
  5. reattachButton={reattachButton}i
  6. detachButton={detachButton}>
  7. ...
  8. </ReactDetachableWindow>

Component properties

  • windowOptions - Optional: A hash of options passed to the window.open(URL, name, specs, replace) ‘specs’ parameter
  • title - Optional: A string title for the new window
  • reattachButton - Optional: A jsx element which, when clicked, closes the popup window
  • detachButton - Optional: A jsx element which, when clicked, opens the popup window

TODO List

  • copy a complete set of attributes from original window into the new popup
  • allow property to define the containing DOM for the detachable portion in the new popup