All files / components/layout/sidebar/story sidebar.js

0% Statements 0/67
0% Branches 0/35
0% Functions 0/18
0% Lines 0/22
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65                                                                                                                                 
import React, { PureComponent } from 'react'
import { Button, Layout } from 'components'
 
import CheckBox from 'components/checkbox'
 
class SidebarStory extends PureComponent {
  constructor (props) {
    super(props)
    this.state = {
      visibleRight: false,
      visibleLeft: false
    }
  }
 
  toggleSidebar = name => {
    this.setState({
      [name]: !this.state[name]
    })
  }
 
  changeBlock = e => {
    const { name, checked } = e.target
    this.setState({
      [name]: checked
    })
  }
 
  changeFloat = e => {
    const { name, checked } = e.target
    this.setState({
      [name]: checked
    })
  }
 
  render () {
    const { visibleLeft, visibleRight, block, float } = this.state
    return (
      <Layout>
 
        <Layout.Sidebar visible={visibleLeft} triggerClose={() => this.toggleSidebar('visibleLeft', block, float)} side='left' width='250px' block={block} float={float}>
          <div style={{ width: '100%', height: '100vh', background: '#314056' }} />
        </Layout.Sidebar>
 
        <Layout.Content flow='column' vAlign='center' hAlign='center' flexBox >
          <div>
            <CheckBox text='Toggle Block View' name='block' onChange={this.changeBlock} />
            <CheckBox text='Toggle Float' name='float' onChange={this.changeFloat} />
          </div>
          <Button width='200px' value='Left Sidebar' type='primary' onClick={() => this.toggleSidebar('visibleLeft')} /> &nbsp;
          <Button width='200px' value='Right Sidebar' type='primary' onClick={() => this.toggleSidebar('visibleRight')} /> &nbsp;
        </Layout.Content>
 
        <Layout.Sidebar visible={visibleRight} triggerClose={() => this.toggleSidebar('visibleRight', block, float)} side='right' width='250px' block={block} float={float}>
          <div style={{ width: '100%', height: '100vh', background: '#fff', borderLeft: 'solid 1px #ccc' }}>
            Content Sidebar Right
          </div>
        </Layout.Sidebar>
 
      </Layout >
    )
  }
}
 
export default SidebarStory