-
-
Notifications
You must be signed in to change notification settings - Fork 425
Expand file tree
/
Copy pathPackageDownloadStats.vue
More file actions
91 lines (85 loc) · 1.78 KB
/
PackageDownloadStats.vue
File metadata and controls
91 lines (85 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<script setup lang="ts">
import { VueUiSparkline } from 'vue-data-ui/vue-ui-sparkline'
const props = defineProps<{
downloads?: Array<{
downloads: number | null
weekStart: string
weekEnd: string
}>
}>()
const dataset = computed(() =>
props.downloads?.map(d => ({
value: d?.downloads ?? 0,
period: `${d.weekStart ?? '-'} to ${d.weekEnd ?? '-'}`,
})),
)
const lastDatapoint = computed(() => {
return (dataset.value || []).at(-1)?.period ?? ''
})
const config = computed(() => ({
theme: 'dark', // enforced dark mode for now
style: {
backgroundColor: 'transparent',
animation: {
show: false,
},
area: {
color: '#6A6A6A',
useGradient: false,
opacity: 10,
},
dataLabel: {
offsetX: -10,
fontSize: 28,
bold: false,
color: '#FAFAFA',
},
line: {
color: '#6A6A6A',
},
plot: {
radius: 6,
stroke: '#FAFAFA',
},
title: {
text: lastDatapoint.value,
fontSize: 12,
color: '#666666',
bold: false,
},
verticalIndicator: {
strokeDasharray: 0,
color: '#FAFAFA',
},
},
}))
</script>
<template>
<div class="space-y-8">
<!-- Download stats -->
<section>
<div class="flex items-center justify-between mb-3">
<h2 id="dependencies-heading" class="text-xs text-fg-subtle uppercase tracking-wider">
Weekly Downloads
</h2>
</div>
<div class="w-full">
<ClientOnly>
<VueUiSparkline :dataset :config />
</ClientOnly>
</div>
</section>
</div>
</template>
<style>
/** Overrides */
.vue-ui-sparkline-title span {
padding: 0 !important;
letter-spacing: 0.04rem;
}
.vue-ui-sparkline text {
font-family:
Geist Mono,
monospace !important;
}
</style>