Skip to content

Commit c2c8a71

Browse files
authored
docs(a11y): fix audited issues (#4608)
1 parent 92a48ab commit c2c8a71

File tree

1 file changed

+13
-2
lines changed
  • packages/core-theme-documentation-generator/src

1 file changed

+13
-2
lines changed

packages/core-theme-documentation-generator/src/theme.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ class SdkThemeContext extends DefaultThemeRenderContext {
124124
// wait for container to exist
125125
waitForElm('.container-main')
126126
.then(elm => {
127+
elm.role = "main"
128+
elm.tabIndex = "-1"
129+
130+
document.querySelector('.tsd-navigation.secondary')['ariaLabel'] = "Types"
131+
127132
if (document.querySelectorAll('img[alt~="NPM"]').length > 0) {
128133
const versionEl = document.querySelector('img[alt="NPM version"]')
129134
const downloadsEl = document.querySelector('img[alt="NPM downloads"]')
@@ -136,7 +141,7 @@ class SdkThemeContext extends DefaultThemeRenderContext {
136141
return res.json()
137142
})
138143
.then(({ version }) => {
139-
versionEl.alt += ' ' + version
144+
versionEl.alt = "NPM latest version V" + version
140145
})
141146
.catch(err => {
142147
console.error(err)
@@ -148,7 +153,12 @@ class SdkThemeContext extends DefaultThemeRenderContext {
148153
return res.json()
149154
})
150155
.then(({ downloads }) => {
151-
downloadsEl.alt += ' ' + downloads.toString() + ' per month'
156+
function formatDownloads(num) {
157+
if (num < 1000) return num.toString()
158+
if (num < 1000000) return (num.toPrecision(2) / 1000).toString() + 'k'
159+
if (num < 1000000000) return (num.toPrecision(2) / 1000000).toString() + 'M'
160+
}
161+
downloadsEl.alt = 'downloads ' + formatDownloads(downloads) + '/month'
152162
})
153163
.catch(err => {
154164
console.error(err)
@@ -331,6 +341,7 @@ class SdkThemeContext extends DefaultThemeRenderContext {
331341
return (
332342
<div>
333343
{categories.map((category: ReflectionCategory) => {
344+
if (category.children.length === 0) return "";
334345
return (
335346
<nav class="tsd-navigation" aria-label={category.title}>
336347
<details class="tsd-index-accordion" open={true}>

0 commit comments

Comments
 (0)