Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add landmark elements and regions for navigation #527

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions lang/ui.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"defaultMessage": "Name of action",
"description": "Placeholder text for user supplied name of a movement-related action, e.g. clapping"
},
"action-region": {
"defaultMessage": "Action \"{action}\"",
"description": "Region label for action row"
},
"action-tooltip": {
"defaultMessage": "The type of movement you want {appNameFull} to recognise e.g. ‘waving’ or ‘clapping’.",
"description": "Tooltip explaining action"
Expand Down Expand Up @@ -395,6 +399,10 @@
"defaultMessage": "Show data features",
"description": "Show data features button text"
},
"data-samples-actions-region": {
"defaultMessage": "Data samples toolbar",
"description": "Region label for data samples actions"
},
"data-samples-label": {
"defaultMessage": "Data samples",
"description": "Heading for data samples column"
Expand Down Expand Up @@ -1387,6 +1395,10 @@
"defaultMessage": "Terms of use",
"description": "Link or menu item link to view terms of use"
},
"testing-model-actions-region": {
"defaultMessage": "Testing model toolbar",
"description": "Region label for testing model actions"
},
"testing-model-title": {
"defaultMessage": "Testing model",
"description": "Testing model page title"
Expand Down
2 changes: 1 addition & 1 deletion src/components/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ActionBar = ({
}: ActionBarProps) => {
return (
<HStack
px={5}
as="header"
alignItems="center"
justifyContent="space-between"
bgColor="brand2.500"
Expand Down
12 changes: 11 additions & 1 deletion src/components/DataSamplesTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@ const DataSamplesTableRow = ({
onConfirm={() => deleteAction(action.ID)}
onCancel={deleteConfirmDisclosure.onClose}
/>
<Box display="contents" onFocusCapture={onSelectRow}>
<Box
role="region"
aria-label={intl.formatMessage(
{
id: "action-region",
},
{ action: action.name }
)}
display="contents"
onFocusCapture={onSelectRow}
>
<GridItem>
<ActionNameCard
value={action}
Expand Down
55 changes: 29 additions & 26 deletions src/components/LedIconPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
PopoverBody,
PopoverContent,
PopoverTrigger,
Portal,
} from "@chakra-ui/react";
import { memo, useCallback } from "react";
import { RiArrowDropDownFill } from "react-icons/ri";
Expand All @@ -28,7 +29,7 @@ const LedIconPicker = ({ onIconSelected }: LedIconPicker) => {
);

return (
<Popover placement="bottom-end" isLazy lazyBehavior="keepMounted">
<Popover placement="right-start" isLazy lazyBehavior="keepMounted">
{({ onClose }) => (
<>
<PopoverTrigger>
Expand All @@ -41,31 +42,33 @@ const LedIconPicker = ({ onIconSelected }: LedIconPicker) => {
<RiArrowDropDownFill size={32} />
</IconButton>
</PopoverTrigger>
<PopoverContent w="100%" height="300px" overflowY="auto">
<PopoverArrow />
<PopoverBody p={4}>
<Grid templateColumns="repeat(4, 1fr)" gap={4}>
{Object.keys(makecodeIcons).map((icon, idx) => (
<IconButton
key={idx}
aria-label={intl.formatMessage(
{ id: "select-icon-option-action-aria" },
{
iconName: intl.formatMessage({
id: `led-icon-option-${icon.toLowerCase()}`,
}),
}
)}
onClick={() => handleClick(icon as MakeCodeIcon, onClose)}
variant="unstyled"
h={20}
w={20}
icon={<LedIconSvg icon={icon as MakeCodeIcon} />}
/>
))}
</Grid>
</PopoverBody>
</PopoverContent>
<Portal>
<PopoverContent w="100%" height="300px" overflowY="auto">
<PopoverArrow />
<PopoverBody p={4}>
<Grid templateColumns="repeat(4, 1fr)" gap={4}>
{Object.keys(makecodeIcons).map((icon, idx) => (
<IconButton
key={idx}
aria-label={intl.formatMessage(
{ id: "select-icon-option-action-aria" },
{
iconName: intl.formatMessage({
id: `led-icon-option-${icon.toLowerCase()}`,
}),
}
)}
onClick={() => handleClick(icon as MakeCodeIcon, onClose)}
variant="unstyled"
h={20}
w={20}
icon={<LedIconSvg icon={icon as MakeCodeIcon} />}
/>
))}
</Grid>
</PopoverBody>
</PopoverContent>
</Portal>
</>
)}
</Popover>
Expand Down
6 changes: 4 additions & 2 deletions src/components/LiveGraphPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
VStack,
} from "@chakra-ui/react";
import { useCallback, useRef } from "react";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";
import { ConnectionStatus } from "../connect-status-hooks";
import { useConnectionStage } from "../connection-stage-hooks";
import microbitImage from "../images/stylised-microbit-black.svg";
Expand Down Expand Up @@ -64,9 +64,11 @@ const LiveGraphPanel = ({
});
void actions.disconnect();
}, [actions, logging]);

const intl = useIntl();
return (
<HStack
role="region"
aria-label={intl.formatMessage({ id: "live-data-graph" })}
position="relative"
h={160}
width="100%"
Expand Down
21 changes: 17 additions & 4 deletions src/components/TestingModelTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Box,
Grid,
GridItem,
GridProps,
Expand All @@ -7,15 +8,16 @@ import {
VStack,
} from "@chakra-ui/react";
import { MakeCodeRenderBlocksProvider } from "@microbit/makecode-embed/react";
import React, { useRef } from "react";
import { useRef } from "react";
import { RiArrowRightLine } from "react-icons/ri";
import { useIntl } from "react-intl";
import { useConnectionStage } from "../connection-stage-hooks";
import { useProject } from "../hooks/project-hooks";
import { mlSettings } from "../mlConfig";
import { getMakeCodeLang } from "../settings";
import { useSettings, useStore } from "../store";
import ActionNameCard from "./ActionNameCard";
import ActionCertaintyCard from "./ActionCertaintyCard";
import ActionNameCard from "./ActionNameCard";
import CodeViewCard from "./CodeViewCard";
import CodeViewDefaultBlockCard from "./CodeViewDefaultBlockCard";
import HeadingGrid from "./HeadingGrid";
Expand Down Expand Up @@ -51,6 +53,7 @@ const TestingModelTable = () => {
const [{ languageId }] = useSettings();
const makeCodeLang = getMakeCodeLang(languageId);
const scrollableAreaRef = useRef<HTMLDivElement>(null);
const intl = useIntl();
return (
<MakeCodeRenderBlocksProvider
key={makeCodeLang}
Expand Down Expand Up @@ -83,7 +86,17 @@ const TestingModelTable = () => {
{actions.map((action, idx) => {
const { requiredConfidence: threshold } = action;
return (
<React.Fragment key={idx}>
<Box
key={idx}
role="region"
aria-label={intl.formatMessage(
{
id: "action-region",
},
{ action: action.name }
)}
display="contents"
>
<GridItem>
<ActionNameCard
value={action}
Expand Down Expand Up @@ -112,7 +125,7 @@ const TestingModelTable = () => {
<CodeViewDefaultBlockCard action={action} />
)}
</GridItem>
</React.Fragment>
</Box>
);
})}
</Grid>
Expand Down
26 changes: 26 additions & 0 deletions src/messages/ui.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
"value": "Name of action"
}
],
"action-region": [
{
"type": 0,
"value": "Action \""
},
{
"type": 1,
"value": "action"
},
{
"type": 0,
"value": "\""
}
],
"action-tooltip": [
{
"type": 0,
Expand Down Expand Up @@ -663,6 +677,12 @@
"value": "Show data features"
}
],
"data-samples-actions-region": [
{
"type": 0,
"value": "Data samples toolbar"
}
],
"data-samples-label": [
{
"type": 0,
Expand Down Expand Up @@ -2435,6 +2455,12 @@
"value": "Terms of use"
}
],
"testing-model-actions-region": [
{
"type": 0,
"value": "Testing model toolbar"
}
],
"testing-model-title": [
{
"type": 0,
Expand Down
20 changes: 13 additions & 7 deletions src/pages/DataSamplesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, HStack, VStack } from "@chakra-ui/react";
import { Button, Flex, HStack, VStack } from "@chakra-ui/react";
import { useCallback, useEffect, useRef, useState } from "react";
import { RiAddLine, RiArrowRightLine } from "react-icons/ri";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";
import { useNavigate } from "react-router";
import DataSamplesTable from "../components/DataSamplesTable";
import DefaultPageLayout, {
Expand Down Expand Up @@ -45,7 +45,7 @@ const DataSamplesPage = () => {
setSelectedActionIdx(actions.length);
addNewAction();
}, [addNewAction, actions]);

const intl = useIntl();
return (
<>
<TrainModelDialogs finalFocusRef={trainButtonRef} />
Expand All @@ -55,12 +55,18 @@ const DataSamplesPage = () => {
menuItems={<ProjectMenuItems />}
toolbarItemsRight={<ProjectToolbarItems />}
>
<DataSamplesTable
selectedActionIdx={selectedActionIdx}
setSelectedActionIdx={setSelectedActionIdx}
/>
<Flex as="main" flexGrow={1} flexDir="column">
<DataSamplesTable
selectedActionIdx={selectedActionIdx}
setSelectedActionIdx={setSelectedActionIdx}
/>
</Flex>
<VStack w="full" flexShrink={0} bottom={0} gap={0} bg="gray.25">
<HStack
role="region"
aria-label={intl.formatMessage({
id: "data-samples-actions-region",
})}
justifyContent="space-between"
px={5}
py={2}
Expand Down
9 changes: 8 additions & 1 deletion src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ const HomePage = () => {
</Button>
}
>
<Container centerContent gap={20} p={8} pb={20} maxW="container.lg">
<Container
as="main"
centerContent
gap={20}
p={8}
pb={20}
maxW="container.lg"
>
<HStack
gap={5}
flexDir={{ base: "column", lg: "row" }}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ImportPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const ImportPage = () => {
toolbarItemsRight={<HomeToolbarItem />}
menuItems={<HomeMenuItem />}
>
<VStack justifyContent="center">
<VStack as="main" justifyContent="center">
<Stack
bgColor="white"
spacing={5}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/NewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const NewPage = () => {
menuItems={<HomeMenuItem />}
>
<LoadProjectInput ref={loadProjectRef} accept=".json,.hex" />
<VStack alignItems="center">
<VStack as="main" alignItems="center">
<Container maxW="1180px" alignItems="stretch" p={4} mt={8}>
<VStack alignItems="stretch" w="100%">
<Heading as="h1" fontSize="4xl" fontWeight="bold">
Expand Down
9 changes: 8 additions & 1 deletion src/pages/TestingModelPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Button,
ButtonGroup,
Flex,
HStack,
Menu,
MenuItem,
Expand Down Expand Up @@ -119,9 +120,15 @@ const TestingModelPage = () => {
stage="openEditor"
onNextLoading={editorLoading}
/>
<TestingModelTable />
<Flex as="main" flexGrow={1} flexDir="column">
<TestingModelTable />
</Flex>
<VStack w="full" flexShrink={0} bottom={0} gap={0} bg="gray.25">
<HStack
role="region"
aria-label={intl.formatMessage({
id: "testing-model-actions-region",
})}
justifyContent="right"
px={5}
py={2}
Expand Down
Loading