Skip to content

Commit e1483ea

Browse files
Added aria-labelledby for table of content (npm#259)
* added aria-labelledby for table of content * added roles
1 parent 41ab70c commit e1483ea

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

theme/src/components/layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ function Layout({children, pageContext, location}) {
108108
pl={1}
109109
pb={1}
110110
>
111-
<Text display="inline-block" fontWeight="bold" mb={1}>
111+
<Text display="inline-block" fontWeight="bold" mb={1} id='table-of-content-label'>
112112
Table of contents
113113
</Text>
114-
<TableOfContents items={pageContext.tableOfContents.items} />
114+
<TableOfContents items={pageContext.tableOfContents.items} labelId='table-of-content-label'/>
115115
</Position>
116116
) : null}
117117
<Box css={{gridArea: 'content'}}>

theme/src/components/table-of-contents.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {Box, Link} from '@primer/components'
22
import React from 'react'
33

4-
function TableOfContents({items, depth}) {
4+
function TableOfContents({items, depth, labelId}) {
55
return (
6-
<Box key={items} as="ul" m={0} p={0} css={{listStyle: 'none', lineHeight: '1.4em'}}>
6+
<Box key={items} as="ul" role='list' m={0} p={0} css={{listStyle: 'none', lineHeight: '1.4em'}} aria-labelledby={labelId}>
77
{items.map(item => (
8-
<Box as="li" key={item.url} pl={depth > 0 ? 3 : 0}>
8+
<Box as="li" role='listitem' key={item.url} pl={depth > 0 ? 3 : 0}>
99
<Link key={item.title} display="inline-block" py={1} href={item.url} color="gray.6">
1010
{item.title}
1111
</Link>

0 commit comments

Comments
 (0)