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-04 19:50:05 +00:00
|
|
|
else if (searchButton.value) searchButton.value.blur()
|
2023-11-04 14:10:18 +00:00
|
|
|
executeSearch()
|
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
|
|
|
const executeSearch = () => {
|
|
|
|
documentStore.setFilter(search.value?.value ?? '')
|
2023-11-01 23:00:59 +00:00
|
|
|
}
|
2023-11-04 14:10:18 +00:00
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
toggleSearchInput
|
|
|
|
})
|
2023-10-26 00:43:44 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-11-04 00:21:35 +00:00
|
|
|
<nav>
|
|
|
|
<div class="buttons">
|
2023-10-26 00:43:44 +01:00
|
|
|
<UploadButton />
|
2023-11-04 20:54:14 +00:00
|
|
|
<SvgButton
|
|
|
|
name="create-folder"
|
|
|
|
@click="() => documentStore.fileExplorer.newFolder()"
|
|
|
|
/>
|
|
|
|
<slot></slot>
|
2023-11-04 00:21:35 +00:00
|
|
|
<div class="spacer"></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"
|
|
|
|
class="margin-input"
|
|
|
|
@keyup.esc="toggleSearchInput"
|
2023-11-04 00:57:54 +00:00
|
|
|
@input="executeSearch"
|
2023-11-04 00:21:35 +00:00
|
|
|
/>
|
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-04 14:10:18 +00:00
|
|
|
<SvgButton name="cog" @click="console.log('TODO open settings')" />
|
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 {
|
|
|
|
padding: 0 0.5em;
|
2023-10-26 00:43:44 +01:00
|
|
|
display: flex;
|
2023-11-04 00:21:35 +00:00
|
|
|
align-items: center;
|
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-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;
|
|
|
|
border-radius: 0.1rem;
|
|
|
|
padding: 0.5rem;
|
|
|
|
outline: none;
|
2023-11-04 19:50:05 +00:00
|
|
|
font-size: 1.5rem;
|
|
|
|
max-width: 30vw;
|
2023-11-03 16:15:37 +00:00
|
|
|
}
|
2023-10-26 00:43:44 +01:00
|
|
|
</style>
|