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
+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>