Skip to content

Commit 9f42775

Browse files
committed
fix: use custom config for built-in skeleton
1 parent 3efcd99 commit 9f42775

1 file changed

Lines changed: 36 additions & 9 deletions

File tree

app/components/PackageWeeklyDownloadStats.vue

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,32 @@ const dataset = computed(() =>
116116
117117
const lastDatapoint = computed(() => dataset.value.at(-1)?.period ?? '')
118118
119-
// oklh or css variables are not supported by vue-data-ui (for now)
120119
const config = computed(() => {
121120
return {
122121
theme: 'dark',
122+
/**
123+
* The built-in skeleton loader kicks in when the component is mounted but the data is not yet ready.
124+
* The configuration of the skeleton is customized for a seemless transition with the final state
125+
*/
126+
skeletonConfig: {
127+
style: {
128+
backgroundColor: 'transparent',
129+
dataLabel: {
130+
show: true,
131+
color: 'transparent',
132+
},
133+
area: {
134+
color: colors.value.borderHover,
135+
useGradient: false,
136+
opacity: 10,
137+
},
138+
line: {
139+
color: colors.value.borderHover,
140+
},
141+
},
142+
},
143+
// Same idea: initialize the line at zero, so it nicely transitions to the final dataset
144+
skeletonDataset: Array.from({ length: 52 }, () => 0),
123145
style: {
124146
backgroundColor: 'transparent',
125147
animation: { show: false },
@@ -196,22 +218,27 @@ const config = computed(() => {
196218

197219
<div class="w-full overflow-hidden">
198220
<ClientOnly>
199-
<VueUiSparkline class="w-full max-w-xs" :dataset :config />
221+
<VueUiSparkline class="w-full max-w-xs" :dataset :config>
222+
<template #skeleton>
223+
<!-- This empty div overrides the default built-in scanning animation on load -->
224+
<div />
225+
</template>
226+
</VueUiSparkline>
200227
<template #fallback>
201228
<!-- Skeleton matching sparkline layout: title row + chart with data label -->
202-
<div class="max-w-xs">
203-
<!-- Title row: date range -->
204-
<div class="h-5 flex items-center ps-3">
229+
<div class="min-h-[100px]">
230+
<!-- Title row: date range (24px height) -->
231+
<div class="h-6 flex items-center pl-3">
205232
<span class="skeleton h-3 w-36" />
206233
</div>
207-
<!-- Chart area: data label left, sparkline right (h-[51px] matches rendered SVG) -->
208-
<div class="h-[55px] flex items-center">
234+
<!-- Chart area: data label left, sparkline right -->
235+
<div class="aspect-[500/80] flex items-center">
209236
<!-- Data label (covers ~42% width) -->
210-
<div class="w-[42%] flex items-center ps-0.5">
237+
<div class="w-[42%] flex items-center pl-0.5">
211238
<span class="skeleton h-7 w-24" />
212239
</div>
213240
<!-- Sparkline area (~58% width) -->
214-
<div class="flex-1 flex items-end gap-0.5 h-4/5 pe-3">
241+
<div class="flex-1 flex items-end gap-0.5 h-4/5 pr-3">
215242
<span
216243
v-for="i in 16"
217244
:key="i"

0 commit comments

Comments
 (0)