blob: 6dd45f62ee47452b40195c719bd9dcfae3e33c90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import { h, Component } from 'preact'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import * as liveActions from '../live/actions'
class ParamGroup extends Component {
constructor(props){
super(props)
this.handleClick = this.handleClick.bind(this)
}
handleClick(e){
clearTimeout(this.timeout)
let new_value = e.target.checked
this.props.actions.set_param(this.props.name, new_value)
}
render() {
const checked = this.props.opt[this.props.name]
const toggle = !this.props.noToggle
const className = (!toggle || checked) ? 'paramGroup active' : 'paramGroup inactive'
return (
<div className={className}>
<label>
<h3>{this.props.title}</h3>
{toggle ?
<input
type='checkbox'
onClick={this.handleClick}
checked={checked}
/>
: null}
</label>
{this.props.children}
</div>
)
}
}
const mapStateToProps = state => ({
opt: state.live.opt,
})
const mapDispatchToProps = (dispatch, ownProps) => ({
actions: bindActionCreators(liveActions, dispatch)
})
export default connect(mapStateToProps, mapDispatchToProps)(ParamGroup)
|