Skip to content

Commit 99269c6

Browse files
authored
Merge pull request #9576 from TylerAPfledderer/a11y/refactor-meetup-list
A11y/refactor meetup list
2 parents 0403552 + 7ae40db commit 99269c6

File tree

1 file changed

+73
-64
lines changed

1 file changed

+73
-64
lines changed

src/components/MeetupList.tsx

Lines changed: 73 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import {
77
Input,
88
LinkBox,
99
LinkOverlay,
10+
List,
11+
ListItem,
1012
Text,
11-
useColorMode,
13+
useColorModeValue,
14+
VisuallyHidden,
1215
} from "@chakra-ui/react"
1316

1417
// Components
@@ -53,7 +56,11 @@ export interface IProps {}
5356
const MeetupList: React.FC<IProps> = () => {
5457
const [searchField, setSearchField] = useState<string>("")
5558
const filteredMeetups = filterMeetups(searchField)
56-
const { colorMode } = useColorMode()
59+
const listBoxShadow = useColorModeValue("tableBox.light", "tableBox.dark")
60+
const listItemBoxShadow = useColorModeValue(
61+
"tableItemBox.light",
62+
"tableItemBox.dark"
63+
)
5764

5865
const handleSearch = (event: React.ChangeEvent<HTMLInputElement>): void => {
5966
setSearchField(event.target.value)
@@ -82,70 +89,72 @@ const MeetupList: React.FC<IProps> = () => {
8289
w="100%"
8390
_focus={{ outline: "auto 1px" }}
8491
_placeholder={{ color: "text200" }}
92+
aria-describedby="input-instruction"
8593
/>
86-
<Box
87-
boxShadow={colorMode === "dark" ? "tableBox.dark" : "tableBox.light"}
88-
>
89-
{filteredMeetups.length ? (
90-
filteredMeetups.map((meetup, idx) => (
91-
<LinkBox
92-
key={idx}
93-
display="flex"
94-
justifyContent="space-between"
95-
boxShadow={
96-
colorMode === "dark"
97-
? "tableItemBox.dark"
98-
: "tableItemBox.light"
99-
}
100-
mb={0.25}
101-
p={4}
102-
w="100%"
103-
_hover={{
104-
textDecoration: "none",
105-
borderRadius: "base",
106-
boxShadow: "0 0 1px primary",
107-
bg: "tableBackgroundHover",
108-
}}
94+
{/* hidden for attachment to input only */}
95+
<VisuallyHidden hidden id="input-instruction">
96+
results update as you type
97+
</VisuallyHidden>
98+
99+
<List m={0} boxShadow={listBoxShadow} aria-label="Event meetup results">
100+
{filteredMeetups.map((meetup, idx) => (
101+
<LinkBox
102+
as={ListItem}
103+
key={idx}
104+
display="flex"
105+
justifyContent="space-between"
106+
boxShadow={listItemBoxShadow}
107+
mb={0.25}
108+
p={4}
109+
w="100%"
110+
_hover={{
111+
textDecoration: "none",
112+
borderRadius: "base",
113+
boxShadow: "0 0 1px primary",
114+
bg: "tableBackgroundHover",
115+
}}
116+
>
117+
<Flex flex="1 1 75%" mr={4}>
118+
<Box mr={4} opacity="0.4">
119+
{idx + 1}
120+
</Box>
121+
<Box>
122+
<LinkOverlay
123+
as={Link}
124+
href={meetup.link}
125+
textDecor="none"
126+
color="text"
127+
hideArrow
128+
>
129+
{meetup.title}
130+
</LinkOverlay>
131+
</Box>
132+
</Flex>
133+
<Flex
134+
textAlign="right"
135+
alignContent="flex-start"
136+
flex="1 1 25%"
137+
mr={4}
138+
flexWrap="wrap"
109139
>
110-
<Flex flex="1 1 75%" mr={4}>
111-
<Box mr={4} opacity="0.4">
112-
{idx + 1}
113-
</Box>
114-
<Box>
115-
<LinkOverlay
116-
as={Link}
117-
href={meetup.link}
118-
textDecor="none"
119-
color="text"
120-
hideArrow
121-
>
122-
{meetup.title}
123-
</LinkOverlay>
124-
</Box>
125-
</Flex>
126-
<Flex
127-
textAlign="right"
128-
alignContent="flex-start"
129-
flex="1 1 25%"
130-
mr={4}
131-
flexWrap="wrap"
132-
>
133-
<Emoji text={meetup.emoji} boxSize={4} mr={2} />
134-
<Text mb={0} opacity={"0.6"}>
135-
{meetup.location}
136-
</Text>
137-
</Flex>
138-
<Box
139-
as="span"
140-
_after={{
141-
content: '"↗"',
142-
ml: 0.5,
143-
mr: 1.5,
144-
}}
145-
></Box>
146-
</LinkBox>
147-
))
148-
) : (
140+
<Emoji text={meetup.emoji} boxSize={4} mr={2} />
141+
<Text mb={0} opacity={"0.6"}>
142+
{meetup.location}
143+
</Text>
144+
</Flex>
145+
<Box
146+
as="span"
147+
_after={{
148+
content: '"↗"',
149+
ml: 0.5,
150+
mr: 1.5,
151+
}}
152+
></Box>
153+
</LinkBox>
154+
))}
155+
</List>
156+
<Box aria-live="assertive" aria-atomic>
157+
{!filteredMeetups.length && (
149158
<InfoBanner emoji=":information_source:">
150159
<Translation id="page-community-meetuplist-no-meetups" />{" "}
151160
<Link to="https://github.com/ethereum/ethereum-org-website/blob/dev/src/data/community-meetups.json">

0 commit comments

Comments
 (0)