Disable fill or outline indicators for brush, line and pen mode.

This commit is contained in:
Paul Kaplan 2017-10-26 17:33:33 -04:00
parent 40ec57fbf1
commit b8aadc3c54
8 changed files with 23 additions and 4 deletions

View file

@ -17,7 +17,7 @@ const messages = defineMessages({
}); });
const FillColorIndicatorComponent = props => ( const FillColorIndicatorComponent = props => (
<InputGroup> <InputGroup disabled={props.disabled}>
<Popover <Popover
body={ body={
<ColorPicker <ColorPicker

View file

@ -3,3 +3,9 @@
.input-group + .input-group { .input-group + .input-group {
margin-left: calc(3 * $grid-unit); margin-left: calc(3 * $grid-unit);
} }
.disabled {
opacity: 0.3;
/* Prevent any user actions */
pointer-events: none;
}

View file

@ -5,7 +5,9 @@ import PropTypes from 'prop-types';
import styles from './input-group.css'; import styles from './input-group.css';
const InputGroup = props => ( const InputGroup = props => (
<div className={classNames(props.className, styles.inputGroup)}> <div className={classNames(props.className, styles.inputGroup, {
[styles.disabled]: props.disabled
})}>
{props.children} {props.children}
</div> </div>
); );

View file

@ -17,7 +17,7 @@ const messages = defineMessages({
}); });
const StrokeColorIndicatorComponent = props => ( const StrokeColorIndicatorComponent = props => (
<InputGroup> <InputGroup disabled={props.disabled}>
<Popover <Popover
body={ body={
<ColorPicker <ColorPicker

View file

@ -9,8 +9,9 @@ import {MAX_STROKE_WIDTH} from '../reducers/stroke-width';
const BufferedInput = BufferedInputHOC(Input); const BufferedInput = BufferedInputHOC(Input);
const StrokeWidthIndicatorComponent = props => ( const StrokeWidthIndicatorComponent = props => (
<InputGroup> <InputGroup disabled={props.disabled}>
<BufferedInput <BufferedInput
disabled={props.disabled}
small small
max={MAX_STROKE_WIDTH} max={MAX_STROKE_WIDTH}
min="0" min="0"

View file

@ -4,6 +4,7 @@ import React from 'react';
import bindAll from 'lodash.bindall'; import bindAll from 'lodash.bindall';
import {changeFillColor} from '../reducers/fill-color'; import {changeFillColor} from '../reducers/fill-color';
import {openFillColor, closeFillColor} from '../reducers/modals'; import {openFillColor, closeFillColor} from '../reducers/modals';
import Modes from '../modes/modes';
import FillColorIndicatorComponent from '../components/fill-color-indicator.jsx'; import FillColorIndicatorComponent from '../components/fill-color-indicator.jsx';
import {applyFillColorToSelection} from '../helper/style-path'; import {applyFillColorToSelection} from '../helper/style-path';
@ -30,6 +31,7 @@ class FillColorIndicator extends React.Component {
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
disabled: state.scratchPaint.mode === Modes.PEN,
fillColor: state.scratchPaint.color.fillColor, fillColor: state.scratchPaint.color.fillColor,
fillColorModalVisible: state.scratchPaint.modals.fillColor fillColorModalVisible: state.scratchPaint.modals.fillColor
}); });
@ -47,6 +49,7 @@ const mapDispatchToProps = dispatch => ({
}); });
FillColorIndicator.propTypes = { FillColorIndicator.propTypes = {
disabled: PropTypes.bool.isRequired,
fillColor: PropTypes.string, fillColor: PropTypes.string,
onChangeFillColor: PropTypes.func.isRequired, onChangeFillColor: PropTypes.func.isRequired,
onUpdateSvg: PropTypes.func.isRequired onUpdateSvg: PropTypes.func.isRequired

View file

@ -4,6 +4,7 @@ import React from 'react';
import bindAll from 'lodash.bindall'; import bindAll from 'lodash.bindall';
import {changeStrokeColor} from '../reducers/stroke-color'; import {changeStrokeColor} from '../reducers/stroke-color';
import {openStrokeColor, closeStrokeColor} from '../reducers/modals'; import {openStrokeColor, closeStrokeColor} from '../reducers/modals';
import Modes from '../modes/modes';
import StrokeColorIndicatorComponent from '../components/stroke-color-indicator.jsx'; import StrokeColorIndicatorComponent from '../components/stroke-color-indicator.jsx';
import {applyStrokeColorToSelection} from '../helper/style-path'; import {applyStrokeColorToSelection} from '../helper/style-path';
@ -30,6 +31,7 @@ class StrokeColorIndicator extends React.Component {
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
disabled: state.scratchPaint.mode === Modes.BRUSH,
strokeColor: state.scratchPaint.color.strokeColor, strokeColor: state.scratchPaint.color.strokeColor,
strokeColorModalVisible: state.scratchPaint.modals.strokeColor strokeColorModalVisible: state.scratchPaint.modals.strokeColor
}); });
@ -47,6 +49,7 @@ const mapDispatchToProps = dispatch => ({
}); });
StrokeColorIndicator.propTypes = { StrokeColorIndicator.propTypes = {
disabled: PropTypes.bool.isRequired,
onChangeStrokeColor: PropTypes.func.isRequired, onChangeStrokeColor: PropTypes.func.isRequired,
onUpdateSvg: PropTypes.func.isRequired, onUpdateSvg: PropTypes.func.isRequired,
strokeColor: PropTypes.string strokeColor: PropTypes.string

View file

@ -5,6 +5,7 @@ import bindAll from 'lodash.bindall';
import {changeStrokeWidth} from '../reducers/stroke-width'; import {changeStrokeWidth} from '../reducers/stroke-width';
import StrokeWidthIndicatorComponent from '../components/stroke-width-indicator.jsx'; import StrokeWidthIndicatorComponent from '../components/stroke-width-indicator.jsx';
import {applyStrokeWidthToSelection} from '../helper/style-path'; import {applyStrokeWidthToSelection} from '../helper/style-path';
import Modes from '../modes/modes';
class StrokeWidthIndicator extends React.Component { class StrokeWidthIndicator extends React.Component {
constructor (props) { constructor (props) {
@ -20,6 +21,7 @@ class StrokeWidthIndicator extends React.Component {
render () { render () {
return ( return (
<StrokeWidthIndicatorComponent <StrokeWidthIndicatorComponent
disabled={this.props.disabled}
strokeWidth={this.props.strokeWidth} strokeWidth={this.props.strokeWidth}
onChangeStrokeWidth={this.handleChangeStrokeWidth} onChangeStrokeWidth={this.handleChangeStrokeWidth}
/> />
@ -28,6 +30,7 @@ class StrokeWidthIndicator extends React.Component {
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
disabled: state.scratchPaint.mode === Modes.BRUSH,
strokeWidth: state.scratchPaint.color.strokeWidth strokeWidth: state.scratchPaint.color.strokeWidth
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
@ -37,6 +40,7 @@ const mapDispatchToProps = dispatch => ({
}); });
StrokeWidthIndicator.propTypes = { StrokeWidthIndicator.propTypes = {
disabled: PropTypes.bool.isRequired,
onChangeStrokeWidth: PropTypes.func.isRequired, onChangeStrokeWidth: PropTypes.func.isRequired,
onUpdateSvg: PropTypes.func.isRequired, onUpdateSvg: PropTypes.func.isRequired,
strokeWidth: PropTypes.number strokeWidth: PropTypes.number