<template>
    <div class="search">
        <div class="search__form" role="form" method="post" autocomplete="off">
            <input v-model="searchInput" @keyup.arrow-down="nextSearchEngine" @keyup.arrow-up="previousSearchEngine"
                class="search__form__input" type="text" placeholder="search">
        </div>
        <SearchIcon />
    </div>
</template>

<script setup>
import { storeToRefs } from 'pinia';
import { useSearchStore } from '@/stores/search';

import SearchIcon from './SearchIcon.vue';

const { nextSearchEngine, previousSearchEngine } = useSearchStore();
const { searchInput } = storeToRefs(useSearchStore());
</script>

<style scoped>
.search {
    width: 100%;

    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    gap: 0.5rem;
}

.search__form {
    flex-grow: 2;
    max-height: var(--input-height);
}

.search__form__input {
    width: 100%;
    height: 100%;

    padding-left: 1rem;
    border: 1px solid #ccc;
    border-radius: 0.25rem;
}
</style>