use computed properties to render correct nav title

This commit is contained in:
geoffrey45
2022-06-10 10:01:12 +03:00
parent a14f35b0e5
commit 857c2484fe
8 changed files with 131 additions and 75 deletions
+2
View File
@@ -53,6 +53,8 @@ const imguri = paths.images.thumb;
const nav = useNavStore();
useVisibility(albumheaderthing, nav.toggleShowPlay);
</script>
<style lang="scss">
+8
View File
@@ -1,6 +1,7 @@
<template>
<div
class="p-header image"
ref="playlistheader"
:style="[
{
backgroundImage: `url(${imguri + props.info.image})`,
@@ -47,10 +48,17 @@ import pContext from "../../contexts/playlist";
import useContextStore from "../../stores/context";
import { paths } from "../../config";
import usePStore from "@/stores/p.ptracks";
import useVisibility from "@/composables/useVisibility";
import { ref } from "vue";
import useNavStore from "@/stores/nav";
const imguri = paths.images.playlist;
const context = useContextStore();
const modal = useModalStore();
const nav = useNavStore();
const playlistheader = ref(null);
useVisibility(playlistheader, nav.toggleShowPlay);
const props = defineProps<{
info: Playlist;
+38 -33
View File
@@ -6,7 +6,7 @@
</div>
<div class="info">
<Album v-show="$route.name == Routes.album && !nav.showPlay" />
<APTitle v-show="showAPTitle" />
<Playlists v-show="$route.name == Routes.playlists" />
<Folder v-show="$route.name == Routes.folder" :subPaths="subPaths" />
</div>
@@ -27,54 +27,59 @@ import NavButtons from "./NavButtons.vue";
import Loader from "../shared/Loader.vue";
import Search from "./Search.vue";
import { useRoute } from "vue-router";
import { onMounted, ref, watch } from "vue";
import { ref, watch } from "vue";
import { Routes } from "@/composables/enums";
import createSubPaths from "@/composables/createSubPaths";
import { subPath } from "@/interfaces";
import Folder from "./Titles/Folder.vue";
import Playlists from "./Titles/Playlists.vue";
import Album from "./Titles/Album.vue";
import APTitle from "./Titles/APTitle.vue";
import useNavStore from "@/stores/nav";
import { computed } from "@vue/reactivity";
const route = useRoute();
const nav = useNavStore();
const subPaths = ref<subPath[]>([]);
function useSubRoutes() {
watch(
() => route.name,
(newRoute: string) => {
switch (newRoute) {
case Routes.folder:
let oldpath = "";
[oldpath, subPaths.value] = createSubPaths(
route.params.path,
oldpath
);
watch(
() => route.params.path,
(newPath) => {
if (newPath == undefined) return;
[oldpath, subPaths.value] = createSubPaths(newPath, oldpath);
}
);
break;
default:
break;
}
}
const showAPTitle = computed(() => {
return (
(route.name == Routes.album || route.name == Routes.playlist) &&
!nav.h_visible
);
}
onMounted(() => {
useSubRoutes();
});
watch(
() => route.name,
(newRoute: string) => {
switch (newRoute) {
case Routes.folder:
let oldpath = "";
[oldpath, subPaths.value] = createSubPaths(
route.params.path as string,
oldpath
);
watch(
() => route.params.path,
(newPath) => {
newPath = newPath as string;
if (newPath == undefined) return;
[oldpath, subPaths.value] = createSubPaths(newPath, oldpath);
}
);
break;
default:
break;
}
}
);
</script>
<!-- !!use nav store to sync the title component!! -->
<style lang="scss">
.topnav {
display: grid;
+57
View File
@@ -0,0 +1,57 @@
<template>
<div class="title albumnavtitle" v-motion-slide-from-left-100>
<PlayBtn :source="things.source" :store="things.store" />
<div class="ellip">
{{ things.text }}
</div>
</div>
</template>
<script setup lang="ts">
import useAlbumStore from "@/stores/album";
import usePStore from "@/stores/p.ptracks";
import PlayBtn from "@/components/shared/PlayBtn.vue";
import { playSources, Routes } from "@/composables/enums";
import { computed } from "@vue/reactivity";
import { useRoute } from "vue-router";
const things = computed(() => {
const route = useRoute();
let thing = {
text: "",
store: null,
source: playSources.album,
};
if (route.name == Routes.album) {
thing = {
source: playSources.album,
text: useAlbumStore().info.title,
store: useAlbumStore,
};
} else if (route.name == Routes.playlist) {
thing = {
source: playSources.playlist,
text: usePStore().info.name,
store: usePStore,
};
}
return thing;
});
</script>
<style lang="scss">
.albumnavtitle {
padding-left: 3rem;
.play-btn {
position: absolute;
left: $smaller;
top: -$smaller;
height: 2.25rem;
aspect-ratio: 1;
}
}
</style>
-29
View File
@@ -1,29 +0,0 @@
<template>
<div class="title albumnavtitle" v-motion-slide-from-left-100>
<PlayBtn :source="playSources.album" :store="useAlbumStore" />
<div class="ellip">
{{ store.info.title }}
</div>
</div>
</template>
<script setup lang="ts">
import useAlbumStore from "@/stores/album";
import PlayBtn from "@/components/shared/PlayBtn.vue";
import { playSources } from "@/composables/enums";
const store = useAlbumStore();
</script>
<style lang="scss">
.albumnavtitle {
padding-left: 3rem;
.play-btn {
position: absolute;
left: $smaller;
top: -$smaller;
height: 2.25rem;
aspect-ratio: 1;
}
}
</style>
+1 -1
View File
@@ -7,7 +7,7 @@
</div>
</template>
<script setup>
<script setup lang="ts">
import useLoaderStore from "../../stores/loader";
const loader = useLoaderStore();
</script>