2017-09-07 17:12:50 -04:00
|
|
|
import {connect} from 'react-redux';
|
2017-10-05 18:12:22 -04:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import bindAll from 'lodash.bindall';
|
2017-09-07 17:12:50 -04:00
|
|
|
import {changeFillColor} from '../reducers/fill-color';
|
|
|
|
import FillColorIndicatorComponent from '../components/fill-color-indicator.jsx';
|
2017-10-02 15:25:04 -04:00
|
|
|
import {applyFillColorToSelection} from '../helper/style-path';
|
2017-10-05 18:12:22 -04:00
|
|
|
|
|
|
|
class FillColorIndicator extends React.Component {
|
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
|
|
|
bindAll(this, [
|
|
|
|
'handleChangeFillColor'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
handleChangeFillColor (newColor) {
|
|
|
|
applyFillColorToSelection(newColor, this.props.onUpdateSvg);
|
|
|
|
this.props.onChangeFillColor(newColor);
|
|
|
|
}
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<FillColorIndicatorComponent
|
|
|
|
fillColor={this.props.fillColor}
|
|
|
|
onChangeFillColor={this.handleChangeFillColor}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-09-07 17:12:50 -04:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2017-09-07 17:49:41 -04:00
|
|
|
fillColor: state.scratchPaint.color.fillColor
|
2017-09-07 17:12:50 -04:00
|
|
|
});
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
2017-09-11 13:28:35 -04:00
|
|
|
onChangeFillColor: fillColor => {
|
2017-09-07 17:12:50 -04:00
|
|
|
dispatch(changeFillColor(fillColor));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-05 18:12:22 -04:00
|
|
|
FillColorIndicator.propTypes = {
|
|
|
|
fillColor: PropTypes.string,
|
|
|
|
onChangeFillColor: PropTypes.func.isRequired,
|
|
|
|
onUpdateSvg: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
2017-09-07 17:12:50 -04:00
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
2017-10-05 18:12:22 -04:00
|
|
|
)(FillColorIndicator);
|