Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ storybook-static
.agents
.vscode/mcp.json
AGENTS.md
.vitest/
19 changes: 16 additions & 3 deletions app/components/Chart/SplitSparkline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const { colors } = useColors(rootEl)

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

const selectedIndex = ref<number | undefined | null>(null)
const selectedIndex = ref<number | undefined>()
const isInteracting = ref(false)

function isLargeSeries(seriesIndex: number): boolean {
Expand Down Expand Up @@ -149,7 +149,7 @@ function startInteraction() {

function resetHover() {
isInteracting.value = false
selectedIndex.value = null
selectedIndex.value = undefined
step.value += 1 // required to reset all chart instances
}

Expand All @@ -175,6 +175,7 @@ const configs = computed(() => {
: (lightenColor(seriesColor, 0.5) ?? seriesColor) // palette uses hex colours

return {
useCursorPointer: true,
a11y: {
translations: {
keyboardNavigation: $t(
Expand Down Expand Up @@ -230,6 +231,7 @@ const configs = computed(() => {
},
line: {
color: seriesColor,
strokeWidth: 1,
dashIndices,
dashArray: 3,
cutNullValues: false,
Expand All @@ -252,14 +254,24 @@ const configs = computed(() => {
},
padding: {
left: 0,
right: 0,
right: 24,
top: 0,
bottom: 0,
},
// Drag to zoom
zoom: {
show: true,
resetButton: {
title: $t('package.trends.sparkline_zoom_reset.title'),
ariaLabel: $t('package.trends.sparkline_zoom_reset.aria_label'),
},
},
},
}
})
})

const zoomState = ref<any>(null)
</script>

<template>
Expand Down Expand Up @@ -308,6 +320,7 @@ const configs = computed(() => {
</div>
<VueUiSparkline
v-if="datasets[i]"
v-model:zoom-state="zoomState"
:key="`${i}_${step}`"
:config
:dataset="datasets[i]"
Expand Down
17 changes: 15 additions & 2 deletions app/components/Package/TrendsChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
nullifyZeroValues,
isMissingDownloadValue,
isLargeDownloadSeries,
MULTI_PACKAGE_MODE_TOP_PADDING,
} from '#shared/utils/trends-chart'
import { downloadFileLink } from '~/utils/download'
import { useCopyChartPng } from '~/composables/useCopyChartPng'
Expand Down Expand Up @@ -1299,10 +1300,13 @@ const chartHeight = computed(() => {
if (isMobile.value) {
return 950
}

const additionalHeight = isMultiPackageMode.value ? MULTI_PACKAGE_MODE_TOP_PADDING : 0

if (props.hideControls) {
return 460
return 460 + additionalHeight
}
return 600
return 600 + additionalHeight
})

const { start } = useTimeoutFn(
Expand Down Expand Up @@ -1490,6 +1494,15 @@ const chartConfig = computed<VueUiXyConfig>(() => {
strokeWidth: 1,
strokeDasharray: 3,
},
dragToZoom: {
show: true,
selection: {
fill: accent.value,
fillOpacity: isDarkMode.value ? 0.05 : 0.08,
stroke: accent.value,
strokeDasharray: 3,
},
},
},
},
}
Expand Down
8 changes: 8 additions & 0 deletions app/components/Package/WeeklyDownloadStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ const config = computed<VueUiSparklineConfig>(() => {
top: 0,
bottom: 0,
},
// Drag to zoom
zoom: {
show: true,
resetButton: {
title: $t('package.trends.sparkline_zoom_reset.title'),
ariaLabel: $t('package.trends.sparkline_zoom_reset.aria_label'),
},
},
},
}
})
Expand Down
4 changes: 4 additions & 0 deletions i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@
"copy_url": "Copy this URL to embed the chart into your website",
"preview": "Preview",
"tip": "If startDate and endDate are not provided in the URL, the graph will display the last 12 months by default."
},
"sparkline_zoom_reset": {
"title": "Reset zoom · double-click chart or press Esc",
"aria_label": "Reset zoom"
}
},
"downloads": {
Expand Down
38 changes: 38 additions & 0 deletions i18n/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"current": "actuel",
"here": "vous êtes ici",
"connected": "connecté",
"keyboard_shortcuts": {},
"state": {
"on": "activé",
"off": "désactivé"
Expand Down Expand Up @@ -203,6 +204,14 @@
"links": "Liens",
"tap_to_search": "Toucher pour rechercher"
},
"tools": {
"deps_stats": {}
},
"deps_stats": {
"upload": {},
"dependencies": {},
"stats": {}
},
"blog": {
"title": "Blog",
"heading": "blog",
Expand All @@ -229,6 +238,9 @@
"more_replies": "{count} réponse supplémentaire... | {count} réponses supplémentaires..."
}
},
"noodles": {
"missing": {}
},
"settings": {
"title": "paramètres",
"tagline": "personnalisez votre expérience npmx",
Expand Down Expand Up @@ -284,6 +296,7 @@
"slate": "Ardoise",
"black": "Noir"
},
"foreground_themes": {},
"keyboard_shortcuts_enabled": "Activer les raccourcis clavier",
"keyboard_shortcuts_enabled_description": "Les raccourcis clavier peuvent être désactivés s'ils entrent en conflit avec d'autres raccourcis du navigateur ou du système",
"enable_code_ligatures": "Activer les ligatures de code",
Expand Down Expand Up @@ -485,6 +498,7 @@
"title": "Exécuter",
"locally": "Exécuter localement"
},
"command": {},
"readme": {
"title": "Readme",
"no_readme": "Aucun README disponible.",
Expand Down Expand Up @@ -717,6 +731,10 @@
"copy_url": "Copiez cette URL pour intégrer le graphique à votre site web",
"preview": "Aperçu",
"tip": "Par défaut, si startDate et endDate ne sont pas renseignés, la période couvre les 12 derniers mois."
},
"sparkline_zoom_reset": {
"title": "Réinitialiser le zoom · double-cliquez sur le graphique ou appuyez sur Esc",
"aria_label": "Réinitialiser le zoom"
}
},
"downloads": {
Expand Down Expand Up @@ -1229,6 +1247,25 @@
}
}
},
"sponsors_page": {
"what_we_do": {},
"what_support_means": {},
"what_this_means_for_you": {
"cards": {
"people": {},
"visitors": {},
"stars": {},
"community": {},
"adoption": {},
"default_source": {}
}
},
"tiers": {
"silver": {},
"gold": {},
"platinum": {}
}
},
"account_menu": {
"connect": "connexion",
"account": "Compte",
Expand Down Expand Up @@ -1403,6 +1440,7 @@
"label": "Étoiles GitHub",
"description": "Nombre d’étoiles du dépôt GitHub"
},
"githubForks": {},
"githubIssues": {
"label": "Issues GitHub",
"description": "Nombre d’issues ouvertes sur GitHub"
Expand Down
12 changes: 12 additions & 0 deletions i18n/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,18 @@
}
},
"additionalProperties": false
},
"sparkline_zoom_reset": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"aria_label": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"vite-plugin-pwa": "1.3.0",
"vite-plus": "catalog:vite-plus",
"vue": "3.5.42",
"vue-data-ui": "3.25.13",
"vue-data-ui": "3.26.1",
"vue-router": "5.2.0"
},
"devDependencies": {
Expand Down
Loading
Loading