/
AppHeader.vue
64 lines (59 loc) · 1.96 KB
/
AppHeader.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
<script setup lang="ts">
import { Icon } from '@iconify/vue'
import { computed } from 'vue'
import AppLogo from './AppLogo.vue'
import { isDark, toggleDark } from '../../util/dark'
import { onKeyboardShortcut } from '../../util/keyboard'
import { makeTooltip } from '../../util/tooltip'
import { histoireConfig } from '../../util/config'
defineEmits({
search: () => true,
})
const themeIcon = computed(() => {
return isDark.value ? 'carbon:moon' : 'carbon:sun'
})
onKeyboardShortcut(['ctrl+shift+d', 'meta+shift+d'], (event) => {
event.preventDefault()
toggleDark()
})
</script>
<template>
<div
class="histoire-app-header htw-px-4 htw-h-16 htw-flex htw-items-center htw-gap-2"
>
<div class="htw-py-3 sm:htw-py-4 htw-flex-1 htw-h-full htw-flex htw-items-center htw-pr-2">
<a
:href="histoireConfig.theme?.logoHref"
target="_blank"
class="htw-w-full htw-h-full htw-flex htw-items-center"
>
<AppLogo
class="htw-max-w-full htw-max-h-full"
/>
</a>
</div>
<div class="htw-ml-auto htw-flex-none htw-flex">
<a
v-tooltip="makeTooltip('Search', ({ isMac }) => isMac ? 'meta+k' : 'ctrl+k')"
class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-text-gray-900 dark:htw-text-gray-100"
data-test-id="search-btn"
@click="$emit('search')"
>
<Icon
icon="carbon:search"
class="htw-w-6 htw-h-6 sm:htw-w-4 sm:htw-h-4"
/>
</a>
<a
v-tooltip="makeTooltip('Toggle dark mode', ({ isMac }) => isMac ? 'meta+shift+d' : 'ctrl+shift+d')"
class="htw-p-2 sm:htw-p-1 hover:htw-text-primary-500 dark:hover:htw-text-primary-400 htw-cursor-pointer htw-text-gray-900 dark:htw-text-gray-100"
@click="toggleDark()"
>
<Icon
:icon="themeIcon"
class="htw-w-6 htw-h-6 sm:htw-w-4 sm:htw-h-4"
/>
</a>
</div>
</div>
</template>