aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/sidebars/sidebar.component.js
blob: 57cdd7111bca0c9c2a4f80add5b3fbb916edf194 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
import WalletView from '../wallet-view'
import { WALLET_VIEW_SIDEBAR } from './sidebar.constants'

export default class Sidebar extends Component {

  static propTypes = {
    sidebarOpen: PropTypes.bool,
    hideSidebar: PropTypes.func,
    transitionName: PropTypes.string,
    type: PropTypes.string,
  };

  renderOverlay () {
    return <div className="sidebar-overlay" onClick={() => this.props.hideSidebar()} />
  }

  renderSidebarContent () {
    const { type } = this.props

    switch (type) {
      case WALLET_VIEW_SIDEBAR:
        return <WalletView responsiveDisplayClassname={'sidebar-right' } />
      default:
        return null
    }

  }

  render () {
    const { transitionName, sidebarOpen } = this.props

    return (
      <div>
        <ReactCSSTransitionGroup
          transitionName={transitionName}
          transitionEnterTimeout={300}
          transitionLeaveTimeout={200}
        >
          { sidebarOpen ? this.renderSidebarContent() : null }
        </ReactCSSTransitionGroup>
        { sidebarOpen ? this.renderOverlay() : null }
      </div>
    )
  }

}