2016-08-12 04:05:26 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import Button from '/imports/ui/components/button/component';
|
|
|
|
import classNames from 'classnames';
|
2016-08-16 01:26:22 +08:00
|
|
|
import Icon from '/imports/ui/components/icon/component';
|
2016-08-12 04:05:26 +08:00
|
|
|
import styles from './styles';
|
2016-08-16 03:44:20 +08:00
|
|
|
|
2016-08-12 04:05:26 +08:00
|
|
|
export default class Dropdown extends Component {
|
2016-08-16 03:44:20 +08:00
|
|
|
|
2016-08-12 04:05:26 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = { isMenuOpen: false, };
|
|
|
|
this.showMenu = this.showMenu.bind(this);
|
|
|
|
this.hideMenu = this.hideMenu.bind(this);
|
|
|
|
}
|
2016-08-16 03:44:20 +08:00
|
|
|
|
2016-08-12 04:05:26 +08:00
|
|
|
showMenu() {
|
2016-08-16 03:44:20 +08:00
|
|
|
this.setState({ isMenuOpen: !this.state.isMenuOpen });
|
2016-08-12 04:05:26 +08:00
|
|
|
}
|
2016-08-16 03:44:20 +08:00
|
|
|
|
2016-08-12 04:05:26 +08:00
|
|
|
hideMenu() {
|
|
|
|
this.setState({ isMenuOpen: false, });
|
2016-08-16 03:44:20 +08:00
|
|
|
|
2016-08-12 04:05:26 +08:00
|
|
|
}
|
2016-08-16 03:44:20 +08:00
|
|
|
|
2016-08-12 04:05:26 +08:00
|
|
|
render() {
|
2016-08-16 03:44:20 +08:00
|
|
|
const { icon, label, circle } = this.props;
|
2016-08-12 04:05:26 +08:00
|
|
|
return (
|
2016-08-16 01:26:22 +08:00
|
|
|
<div className={styles.dropdown}>
|
2016-08-12 04:05:26 +08:00
|
|
|
<Button className={styles.settingBtn}
|
2016-08-16 01:26:22 +08:00
|
|
|
role='button'
|
|
|
|
label={'settings'}
|
|
|
|
icon={'more'}
|
|
|
|
ghost={true}
|
|
|
|
circle={true}
|
|
|
|
hideLabel={true}
|
|
|
|
onClick={this.showMenu}
|
2016-08-16 03:44:20 +08:00
|
|
|
onKeyDown={this.showMenu}/>
|
2016-08-16 01:26:22 +08:00
|
|
|
{
|
|
|
|
this.state.isMenuOpen ?
|
|
|
|
this.props.children
|
|
|
|
: null
|
2016-08-12 04:05:26 +08:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|