Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions app/components/CollapsibleSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LinkBase } from '#components'

interface Props {
title: string
subtitle?: string
isLoading?: boolean
headingLevel?: `h${number}`
id: string
Expand Down Expand Up @@ -81,7 +82,8 @@ useHead({
<div class="flex items-center justify-between mb-3 px-1">
<component
:is="headingLevel"
class="group text-xs text-fg-subtle uppercase tracking-wider flex items-center gap-2"
class="group text-xs text-fg-subtle uppercase tracking-wider flex gap-2"
:class="subtitle ? 'items-start' : 'items-center'"
>
<button
:id="buttonId"
Expand All @@ -101,9 +103,14 @@ useHead({
/>
</button>

<LinkBase :to="`#${id}`">
{{ title }}
</LinkBase>
<span>
<LinkBase :to="`#${id}`">
{{ title }}
</LinkBase>
<span v-if="subtitle" class="block text-2xs normal-case tracking-normal">{{
subtitle
}}</span>
</span>
</component>

<!-- Actions slot for buttons or other elements -->
Expand Down
19 changes: 16 additions & 3 deletions app/components/Modal.client.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
const props = defineProps<{
modalTitle: string
modalSubtitle?: string
}>()

const dialogRef = useTemplateRef('dialogRef')
Expand All @@ -14,6 +15,12 @@ const modalTitleId = computed(() => {
return id ? `${id}-title` : undefined
})

const modalSubtitleId = computed(() => {
if (!props.modalSubtitle) return undefined
const id = getCurrentInstance()?.attrs.id
return id ? `${id}-subtitle` : undefined
})

function handleModalClose() {
dialogRef.value?.close()
}
Expand Down Expand Up @@ -45,14 +52,20 @@ defineExpose({
closedby="any"
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"
:aria-labelledby="modalTitleId"
:aria-describedby="modalSubtitleId"
v-bind="$attrs"
@transitionend="onDialogTransitionEnd"
>
<!-- Modal top header section -->
<div class="flex items-center justify-between mb-6">
<h2 :id="modalTitleId" class="font-mono text-lg font-medium">
{{ modalTitle }}
</h2>
<div>
<h2 :id="modalTitleId" class="font-mono text-lg font-medium">
{{ modalTitle }}
</h2>
<p v-if="modalSubtitle" :id="modalSubtitleId" class="text-xs text-fg-subtle">
{{ modalSubtitle }}
</p>
</div>
<ButtonBase
type="button"
:aria-label="$t('common.close')"
Expand Down
2 changes: 2 additions & 0 deletions app/components/Package/ChartModal.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
const props = defineProps<{
modalTitle?: string
modalSubtitle?: string
}>()

const emit = defineEmits<{
Expand All @@ -11,6 +12,7 @@ const emit = defineEmits<{
<template>
<Modal
:modalTitle="modalTitle ?? $t('package.trends.title')"
:modalSubtitle="modalSubtitle"
id="chart-modal"
class="h-full sm:h-min sm:border sm:border-border sm:rounded-lg shadow-xl sm:max-h-[90vh] sm:max-w-3xl"
@transitioned="emit('transitioned')"
Expand Down
13 changes: 12 additions & 1 deletion app/components/Package/WeeklyDownloadStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const modalTitle = computed(() => {
return $t('package.trends.items.downloads')
})

const modalSubtitle = computed(() => {
const facet = route.query.facet as string | undefined
if (facet === 'likes' || facet === 'contributors') return undefined
return $t('package.downloads.subtitle')
})

const isChartModalOpen = shallowRef<boolean>(false)

function handleModalClose() {
Expand Down Expand Up @@ -281,7 +287,11 @@ const config = computed<VueUiSparklineConfig>(() => {

<template>
<div class="space-y-8">
<CollapsibleSection id="downloads" :title="$t('package.downloads.title')">
<CollapsibleSection
id="downloads"
:title="$t('package.downloads.title')"
:subtitle="$t('package.downloads.subtitle')"
>
<template #actions>
<ButtonBase
v-if="hasWeeklyDownloads"
Expand Down Expand Up @@ -351,6 +361,7 @@ const config = computed<VueUiSparklineConfig>(() => {
<PackageChartModal
v-if="isChartModalOpen && hasWeeklyDownloads"
:modal-title="modalTitle"
:modal-subtitle="modalSubtitle"
@close="handleModalClose"
@transitioned="handleModalTransitioned"
>
Expand Down
3 changes: 2 additions & 1 deletion i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@
},
"downloads": {
"title": "Weekly Downloads",
"community_distribution": "View community adoption distribution"
"community_distribution": "View community adoption distribution",
"subtitle": "Across all versions"
},
"install_scripts": {
"title": "Install Scripts",
Expand Down
3 changes: 2 additions & 1 deletion i18n/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@
},
"downloads": {
"title": "Téléchargements hebdo.",
"community_distribution": "Voir la distribution des versions téléchargées par la communauté"
"community_distribution": "Voir la distribution des versions téléchargées par la communauté",
"subtitle": "Toutes versions confondues"
},
"install_scripts": {
"title": "Scripts d'installation",
Expand Down
3 changes: 3 additions & 0 deletions i18n/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,9 @@
},
"community_distribution": {
"type": "string"
},
"subtitle": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
3 changes: 2 additions & 1 deletion lunaria/files/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@
},
"downloads": {
"title": "Weekly Downloads",
"community_distribution": "View community adoption distribution"
"community_distribution": "View community adoption distribution",
"subtitle": "Across all versions"
},
"install_scripts": {
"title": "Install Scripts",
Expand Down
3 changes: 2 additions & 1 deletion lunaria/files/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@
},
"downloads": {
"title": "Weekly Downloads",
"community_distribution": "View community adoption distribution"
"community_distribution": "View community adoption distribution",
"subtitle": "Across all versions"
},
"install_scripts": {
"title": "Install Scripts",
Expand Down
3 changes: 2 additions & 1 deletion lunaria/files/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@
},
"downloads": {
"title": "Téléchargements hebdo.",
"community_distribution": "Voir la distribution des versions téléchargées par la communauté"
"community_distribution": "Voir la distribution des versions téléchargées par la communauté",
"subtitle": "Toutes versions confondues"
},
"install_scripts": {
"title": "Scripts d'installation",
Expand Down
2 changes: 2 additions & 0 deletions test/nuxt/components/PackageWeeklyDownloadStats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('PackageWeeklyDownloadStats', () => {
})

expect(component.text()).toContain('Weekly Downloads')
expect(component.text()).toContain('Across all versions')
expect(component.text()).toContain('No data available')
})

Expand All @@ -60,6 +61,7 @@ describe('PackageWeeklyDownloadStats', () => {
})

expect(component.text()).toContain('Weekly Downloads')
expect(component.text()).toContain('Across all versions')
expect(component.text()).not.toContain('No data available')
})
})
Loading