2017-09-08 11:52:36 -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-08 11:52:36 -04:00
|
|
|
import {changeStrokeWidth} from '../reducers/stroke-width';
|
|
|
|
import StrokeWidthIndicatorComponent from '../components/stroke-width-indicator.jsx';
|
2017-10-02 15:25:04 -04:00
|
|
|
import {applyStrokeWidthToSelection} from '../helper/style-path';
|
2017-10-26 17:33:33 -04:00
|
|
|
import Modes from '../modes/modes';
|
2017-10-05 18:12:22 -04:00
|
|
|
|
|
|
|
class StrokeWidthIndicator extends React.Component {
|
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
|
|
|
bindAll(this, [
|
|
|
|
'handleChangeStrokeWidth'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
handleChangeStrokeWidth (newWidth) {
|
|
|
|
applyStrokeWidthToSelection(newWidth, this.props.onUpdateSvg);
|
|
|
|
this.props.onChangeStrokeWidth(newWidth);
|
|
|
|
}
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<StrokeWidthIndicatorComponent
|
2017-10-26 17:33:33 -04:00
|
|
|
disabled={this.props.disabled}
|
2017-10-05 18:12:22 -04:00
|
|
|
strokeWidth={this.props.strokeWidth}
|
|
|
|
onChangeStrokeWidth={this.handleChangeStrokeWidth}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-09-08 11:52:36 -04:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2017-10-26 17:33:33 -04:00
|
|
|
disabled: state.scratchPaint.mode === Modes.BRUSH,
|
2017-09-08 11:52:36 -04:00
|
|
|
strokeWidth: state.scratchPaint.color.strokeWidth
|
|
|
|
});
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
2017-09-11 13:54:48 -04:00
|
|
|
onChangeStrokeWidth: strokeWidth => {
|
2017-09-08 11:52:36 -04:00
|
|
|
dispatch(changeStrokeWidth(strokeWidth));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-05 18:12:22 -04:00
|
|
|
StrokeWidthIndicator.propTypes = {
|
2017-10-26 17:33:33 -04:00
|
|
|
disabled: PropTypes.bool.isRequired,
|
2017-10-05 18:12:22 -04:00
|
|
|
onChangeStrokeWidth: PropTypes.func.isRequired,
|
|
|
|
onUpdateSvg: PropTypes.func.isRequired,
|
|
|
|
strokeWidth: PropTypes.number
|
|
|
|
};
|
|
|
|
|
2017-09-08 11:52:36 -04:00
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
2017-10-05 18:12:22 -04:00
|
|
|
)(StrokeWidthIndicator);
|