2023-10-26 00:43:44 +01:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { useDocumentStore } from '@/stores/documents'
|
2023-11-04 19:50:05 +00:00
|
|
|
import { ref, nextTick } from 'vue'
|
2023-10-26 00:43:44 +01:00
|
|
|
|
|
|
|
const documentStore = useDocumentStore()
|
2023-10-27 16:32:21 +01:00
|
|
|
const showSearchInput = ref<boolean>(false)
|
2023-11-04 00:21:35 +00:00
|
|
|
const search = ref<HTMLInputElement | null>()
|
2023-11-04 19:50:05 +00:00
|
|
|
const searchButton = ref<HTMLButtonElement | null>()
|
2023-10-27 16:32:21 +01:00
|
|
|
|
|
|
|
const toggleSearchInput = () => {
|
2023-11-03 20:07:05 +00:00
|
|
|
showSearchInput.value = !showSearchInput.value
|
2023-11-04 00:21:35 +00:00
|
|
|
nextTick(() => {
|
|
|
|
const input = search.value
|
|
|
|
if (input) input.focus()
|
2023-11-07 00:44:55 +00:00
|
|
|
//else if (searchButton.value) document.querySelector('.breadcrumb')!.focus()
|
2023-11-04 00:21:35 +00:00
|
|
|
})
|
2023-11-01 23:00:59 +00:00
|
|
|
}
|
2023-10-27 16:32:21 +01:00
|
|
|
|
2023-11-04 14:10:18 +00:00
|
|
|
defineExpose({
|
|
|
|
toggleSearchInput
|
|
|
|
})
|
2023-10-26 00:43:44 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-11-07 00:44:55 +00:00
|
|
|
<nav class="headermain">
|
2023-11-04 00:21:35 +00:00
|
|
|
<div class="buttons">
|
2023-10-26 00:43:44 +01:00
|
|
|
<UploadButton />
|
2023-11-04 20:54:14 +00:00
|
|
|
<SvgButton
|
|
|
|
name="create-folder"
|
2023-11-06 15:33:43 +00:00
|
|
|
data-tooltip="New folder"
|
2023-11-04 20:54:14 +00:00
|
|
|
@click="() => documentStore.fileExplorer.newFolder()"
|
|
|
|
/>
|
|
|
|
<slot></slot>
|
2023-11-06 18:51:51 +00:00
|
|
|
<div class="spacer smallgap"></div>
|
2023-10-27 16:32:21 +01:00
|
|
|
<template v-if="showSearchInput">
|
2023-11-04 00:21:35 +00:00
|
|
|
<input
|
|
|
|
ref="search"
|
|
|
|
type="search"
|
2023-11-06 21:50:29 +00:00
|
|
|
v-model="documentStore.search"
|
2023-11-04 00:21:35 +00:00
|
|
|
class="margin-input"
|
2023-11-06 21:50:29 +00:00
|
|
|
@blur="() => { if (documentStore.search === '') toggleSearchInput() }"
|
2023-11-04 00:21:35 +00:00
|
|
|
@keyup.esc="toggleSearchInput"
|
|
|
|
/>
|
2023-10-27 16:32:21 +01:00
|
|
|
</template>
|
2023-11-04 19:50:05 +00:00
|
|
|
<SvgButton ref="searchButton" name="find" @click="toggleSearchInput" />
|
2023-11-05 23:12:42 +00:00
|
|
|
<SvgButton name="cog" @click="console.log('settings menu')" />
|
2023-10-26 00:43:44 +01:00
|
|
|
</div>
|
2023-11-04 00:21:35 +00:00
|
|
|
</nav>
|
2023-10-26 00:43:44 +01:00
|
|
|
</template>
|
|
|
|
|
2023-11-04 00:21:35 +00:00
|
|
|
<style scoped>
|
|
|
|
.buttons {
|
2023-11-06 15:33:43 +00:00
|
|
|
padding: 0;
|
2023-10-26 00:43:44 +01:00
|
|
|
display: flex;
|
2023-11-04 00:21:35 +00:00
|
|
|
align-items: center;
|
2023-11-06 16:51:10 +00:00
|
|
|
height: 3.5em;
|
2023-11-06 15:33:43 +00:00
|
|
|
z-index: 10;
|
2023-10-26 00:43:44 +01:00
|
|
|
}
|
2023-11-04 19:50:05 +00:00
|
|
|
.buttons > * {
|
|
|
|
flex-shrink: 1;
|
|
|
|
}
|
2023-11-04 00:21:35 +00:00
|
|
|
.spacer {
|
|
|
|
flex-grow: 1;
|
2023-10-26 00:43:44 +01:00
|
|
|
}
|
2023-11-06 18:51:51 +00:00
|
|
|
.smallgap {
|
|
|
|
margin-left: 2em;
|
|
|
|
}
|
2023-11-04 00:21:35 +00:00
|
|
|
input[type='search'] {
|
|
|
|
background: var(--primary-background);
|
2023-11-04 19:50:05 +00:00
|
|
|
color: var(--primary-color);
|
2023-11-04 00:21:35 +00:00
|
|
|
border: 0;
|
2023-11-06 16:51:10 +00:00
|
|
|
border-radius: 0.1em;
|
|
|
|
padding: 0.5em;
|
2023-11-04 00:21:35 +00:00
|
|
|
outline: none;
|
2023-11-06 16:51:10 +00:00
|
|
|
font-size: 1.5em;
|
2023-11-04 19:50:05 +00:00
|
|
|
max-width: 30vw;
|
2023-11-03 16:15:37 +00:00
|
|
|
}
|
2023-10-26 00:43:44 +01:00
|
|
|
</style>
|