-
Notifications
You must be signed in to change notification settings - Fork 972
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e6c1ce
commit fa94c4e
Showing
4 changed files
with
62 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,32 @@ | ||
import React from 'react'; | ||
import style from './style'; | ||
|
||
class Drawer extends React.Component { | ||
static propTypes = { | ||
active: React.PropTypes.bool, | ||
className: React.PropTypes.string, | ||
hideable: React.PropTypes.bool, | ||
type: React.PropTypes.oneOf(['left', 'right']) | ||
}; | ||
|
||
static defaultProps = { | ||
className: '', | ||
hideable: true, | ||
type: 'left' | ||
}; | ||
|
||
state = { | ||
active: this.props.active | ||
}; | ||
|
||
handleOverlayClick = () => { | ||
if (this.props.hideable) { | ||
this.setState({active: false}); | ||
} | ||
}; | ||
|
||
render () { | ||
let className = `${style.drawer} ${style[this.props.type]}`; | ||
if (this.state.active) className += ` ${style.active}`; | ||
if (this.props.className) className += ` ${this.props.className}`; | ||
|
||
return ( | ||
<div data-react-toolbox='drawer' className={className}> | ||
<div className={style.overlay} onClick={this.handleOverlayClick}></div> | ||
<aside className={style.content}> | ||
{ this.props.children } | ||
</aside> | ||
</div> | ||
); | ||
} | ||
|
||
show () { | ||
this.setState({active: true}); | ||
} | ||
|
||
hide () { | ||
this.setState({active: false}); | ||
} | ||
} | ||
const Drawer = (props) => { | ||
let className = `${style.drawer} ${style[props.type]}`; | ||
if (props.active) className += ` ${style.active}`; | ||
if (props.className) className += ` ${props.className}`; | ||
|
||
return ( | ||
<div data-react-toolbox='drawer' className={className}> | ||
<div className={style.overlay} onClick={props.onOverlayClick}></div> | ||
<aside className={style.content}> | ||
{ props.children } | ||
</aside> | ||
</div> | ||
); | ||
}; | ||
|
||
Drawer.propTypes = { | ||
active: React.PropTypes.bool, | ||
className: React.PropTypes.string, | ||
onOverlayClick: React.PropTypes.func, | ||
type: React.PropTypes.oneOf(['left', 'right']) | ||
}; | ||
|
||
Drawer.defaultProps = { | ||
active: false, | ||
className: '', | ||
type: 'left' | ||
}; | ||
|
||
export default Drawer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
docs/app/components/layout/main/modules/examples/drawer_example_1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters