VueTube/NUXT/components/topNavigation.vue

116 lines
2.5 KiB
Vue
Raw Normal View History

<template>
<v-card
style="height: 4rem !important; display: flex; box-shadow: none !important"
2022-03-22 00:52:45 +00:00
color="accent"
2022-03-21 21:01:37 +00:00
class="topNav rounded-0 pa-3"
>
2022-03-21 23:47:11 +00:00
<h3 v-show="!search" class="my-auto ml-4" v-text="page" />
2022-03-21 23:47:11 +00:00
<v-btn
v-if="search"
icon
class="mr-3 my-auto"
@click="$emit('close-search')"
>
<v-icon>mdi-close</v-icon>
</v-btn>
<v-text-field
2022-03-21 23:47:11 +00:00
v-if="search"
v-model="text"
solo
dense
flat
label="Search"
class="searchBar"
2022-03-21 23:47:11 +00:00
@input="$emit('text-changed', text)"
@keyup.enter="$emit('search-btn', text)"
/>
<v-spacer v-if="!search" />
2022-03-24 04:55:38 +00:00
<v-btn
v-show="page == 'Home'"
icon
tile
class="ml-3 mr-1 my-auto fill-height"
style="border-radius: 0.25rem !important"
@click="refreshRecommendations"
><v-icon>mdi-refresh</v-icon></v-btn
>
<v-btn
icon
tile
2022-03-21 21:01:37 +00:00
class="ml-3 my-auto fill-height"
style="border-radius: 0.25rem !important"
@click="$emit('search-btn', text)"
><v-icon>mdi-magnify</v-icon></v-btn
>
<v-btn
2022-03-21 23:47:11 +00:00
v-show="!search"
icon
tile
class="ml-4 mr-2 my-auto fill-height"
style="border-radius: 0.25rem !important"
to="/settings"
2022-03-23 16:34:38 +00:00
><v-icon>mdi-cog-outline</v-icon></v-btn
>
</v-card>
</template>
<script>
export default {
2022-03-21 23:47:11 +00:00
props: {
search: {
type: Boolean,
default: false,
},
page: {
type: String,
default: "Home",
},
},
events: ["searchBtn", "textChanged", "closeSearch"],
data: () => ({
text: "",
}),
2022-03-24 04:55:38 +00:00
methods: {
refreshRecommendations() {
this.$emit("scroll-to-top");
2022-03-31 02:22:22 +00:00
const continuations = this.$store.state.recommendedVideos.continuations;
2022-03-24 04:55:38 +00:00
this.$store.commit("updateRecommendedVideos", []);
this.$youtube
2022-03-31 02:22:22 +00:00
.continuation(
continuations[1].reloadContinuationData.continuation,
"browse"
)
2022-03-24 04:55:38 +00:00
.then((result) => {
2022-03-31 02:22:22 +00:00
if (result)
this.$youtube.recommend(result).then((result) => {
if (result) this.$store.commit("updateRecommendedVideos", result);
});
2022-03-24 04:55:38 +00:00
})
.catch((error) => this.$logger("Home Page (Nav Refresh)", error, true));
},
},
};
</script>
<style scoped>
.topNav {
position: fixed;
width: 100%;
top: 0;
z-index: 999;
/*border-radius: 0 0 1em 1em !important;*/
}
.topNavSearch {
margin-bottom: -10em;
margin-left: 2em;
/*transform: translateY(-2.5%);*/
}
.searchBar {
margin: 0;
}
</style>