explorer-app/components/SearchBox.vue

128 lines
2.6 KiB
Vue
Raw Permalink Normal View History

2023-12-19 18:43:42 +01:00
<script setup lang="ts">
import type { InputOption } from '~/types'
defineProps<{ placeholder?: string, includeSort?: boolean }>()
2023-12-19 18:43:42 +01:00
const { filter, switcher } = storeToRefs(useData())
const options: InputOption[] = [
{ label: 'A to Z', value: 'atoz' },
{ label: 'Score', value: 'score' },
{ label: 'Anonymity', value: 'anonymity' },
]
const isSearchFocused = ref(false)
</script>
<template>
<div
flex
justify-between
gap-16px
items-centeer
>
<div
border-2px
flex
items-center
w-full
h-40px
hover:opacity-100
2024-09-27 12:14:49 +02:00
md:max-w-470px
:class="isSearchFocused ? 'opacity-100' : 'opacity-25'"
>
<div
px-12px
py-0px
flex
w-fit
>
2023-12-19 18:43:42 +01:00
<UnoIcon
i-heroicons-solid-magnifying-glass
text-16px
2023-12-19 18:43:42 +01:00
:class="isSearchFocused ? 'opacity-100' : 'opacity-50' "
class="uno-icon"
/>
</div>
<input
v-model="filter.query"
:placeholder="placeholder"
type="text"
bg-transparent
border-transparent
focus:border-transparent
focus:ring-0
h-full
w-full
outline-none
@focus="isSearchFocused = true"
@blur="isSearchFocused = false"
2023-12-19 18:43:42 +01:00
>
</div>
<div v-if="includeSort">
<div
flex
gap-24px
items-center
w-full
>
<div
gap-12px
items-center
xl:flex
hidden
invisible
>
<UnoIcon
i-web-list
text-16px
cursor-pointer
hover:opacity-100
:class="switcher ? 'opacity-100' : 'opacity-50'"
@click="switcher = true"
/>
<UnoIcon
i-web-blocks
text-16px
cursor-pointer
hover:opacity-100
:class="!switcher ? 'opacity-100' : 'opacity-50'"
@click="switcher = false"
/>
2023-12-19 18:43:42 +01:00
</div>
<div
flex
gap-12px
items-center
w-full
>
<h4
xl:block
hidden
text-16px
opacity-50
w-fit
>
2023-12-19 18:43:42 +01:00
Sort by
</h4>
<SelectBox
v-model="filter.sortby"
:black-and-white="false"
:options="options"
w-99px
sm:w-162px
text-black
:is-margin-top="false"
/>
2023-12-19 18:43:42 +01:00
</div>
</div>
</div>
</div>
</template>
<style scoped>
div:hover .uno-icon {
opacity: 1;
}
</style>