0.7.0 • Published 9 months ago

react-dock v0.7.0

Weekly downloads
56,389
License
MIT
Repository
github
Last release
9 months ago

react-dock

Resizable dockable react component.

Demo

http://alexkuz.github.io/react-dock/demo/

Install

$ npm i -S react-dock

Example

render() {
  return (
    <Dock position='right' isVisible={this.state.isVisible}>
      {/* you can pass a function as a child here */}
      <div onClick={() => this.setState({ isVisible: !this.state.isVisible })}>X</div>
    </Dock>
  );
}

Dock Props

Prop NameDescription
positionSide to dock (left, right, top or bottom). Default is left.
fluidIf true, resize dock proportionally on window resize.
sizeSize of dock panel (width or height, depending on position). If this prop is set, Dock is considered as a controlled component, so you need to use onSizeChange to track dock resizing. Value is a fraction of window width/height, if fluid is true, or pixels otherwise
defaultSizeDefault size of dock panel (used for uncontrolled Dock component)
isVisibleIf true, dock is visible
dimModeIf none - content is not dimmed, if transparent - pointer events are disabled (so you can click through it), if opaque - click on dim area closes the dock. Default is opaque
durationAnimation duration. Should be synced with transition animation in style properties
dimStyleStyle for dim area
dockStyleStyle for dock
zIndexZ-index for wrapper
onVisibleChangeFires when Dock wants to change isVisible (when opaque dim is clicked, in particular)
onSizeChangeFires when Dock wants to change size
childrenDock content - react elements or function that returns an element. Function receives an object with these state values: { position, isResizing, size, isVisible }