-
Notifications
You must be signed in to change notification settings - Fork 712
/
Copy pathapp.vue
115 lines (102 loc) · 2.77 KB
/
app.vue
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
107
108
109
110
111
112
113
114
115
<script setup lang="ts">
import { splitByCase, upperFirst } from 'scule'
import { useRouter } from 'vue-router'
import { reactive, ref } from 'vue'
import { useColorMode } from '@vueuse/core'
const appConfig = useAppConfig()
const mode = useColorMode()
appConfig.toaster = reactive({
position: 'bottom-right' as const,
expand: true,
duration: 5000
})
const router = useRouter()
const components = [
'accordion',
'alert',
'avatar',
'badge',
'breadcrumb',
'button',
'button-group',
'card',
'calendar',
'carousel',
'checkbox',
'checkbox-group',
'chip',
'collapsible',
'color-picker',
'context-menu',
'command-palette',
'drawer',
'dropdown-menu',
'form',
'form-field',
'input',
'input-menu',
'input-number',
'kbd',
'link',
'modal',
'navigation-menu',
'pagination',
'pin-input',
'popover',
'progress',
'radio-group',
'select',
'select-menu',
'separator',
'shortcuts',
'skeleton',
'slideover',
'slider',
'stepper',
'switch',
'tabs',
'table',
'textarea',
'toast',
'tooltip',
'tree'
]
const items = components.map(component => ({ label: upperName(component), to: `/components/${component}` }))
function upperName(name: string) {
return splitByCase(name).map(p => upperFirst(p)).join('')
}
const isCommandPaletteOpen = ref(false)
function onSelect(item: any) {
router.push(item.to)
}
defineShortcuts({
meta_k: () => isCommandPaletteOpen.value = true
})
</script>
<template>
<UApp :toaster="(appConfig.toaster as any)">
<div class="h-screen w-screen overflow-hidden flex min-h-0 bg-default" data-vaul-drawer-wrapper>
<UNavigationMenu :items="items" orientation="vertical" class="hidden lg:flex border-e border-default overflow-y-auto w-48 p-4" />
<UNavigationMenu :items="items" orientation="horizontal" class="lg:hidden border-b border-default [&>div]:min-w-min overflow-x-auto" />
<div class="fixed top-15 lg:top-3 end-4 flex items-center gap-2">
<UButton
:icon="mode === 'dark' ? 'i-lucide-moon' : 'i-lucide-sun'"
color="neutral"
variant="ghost"
:aria-label="`Switch to ${mode === 'dark' ? 'light' : 'dark'} mode`"
@click="mode = mode === 'dark' ? 'light' : 'dark'"
/>
</div>
<div class="flex-1 flex flex-col items-center justify-around overflow-y-auto w-full py-14 px-4">
<Suspense>
<RouterView />
</Suspense>
</div>
</div>
<UModal v-model:open="isCommandPaletteOpen" class="sm:h-96">
<template #content>
<UCommandPalette placeholder="Search a component..." :groups="[{ id: 'items', items }]" :fuse="{ resultLimit: 100 }" @update:model-value="onSelect" @update:open="value => isCommandPaletteOpen = value" />
</template>
</UModal>
</UApp>
</template>