Skip to content

Commit b413385

Browse files
committed
fix: package code page - codecov fixes, a11y test fix
1 parent 40071d0 commit b413385

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

app/components/Code/Header.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,22 @@ const isPathDropdownOpen = shallowRef(false)
8484
const pathDropdownButtonRef = useTemplateRef('pathDropdownButtonRef')
8585
const pathDropdownListRef = useTemplateRef<HTMLElement>('pathDropdownListRef')
8686
87-
function togglePathDropdown(force: boolean) {
88-
if (force !== undefined) {
89-
isPathDropdownOpen.value = force
87+
function togglePathDropdown(forceClose?: boolean) {
88+
if (forceClose) {
89+
isPathDropdownOpen.value = false
9090
return
9191
}
9292
9393
isPathDropdownOpen.value = !isPathDropdownOpen.value
9494
}
9595
96-
onClickOutside(pathDropdownListRef, () => togglePathDropdown(false), {
96+
onClickOutside(pathDropdownListRef, () => togglePathDropdown(true), {
9797
ignore: [pathDropdownButtonRef],
9898
})
9999
100100
useEventListener('keydown', (event: KeyboardEvent) => {
101101
if (event.key === 'Escape' && isPathDropdownOpen.value) {
102-
togglePathDropdown(false)
102+
togglePathDropdown(true)
103103
}
104104
})
105105
</script>
@@ -180,11 +180,11 @@ useEventListener('keydown', (event: KeyboardEvent) => {
180180
>
181181
<!-- add └ mark to better visualize nested folders) -->
182182
<template v-if="level === index">
183-
<span class="absolute top-0 bottom-1/2 left-2 w-px bg-fg-subtle/50" />
184-
<span class="absolute top-1/2 left-2 right-0 h-px bg-fg-subtle/50" />
183+
<span class="absolute top-0 bottom-1/2 inset-is-2 w-px bg-fg-subtle/50" />
184+
<span class="absolute top-1/2 inset-is-2 inset-ie-0 h-px bg-fg-subtle/50" />
185185
</template>
186186
</span>
187-
<span :class="{ 'pl-1': index > 0 }" class="min-w-0 break-all"
187+
<span :class="{ 'ps-1': index > 0 }" class="min-w-0 break-all"
188188
>{{ crumb.name }}<span class="text-fg-subtle">/</span></span
189189
>
190190
</NuxtLink>
@@ -241,6 +241,7 @@ useEventListener('keydown', (event: KeyboardEvent) => {
241241
variant="button-secondary"
242242
:to="`https://cdn.jsdelivr.net/npm/${packageName}@${version}/${filePath}`"
243243
class="px-3"
244+
:aria-label="$t('code.open_raw_file')"
244245
/>
245246
</template>
246247
<ButtonBase

app/components/Code/SkeletonLoader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex min-h-full" aria-busy="true" :aria-label="$t('common.loading')">
2+
<div class="flex min-h-full" role="status" aria-busy="true" :aria-label="$t('common.loading')">
33
<!-- Fake line numbers column -->
44
<div class="shrink-0 bg-bg-subtle border-ie border-border w-14 py-0">
55
<div v-for="n in 20" :key="n" class="px-3 h-6 flex items-center justify-end">

app/pages/package-code/[[org]]/[packageName]/v/[version]/[...filePath].vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ defineOgImageComponent('Default', {
325325
<!-- Main content: file tree + file viewer -->
326326
<div
327327
v-else-if="!!fileTree"
328-
class="container w-full grid grid-cols-[18rem_1fr] max-lg:grid-cols-[16rem_1fr] max-md:grid-cols-[1fr] border-border border-r border-l transition-mix-width duration-200 ease-in-out px-0"
328+
class="container w-full grid grid-cols-[18rem_1fr] max-lg:grid-cols-[16rem_1fr] max-md:grid-cols-[1fr] border-border border-is border-ie transition-mix-width duration-200 ease-in-out px-0"
329329
:class="{ 'max-w-full border-0': codeContainerFull }"
330330
dir="ltr"
331331
>
@@ -362,7 +362,7 @@ defineOgImageComponent('Default', {
362362
<CodeSkeletonLoader v-if="isLoading" />
363363

364364
<!-- File viewer -->
365-
<template v-else-if="!isBinaryFile && fileContent">
365+
<template v-else-if="isViewingFile && !isBinaryFile && fileContent">
366366
<div
367367
v-if="fileContent.markdownHtml"
368368
v-show="markdownViewMode === 'preview'"

i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@
821821
"copy_link": "Copy link",
822822
"view_raw": "View raw file",
823823
"toggle_container": "Toggle code container width",
824+
"open_raw_file": "Open raw file",
824825
"open_path_dropdown": "Open path segments dropdown",
825826
"file_too_large": "File too large to preview",
826827
"file_size_warning": "{size} exceeds the 500KB limit for syntax highlighting",

test/nuxt/a11y.spec.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,15 +1164,23 @@ describe('component accessibility audits', () => {
11641164
it('should have no accessibility violations', async () => {
11651165
const component = await mountSuspended(CodeHeader, {
11661166
props: {
1167-
html: '<pre><code><span class="line">const x = 1;</span></code></pre>',
11681167
filePath: 'dir1/dir2/sourcefile.js',
11691168
loading: false,
11701169
isViewingFile: true,
11711170
isBinaryFile: false,
1172-
fileContent: '<pre><code><span class="line">const x = 1;</span></code></pre>',
1171+
fileContent: {
1172+
package: 'vite',
1173+
version: '1.0.0',
1174+
path: 'dir1/dir2/sourcefile.js',
1175+
language: 'javascript',
1176+
contentType: 'application/javascript',
1177+
content: 'const x = 1;',
1178+
html: '<pre><code><span class="line">const x = 1;</span></code></pre>',
1179+
lines: 1,
1180+
},
11731181
markdownViewMode: 'preview',
11741182
selectedLines: null,
1175-
getCodeUrlWithPath: path => path,
1183+
getCodeUrlWithPath: (path = '') => path,
11761184
packageName: 'vite',
11771185
version: '1.0.0',
11781186
},
@@ -1181,7 +1189,7 @@ describe('component accessibility audits', () => {
11811189
expect(results.violations).toEqual([])
11821190
})
11831191
})
1184-
1192+
11851193
describe('CodeSkeletonLoader', () => {
11861194
it('should have no accessibility violations', async () => {
11871195
const component = await mountSuspended(CodeSkeletonLoader)

0 commit comments

Comments
 (0)