split the code into components

This commit is contained in:
or-else
2018-10-23 21:31:28 +03:00
parent 8b02f39557
commit 4b7d76c150
49 changed files with 5213 additions and 5159 deletions
+28
View File
@@ -0,0 +1,28 @@
import React from 'react';
// Toggle [Title text >] -> [Title text v]
export default class MoreButton extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
open: props.open
};
this.handleToggle = this.handleToggle.bind(this);
}
handleToggle() {
let open = !this.state.open;
this.setState({open: open});
if (this.props.onToggle) {
this.props.onToggle(open);
}
}
render() {
return (<label className="small" onClick={this.handleToggle}>{this.props.title}...
{this.state.open ? <i className="material-icons">expand_more</i> :
<i className="material-icons">chevron_right</i>}
</label>);
}
}