Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 70 additions & 11 deletions packages/scratch-gui/src/components/gui/gui.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import classNames from 'classnames';
import omit from 'lodash.omit';
import PropTypes from 'prop-types';
import React, {useEffect, useCallback} from 'react';
import {FormattedMessage, useIntl} from 'react-intl';
import {defineMessages, FormattedMessage, useIntl} from 'react-intl';
import {connect} from 'react-redux';
import MediaQuery from 'react-responsive';
import {Tab, Tabs, TabList, TabPanel} from 'react-tabs';
Expand Down Expand Up @@ -47,6 +47,64 @@ import {setPlatform} from '../../reducers/platform.js';
import {setTheme} from '../../reducers/settings.js';
import {PLATFORM} from '../../lib/platform.js';

const ariaMessages = defineMessages({
menuBar: {
id: 'gui.aria.menuBar',
defaultMessage: 'Menu topbar',
description: 'ARIA label for the top menu bar'
},
editor: {
id: 'gui.aria.editor',
defaultMessage: 'Editor',
description: 'ARIA label for the main editor area'
},
tabList: {
id: 'gui.aria.tabList',
defaultMessage: 'Tab list',
description: 'ARIA label for the editor tab list'
},
codePanel: {
id: 'gui.aria.codePanel',
defaultMessage: 'Code editor panel',
description: 'ARIA label for the code editor panel'
},
costumesPanel: {
id: 'gui.aria.costumesPanel',
defaultMessage: 'Costumes editor panel',
description: 'ARIA label for the costumes editor panel'
},
backdropsPanel: {
id: 'gui.aria.backdropsPanel',
defaultMessage: 'Backdrops editor panel',
description: 'ARIA label for the backdrops editor panel'
},
soundsPanel: {
id: 'gui.aria.soundsPanel',
defaultMessage: 'Sounds editor panel',
description: 'ARIA label for the sounds editor panel'
},
backpack: {
id: 'gui.aria.backpack',
defaultMessage: 'Backpack',
description: 'ARIA label for the backpack'
},
stageAndTarget: {
id: 'gui.aria.stageAndTarget',
defaultMessage: 'Stage and target',
description: 'ARIA label for stage and target area'
},
stage: {
id: 'gui.aria.stage',
defaultMessage: 'Stage',
description: 'ARIA label for the stage'
},
targetPane: {
id: 'gui.aria.targetPane',
defaultMessage: 'Target pane',
description: 'ARIA label for the target pane'
}
});

// Cache this value to only retrieve it once the first time.
// Assume that it doesn't change for a session.
let isRendererSupported = null;
Expand Down Expand Up @@ -274,7 +332,7 @@ const GUIComponent = props => {
) : null}
{!menuBarHidden && <MenuBar
ariaRole="banner"
ariaLabel="Menu topbar"
ariaLabel={intl.formatMessage(ariaMessages.menuBar)}
accountNavOpen={accountNavOpen}
authorId={authorId}
authorThumbnailUrl={authorThumbnailUrl}
Expand Down Expand Up @@ -316,7 +374,7 @@ const GUIComponent = props => {
<Box className={classNames(boxStyles, styles.flexWrapper)}>
<Box
role="main"
aria-label="Editor"
aria-label={intl.formatMessage(ariaMessages.editor)}
className={styles.editorWrapper}
>
<Tabs
Expand All @@ -340,7 +398,7 @@ const GUIComponent = props => {
>
<Box
role="region"
aria-label="Tab List"
aria-label={intl.formatMessage(ariaMessages.tabList)}
>
<TabList className={tabClassNames.tabList}>
<Tab className={tabClassNames.tab}>
Expand Down Expand Up @@ -396,7 +454,7 @@ const GUIComponent = props => {
<Box
className={styles.blocksWrapper}
role="region"
aria-label="Code Editor Panel"
aria-label={intl.formatMessage(ariaMessages.codePanel)}
>
<Blocks
key={`${blocksId}/${colorMode}/${theme}`}
Expand Down Expand Up @@ -427,7 +485,8 @@ const GUIComponent = props => {
</TabPanel>
<TabPanel className={tabClassNames.tabPanel}>
{costumesTabVisible ? <CostumeTab
ariaLabel={targetIsStage ? 'Backdrops Editor Panel' : 'Costumes Editor Panel'}
ariaLabel={targetIsStage ? intl.formatMessage(ariaMessages.backdropsPanel) :
intl.formatMessage(ariaMessages.costumesPanel)}
ariaRole="region"
vm={vm}
onNewLibraryBackdropClick={onNewLibraryBackdropClick}
Expand All @@ -437,7 +496,7 @@ const GUIComponent = props => {
<TabPanel className={tabClassNames.tabPanel}>
{soundsTabVisible ?
<SoundTab
ariaLabel="Sounds Editor Panel"
ariaLabel={intl.formatMessage(ariaMessages.soundsPanel)}
ariaRole="region"
vm={vm}
/> : null}
Expand All @@ -447,14 +506,14 @@ const GUIComponent = props => {
<Backpack
host={backpackHost}
ariaRole="region"
ariaLabel="Backpack"
ariaLabel={intl.formatMessage(ariaMessages.backpack)}
/>
) : null}
</Box>

<Box
role="complementary"
aria-label="Stage and Target"
aria-label={intl.formatMessage(ariaMessages.stageAndTarget)}
className={classNames(styles.stageAndTargetWrapper, styles[stageSize])}
>
<StageWrapper
Expand All @@ -464,12 +523,12 @@ const GUIComponent = props => {
stageSize={stageSize}
vm={vm}
ariaRole="region"
ariaLabel="Stage"
ariaLabel={intl.formatMessage(ariaMessages.stage)}
/>
<Box
className={styles.targetWrapper}
role="region"
aria-label="Target Pane"
aria-label={intl.formatMessage(ariaMessages.targetPane)}
>
<TargetPane
stageSize={stageSize}
Expand Down
Loading