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

87 lines
2.0 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { useDocumentStore } from '@/stores/documents'
import { ref, nextTick, watchEffect } 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>()
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()
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
const executeSearch = () => {
documentStore.setFilter(search.value?.value ?? '')
2023-11-01 23:00:59 +00:00
}
defineExpose({
toggleSearchInput
})
</script>
<template>
2023-11-04 00:21:35 +00:00
<nav>
<div class="buttons">
<UploadButton />
<SvgButton name="create-folder" @click="() => documentStore.fileExplorer.newFolder()"/>
<template v-if="documentStore.selected.size > 0">
2023-11-04 00:21:35 +00:00
<div class="smallgap"></div>
<p class="select-text">{{ documentStore.selected.size }} selected </p>
2023-11-04 00:21:35 +00:00
<!-- Needs better icons for copy/move/remove -->
<SvgButton name="download" />
<SvgButton name="copy" />
2023-11-04 00:21:35 +00:00
<SvgButton name="paste" />
<SvgButton name="trash" />
<button @click="documentStore.selected.clear()"></button>
</template>
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>
<SvgButton name="find" @click="toggleSearchInput" />
<SvgButton name="cog" @click="console.log('TODO open settings')" />
</div>
2023-11-04 00:21:35 +00:00
</nav>
</template>
2023-11-04 00:21:35 +00:00
<style scoped>
.buttons {
padding: 0 0.5em;
display: flex;
2023-11-04 00:21:35 +00:00
align-items: center;
}
2023-11-04 00:21:35 +00:00
.spacer {
flex-grow: 1;
}
2023-11-04 00:21:35 +00:00
.smallgap {
margin-left: 2em;
}
.select-text {
color: var(--accent-color);
}
2023-11-04 00:21:35 +00:00
.search-widget {
display: flex;
align-items: center;
2023-10-27 16:32:21 +01:00
}
2023-11-04 00:21:35 +00:00
input[type='search'] {
background: var(--primary-background);
color: var(--text-color);
border: 0;
border-radius: 0.1rem;
padding: 0.5rem;
outline: none;
font-size: 1.2rem;
}
</style>