import { h, Component } from 'preact' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import * as liveActions from '../live/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 (
{this.props.children}
) } } const mapStateToProps = state => ({ opt: state.live.opt, }) const mapDispatchToProps = (dispatch, ownProps) => ({ actions: bindActionCreators(liveActions, dispatch) }) export default connect(mapStateToProps, mapDispatchToProps)(ParamGroup)