scratch-gui
Version:
GraphicaL User Interface for creating and running Scratch 3.0 projects
72 lines (64 loc) • 1.79 kB
JSX
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import {defineMessages, injectIntl, intlShape} from 'react-intl';
import GreenFlag from '../green-flag/green-flag.jsx';
import StopAll from '../stop-all/stop-all.jsx';
import TurboMode from '../turbo-mode/turbo-mode.jsx';
import styles from './controls.css';
const messages = defineMessages({
goTitle: {
id: 'gui.controls.go',
defaultMessage: 'Go',
description: 'Green flag button title'
},
stopTitle: {
id: 'gui.controls.stop',
defaultMessage: 'Stop',
description: 'Stop button title'
}
});
const Controls = function (props) {
const {
active,
className,
intl,
onGreenFlagClick,
onStopAllClick,
turbo,
...componentProps
} = props;
return (
<div
className={classNames(styles.controlsContainer, className)}
{...componentProps}
>
<GreenFlag
active={active}
title={intl.formatMessage(messages.goTitle)}
onClick={onGreenFlagClick}
/>
<StopAll
active={active}
title={intl.formatMessage(messages.stopTitle)}
onClick={onStopAllClick}
/>
{turbo ? (
<TurboMode />
) : null}
</div>
);
};
Controls.propTypes = {
active: PropTypes.bool,
className: PropTypes.string,
intl: intlShape.isRequired,
onGreenFlagClick: PropTypes.func.isRequired,
onStopAllClick: PropTypes.func.isRequired,
turbo: PropTypes.bool
};
Controls.defaultProps = {
active: false,
turbo: false
};
export default injectIntl(Controls);