Skip to content

Commit ad2b174

Browse files
trueberrylesscoderabbitai[bot]graphieros
authored
feat: opt-in repeated pulse animation on download graph (#2121)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Alec Lloyd Probert <55991794+graphieros@users.noreply.github.com>
1 parent a0e8534 commit ad2b174

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

app/components/Package/WeeklyDownloadStats.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ const dataset = computed<VueUiSparklineDatasetItem[]>(() =>
208208
209209
const lastDatapoint = computed(() => dataset.value.at(-1)?.period ?? '')
210210
211-
const isLoop = shallowRef(false)
212211
const showPulse = shallowRef(true)
213212
const keyboardShortcuts = useKeyboardShortcuts()
214213
@@ -307,7 +306,7 @@ function layEgg() {
307306
showPulse.value = false
308307
nextTick(() => {
309308
showPulse.value = true
310-
isLoop.value = !isLoop.value
309+
settings.value.enableGraphPulseLooping = !settings.value.enableGraphPulseLooping
311310
playEggPulse()
312311
})
313312
}
@@ -356,7 +355,7 @@ const config = computed<VueUiSparklineConfig>(() => {
356355
color: colors.value.borderHover,
357356
pulse: {
358357
show: showPulse.value, // the pulse will not show if prefers-reduced-motion (enforced by vue-data-ui)
359-
loop: isLoop.value,
358+
loop: settings.value.enableGraphPulseLooping,
360359
radius: 1.5,
361360
color: pulseColor.value!,
362361
easing: 'ease-in-out',

app/composables/useSettings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export interface AppSettings {
2323
preferredBackgroundTheme: BackgroundThemeId | null
2424
/** Hide platform-specific packages (e.g., @scope/pkg-linux-x64) from search results */
2525
hidePlatformPackages: boolean
26+
/** Enable weekly download graph pulse looping animation */
27+
enableGraphPulseLooping: boolean
2628
/** User-selected locale */
2729
selectedLocale: LocaleObject['code'] | null
2830
/** Search provider for package search */
@@ -52,6 +54,7 @@ const DEFAULT_SETTINGS: AppSettings = {
5254
includeTypesInInstall: true,
5355
accentColorId: null,
5456
hidePlatformPackages: true,
57+
enableGraphPulseLooping: false,
5558
selectedLocale: null,
5659
preferredBackgroundTheme: null,
5760
searchProvider: import.meta.test ? 'npm' : 'algolia',

app/pages/settings.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ const setLocale: typeof setNuxti18nLocale = newLocale => {
142142
:description="$t('settings.hide_platform_packages_description')"
143143
v-model="settings.hidePlatformPackages"
144144
/>
145+
146+
<!-- Divider -->
147+
<div class="border-t border-border my-4" />
148+
149+
<!-- Enable weekly download graph pulse looping animation -->
150+
<SettingsToggle
151+
:label="$t('settings.enable_graph_pulse_loop')"
152+
:description="$t('settings.enable_graph_pulse_loop_description')"
153+
v-model="settings.enableGraphPulseLooping"
154+
/>
145155
</div>
146156
</section>
147157

i18n/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@
138138
"include_types_description": "Add {'@'}types package to install commands for untyped packages",
139139
"hide_platform_packages": "Hide platform-specific packages in search",
140140
"hide_platform_packages_description": "Hide native binary packages like {'@'}esbuild/linux-x64 from results",
141+
"enable_graph_pulse_loop": "Enable looping of pulse effect on mini graph",
142+
"enable_graph_pulse_loop_description": "Activate a continuous pulse animation on the weekly download graph. This animation may be distracting for some users.",
141143
"theme": "Theme",
142144
"theme_light": "Light",
143145
"theme_dark": "Dark",

i18n/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@
418418
"hide_platform_packages_description": {
419419
"type": "string"
420420
},
421+
"enable_graph_pulse_loop": {
422+
"type": "string"
423+
},
424+
"enable_graph_pulse_loop_description": {
425+
"type": "string"
426+
},
421427
"theme": {
422428
"type": "string"
423429
},

0 commit comments

Comments
 (0)