diff --git a/src/App.vue b/src/App.vue index 7133aa0c..d420dcba 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,8 +3,13 @@
diff --git a/src/components/TrendingPage.vue b/src/components/TrendingPage.vue index 16432095..83db71eb 100644 --- a/src/components/TrendingPage.vue +++ b/src/components/TrendingPage.vue @@ -18,8 +18,14 @@ class="uk-search-input" style="border-radius: 9999px; padding: 12px 18px 12px 40px;" :style="{ backgroundColor: secondaryBackgroundColor }" - type="search" + v-model="searchText" + type="text" + role="search" + :title="$t('actions.search')" :placeholder="$t('actions.search')" + @keyup="onKeyUp" + @focus="onInputFocus" + @blur="onInputBlur" /> +
import VideoItem from "@/components/VideoItem.vue"; +import SearchSuggestions from "@/components/SearchSuggestions"; import { useIsMobile } from "../store"; export default { components: { + SearchSuggestions, VideoItem, }, props: { @@ -71,8 +85,11 @@ export default { data() { return { videos: [], + searchText: "", + suggestionsVisible: false, }; }, + mounted() { let region = this.getPreferenceString("region", "US"); @@ -91,6 +108,29 @@ export default { region: region || "US", }); }, + + onKeyUp(e) { + if (e.key === "Enter") { + e.target.blur(); + this.$router.push({ + name: "SearchResults", + query: { search_query: this.searchText }, + }); + return; + } else if (e.key === "ArrowUp" || e.key === "ArrowDown") { + e.preventDefault(); + } + this.$refs.searchSuggestions.onKeyUp(e); + }, + onInputFocus() { + this.suggestionsVisible = true; + }, + onInputBlur() { + this.suggestionsVisible = false; + }, + onSearchTextChange(searchText) { + this.searchText = searchText; + }, }, };