Skip to content

Commit 6f5ff46

Browse files
committed
feat: update charts with keyboard navigation & hints
1 parent 80925c0 commit 6f5ff46

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

app/components/Compare/FacetBarChart.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ const config = computed<VueUiHorizontalBarConfig>(() => {
272272
<div class="font-mono facet-bar">
273273
<ClientOnly v-if="dataset.length">
274274
<VueUiHorizontalBar :key="chartKey" :dataset :config class="[direction:ltr]">
275+
<template #hint="{ isVisible }">
276+
<p v-if="isVisible" class="text-accent text-xs pt-2" aria-hidden="true">
277+
{{ $t('compare.packages.bar_chart_nav_hint') }}
278+
</p>
279+
</template>
280+
275281
<template #pattern="{ patternId, seriesIndex }">
276282
<ChartPatternSlot
277283
v-if="seriesIndex != 0"
@@ -349,6 +355,19 @@ const config = computed<VueUiHorizontalBarConfig>(() => {
349355
</div>
350356
</template>
351357

358+
<style scoped>
359+
:deep(.vue-data-ui-component svg:focus-visible) {
360+
outline: 1px solid var(--accent-color) !important;
361+
border-radius: 0.1rem;
362+
outline-offset: 3px !important;
363+
}
364+
:deep(.vue-ui-user-options-button:focus-visible),
365+
:deep(.vue-ui-user-options :first-child:focus-visible) {
366+
outline: 0.1rem solid var(--accent-color) !important;
367+
border-radius: 0.25rem;
368+
}
369+
</style>
370+
352371
<style>
353372
.facet-bar .atom-subtitle {
354373
width: 80% !important;

app/components/Package/TrendsChart.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,13 @@ watch(selectedMetric, value => {
18781878
@zoomEnd="setIsZoom"
18791879
@zoomReset="isZoomed = false"
18801880
>
1881+
<!-- Keyboard navigation hint -->
1882+
<template #hint="{ isVisible }">
1883+
<p v-if="isVisible" class="text-accent text-xs -mt-6 text-center" aria-hidden="true">
1884+
{{ $t('compare.packages.line_chart_nav_hint') }}
1885+
</p>
1886+
</template>
1887+
18811888
<!-- Injecting custom svg elements -->
18821889
<template #svg="{ svg }">
18831890
<!-- Estimation lines for monthly & yearly granularities when the end date induces a downwards trend -->
@@ -2130,6 +2137,19 @@ watch(selectedMetric, value => {
21302137
</div>
21312138
</template>
21322139

2140+
<style scoped>
2141+
:deep(.vue-data-ui-component svg:focus-visible) {
2142+
outline: 1px solid var(--accent-color) !important;
2143+
border-radius: 0.1rem;
2144+
outline-offset: 0;
2145+
}
2146+
:deep(.vue-ui-user-options-button:focus-visible),
2147+
:deep(.vue-ui-user-options :first-child:focus-visible) {
2148+
outline: 0.1rem solid var(--accent-color) !important;
2149+
border-radius: 0.25rem;
2150+
}
2151+
</style>
2152+
21332153
<style>
21342154
.vue-ui-pen-and-paper-actions {
21352155
background: var(--bg-elevated) !important;

app/components/Package/VersionDistribution.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,13 @@ const chartConfig = computed<VueUiXyConfig>(() => {
447447
<ClientOnly v-if="xyDataset.length > 0 && !error">
448448
<div class="chart-container w-full" :key="groupingMode">
449449
<VueUiXy :dataset="xyDataset" :config="chartConfig" class="[direction:ltr]">
450+
<!-- Keyboard navigation hint -->
451+
<template #hint="{ isVisible }">
452+
<p v-if="isVisible" class="text-accent text-xs -mt-6 text-center" aria-hidden="true">
453+
{{ $t('compare.packages.line_chart_nav_hint') }}
454+
</p>
455+
</template>
456+
450457
<!-- Injecting custom svg elements -->
451458
<template #svg="{ svg }">
452459
<!-- Inject legend during SVG print only -->
@@ -664,6 +671,18 @@ const chartConfig = computed<VueUiXyConfig>(() => {
664671
:deep(.vue-ui-xy) svg rect {
665672
transition: none !important;
666673
}
674+
675+
:deep(.vue-data-ui-component svg:focus-visible) {
676+
outline: 1px solid var(--accent-color) !important;
677+
border-radius: 0.1rem;
678+
outline-offset: 0 !important;
679+
}
680+
681+
:deep(.vue-ui-user-options-button:focus-visible),
682+
:deep(.vue-ui-user-options :first-child:focus-visible) {
683+
outline: 0.1rem solid var(--accent-color) !important;
684+
border-radius: 0.25rem;
685+
}
667686
</style>
668687

669688
<style>

app/components/Package/WeeklyDownloadStats.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,13 @@ const config = computed<VueUiSparklineConfig>(() => {
416416
<template v-if="isLoadingWeeklyDownloads || hasWeeklyDownloads">
417417
<ClientOnly>
418418
<VueUiSparkline class="w-full max-w-xs" :dataset :config>
419+
<!-- Keyboard navigation hint -->
420+
<template #hint="{ isVisible }">
421+
<p v-if="isVisible" class="text-accent text-xs text-center mt-2" aria-hidden="true">
422+
{{ $t('compare.packages.line_chart_nav_hint') }}
423+
</p>
424+
</template>
425+
419426
<template #skeleton>
420427
<!-- This empty div overrides the default built-in scanning animation on load -->
421428
<div />
@@ -493,6 +500,12 @@ const config = computed<VueUiSparklineConfig>(() => {
493500
.opacity-leave-from {
494501
opacity: 1;
495502
}
503+
504+
:deep(.vue-data-ui-component svg:focus-visible) {
505+
outline: 0.1rem solid var(--accent-color) !important;
506+
border-radius: 0.1rem;
507+
outline-offset: 3px;
508+
}
496509
</style>
497510

498511
<style>

0 commit comments

Comments
 (0)