Skip to content

Commit 939346c

Browse files
committed
feat: use accent color on charts
1 parent 4232ae2 commit 939346c

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

app/components/PackageDownloadAnalytics.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ const {
1616
createdIso: string | null
1717
}>()
1818
19+
const { accentColors, selectedAccentColor } = useAccentColor()
20+
21+
const accentColorValueById = computed<Record<string, string>>(() => {
22+
const map: Record<string, string> = {}
23+
for (const item of accentColors) {
24+
map[item.id] = item.value
25+
}
26+
return map
27+
})
28+
29+
const accent = computed(() => {
30+
const id = selectedAccentColor.value
31+
return id ? (accentColorValueById.value[id] ?? '#8A8A8A') : '#8A8A8A'
32+
})
33+
1934
type ChartTimeGranularity = 'daily' | 'weekly' | 'monthly' | 'yearly'
2035
type EvolutionData =
2136
| DailyDownloadPoint[]
@@ -81,7 +96,7 @@ function formatXyDataset(
8196
name: packageName,
8297
type: 'line',
8398
series: dataset.map(d => d.downloads),
84-
color: '#8A8A8A',
99+
color: accent.value,
85100
},
86101
],
87102
dates: dataset.map(d => `${d.weekStart}\nto ${d.weekEnd}`),
@@ -94,7 +109,7 @@ function formatXyDataset(
94109
name: packageName,
95110
type: 'line',
96111
series: dataset.map(d => d.downloads),
97-
color: '#8A8A8A',
112+
color: accent.value,
98113
},
99114
],
100115
dates: dataset.map(d => d.day),
@@ -107,7 +122,7 @@ function formatXyDataset(
107122
name: packageName,
108123
type: 'line',
109124
series: dataset.map(d => d.downloads),
110-
color: '#8A8A8A',
125+
color: accent.value,
111126
},
112127
],
113128
dates: dataset.map(d => d.month),
@@ -120,7 +135,7 @@ function formatXyDataset(
120135
name: packageName,
121136
type: 'line',
122137
series: dataset.map(d => d.downloads),
123-
color: '#8A8A8A',
138+
color: accent.value,
124139
},
125140
],
126141
dates: dataset.map(d => d.year),

app/components/PackageWeeklyDownloadStats.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ const { packageName } = defineProps<{
66
packageName: string
77
}>()
88
9+
const { accentColors, selectedAccentColor } = useAccentColor()
10+
11+
const accentColorValueById = computed<Record<string, string>>(() => {
12+
const map: Record<string, string> = {}
13+
for (const item of accentColors) {
14+
map[item.id] = item.value
15+
}
16+
return map
17+
})
18+
19+
const accent = computed(() => {
20+
const id = selectedAccentColor.value
21+
return id ? (accentColorValueById.value[id] ?? '#6A6A6A') : '#6A6A6A'
22+
})
23+
24+
const pulseColor = computed(() => (selectedAccentColor.value ? '#FAFAFA90' : '#8A8A8A'))
25+
926
const showModal = ref(false)
1027
1128
const { data: packument } = usePackage(() => packageName)
@@ -56,15 +73,15 @@ const config = computed(() => ({
5673
style: {
5774
backgroundColor: 'transparent',
5875
animation: { show: false },
59-
area: { color: '#6A6A6A', useGradient: false, opacity: 10 },
76+
area: { color: accent.value, useGradient: false, opacity: 10 },
6077
dataLabel: { offsetX: -10, fontSize: 28, bold: false, color: '#FAFAFA' },
6178
line: {
62-
color: '#6A6A6A',
79+
color: accent.value,
6380
pulse: {
6481
show: true,
6582
loop: true,
6683
radius: 2,
67-
color: '#8A8A8A',
84+
color: pulseColor.value,
6885
easing: 'ease-in-out',
6986
trail: { show: true, length: 6 },
7087
},

0 commit comments

Comments
 (0)