generated from Seekra/repository-template
Move search form to the search bar component
This commit is contained in:
@@ -16,19 +16,34 @@ limitations under the License.
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
const searchQuery = defineModel();
|
const searchQuery = defineModel();
|
||||||
|
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const props = defineProps(['autoSubmit'])
|
||||||
|
|
||||||
|
const submitSearch = function () {
|
||||||
|
if (props.autoSubmit !== undefined) {
|
||||||
|
router.push({
|
||||||
|
name: 'searchResults',
|
||||||
|
query: { q: searchQuery.value }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<form @submit.prevent="submitSearch">
|
||||||
<div class="search-wrapper">
|
<div class="search-wrapper">
|
||||||
<input
|
<input
|
||||||
v-model="searchQuery"
|
v-model="searchQuery"
|
||||||
type="search"
|
type="search"
|
||||||
name="search"
|
|
||||||
placeholder="Search..."
|
placeholder="Search..."
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<button type="submit" class="search-button">Search</button>
|
<button type="submit" class="search-button">Search</button>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -25,10 +25,7 @@ const router = useRouter();
|
|||||||
const searchQuery = ref('');
|
const searchQuery = ref('');
|
||||||
|
|
||||||
const submitSearch = function () {
|
const submitSearch = function () {
|
||||||
router.push({
|
|
||||||
name: 'searchResults',
|
|
||||||
query: { q: searchQuery.value }
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -41,9 +38,9 @@ const submitSearch = function () {
|
|||||||
</span>
|
</span>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<form class="search-form" @submit.prevent="submitSearch">
|
<div class="search-container">
|
||||||
<Searchbar v-model="searchQuery" ref="searchbar" />
|
<Searchbar v-model="searchQuery" ref="searchbar" auto-submit />
|
||||||
</form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -79,7 +76,7 @@ const submitSearch = function () {
|
|||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-form {
|
.search-container {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
max-width: 624px;
|
max-width: 624px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user