From 70b4cc5adcef18d498b539579ecfa626aa5e6c18 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 30 Aug 2018 22:59:28 +0200 Subject: group sequences/checkpoints by folder --- app/client/common/selectGroup.component.js | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app/client/common/selectGroup.component.js (limited to 'app/client/common/selectGroup.component.js') diff --git a/app/client/common/selectGroup.component.js b/app/client/common/selectGroup.component.js new file mode 100644 index 0000000..b653fdf --- /dev/null +++ b/app/client/common/selectGroup.component.js @@ -0,0 +1,66 @@ +import { h, Component } from 'preact' +import { connect } from 'react-redux' +import { bindActionCreators } from 'redux' + +class SelectGroup extends Component { + constructor(props){ + super(props) + this.handleChange = this.handleChange.bind(this) + } + handleChange(e){ + clearTimeout(this.timeout) + let new_value = e.target.value + if (new_value === 'PLACEHOLDER') return + this.props.onChange && this.props.onChange(this.props.name, new_value) + } + render() { + const currentValue = this.props.live ? this.props.opt[this.props.name] : this.props.value + let lastValue + const options = (this.props.options || []).map((group, i) => { + const groupName = group.name + const children = group.options.map(key => { + let name = key.length < 2 ? key.toUpperCase() : key + let value = key.replace(/_/g, ' ') + lastValue = value + return ( + + ) + }) + return ( + + {children} + + ) + }) + return ( +
+ + {this.props.children} +
+ ) + } +} + +function capitalize(s){ + return (s || "").replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); +} + +const mapStateToProps = (state, props) => ({ + opt: props.opt || state.live.opt, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ +}) + +export default connect(mapStateToProps, mapDispatchToProps)(SelectGroup) -- cgit v1.2.3-70-g09d2