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
8 changes: 7 additions & 1 deletion app/components/ChartModal.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<script setup lang="ts">
const open = defineModel<boolean>('open', { default: false })

function close() {
open.value = false
}

function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') {
open.value = false
close()
}
}
</script>
Expand Down Expand Up @@ -53,6 +57,8 @@ function handleKeydown(event: KeyboardEvent) {
<slot />
</div>
</div>

<slot name="after" v-bind="{ close }" />
</div>
</div>
</Transition>
Expand Down
23 changes: 16 additions & 7 deletions app/components/PackageDownloadAnalytics.vue
Copy link
Copy Markdown
Member

@9romise 9romise Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! 👋 Thanks for your work! ❤️
I think we can use useResizeObserver useElementSize here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)
So much better indeed!

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ref, computed, shallowRef, watch } from 'vue'
import type { VueUiXyDatasetItem } from 'vue-data-ui'
import { VueUiXy } from 'vue-data-ui/vue-ui-xy'
import { useDebounceFn } from '@vueuse/core'
import { useDebounceFn, useElementSize } from '@vueuse/core'

const {
weeklyDownloads,
Expand All @@ -18,8 +18,10 @@ const {

const { accentColors, selectedAccentColor } = useAccentColor()
const colorMode = useColorMode()

const resolvedMode = ref<'light' | 'dark'>('light')
const rootEl = shallowRef<HTMLElement | null>(null)

const { width } = useElementSize(rootEl)

onMounted(() => {
resolvedMode.value = colorMode.value === 'dark' ? 'dark' : 'light'
Expand Down Expand Up @@ -50,6 +52,16 @@ const accent = computed(() => {
return id ? (oklchToHex(accentColorValueById.value[id]!) ?? '#8A8A8A') : '#8A8A8A'
})

const mobileBreakpointWidth = 640

const isMobile = computed(() => {
return width.value > 0 && width.value < mobileBreakpointWidth
})

onMounted(() => {
rootEl.value = document.documentElement
})

type ChartTimeGranularity = 'daily' | 'weekly' | 'monthly' | 'yearly'
type EvolutionData =
| DailyDownloadPoint[]
Expand Down Expand Up @@ -417,6 +429,7 @@ const formatter = ({ value }: { value: number }) => formatCompactNumber(value, {
const config = computed(() => ({
theme: isDarkMode.value ? 'dark' : 'default',
chart: {
height: isMobile.value ? 850 : 600,
userOptions: {
buttons: {
pdf: false,
Expand Down Expand Up @@ -474,6 +487,7 @@ const config = computed(() => ({
},
},
zoom: {
maxWidth: 500,
highlightColor: isDarkMode.value ? '#2A2A2A' : '#E1E5E8',
minimap: {
show: true,
Expand Down Expand Up @@ -699,9 +713,4 @@ const config = computed(() => ({
background: var(--bg-elevated) !important;
box-shadow: none !important;
}

.vue-data-ui-zoom {
max-width: 500px;
margin: 0 auto;
}
</style>
13 changes: 13 additions & 0 deletions app/components/PackageWeeklyDownloadStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ const config = computed(() => {
:packageName="packageName"
:createdIso="createdIso"
/>

<template #after="{ close }">
<div class="sm:hidden flex justify-center">
<button
type="button"
@click="close"
class="w-12 h-12 bg-bg-elevated border border-border rounded-full shadow-lg flex items-center justify-center text-fg-muted hover:text-fg transition-colors"
:aria-label="$t('common.close')"
>
<span class="w-5 h-5 i-carbon-close" />
</button>
</div>
</template>
</ChartModal>
</template>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"validate-npm-package-name": "^7.0.2",
"virtua": "^0.48.3",
"vue": "3.5.27",
"vue-data-ui": "^3.13.2"
"vue-data-ui": "^3.13.4"
},
"devDependencies": {
"@iconify-json/carbon": "1.2.18",
Expand Down
96 changes: 84 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.