import classNames from 'classnames'; import {connect} from 'react-redux'; import PropTypes from 'prop-types'; import React from 'react'; import MediaQuery from 'react-responsive'; import {shouldShowGroup, shouldShowUngroup} from '../../helper/group'; import {shouldShowBringForward, shouldShowSendBackward} from '../../helper/order'; import BufferedInputHOC from '../forms/buffered-input-hoc.jsx'; import Button from '../button/button.jsx'; import ButtonGroup from '../button-group/button-group.jsx'; import Dropdown from '../dropdown/dropdown.jsx'; import {defineMessages, injectIntl, intlShape} from 'react-intl'; import Formats, {isVector} from '../../lib/format'; import Input from '../forms/input.jsx'; import InputGroup from '../input-group/input-group.jsx'; import Label from '../forms/label.jsx'; import LabeledIconButton from '../labeled-icon-button/labeled-icon-button.jsx'; import layout from '../../lib/layout-constants'; import {hideLabel} from '../../lib/hide-label'; import styles from './fixed-tools.css'; import groupIcon from './icons/group.svg'; import redoIcon from './icons/redo.svg'; import sendBackIcon from './icons/send-back.svg'; import sendBackwardIcon from './icons/send-backward.svg'; import sendForwardIcon from './icons/send-forward.svg'; import sendFrontIcon from './icons/send-front.svg'; import undoIcon from './icons/undo.svg'; import ungroupIcon from './icons/ungroup.svg'; const BufferedInput = BufferedInputHOC(Input); const messages = defineMessages({ costume: { id: 'paint.paintEditor.costume', description: 'Label for the name of a costume', defaultMessage: 'Costume' }, group: { defaultMessage: 'Group', description: 'Label for the button to group shapes', id: 'paint.paintEditor.group' }, ungroup: { defaultMessage: 'Ungroup', description: 'Label for the button to ungroup shapes', id: 'paint.paintEditor.ungroup' }, undo: { defaultMessage: 'Undo', description: 'Alt to image for the button to undo an action', id: 'paint.paintEditor.undo' }, redo: { defaultMessage: 'Redo', description: 'Alt to image for the button to redo an action', id: 'paint.paintEditor.redo' }, forward: { defaultMessage: 'Forward', description: 'Label for the `Send forward on canvas` button', id: 'paint.paintEditor.forward' }, backward: { defaultMessage: 'Backward', description: 'Label for the `Send backward on canvas` button', id: 'paint.paintEditor.backward' }, front: { defaultMessage: 'Front', description: 'Label for the `Send to front of canvas` button', id: 'paint.paintEditor.front' }, back: { defaultMessage: 'Back', description: 'Label for the `Send to back of canvas` button', id: 'paint.paintEditor.back' }, more: { defaultMessage: 'More', description: 'Label for dropdown to access more action buttons', id: 'paint.paintEditor.more' } }); const FixedToolsComponent = props => { const redoDisabled = !props.canRedo(); const undoDisabled = !props.canUndo(); return (
{/* Name field */} {/* Undo/Redo */} {/* Group/Ungroup */} {isVector(props.format) ? : null } {/* Forward/Backward */} {isVector(props.format) ? : null } {isVector(props.format) ? {/* To be rotation point */} {/* */} : null } {isVector(props.format) ? {/* To be rotation point */} {/* */} } tipSize={.01} > {props.intl.formatMessage(messages.more)} : null }
); }; FixedToolsComponent.propTypes = { canRedo: PropTypes.func.isRequired, canUndo: PropTypes.func.isRequired, format: PropTypes.oneOf(Object.keys(Formats)), intl: intlShape, name: PropTypes.string, onGroup: PropTypes.func.isRequired, onRedo: PropTypes.func.isRequired, onSendBackward: PropTypes.func.isRequired, onSendForward: PropTypes.func.isRequired, onSendToBack: PropTypes.func.isRequired, onSendToFront: PropTypes.func.isRequired, onUndo: PropTypes.func.isRequired, onUngroup: PropTypes.func.isRequired, onUpdateName: PropTypes.func.isRequired, rtl: PropTypes.bool.isRequired, width: PropTypes.number }; const mapStateToProps = state => ({ format: state.scratchPaint.format, rtl: state.scratchPaint.layout.rtl, selectedItems: state.scratchPaint.selectedItems, undoState: state.scratchPaint.undo }); export default connect( mapStateToProps )(injectIntl(FixedToolsComponent));