Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
36 changes: 31 additions & 5 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 @@ -50,6 +50,35 @@ const accent = computed(() => {
return id ? (oklchToHex(accentColorValueById.value[id]!) ?? '#8A8A8A') : '#8A8A8A'
})

const mobileBreakpointWidth = 640
const isMobile = ref(false)

let resizeObserver: ResizeObserver | null = null

function updateIsMobileFromWidth(width: number) {
isMobile.value = width < mobileBreakpointWidth
}

onMounted(() => {
if (!import.meta.client) return

updateIsMobileFromWidth(window.innerWidth)

resizeObserver = new ResizeObserver(entries => {
const entry = entries[0]
if (!entry) return
updateIsMobileFromWidth(entry.contentRect.width)
})

resizeObserver.observe(document.documentElement)
})

onBeforeUnmount(() => {
if (!resizeObserver) return
resizeObserver.disconnect()
resizeObserver = null
})

type ChartTimeGranularity = 'daily' | 'weekly' | 'monthly' | 'yearly'
type EvolutionData =
| DailyDownloadPoint[]
Expand Down Expand Up @@ -417,6 +446,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 +504,7 @@ const config = computed(() => ({
},
},
zoom: {
maxWidth: 500,
highlightColor: isDarkMode.value ? '#2A2A2A' : '#E1E5E8',
minimap: {
show: true,
Expand Down Expand Up @@ -699,9 +730,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.

Loading