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
19 changes: 18 additions & 1 deletion app/components/Package/WeeklyDownloadStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const props = defineProps<{

const router = useRouter()
const route = useRoute()
const { settings } = useSettings()

const chartModal = useModal('chart-modal')
const hasChartModalTransitioned = shallowRef(false)
Expand Down Expand Up @@ -87,6 +88,12 @@ const { colors } = useCssVariables(
},
)

function toggleSparklineAnimation() {
settings.value.sidebar.animateSparkline = !settings.value.sidebar.animateSparkline
}

const hasSparklineAnimation = computed(() => settings.value.sidebar.animateSparkline)

const isDarkMode = computed(() => resolvedMode.value === 'dark')

const accentColorValueById = computed<Record<string, string>>(() => {
Expand Down Expand Up @@ -224,7 +231,7 @@ const config = computed(() => {
line: {
color: colors.value.borderHover,
pulse: {
show: true, // the pulse will not show if prefers-reduced-motion (enforced by vue-data-ui)
show: hasSparklineAnimation.value, // the pulse will not show if prefers-reduced-motion (enforced by vue-data-ui)
loop: true, // runs only once if false
radius: 1.5,
color: pulseColor.value,
Expand Down Expand Up @@ -302,6 +309,16 @@ const config = computed(() => {
</div>
</template>
</ClientOnly>

<div v-if="hasWeeklyDownloads" class="hidden motion-safe:flex justify-end">
<ButtonBase size="small" @click="toggleSparklineAnimation">
{{
hasSparklineAnimation
? $t('package.trends.pause_animation')
: $t('package.trends.play_animation')
}}
</ButtonBase>
</div>
</template>
<p v-else class="py-2 text-sm font-mono text-fg-subtle">
{{ $t('package.trends.no_data') }}
Expand Down
2 changes: 2 additions & 0 deletions app/composables/useSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface AppSettings {
}
sidebar: {
collapsed: string[]
animateSparkline: boolean
}
}

Expand All @@ -52,6 +53,7 @@ const DEFAULT_SETTINGS: AppSettings = {
},
sidebar: {
collapsed: [],
animateSparkline: true,
},
}

Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@
"downloads": "Downloads",
"likes": "Likes",
"contributors": "Contributors"
}
},
"play_animation": "Play animation",
"pause_animation": "Pause animation"
},
"downloads": {
"title": "Weekly Downloads",
Expand Down
4 changes: 3 additions & 1 deletion i18n/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@
"downloads": "Téléchargements",
"likes": "J'aime",
"contributors": "Contributeurs"
}
},
"play_animation": "Lancer l'animation",
"pause_animation": "Mettre l'animation en pause"
},
"downloads": {
"title": "Téléchargements hebdo.",
Expand Down
6 changes: 6 additions & 0 deletions i18n/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,12 @@
}
},
"additionalProperties": false
},
"play_animation": {
"type": "string"
},
"pause_animation": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@
"downloads": "Downloads",
"likes": "Likes",
"contributors": "Contributors"
}
},
"play_animation": "Play animation",
"pause_animation": "Pause animation"
},
"downloads": {
"title": "Weekly Downloads",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@
"downloads": "Downloads",
"likes": "Likes",
"contributors": "Contributors"
}
},
"play_animation": "Play animation",
"pause_animation": "Pause animation"
},
"downloads": {
"title": "Weekly Downloads",
Expand Down
4 changes: 3 additions & 1 deletion lunaria/files/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@
"downloads": "Téléchargements",
"likes": "J'aime",
"contributors": "Contributeurs"
}
},
"play_animation": "Lancer l'animation",
"pause_animation": "Mettre l'animation en pause"
},
"downloads": {
"title": "Téléchargements hebdo.",
Expand Down
Loading