forked from npmx-dev/npmx.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMobileSidebarDrawer.vue
More file actions
106 lines (100 loc) · 3.65 KB
/
MobileSidebarDrawer.vue
File metadata and controls
106 lines (100 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<script setup lang="ts">
const props = defineProps<{
compare: CompareResponse
groupedDeps: Map<string, CompareResponse['dependencyChanges']>
allChanges: FileChange[]
pkg?: Pick<SlimPackument, 'versions' | 'dist-tags'> | null
packageName: string
toVersion: string
toVersionUrlPattern: string
}>()
const selectedFile = defineModel<FileChange | null>('selectedFile', { default: null })
const fileFilter = defineModel<'all' | 'added' | 'removed' | 'modified'>('fileFilter', {
default: 'all',
})
const open = defineModel<boolean>('open', { default: false })
const route = useRoute()
watch(
() => route.fullPath,
() => {
open.value = false
},
)
const isLocked = useScrollLock(import.meta.client ? document : null)
watch(open, value => {
isLocked.value = value
})
</script>
<template>
<!-- Backdrop -->
<Transition
enter-active-class="transition-opacity duration-200"
enter-from-class="opacity-0"
enter-to-class="opacity-100"
leave-active-class="transition-opacity duration-200"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<div v-if="open" class="md:hidden fixed inset-0 z-40 bg-black/50" @click="open = false" />
</Transition>
<!-- Drawer -->
<Transition
enter-active-class="transition-transform duration-200"
enter-from-class="-translate-x-full"
enter-to-class="translate-x-0"
leave-active-class="transition-transform duration-200"
leave-from-class="translate-x-0"
leave-to-class="-translate-x-full"
>
<aside
v-if="open"
class="md:hidden fixed inset-y-0 inset-is-0 z-50 w-72 max-w-[85vw] bg-bg-subtle border-ie border-border overflow-y-auto flex flex-col"
>
<div class="sticky top-0 bg-bg-subtle border-b border-border z-50">
<div class="flex items-center justify-between gap-2 py-2 px-4">
<div class="text-xs font-mono text-fg-muted flex items-center gap-2">
<span class="flex items-center gap-1">
<span class="text-green-500">+{{ props.compare.stats.filesAdded }}</span>
<span class="text-fg-subtle">/</span>
<span class="text-red-500">-{{ props.compare.stats.filesRemoved }}</span>
<span class="text-fg-subtle">/</span>
<span class="text-yellow-500">~{{ props.compare.stats.filesModified }}</span>
</span>
<span class="text-fg-subtle">•</span>
<span>{{
$t('compare.files_count', { count: props.allChanges.length }, props.allChanges.length)
}}</span>
</div>
<button
type="button"
class="text-fg-muted hover:text-fg transition-colors"
:aria-label="$t('compare.close_files_panel')"
@click="open = false"
>
<span class="i-lucide:x w-5 h-5" />
</button>
</div>
<div v-if="pkg?.versions && pkg?.['dist-tags']" class="py-2 border-t border-border px-4">
<p class="text-xs font-medium text-fg mb-1 flex items-center gap-1.5">
<span class="block i-lucide-git-compare-arrows w-3.5 h-3.5" />
{{ $t('compare.version_selector_title') }}
</p>
<VersionSelector
:package-name="packageName"
:current-version="toVersion"
:versions="pkg.versions"
:dist-tags="pkg['dist-tags']"
:url-pattern="toVersionUrlPattern"
/>
</div>
</div>
<DiffSidebarPanel
:compare="props.compare"
:grouped-deps="props.groupedDeps"
:all-changes="props.allChanges"
v-model:selected-file="selectedFile"
v-model:file-filter="fileFilter"
/>
</aside>
</Transition>
</template>