Skip to content

Commit 5c5b907

Browse files
authored
a11y tweaks and fixes (#2099)
1 parent b17f6aa commit 5c5b907

File tree

8 files changed

+38
-14
lines changed

8 files changed

+38
-14
lines changed

components/Button.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Props = PropsWithChildren & {
1111
openInNewTab?: boolean;
1212
style?: StyleProp<TextStyle>;
1313
containerStyle?: StyleProp<ViewStyle>;
14+
tabIndex?: number;
1415
};
1516

1617
export function Button({
@@ -20,6 +21,7 @@ export function Button({
2021
style,
2122
containerStyle,
2223
openInNewTab,
24+
tabIndex,
2325
...rest
2426
}: Props) {
2527
const isLink = !!href;
@@ -36,14 +38,15 @@ export function Button({
3638
<A
3739
href={href}
3840
style={tw`rounded font-sans`}
41+
tabIndex={tabIndex}
3942
{...(openInNewTab ? { target: '_blank' } : {})}
4043
{...rest}>
4144
<Pressable focusable={false} style={buttonStyle} accessible={false}>
4245
{content}
4346
</Pressable>
4447
</A>
4548
) : (
46-
<Pressable onPress={onPress} style={buttonStyle} {...rest}>
49+
<Pressable onPress={onPress} style={buttonStyle} role="button" {...rest}>
4750
{content}
4851
</Pressable>
4952
)}

components/CompatibilityTags.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export default function CompatibilityTags({ library }: Props) {
5454
<Tooltip
5555
side="bottom"
5656
trigger={
57-
<View style={tw`items-center justify-center cursor-pointer`}>
57+
<View
58+
style={tw`items-center justify-center cursor-pointer rounded-full`}
59+
role="button"
60+
aria-label="Additional information">
5861
<Info style={tw`text-icon`} />
5962
</View>
6063
}>

components/Library/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default function Library({ library, skipMetadata, showTrendingMark }: Pro
7777
{libName}
7878
</A>
7979
<HoverEffect>
80-
<A href={library.githubUrl} style={tw`size-5`}>
80+
<A href={library.githubUrl} style={tw`size-5`} aria-label="GitHub repository">
8181
<GitHub
8282
width={20}
8383
height={20}

components/Package/PackageHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function PackageHeader({ library, registryData, rightSlot }: Prop
5252
</View>
5353
)}
5454
<HoverEffect>
55-
<A href={library.githubUrl} style={tw`size-5`}>
55+
<A href={library.githubUrl} style={tw`size-5`} aria-label="GitHub repository">
5656
<GitHub
5757
width={20}
5858
height={20}

components/Package/ReadmeCodeBlock.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export default function ReadmeCodeBlock({ code, lang }: Props) {
3131
if (navigator.clipboard && navigator.clipboard.writeText) {
3232
await navigator.clipboard.writeText(code);
3333
}
34-
}}>
34+
}}
35+
aria-label="Copy to clipboard">
3536
<Copy width={20} height={20} style={tw`text-palette-gray4 dark:text-pewter`} />
3637
</Button>
3738
}>

components/TopBar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export default function TopBar() {
6464
<Button
6565
aria-label="Tools"
6666
href="/tools"
67-
style={tw`size-8.5 px-1 bg-transparent rounded-full`}>
67+
style={tw`size-8.5 px-1 bg-transparent rounded-full`}
68+
tabIndex={-1}>
6869
<Tools style={tw`text-white`} />
6970
</Button>
7071
</View>
@@ -78,7 +79,8 @@ export default function TopBar() {
7879
openInNewTab
7980
aria-label="GitHub repository"
8081
href="https://github.com/react-native-community/directory"
81-
style={tw`size-8.5 px-1 bg-transparent rounded-full`}>
82+
style={tw`size-8.5 px-1 bg-transparent rounded-full`}
83+
tabIndex={-1}>
8284
<GitHub style={tw`text-white`} />
8385
</Button>
8486
</View>

pages/_app.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { SafeAreaProvider } from 'react-native-safe-area-context';
55

66
import Footer from '~/components/Footer';
77
import CustomAppearanceProvider from '~/context/CustomAppearanceProvider';
8-
import tw from '~/util/tailwind';
98

109
import '~/styles/styles.css';
1110

@@ -23,14 +22,16 @@ Sentry.init({
2322
function App({ pageProps, Component }: AppProps) {
2423
return (
2524
<CustomAppearanceProvider>
26-
<SafeAreaProvider style={tw`flex-1`}>
25+
<SafeAreaProvider>
2726
<Head>
2827
<meta
2928
name="viewport"
3029
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=2,viewport-fit=cover"
3130
/>
3231
</Head>
33-
<Component {...pageProps} />
32+
<main>
33+
<Component {...pageProps} />
34+
</main>
3435
<Footer />
3536
</SafeAreaProvider>
3637
</CustomAppearanceProvider>

styles/styles.css

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
format("woff2");
77
font-weight: 300;
88
font-style: normal;
9+
font-display: swap;
910
}
1011

1112
@font-face {
@@ -14,6 +15,7 @@
1415
format("woff2");
1516
font-weight: 500;
1617
font-style: normal;
18+
font-display: swap;
1719
}
1820

1921
@font-face {
@@ -22,6 +24,7 @@
2224
format("woff2");
2325
font-weight: 700;
2426
font-style: normal;
27+
font-display: swap;
2528
}
2629

2730
/* TODO: refactor colors and naming */
@@ -396,6 +399,12 @@ select {
396399
p {
397400
margin-bottom: 0;
398401

402+
&[align="center"] {
403+
picture {
404+
display: block
405+
}
406+
}
407+
399408
& a {
400409
font-size: inherit;
401410
}
@@ -444,7 +453,7 @@ select {
444453
}
445454

446455
picture {
447-
display: block;
456+
display: contents;
448457
}
449458

450459
img {
@@ -518,14 +527,14 @@ select {
518527
margin-bottom: 0;
519528

520529
ul, ol {
521-
padding-top: 8px;
530+
padding-block: 4px;
522531
margin-inline-start: 0;
523532
}
524533
}
525534

526535
li {
527-
&:last-child {
528-
margin-bottom: 12px;
536+
div:last-child {
537+
margin-bottom: 8px;
529538
}
530539

531540
pre {
@@ -534,6 +543,7 @@ select {
534543
}
535544

536545
details {
546+
background-color: var(--table-alt-row);
537547
padding-inline-start: 1rem;
538548

539549
summary {
@@ -560,6 +570,10 @@ select {
560570
text-align: inherit;
561571
}
562572

573+
p {
574+
margin-top: 8px;
575+
}
576+
563577
sub, sup {
564578
text-align: inherit;
565579
}

0 commit comments

Comments
 (0)