2017-06-30 04:24:34 +00:00
|
|
|
import React from 'react';
|
|
|
|
import IconButton from '../../../components/icon_button';
|
|
|
|
|
2017-06-30 04:45:09 +00:00
|
|
|
const iconStyle = {
|
|
|
|
height: null,
|
|
|
|
lineHeight: '27px',
|
|
|
|
};
|
|
|
|
|
2017-06-30 04:24:34 +00:00
|
|
|
export default class AdvancedOptionsDropdown extends React.PureComponent {
|
|
|
|
onToggleDropdown = () => {
|
|
|
|
this.setState({ open: !this.state.open });
|
|
|
|
};
|
|
|
|
|
|
|
|
onGlobalClick = (e) => {
|
|
|
|
if (e.target !== this.node && !this.node.contains(e.target) && this.state.open) {
|
|
|
|
this.setState({ open: false });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount () {
|
|
|
|
window.addEventListener('click', this.onGlobalClick);
|
|
|
|
window.addEventListener('touchstart', this.onGlobalClick);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
|
|
|
window.removeEventListener('click', this.onGlobalClick);
|
|
|
|
window.removeEventListener('touchstart', this.onGlobalClick);
|
|
|
|
}
|
|
|
|
|
|
|
|
state = {
|
|
|
|
open: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
setRef = (c) => {
|
|
|
|
this.node = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { open } = this.state;
|
2017-06-30 04:45:09 +00:00
|
|
|
|
|
|
|
const options = [
|
|
|
|
{ icon: 'wifi', shortText: 'Local-only', longText: 'bla' },
|
|
|
|
];
|
|
|
|
const optionElems = options.map((option) => {
|
|
|
|
return <div role='button' className='advanced-options-dropdown__option'>
|
|
|
|
<div className='advanced-options-dropdown__option__icon'>
|
|
|
|
<IconButton icon={option.icon} />
|
|
|
|
</div>
|
|
|
|
<div className='advanced-options-dropdown__option__content'>
|
|
|
|
<strong>{option.shortText}</strong>
|
|
|
|
{option.longText}
|
|
|
|
</div>
|
|
|
|
</div>;
|
|
|
|
});
|
2017-06-30 04:24:34 +00:00
|
|
|
return <div ref={this.setRef} className={`advanced-options-dropdown ${open ? 'active' : ''}`}>
|
|
|
|
<div className='advanced-options-dropdown__value'>
|
|
|
|
<IconButton className='advanced-options-dropdown__value'
|
|
|
|
icon='ellipsis-h' active={open}
|
|
|
|
size={18} inverted
|
2017-06-30 04:45:09 +00:00
|
|
|
style={iconStyle}
|
2017-06-30 04:24:34 +00:00
|
|
|
onClick={this.onToggleDropdown} />
|
|
|
|
</div>
|
|
|
|
<div className='advanced-options-dropdown__dropdown'>
|
2017-06-30 04:45:09 +00:00
|
|
|
{optionElems}
|
2017-06-30 04:24:34 +00:00
|
|
|
</div>
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
}
|