highlight current folder in pathlist in nav

This commit is contained in:
geoffrey45
2022-06-09 09:30:43 +03:00
parent 14364a1257
commit 6aad05084f
8 changed files with 77 additions and 60 deletions
+8 -1
View File
@@ -6,6 +6,7 @@
</div> </div>
<div class="info"> <div class="info">
<Album v-show="$route.name == Routes.album" />
<Playlists v-show="$route.name == Routes.playlists" /> <Playlists v-show="$route.name == Routes.playlists" />
<Folder v-show="$route.name == Routes.folder" :subPaths="subPaths" /> <Folder v-show="$route.name == Routes.folder" :subPaths="subPaths" />
</div> </div>
@@ -32,6 +33,7 @@ import createSubPaths from "@/composables/createSubPaths";
import { subPath } from "@/interfaces"; import { subPath } from "@/interfaces";
import Folder from "./Titles/Folder.vue"; import Folder from "./Titles/Folder.vue";
import Playlists from "./Titles/Playlists.vue"; import Playlists from "./Titles/Playlists.vue";
import Album from "./Titles/Album.vue";
const route = useRoute(); const route = useRoute();
@@ -44,7 +46,10 @@ function useSubRoutes() {
switch (newRoute) { switch (newRoute) {
case Routes.folder: case Routes.folder:
let oldpath = ""; let oldpath = "";
[oldpath, subPaths.value] = createSubPaths(route.params.path, oldpath); [oldpath, subPaths.value] = createSubPaths(
route.params.path,
oldpath
);
watch( watch(
() => route.params.path, () => route.params.path,
@@ -87,6 +92,8 @@ onMounted(() => {
.title { .title {
font-size: 1.5rem; font-size: 1.5rem;
font-weight: bold; font-weight: bold;
margin-top: $smaller;
display: flex;
} }
} }
} }
+29
View File
@@ -0,0 +1,29 @@
<template>
<div class="title albumnavtitle" v-motion-slide-from-left-100>
<PlayBtn />
<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";
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>
+19 -18
View File
@@ -1,20 +1,6 @@
<template> <template>
<div id="folder-nav-title"> <div id="folder-nav-title">
<div <div class="folder" v-motion-slide-from-left-100>
class="folder"
v-motion
:initial="{
opacity: 0,
x: -20,
}"
:visible="{
opacity: 1,
x: 0,
transition: {
delay: 100,
},
}"
>
<div class="fname"> <div class="fname">
<div class="icon image"></div> <div class="icon image"></div>
<div class="paths"> <div class="paths">
@@ -22,7 +8,11 @@
class="path" class="path"
v-for="path in subPaths" v-for="path in subPaths"
:key="path.path" :key="path.path"
:class="{ current: path.active }" :class="{ inthisfolder: path.active }"
v-motion-slide-from-left-100
@click="
$router.push({ name: 'FolderView', params: { path: path.path } })
"
> >
<span class="text">{{ path.name }}</span> <span class="text">{{ path.name }}</span>
</div> </div>
@@ -33,11 +23,17 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { focusElem } from "@/composables/perks";
import { subPath } from "@/interfaces"; import { subPath } from "@/interfaces";
import { onUpdated } from "vue";
defineProps<{ defineProps<{
subPaths: subPath[]; subPaths: subPath[];
}>(); }>();
onUpdated(() => {
focusElem("inthisfolder");
});
</script> </script>
<style lang="scss"> <style lang="scss">
@@ -68,6 +64,7 @@ defineProps<{
margin-left: $smaller; margin-left: $smaller;
overflow: auto; overflow: auto;
padding-right: $smaller; padding-right: $smaller;
color: rgba(255, 255, 255, 0.678);
.icon { .icon {
height: 2rem; height: 2rem;
@@ -125,8 +122,12 @@ defineProps<{
} }
} }
.current > .text { .inthisfolder > .text {
background-color: $accent; color: #fff;
font-weight: bold;
background-color: $gray;
transition: all 0.5s;
} }
} }
} }
+1 -13
View File
@@ -1,19 +1,7 @@
<template> <template>
<div <div
class="title" class="title"
v-show="$route.name == 'Playlists'" v-motion-slide-from-left-100
v-motion
:initial="{
opacity: 0,
x: -20,
}"
:visible="{
opacity: 1,
x: 0,
transition: {
delay: 100,
},
}"
> >
Playlists Playlists
</div> </div>
+3 -3
View File
@@ -9,17 +9,17 @@ function playThis(e: Event) {
</script> </script>
<style lang="scss"> <style lang="scss">
.play-btn { .play-btn {
width: 2.5rem; height: 2.25rem;
height: 2.5rem;
background-color: $gray3; background-color: $gray3;
background-image: url("../../assets/icons/play.svg"); background-image: url("../../assets/icons/play.svg");
background-size: 1.75rem; background-size: 1.75rem;
background-repeat: no-repeat;
background-position: 50% 50%; background-position: 50% 50%;
transition: all 0.25s ease-in-out; transition: all 0.25s ease-in-out;
aspect-ratio: 1;
&:hover { &:hover {
background-color: $accent; background-color: $accent;
transform: scale(1.1);
} }
} }
</style> </style>
+13 -10
View File
@@ -12,16 +12,19 @@ const putCommas = (artists: string[]) => {
return result; return result;
}; };
function focusCurrent() { function focusElem(className: string, delay?: number) {
const elem = document.getElementsByClassName("currentInQueue")[0]; const dom = document.getElementsByClassName(className)[0];
if (!delay) delay = 300;
if (elem) { setTimeout(() => {
elem.scrollIntoView({ if (dom) {
behavior: "smooth", dom.scrollIntoView({
block: "center", behavior: "smooth",
inline: "center", block: "center",
}); inline: "center",
} });
}
}, delay);
} }
function getElem(id: string, type: string) { function getElem(id: string, type: string) {
@@ -75,4 +78,4 @@ function formatSeconds(seconds: number, long?: boolean) {
} }
} }
export { putCommas, focusCurrent, formatSeconds, getElem }; export { putCommas, focusElem, formatSeconds, getElem };
+2 -2
View File
@@ -1,5 +1,5 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { focusCurrent } from "../composables/perks"; import { focusElem } from "../composables/perks";
const tablist = { const tablist = {
home: "home", home: "home",
@@ -16,7 +16,7 @@ export default defineStore("tabs", {
changeTab(tab: string) { changeTab(tab: string) {
if (tab === this.tabs.queue) { if (tab === this.tabs.queue) {
setTimeout(() => { setTimeout(() => {
focusCurrent(); focusElem("currentInQueue");
}, 500); }, 500);
} }
this.current = tab; this.current = tab;
+2 -13
View File
@@ -4,7 +4,7 @@ export default {
initial: { initial: {
opacity: 0, opacity: 0,
x: 0, x: 0,
y: 20 y: 20,
}, },
enter: { enter: {
opacity: 1, opacity: 1,
@@ -21,7 +21,7 @@ export default {
opacity: 0, opacity: 0,
x: -20, x: -20,
}, },
enter: { visible: {
opacity: 1, opacity: 1,
x: 0, x: 0,
transition: { transition: {
@@ -55,16 +55,5 @@ export default {
}, },
}, },
}, },
scale: {
initial: {
scale: 0.8,
},
enter: {
scale: 1,
transition: {
duration: 200,
},
},
},
}, },
}; };