a11y support
This commit is contained in:
@@ -31,6 +31,7 @@ const CustomError: FC<Props> = ({ statusCode }) => (
|
|||||||
<VStack h="100vh">
|
<VStack h="100vh">
|
||||||
<Header/>
|
<Header/>
|
||||||
<Stack
|
<Stack
|
||||||
|
as="main"
|
||||||
flexGrow={1}
|
flexGrow={1}
|
||||||
color={useColorModeValue("lingva.900", "lingva.100")}
|
color={useColorModeValue("lingva.900", "lingva.100")}
|
||||||
direction={["column", null, "row"]}
|
direction={["column", null, "row"]}
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ type Props = {
|
|||||||
|
|
||||||
const Footer: FC<Props> = (props) => (
|
const Footer: FC<Props> = (props) => (
|
||||||
<Center
|
<Center
|
||||||
|
as="footer"
|
||||||
w="full"
|
w="full"
|
||||||
p={3}
|
p={3}
|
||||||
fontSize={["sm", null, "md"]}
|
fontSize={["sm", null, "md"]}
|
||||||
bgColor={useColorModeValue("lingva.100", "lingva.900")}
|
bgColor={useColorModeValue("lingva.100", "lingva.900")}
|
||||||
color={useColorModeValue("lingva.800", "lingva.200")}
|
color={useColorModeValue("lingva.900", "lingva.100")}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<Text as="span">© 2021 TheDavidDelta</Text>
|
<Text as="span">© 2021 TheDavidDelta</Text>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ type Props = {
|
|||||||
|
|
||||||
const Header: FC<Props> = (props) => (
|
const Header: FC<Props> = (props) => (
|
||||||
<Flex
|
<Flex
|
||||||
|
as="header"
|
||||||
px={1}
|
px={1}
|
||||||
py={3}
|
py={3}
|
||||||
justify="space-around"
|
justify="space-around"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { FC, ChangeEvent } from "react";
|
import { FC, ChangeEvent } from "react";
|
||||||
import { Select } from "@chakra-ui/react";
|
import { Select } from "@chakra-ui/react";
|
||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
value: string,
|
value: string,
|
||||||
onChange: (e: ChangeEvent<any>) => void,
|
onChange: (e: ChangeEvent<any>) => void,
|
||||||
@@ -15,6 +16,7 @@ const LangSelect: FC<Props> = ({ value, onChange, langs, ...props }) => (
|
|||||||
variant="flushed"
|
variant="flushed"
|
||||||
px={2}
|
px={2}
|
||||||
textAlign="center"
|
textAlign="center"
|
||||||
|
style={{ textAlignLast: "center" }}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{langs.map(([code, name]) => (
|
{langs.map(([code, name]) => (
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ const TranslationArea: FC<Props> = ({ value, onChange, readOnly, ...props }) =>
|
|||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
|
lang="auto"
|
||||||
|
dir="auto"
|
||||||
resize="none"
|
resize="none"
|
||||||
rows={useBreakpointValue([6, null, 12]) ?? undefined}
|
rows={useBreakpointValue([6, null, 12]) ?? undefined}
|
||||||
size="lg"
|
size="lg"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useState, useEffect, useReducer, FC, ChangeEvent } from "react";
|
|||||||
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from "next";
|
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from "next";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import Router from "next/router";
|
import Router from "next/router";
|
||||||
import { Stack, VStack, HStack, IconButton } from "@chakra-ui/react";
|
import { Stack, VStack, HStack, IconButton, Button, Link } from "@chakra-ui/react";
|
||||||
import { FaExchangeAlt } from "react-icons/fa";
|
import { FaExchangeAlt } from "react-icons/fa";
|
||||||
import { CustomError, Header, Footer, LangSelect, TranslationArea } from "../components";
|
import { CustomError, Header, Footer, LangSelect, TranslationArea } from "../components";
|
||||||
import { useToastOnLoad } from "../hooks";
|
import { useToastOnLoad } from "../hooks";
|
||||||
@@ -37,7 +37,7 @@ const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ translation,
|
|||||||
const queryIsEmpty = !delayedQuery || delayedQuery === initialState.query;
|
const queryIsEmpty = !delayedQuery || delayedQuery === initialState.query;
|
||||||
const queryIsInitial = delayedQuery === initial?.query;
|
const queryIsInitial = delayedQuery === initial?.query;
|
||||||
const sourceIsInitial = source === initialState.source || source === initial?.source;
|
const sourceIsInitial = source === initialState.source || source === initial?.source;
|
||||||
const targetIsInitial = target === initialState.target || source === initial?.target;
|
const targetIsInitial = target === initialState.target || target === initial?.target;
|
||||||
const allAreInitials = queryIsInitial && sourceIsInitial && targetIsInitial;
|
const allAreInitials = queryIsInitial && sourceIsInitial && targetIsInitial;
|
||||||
|
|
||||||
queryIsEmpty || allAreInitials || Router.push(`/${source}/${target}/${encodeURIComponent(delayedQuery)}`);
|
queryIsEmpty || allAreInitials || Router.push(`/${source}/${target}/${encodeURIComponent(delayedQuery)}`);
|
||||||
@@ -63,12 +63,32 @@ const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ translation,
|
|||||||
<link rel="icon" href="/favicon.svg" />
|
<link rel="icon" href="/favicon.svg" />
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
as={Link}
|
||||||
|
href="#main"
|
||||||
|
userSelect="none"
|
||||||
|
position="absolute"
|
||||||
|
top="-100px"
|
||||||
|
left="0"
|
||||||
|
_focus={{
|
||||||
|
top: "0"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Skip to content
|
||||||
|
</Button>
|
||||||
|
|
||||||
<VStack minH="100vh" spacing={8}>
|
<VStack minH="100vh" spacing={8}>
|
||||||
<Header />
|
<Header />
|
||||||
<VStack px={[8, null, 24, 40]} flexGrow={1} w="full">
|
<VStack
|
||||||
|
as="main"
|
||||||
|
id="main"
|
||||||
|
px={[8, null, 24, 40]}
|
||||||
|
flexGrow={1}
|
||||||
|
w="full">
|
||||||
<HStack px={[1, null, 3, 4]} w="full">
|
<HStack px={[1, null, 3, 4]} w="full">
|
||||||
<LangSelect
|
<LangSelect
|
||||||
id="source"
|
id="source"
|
||||||
|
aria-label="Source language"
|
||||||
value={source}
|
value={source}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
langs={sourceLangs}
|
langs={sourceLangs}
|
||||||
@@ -83,6 +103,7 @@ const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ translation,
|
|||||||
/>
|
/>
|
||||||
<LangSelect
|
<LangSelect
|
||||||
id="target"
|
id="target"
|
||||||
|
aria-label="Target language"
|
||||||
value={target}
|
value={target}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
langs={targetLangs}
|
langs={targetLangs}
|
||||||
@@ -91,12 +112,14 @@ const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ translation,
|
|||||||
<Stack direction={["column", null, "row"]} w="full">
|
<Stack direction={["column", null, "row"]} w="full">
|
||||||
<TranslationArea
|
<TranslationArea
|
||||||
id="query"
|
id="query"
|
||||||
|
aria-label="Translation query"
|
||||||
placeholder="Text"
|
placeholder="Text"
|
||||||
value={query}
|
value={query}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
<TranslationArea
|
<TranslationArea
|
||||||
id="translation"
|
id="translation"
|
||||||
|
aria-label="Translation result"
|
||||||
placeholder="Translation"
|
placeholder="Translation"
|
||||||
value={translation ?? ""}
|
value={translation ?? ""}
|
||||||
readOnly={true}
|
readOnly={true}
|
||||||
|
|||||||
Reference in New Issue
Block a user