-
-
Notifications
You must be signed in to change notification settings - Fork 250
Expand file tree
/
Copy pathHeader.vue
More file actions
81 lines (76 loc) · 2.21 KB
/
Header.vue
File metadata and controls
81 lines (76 loc) · 2.21 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
<script setup lang="ts">
import { useApp, useSnippets, useSnippetUpdate } from '@/composables'
import { i18n } from '@/electron'
import { Plus, Type } from 'lucide-vue-next'
const { selectedSnippet, addFragment } = useSnippets()
const { isFocusedSnippetName, state } = useApp()
const { addToUpdateQueue } = useSnippetUpdate()
const isShowDescription = ref(false)
const name = computed({
get() {
return selectedSnippet?.value?.name
},
set(v: string) {
addToUpdateQueue(selectedSnippet.value!.id, {
name: v,
description: selectedSnippet.value!.description,
folderId: selectedSnippet.value!.folder?.id || null,
isDeleted: selectedSnippet.value!.isDeleted,
isFavorites: selectedSnippet.value!.isFavorites,
})
},
})
function onClickTab(index: number) {
state.snippetContentIndex = index
}
</script>
<template>
<div data-editor-header>
<div
class="border-border grid grid-cols-[1fr_auto] items-center border-b px-2"
>
<UiInput
v-model="name"
variant="ghost"
class="w-full truncate px-0"
:select="isFocusedSnippetName"
@blur="isFocusedSnippetName = false"
/>
<div class="ml-2 flex">
<UiActionButton
:tooltip="i18n.t('action.add.description')"
@click="isShowDescription = !isShowDescription"
>
<Type class="h-3 w-3" />
</UiActionButton>
<UiActionButton
:tooltip="i18n.t('action.new.fragment')"
@click="addFragment"
>
<Plus class="h-4 w-4" />
</UiActionButton>
</div>
</div>
<div
v-if="selectedSnippet?.contents && selectedSnippet.contents.length > 1"
class="border-border grid auto-cols-fr grid-flow-col border-b"
>
<EditorTab
v-for="(i, index) in selectedSnippet?.contents"
:id="i.id"
:key="i.id"
:index="index"
:name="i.label"
:class="{
'bg-list-selection text-list-selection-fg':
state.snippetContentIndex === index,
}"
@click="onClickTab(index)"
/>
</div>
<EditorDescription v-model:show="isShowDescription" />
<div class="pt-1">
<EditorHeaderTags />
</div>
</div>
</template>