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

54 lines
1.7 KiB
React
Raw Normal View History

2017-09-07 17:59:14 -04:00
import React from 'react';
import PropTypes from 'prop-types';
2017-10-11 09:05:34 -04:00
import Popover from 'react-popover';
2017-09-07 17:59:14 -04:00
import {defineMessages, injectIntl, intlShape} from 'react-intl';
import ColorPicker from './color-picker/color-picker.jsx';
import ColorButton from './color-button/color-button.jsx';
import InputGroup from './input-group/input-group.jsx';
import Label from './forms/label.jsx';
2017-09-07 17:59:14 -04:00
const messages = defineMessages({
stroke: {
id: 'paint.paintEditor.stroke',
description: 'Label for the color picker for the outline color',
defaultMessage: 'Outline'
}
});
2017-10-11 09:05:34 -04:00
2017-09-07 17:59:14 -04:00
const StrokeColorIndicatorComponent = props => (
<InputGroup disabled={props.disabled}>
2017-10-11 09:05:34 -04:00
<Popover
body={
<ColorPicker
color={props.strokeColor}
onChangeColor={props.onChangeStrokeColor}
/>
}
isOpen={props.strokeColorModalVisible}
preferPlace="below"
onOuterAction={props.onCloseStrokeColor}
>
<Label text={props.intl.formatMessage(messages.stroke)}>
<ColorButton
outline
2017-10-11 09:05:34 -04:00
color={props.strokeColor}
onClick={props.onOpenStrokeColor}
/>
</Label>
</Popover>
</InputGroup>
2017-09-07 17:59:14 -04:00
);
StrokeColorIndicatorComponent.propTypes = {
2017-10-26 18:16:14 -04:00
disabled: PropTypes.bool.isRequired,
2017-09-07 17:59:14 -04:00
intl: intlShape,
onChangeStrokeColor: PropTypes.func.isRequired,
2017-10-11 09:05:34 -04:00
onCloseStrokeColor: PropTypes.func.isRequired,
onOpenStrokeColor: PropTypes.func.isRequired,
strokeColor: PropTypes.string,
strokeColorModalVisible: PropTypes.bool.isRequired
2017-09-07 17:59:14 -04:00
};
export default injectIntl(StrokeColorIndicatorComponent);