go-ethereum/src/components/UI/search/Search.tsx
Paul Wackerow 266b4a3ec4
Accessibility (a11y) clean up (#138)
* Add hidden skip to content for keyboard a11y

* update green.900 value

used for button background; increases contrast ratio

* adjusts light primary to green.700 for contrast

Improves contrast ratio when paired with yellow.50 and removes browser a11y warnings

* add aria-labels

* add lang to html element

* fix improperly ordered headers

We should not be using headers (h4/h5) for these aside navigations. Updated to remove browser warnings.

* add remaining aria-label

* add aria-label for mobile menu
2022-12-12 20:34:10 -03:00

60 lines
1.8 KiB
TypeScript

import { FC, useState } from 'react';
import { Button, Input, InputGroup, Stack } from '@chakra-ui/react';
import { BORDER_WIDTH } from '../../../constants';
import { LensIcon } from '../icons';
export const Search: FC = () => {
const [query, setQuery] = useState<string>('');
// Handlers
const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {
setQuery(e.target.value);
};
return (
<Stack
borderBottom={{ base: BORDER_WIDTH, md: 'none' }}
borderRight={{ base: 'none', md: BORDER_WIDTH }}
borderColor={{ base: 'bg', md: 'primary' }}
_hover={{ base: { bg: 'primary' }, md: { bg: 'none' } }}
>
<form method='get' action='https://duckduckgo.com/' role='search' target='blank'>
<InputGroup alignItems='center'>
<Input type="hidden" name="sites" value="geth.ethereum.org" />
<Input
type="text"
name="q"
py={{ base: 8, md: 4 }}
px={4}
variant='unstyled'
placeholder='search'
size='md'
_placeholder={{ color: { base: 'bg', md: 'primary' }, fontStyle: 'italic' }}
value={query}
onChange={handleChange}
outlineOffset={4}
/>
<Button
type="submit"
px={4}
me={2}
borderRadius='0'
bg='none'
_focusVisible={{
outline: '2px solid var(--chakra-colors-primary)',
outlineOffset: -2
}}
_hover={{
bg: 'primary',
svg: { color: 'bg' }
}}
aria-label="Search"
>
<LensIcon color={{ base: 'bg', md: 'primary' }} fontSize={{ base: '3xl', md: 'xl' }} />
</Button>
</InputGroup>
</form>
</Stack>
);
};