2021-05-10 18:14:28 +00:00
|
|
|
<template>
|
|
|
|
<nav
|
2021-06-28 19:45:03 +00:00
|
|
|
class="uk-navbar-container uk-container-expand uk-position-relative"
|
|
|
|
:style="[{ background: backgroundColor, colour: foregroundColor }]"
|
2021-03-31 22:09:39 +00:00
|
|
|
uk-navbar
|
|
|
|
>
|
|
|
|
<div class="uk-navbar-left">
|
2021-06-28 19:45:03 +00:00
|
|
|
<router-link class="uk-navbar-item uk-logo uk-text-bold" :style="[{ colour: foregroundColor }]" to="/"
|
2021-05-10 18:14:28 +00:00
|
|
|
><img alt="logo" src="/img/icons/logo.svg" height="32" width="32" />iped</router-link
|
2021-03-31 22:09:39 +00:00
|
|
|
>
|
|
|
|
</div>
|
|
|
|
<div class="uk-navbar-center uk-flex uk-visible@m">
|
|
|
|
<input
|
2021-04-07 09:27:17 +00:00
|
|
|
class="uk-input uk-width-medium"
|
2021-03-31 22:09:39 +00:00
|
|
|
type="text"
|
|
|
|
placeholder="Search"
|
|
|
|
v-model="searchText"
|
2021-04-07 09:22:55 +00:00
|
|
|
@keyup="onKeyUp"
|
2021-03-31 22:09:39 +00:00
|
|
|
@focus="onInputFocus"
|
|
|
|
@blur="onInputBlur"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="uk-navbar-right">
|
|
|
|
<ul class="uk-navbar-nav">
|
|
|
|
<li>
|
|
|
|
<router-link to="/preferences">Preferences</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
<div class="uk-container-expand uk-hidden@m">
|
|
|
|
<input
|
|
|
|
class="uk-input"
|
|
|
|
type="text"
|
|
|
|
placeholder="Search"
|
|
|
|
v-model="searchText"
|
2021-04-07 09:22:55 +00:00
|
|
|
@keyup="onKeyUp"
|
2021-03-31 22:09:39 +00:00
|
|
|
@focus="onInputFocus"
|
|
|
|
@blur="onInputBlur"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<SearchSuggestions
|
2021-04-06 10:10:17 +00:00
|
|
|
v-show="searchText && suggestionsVisible"
|
|
|
|
:searchText="searchText"
|
|
|
|
@searchchange="onSearchTextChange"
|
2021-04-07 09:22:55 +00:00
|
|
|
ref="searchSuggestions"
|
2021-03-31 22:09:39 +00:00
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import SearchSuggestions from "@/components/SearchSuggestions";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2021-05-10 18:14:28 +00:00
|
|
|
SearchSuggestions,
|
2021-03-31 22:09:39 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
searchText: "",
|
2021-05-10 18:14:28 +00:00
|
|
|
suggestionsVisible: false,
|
2021-03-31 22:09:39 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2021-04-07 09:22:55 +00:00
|
|
|
onKeyUp(e) {
|
2021-03-31 22:09:39 +00:00
|
|
|
if (e.key === "Enter") {
|
2021-07-14 19:22:00 +00:00
|
|
|
e.target.blur();
|
2021-03-31 22:09:39 +00:00
|
|
|
this.$router.push({
|
|
|
|
name: "SearchResults",
|
2021-05-10 18:14:28 +00:00
|
|
|
query: { search_query: this.searchText },
|
2021-03-31 22:09:39 +00:00
|
|
|
});
|
|
|
|
return;
|
2021-04-06 10:10:17 +00:00
|
|
|
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
|
|
e.preventDefault();
|
2021-03-31 22:09:39 +00:00
|
|
|
}
|
2021-04-07 09:22:55 +00:00
|
|
|
this.$refs.searchSuggestions.onKeyUp(e);
|
2021-03-31 22:09:39 +00:00
|
|
|
},
|
|
|
|
onInputFocus() {
|
|
|
|
this.suggestionsVisible = true;
|
|
|
|
},
|
|
|
|
onInputBlur() {
|
|
|
|
this.suggestionsVisible = false;
|
2021-04-06 10:10:17 +00:00
|
|
|
},
|
|
|
|
onSearchTextChange(searchText) {
|
|
|
|
this.searchText = searchText;
|
2021-05-10 18:14:28 +00:00
|
|
|
},
|
|
|
|
},
|
2021-03-31 22:09:39 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|