Skip to content

Commit 4295395

Browse files
committed
refactor: use useModal
1 parent d303dd1 commit 4295395

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

app/components/PackageWeeklyDownloadStats.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ import { VueUiSparkline } from 'vue-data-ui/vue-ui-sparkline'
44
import { useCssVariables } from '../composables/useColors'
55
import { OKLCH_NEUTRAL_FALLBACK, lightenOklch } from '../utils/colors'
66
7-
const { packageName } = defineProps<{
7+
const props = defineProps<{
88
packageName: string
99
}>()
1010
11-
function showChartModal() {
12-
const chartModal = document.querySelector<HTMLDialogElement>('#chart-modal')
13-
if (chartModal) {
14-
chartModal.showModal()
15-
}
16-
}
11+
const chartModal = useModal('chart-modal')
1712
18-
const { data: packument } = usePackage(() => packageName)
13+
const { data: packument } = usePackage(() => props.packageName)
1914
const createdIso = computed(() => packument.value?.time?.created ?? null)
2015
2116
const { fetchPackageDownloadEvolution } = useCharts()
@@ -90,7 +85,7 @@ async function loadWeeklyDownloads() {
9085
9186
try {
9287
const result = await fetchPackageDownloadEvolution(
93-
() => packageName,
88+
() => props.packageName,
9489
() => createdIso.value,
9590
() => ({ granularity: 'week' as const, weeks: 52 }),
9691
)
@@ -105,7 +100,7 @@ onMounted(() => {
105100
})
106101
107102
watch(
108-
() => packageName,
103+
() => props.packageName,
109104
() => loadWeeklyDownloads(),
110105
)
111106
@@ -200,7 +195,7 @@ const config = computed(() => {
200195
<template #actions>
201196
<button
202197
type="button"
203-
@click="showChartModal"
198+
@click="chartModal.open()"
204199
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5 ms-auto shrink-0 self-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50 rounded"
205200
:title="$t('package.downloads.analyze')"
206201
>

0 commit comments

Comments
 (0)