import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; import {defineMessages, FormattedMessage, injectIntl, intlShape} from 'react-intl'; import {Tab, Tabs, TabList, TabPanel} from 'react-tabs'; import MediaQuery from 'react-responsive'; import tabStyles from 'react-tabs/style/react-tabs.css'; import VM from 'scratch-vm'; import Renderer from 'scratch-render'; import Blocks from '../../containers/blocks.jsx'; import CostumeTab from '../../containers/costume-tab.jsx'; import TargetPane from '../../containers/target-pane.jsx'; import SoundTab from '../../containers/sound-tab.jsx'; import StageHeader from '../../containers/stage-header.jsx'; import Stage from '../../containers/stage.jsx'; import Loader from '../loader/loader.jsx'; import Box from '../box/box.jsx'; import FeedbackForm from '../feedback-form/feedback-form.jsx'; import MenuBar from '../menu-bar/menu-bar.jsx'; import PreviewModal from '../../containers/preview-modal.jsx'; import ImportModal from '../../containers/import-modal.jsx'; import WebGlModal from '../../containers/webgl-modal.jsx'; import layout from '../../lib/layout-constants.js'; import styles from './gui.css'; import addExtensionIcon from './icon--extensions.svg'; import codeIcon from './icon--code.svg'; import costumesIcon from './icon--costumes.svg'; import soundsIcon from './icon--sounds.svg'; const messages = defineMessages({ addExtension: { id: 'gui.gui.addExtension', description: 'Button to add an extension in the target pane', defaultMessage: 'Add Extension' } }); // Cache this value to only retreive it once the first time. // Assume that it doesn't change for a session. let isRendererSupported = null; const GUIComponent = props => { const { activeTabIndex, basePath, blocksTabVisible, children, costumesTabVisible, feedbackFormVisible, importInfoVisible, intl, loading, onExtensionButtonClick, onActivateTab, previewInfoVisible, soundsTabVisible, vm, ...componentProps } = props; if (children) { return ( {children} ); } const tabClassNames = { tabs: styles.tabs, tab: classNames(tabStyles.reactTabsTab, styles.tab), tabList: classNames(tabStyles.reactTabsTabList, styles.tabList), tabPanel: classNames(tabStyles.reactTabsTabPanel, styles.tabPanel), tabPanelSelected: classNames(tabStyles.reactTabsTabPanelSelected, styles.isSelected), tabSelected: classNames(tabStyles.reactTabsTabSelected, styles.isSelected) }; if (isRendererSupported === null) { isRendererSupported = Renderer.isSupported(); } return ( {previewInfoVisible ? ( ) : null} {loading ? ( ) : null} {importInfoVisible ? ( ) : null} {feedbackFormVisible ? ( ) : null} {isRendererSupported ? null : ( )} {costumesTabVisible ? : null} {soundsTabVisible ? : null} {/* eslint-disable arrow-body-style */} {isFullSize => { return isRendererSupported ? ( ) : null; }} {/* eslint-enable arrow-body-style */} ); }; GUIComponent.propTypes = { activeTabIndex: PropTypes.number, basePath: PropTypes.string, blocksTabVisible: PropTypes.bool, children: PropTypes.node, costumesTabVisible: PropTypes.bool, feedbackFormVisible: PropTypes.bool, importInfoVisible: PropTypes.bool, intl: intlShape.isRequired, loading: PropTypes.bool, onActivateTab: PropTypes.func, onExtensionButtonClick: PropTypes.func, onTabSelect: PropTypes.func, previewInfoVisible: PropTypes.bool, soundsTabVisible: PropTypes.bool, vm: PropTypes.instanceOf(VM).isRequired }; GUIComponent.defaultProps = { basePath: './' }; export default injectIntl(GUIComponent);