Skip to content

Commit 80dc9be

Browse files
authored
feat(ui): add subheading to weekly downloads to clarify scope (#1752)
1 parent ff5b13f commit 80dc9be

File tree

11 files changed

+56
-13
lines changed

11 files changed

+56
-13
lines changed

app/components/CollapsibleSection.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { LinkBase } from '#components'
44
55
interface Props {
66
title: string
7+
subtitle?: string
78
isLoading?: boolean
89
headingLevel?: `h${number}`
910
id: string
@@ -81,7 +82,8 @@ useHead({
8182
<div class="flex items-center justify-between mb-3 px-1">
8283
<component
8384
:is="headingLevel"
84-
class="group text-xs text-fg-subtle uppercase tracking-wider flex items-center gap-2"
85+
class="group text-xs text-fg-subtle uppercase tracking-wider flex gap-2"
86+
:class="subtitle ? 'items-start' : 'items-center'"
8587
>
8688
<button
8789
:id="buttonId"
@@ -101,9 +103,14 @@ useHead({
101103
/>
102104
</button>
103105

104-
<LinkBase :to="`#${id}`">
105-
{{ title }}
106-
</LinkBase>
106+
<span>
107+
<LinkBase :to="`#${id}`">
108+
{{ title }}
109+
</LinkBase>
110+
<span v-if="subtitle" class="block text-2xs normal-case tracking-normal">{{
111+
subtitle
112+
}}</span>
113+
</span>
107114
</component>
108115

109116
<!-- Actions slot for buttons or other elements -->

app/components/Modal.client.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
const props = defineProps<{
33
modalTitle: string
4+
modalSubtitle?: string
45
}>()
56
67
const dialogRef = useTemplateRef('dialogRef')
@@ -14,6 +15,12 @@ const modalTitleId = computed(() => {
1415
return id ? `${id}-title` : undefined
1516
})
1617
18+
const modalSubtitleId = computed(() => {
19+
if (!props.modalSubtitle) return undefined
20+
const id = getCurrentInstance()?.attrs.id
21+
return id ? `${id}-subtitle` : undefined
22+
})
23+
1724
function handleModalClose() {
1825
dialogRef.value?.close()
1926
}
@@ -45,14 +52,20 @@ defineExpose({
4552
closedby="any"
4653
class="w-[calc(100%-2rem)] bg-bg border border-border rounded-lg shadow-xl max-h-[90vh] overflow-y-auto overscroll-contain m-0 m-auto p-6 text-fg focus-visible:outline focus-visible:outline-accent/70"
4754
:aria-labelledby="modalTitleId"
55+
:aria-describedby="modalSubtitleId"
4856
v-bind="$attrs"
4957
@transitionend="onDialogTransitionEnd"
5058
>
5159
<!-- Modal top header section -->
5260
<div class="flex items-center justify-between mb-6">
53-
<h2 :id="modalTitleId" class="font-mono text-lg font-medium">
54-
{{ modalTitle }}
55-
</h2>
61+
<div>
62+
<h2 :id="modalTitleId" class="font-mono text-lg font-medium">
63+
{{ modalTitle }}
64+
</h2>
65+
<p v-if="modalSubtitle" :id="modalSubtitleId" class="text-xs text-fg-subtle">
66+
{{ modalSubtitle }}
67+
</p>
68+
</div>
5669
<ButtonBase
5770
type="button"
5871
:aria-label="$t('common.close')"

app/components/Package/ChartModal.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
const props = defineProps<{
33
modalTitle?: string
4+
modalSubtitle?: string
45
}>()
56
67
const emit = defineEmits<{
@@ -11,6 +12,7 @@ const emit = defineEmits<{
1112
<template>
1213
<Modal
1314
:modalTitle="modalTitle ?? $t('package.trends.title')"
15+
:modalSubtitle="modalSubtitle"
1416
id="chart-modal"
1517
class="h-full sm:h-min sm:border sm:border-border sm:rounded-lg shadow-xl sm:max-h-[90vh] sm:max-w-3xl"
1618
@transitioned="emit('transitioned')"

app/components/Package/WeeklyDownloadStats.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ const modalTitle = computed(() => {
2828
return $t('package.trends.items.downloads')
2929
})
3030
31+
const modalSubtitle = computed(() => {
32+
const facet = route.query.facet as string | undefined
33+
if (facet === 'likes' || facet === 'contributors') return undefined
34+
return $t('package.downloads.subtitle')
35+
})
36+
3137
const isChartModalOpen = shallowRef<boolean>(false)
3238
3339
function handleModalClose() {
@@ -281,7 +287,11 @@ const config = computed<VueUiSparklineConfig>(() => {
281287

282288
<template>
283289
<div class="space-y-8">
284-
<CollapsibleSection id="downloads" :title="$t('package.downloads.title')">
290+
<CollapsibleSection
291+
id="downloads"
292+
:title="$t('package.downloads.title')"
293+
:subtitle="$t('package.downloads.subtitle')"
294+
>
285295
<template #actions>
286296
<ButtonBase
287297
v-if="hasWeeklyDownloads"
@@ -351,6 +361,7 @@ const config = computed<VueUiSparklineConfig>(() => {
351361
<PackageChartModal
352362
v-if="isChartModalOpen && hasWeeklyDownloads"
353363
:modal-title="modalTitle"
364+
:modal-subtitle="modalSubtitle"
354365
@close="handleModalClose"
355366
@transitioned="handleModalTransitioned"
356367
>

i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@
440440
},
441441
"downloads": {
442442
"title": "Weekly Downloads",
443-
"community_distribution": "View community adoption distribution"
443+
"community_distribution": "View community adoption distribution",
444+
"subtitle": "Across all versions"
444445
},
445446
"install_scripts": {
446447
"title": "Install Scripts",

i18n/locales/fr-FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@
415415
},
416416
"downloads": {
417417
"title": "Téléchargements hebdo.",
418-
"community_distribution": "Voir la distribution des versions téléchargées par la communauté"
418+
"community_distribution": "Voir la distribution des versions téléchargées par la communauté",
419+
"subtitle": "Toutes versions confondues"
419420
},
420421
"install_scripts": {
421422
"title": "Scripts d'installation",

i18n/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,9 @@
13261326
},
13271327
"community_distribution": {
13281328
"type": "string"
1329+
},
1330+
"subtitle": {
1331+
"type": "string"
13291332
}
13301333
},
13311334
"additionalProperties": false

lunaria/files/en-GB.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@
439439
},
440440
"downloads": {
441441
"title": "Weekly Downloads",
442-
"community_distribution": "View community adoption distribution"
442+
"community_distribution": "View community adoption distribution",
443+
"subtitle": "Across all versions"
443444
},
444445
"install_scripts": {
445446
"title": "Install Scripts",

lunaria/files/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@
439439
},
440440
"downloads": {
441441
"title": "Weekly Downloads",
442-
"community_distribution": "View community adoption distribution"
442+
"community_distribution": "View community adoption distribution",
443+
"subtitle": "Across all versions"
443444
},
444445
"install_scripts": {
445446
"title": "Install Scripts",

lunaria/files/fr-FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@
414414
},
415415
"downloads": {
416416
"title": "Téléchargements hebdo.",
417-
"community_distribution": "Voir la distribution des versions téléchargées par la communauté"
417+
"community_distribution": "Voir la distribution des versions téléchargées par la communauté",
418+
"subtitle": "Toutes versions confondues"
418419
},
419420
"install_scripts": {
420421
"title": "Scripts d'installation",

0 commit comments

Comments
 (0)