cista-storage/cista-front/src/components/HeaderMain.vue

79 lines
1.8 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { useDocumentStore } from '@/stores/documents'
import { ref, nextTick } from 'vue'
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>()
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()
//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
defineExpose({
toggleSearchInput
})
</script>
<template>
<nav class="headermain">
2023-11-04 00:21:35 +00:00
<div class="buttons">
<UploadButton />
2023-11-04 20:54:14 +00:00
<SvgButton
name="create-folder"
data-tooltip="New folder"
2023-11-04 20:54:14 +00:00
@click="() => documentStore.fileExplorer.newFolder()"
/>
<slot></slot>
<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"
v-model="documentStore.search"
2023-11-04 00:21:35 +00:00
class="margin-input"
@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>
<SvgButton ref="searchButton" name="find" @click="toggleSearchInput" />
<SvgButton name="cog" @click="console.log('settings menu')" />
</div>
2023-11-04 00:21:35 +00:00
</nav>
</template>
2023-11-04 00:21:35 +00:00
<style scoped>
.buttons {
padding: 0;
display: flex;
2023-11-04 00:21:35 +00:00
align-items: center;
height: 3.5em;
z-index: 10;
}
.buttons > * {
flex-shrink: 1;
}
2023-11-04 00:21:35 +00:00
.spacer {
flex-grow: 1;
}
.smallgap {
margin-left: 2em;
}
2023-11-04 00:21:35 +00:00
input[type='search'] {
background: var(--primary-background);
color: var(--primary-color);
2023-11-04 00:21:35 +00:00
border: 0;
border-radius: 0.1em;
padding: 0.5em;
2023-11-04 00:21:35 +00:00
outline: none;
font-size: 1.5em;
max-width: 30vw;
}
</style>