|
1 | 1 | <script setup lang="ts"> |
2 | 2 | // Framework |
3 | | - import { Atom, useBreakpoints, useDocumentEventListener, useFeatures, useHotkey, useStorage, useTheme } from '@vuetify/v0' |
| 3 | + import { Atom, useBreakpoints, useFeatures, useStorage, useTheme } from '@vuetify/v0' |
4 | 4 |
|
5 | 5 | // Components |
6 | 6 | import { Discovery } from '@/components/discovery' |
7 | 7 |
|
8 | 8 | // Composables |
9 | | - import { useDiscovery } from '@/composables/useDiscovery' |
10 | 9 | import { useSearch } from '@/composables/useSearch' |
11 | 10 | import { useSettings } from '@/composables/useSettings' |
12 | 11 |
|
13 | 12 | // Utilities |
14 | | - import { nextTick, ref, toRef, watch } from 'vue' |
| 13 | + import { toRef, watch } from 'vue' |
15 | 14 | import { useRoute } from 'vue-router' |
16 | 15 |
|
17 | 16 | // Types |
|
29 | 28 | const isHomePage = toRef(() => route.path === '/') |
30 | 29 |
|
31 | 30 | const breakpoints = useBreakpoints() |
32 | | - const discovery = useDiscovery() |
33 | 31 | const features = useFeatures() |
34 | 32 | const theme = useTheme() |
35 | | - const { open: openSearch } = useSearch() |
| 33 | + const search = useSearch() |
36 | 34 | const { showSkillFilter, showThemeToggle, showSocialLinks } = useSettings() |
37 | 35 |
|
38 | 36 | const devmode = features.get('devmode')! |
|
45 | 43 | ? 'https://cdn.vuetifyjs.com/docs/images/logos/vzero-logo-dark.png' |
46 | 44 | : 'https://cdn.vuetifyjs.com/docs/images/logos/vzero-logo-light.png', |
47 | 45 | ) |
48 | | -
|
49 | | - discovery.on('start:open-search', () => { |
50 | | - const once = useDocumentEventListener('keydown', (event: KeyboardEvent) => { |
51 | | - if (!event.ctrlKey || event.key !== 'k') return |
52 | | - nextTick(() => { |
53 | | - discovery.next() |
54 | | - once() |
55 | | - }) |
56 | | - }) |
57 | | - }) |
58 | | -
|
59 | | - discovery.on('back:open-search', () => { |
60 | | - console.log('back to open-search') |
61 | | - }) |
62 | | -
|
63 | | - discovery.on('complete:open-search', () => { |
64 | | - console.log('completed open-search') |
65 | | - }) |
66 | 46 | </script> |
67 | 47 |
|
68 | 48 | <template> |
|
93 | 73 | <AppIcon :icon="app.drawer ? 'close' : 'menu'" /> |
94 | 74 | </button> |
95 | 75 |
|
96 | | - <Discovery.Root step="open-search"> |
97 | | - <Discovery.Activator class="rounded-2xl" step="open-search"> |
98 | | - <button |
99 | | - aria-label="Search (Ctrl+K)" |
100 | | - class="inline-flex items-center gap-1.5 md:bg-glass-surface rounded-full md:border md:border-divider md:pl-1.5 md:pr-1.5 md:py-1.5 hover:border-primary/50 transition-colors" |
101 | | - title="Search (Ctrl+K)" |
102 | | - type="button" |
103 | | - @click="openSearch" |
104 | | - > |
105 | | - <span class="shrink-0 size-6 rounded-full bg-primary text-on-primary flex items-center justify-center"> |
106 | | - <AppIcon icon="search" size="12" /> |
107 | | - </span> |
108 | | - <span class="hidden md:inline text-sm text-on-surface-variant">Search the docs...</span> |
109 | | - <kbd class="hidden md:inline-flex shrink-0 px-1.5 py-0.5 rounded bg-surface-tint text-on-surface-tint text-[10px] font-mono items-center rounded-r-lg">Ctrl+K</kbd> |
110 | | - </button> |
111 | | - </Discovery.Activator> |
112 | | - |
113 | | - <Discovery.Content class="p-4 bg-surface border border-divider rounded-xl shadow-xl max-w-xs"> |
114 | | - <div class="flex justify-between items-center"> |
115 | | - <Discovery.Title class="text-lg font-semibold text-on-surface mb-1">Open Search</Discovery.Title> |
116 | | - <Discovery.Progress class="text-xs text-on-surface-variant mb-2" /> |
117 | | - </div> |
118 | | - |
119 | | - <Discovery.Description class="text-sm text-on-surface-variant mb-4"> |
120 | | - Press <kbd class="px-1.5 py-0.5 rounded bg-surface-tint text-on-surface-tint text-xs font-mono">Ctrl+K</kbd> to open the search dialog. |
121 | | - </Discovery.Description> |
122 | | - |
123 | | - <div class="flex justify-end"> |
124 | | - <Discovery.Skip class="px-3 py-1.5 text-sm text-on-surface-variant hover:text-on-surface"> |
125 | | - Skip tour |
126 | | - </Discovery.Skip> |
127 | | - </div> |
128 | | - </Discovery.Content> |
129 | | - </Discovery.Root> |
| 76 | + <Discovery.Activator class="rounded-2xl" step="open-search"> |
| 77 | + <button |
| 78 | + aria-label="Search (Ctrl+K)" |
| 79 | + class="inline-flex items-center gap-1.5 md:bg-glass-surface rounded-full md:border md:border-divider md:pl-1.5 md:pr-1.5 md:py-1.5 hover:border-primary/50 transition-colors" |
| 80 | + title="Search (Ctrl+K)" |
| 81 | + type="button" |
| 82 | + @click="search.open()" |
| 83 | + > |
| 84 | + <span class="shrink-0 size-6 rounded-full bg-primary text-on-primary flex items-center justify-center"> |
| 85 | + <AppIcon icon="search" size="12" /> |
| 86 | + </span> |
| 87 | + <span class="hidden md:inline text-sm text-on-surface-variant">Search the docs...</span> |
| 88 | + <kbd class="hidden md:inline-flex shrink-0 px-1.5 py-0.5 rounded bg-surface-tint text-on-surface-tint text-[10px] font-mono items-center rounded-r-lg">Ctrl+K</kbd> |
| 89 | + </button> |
| 90 | + </Discovery.Activator> |
130 | 91 | </div> |
131 | 92 |
|
132 | 93 | <div class="flex align-center items-center gap-3"> |
|
0 commit comments