mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 11:04:00 +00:00
Convert ClutterBar to mapDispatchToProps
This commit is contained in:
parent
b5d1601726
commit
16a3be5f31
1 changed files with 24 additions and 29 deletions
|
|
@ -3,36 +3,31 @@ import {connect} from 'react-redux';
|
|||
import classnames from 'classnames';
|
||||
|
||||
|
||||
class ClutterBar extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.handleMouseDownDouble = this.handleMouseDownDouble.bind(this);
|
||||
this.handleMouseUpDouble = this.handleMouseUpDouble.bind(this);
|
||||
}
|
||||
const ClutterBar = (props) => (
|
||||
<div id='clutter-bar'>
|
||||
<div id='button-o' />
|
||||
<div id='button-a' />
|
||||
<div id='button-i' />
|
||||
<div
|
||||
id='button-d'
|
||||
className={classnames({selected: props.doubled})}
|
||||
onMouseUp={props.handleMouseUp}
|
||||
onMouseDown={props.handleMouseDown}
|
||||
/>
|
||||
<div id='button-v' />
|
||||
</div>
|
||||
);
|
||||
|
||||
handleMouseDownDouble() {
|
||||
this.props.dispatch({type: 'SET_FOCUS', input: 'double'});
|
||||
}
|
||||
const mapStateToProps = (state) => ({
|
||||
doubled: state.display.doubled
|
||||
});
|
||||
|
||||
handleMouseUpDouble() {
|
||||
this.props.dispatch({type: 'TOGGLE_DOUBLESIZE_MODE'});
|
||||
this.props.dispatch({type: 'UNSET_FOCUS'});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
handleMouseDown: () => dispatch({type: 'SET_FOCUS', input: 'double'}),
|
||||
handleMouseUp: () => {
|
||||
dispatch({type: 'TOGGLE_DOUBLESIZE_MODE'});
|
||||
dispatch({type: 'UNSET_FOCUS'});
|
||||
}
|
||||
});
|
||||
|
||||
render() {
|
||||
return <div id='clutter-bar'>
|
||||
<div id='button-o' />
|
||||
<div id='button-a' />
|
||||
<div id='button-i' />
|
||||
<div
|
||||
id='button-d'
|
||||
className={classnames({selected: this.props.doubled})}
|
||||
onMouseUp={this.handleMouseUpDouble}
|
||||
onMouseDown={this.handleMouseDownDouble}
|
||||
/>
|
||||
<div id='button-v' />
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = connect((state) => state.display)(ClutterBar);
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(ClutterBar);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue