Skip to content

Commit a494940

Browse files
committed
chore: more accessible and lessen the indentation
1 parent af40de0 commit a494940

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/components/TocMobile.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@ export function TocMobile({ headings }: TocMobileProps) {
2121
return (
2222
<div className="lg:hidden flex -mx-2 -mt-2 md:-mx-6 md:-mt-6 pb-3 md:pb-5">
2323
<details className="w-full" onToggle={handleToggle}>
24-
<summary className="px-4 py-3 text-sm font-medium w-full flex content-start items-center gap-2 bg-white/50 dark:bg-black/60 backdrop-blur-lg border-b border-gray-500 border-opacity-20">
24+
<summary
25+
className="px-4 py-3 text-sm font-medium w-full flex content-start items-center gap-2 bg-white/50 dark:bg-black/60 backdrop-blur-lg border-b border-gray-500 border-opacity-20"
26+
aria-expanded={isOpen}
27+
>
2528
<span>{isOpen ? <FaCaretDown /> : <FaCaretRight />}</span>
2629
<span>On this page</span>
2730
</summary>
2831
<div className="px-2 py-2">
2932
<ul className="list-none grid gap-2">
3033
{headings.map((heading) => (
3134
<li
32-
key={heading.id}
35+
key={`mobile-toc-${heading.id}`}
3336
style={{
34-
paddingLeft: `${(heading.level - 1) * 1.5}rem`,
37+
paddingLeft: `${(heading.level - 1) * 0.7}rem`,
3538
}}
3639
>
3740
<Link
3841
to="."
3942
className="text-sm"
4043
hash={heading.id}
4144
dangerouslySetInnerHTML={{ __html: heading.text }}
45+
aria-label={heading.text.replace(/<\/?[^>]+(>|$)/g, '')}
4246
/>
4347
</li>
4448
))}

0 commit comments

Comments
 (0)