scratch-paint/src/containers/stroke-color-indicator.jsx

74 lines
2.6 KiB
React
Raw Normal View History

2017-09-07 17:59:14 -04:00
import {connect} from 'react-redux';
import {defineMessages} from 'react-intl';
import {changeColorIndex} from '../reducers/color-index';
import {changeStrokeColor, changeStrokeColor2, changeStrokeGradientType} from '../reducers/stroke-style';
import {changeStrokeWidth} from '../reducers/stroke-width';
2017-10-11 09:05:34 -04:00
import {openStrokeColor, closeStrokeColor} from '../reducers/modals';
import {getSelectedLeafItems} from '../helper/selection';
import {setSelectedItems} from '../reducers/selected-items';
import Modes, {GradientToolsModes} from '../lib/modes';
import {isBitmap} from '../lib/format';
2017-10-11 09:05:34 -04:00
import makeColorIndicator from './color-indicator.jsx';
const messages = defineMessages({
label: {
id: 'paint.paintEditor.stroke',
description: 'Label for the color picker for the outline color',
defaultMessage: 'Outline'
}
});
const StrokeColorIndicator = makeColorIndicator(messages.label, true);
2017-09-07 17:59:14 -04:00
const mapStateToProps = state => ({
colorIndex: state.scratchPaint.fillMode.colorIndex,
2018-03-22 17:53:17 -04:00
disabled: state.scratchPaint.mode === Modes.BRUSH ||
2018-07-17 16:37:03 -04:00
state.scratchPaint.mode === Modes.TEXT ||
state.scratchPaint.mode === Modes.FILL,
color: state.scratchPaint.color.strokeColor.primary,
color2: state.scratchPaint.color.strokeColor.secondary,
2020-06-09 15:02:36 -04:00
fillBitmapShapes: state.scratchPaint.fillBitmapShapes,
colorModalVisible: state.scratchPaint.modals.strokeColor,
format: state.scratchPaint.format,
gradientType: state.scratchPaint.color.strokeColor.gradientType,
isEyeDropping: state.scratchPaint.color.eyeDropper.active,
mode: state.scratchPaint.mode,
shouldShowGradientTools: state.scratchPaint.mode in GradientToolsModes,
textEditTarget: state.scratchPaint.textEditTarget
2017-09-07 17:59:14 -04:00
});
2017-10-11 09:05:34 -04:00
2017-09-07 17:59:14 -04:00
const mapDispatchToProps = dispatch => ({
onChangeColorIndex: index => {
dispatch(changeColorIndex(index));
},
onChangeColor: (strokeColor, index) => {
if (index === 0) {
dispatch(changeStrokeColor(strokeColor));
} else if (index === 1) {
dispatch(changeStrokeColor2(strokeColor));
}
2017-10-11 09:05:34 -04:00
},
onChangeStrokeWidth: strokeWidth => {
dispatch(changeStrokeWidth(strokeWidth));
},
onOpenColor: () => {
2017-10-11 09:05:34 -04:00
dispatch(openStrokeColor());
},
onCloseColor: () => {
2017-10-11 09:05:34 -04:00
dispatch(closeStrokeColor());
},
onChangeGradientType: gradientType => {
dispatch(changeStrokeGradientType(gradientType));
},
setSelectedItems: format => {
dispatch(setSelectedItems(getSelectedLeafItems(), isBitmap(format)));
2017-09-07 17:59:14 -04:00
}
});
export default connect(
mapStateToProps,
mapDispatchToProps
2017-10-05 18:12:22 -04:00
)(StrokeColorIndicator);