mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 13:03:02 +00:00
add favorite button to TrackItem component
+ show playing folder name in queue page + add no_emit prop to heartSvg component
This commit is contained in:
committed by
Mungai Njoroge
parent
d56db5e6c1
commit
f8f3f7317e
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ellip2 {
|
.ellip2 {
|
||||||
word-wrap: break-word;
|
word-wrap: anywhere;
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-line-clamp: 2;
|
-webkit-line-clamp: 2;
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
load_disabled: !can_load_more,
|
load_disabled: !can_load_more,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div class="text">Load More {{ can_load_more }}</div>
|
<div class="text">Load More</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ function getSource() {
|
|||||||
name: "Favorite tracks",
|
name: "Favorite tracks",
|
||||||
icon: HeartSvg,
|
icon: HeartSvg,
|
||||||
location: {
|
location: {
|
||||||
name: Routes.favorites,
|
name: Routes.favoriteTracks,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
class="heart-button circular"
|
class="heart-button circular"
|
||||||
@click="emit('handleFav')"
|
@click="!no_emit && emit('handleFav')"
|
||||||
:class="{
|
:class="{
|
||||||
is_fav: state,
|
is_fav: state,
|
||||||
}"
|
}"
|
||||||
@@ -17,6 +17,7 @@ import HeartFillSvg from "@/assets/icons/heart.fill.svg";
|
|||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
state: boolean | undefined;
|
state: boolean | undefined;
|
||||||
|
no_emit?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
<!-- Track component used in app body -->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="songlist-item rounded-sm"
|
class="songlist-item rounded-sm"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- Track component used in the right sidebar -->
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="track-item"
|
class="track-item"
|
||||||
@@ -31,20 +32,26 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="float-buttons flex" v-if="isQueueTrack">
|
||||||
<div
|
<div
|
||||||
class="remove-track flex"
|
:title="is_fav ? 'Add to favorites' : 'Remove from favorites'"
|
||||||
@click.stop="queue.removeFromQueue(index)"
|
@click.stop="() => addToFav(track.trackhash)"
|
||||||
v-if="isQueueTrack"
|
|
||||||
>
|
>
|
||||||
<div title="remove from queue" >
|
<HeartSvg :state="is_fav" :no_emit="true" />
|
||||||
<DelSvg/>
|
</div>
|
||||||
|
<div
|
||||||
|
class="remove-track"
|
||||||
|
title="remove from queue"
|
||||||
|
@click.stop="queue.removeFromQueue(index)"
|
||||||
|
>
|
||||||
|
<DelSvg />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref, watch } from "vue";
|
||||||
|
|
||||||
import DelSvg from "@/assets/icons/plus.svg";
|
import DelSvg from "@/assets/icons/plus.svg";
|
||||||
import { showTrackContextMenu as showContext } from "@/composables/context";
|
import { showTrackContextMenu as showContext } from "@/composables/context";
|
||||||
@@ -52,6 +59,9 @@ import { paths } from "@/config";
|
|||||||
import { Track } from "@/interfaces";
|
import { Track } from "@/interfaces";
|
||||||
import useQueueStore from "@/stores/queue";
|
import useQueueStore from "@/stores/queue";
|
||||||
import ArtistName from "./ArtistName.vue";
|
import ArtistName from "./ArtistName.vue";
|
||||||
|
import HeartSvg from "./HeartSvg.vue";
|
||||||
|
import favoriteHandler from "@/composables/favoriteHandler";
|
||||||
|
import { favType } from "@/composables/enums";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
track: Track;
|
track: Track;
|
||||||
@@ -63,6 +73,7 @@ const props = defineProps<{
|
|||||||
|
|
||||||
const queue = useQueueStore();
|
const queue = useQueueStore();
|
||||||
const context_on = ref(false);
|
const context_on = ref(false);
|
||||||
|
const is_fav = ref(props.track.is_favorite);
|
||||||
|
|
||||||
function showMenu(e: MouseEvent) {
|
function showMenu(e: MouseEvent) {
|
||||||
showContext(e, props.track, context_on);
|
showContext(e, props.track, context_on);
|
||||||
@@ -75,6 +86,23 @@ const emit = defineEmits<{
|
|||||||
const playThis = (track: Track) => {
|
const playThis = (track: Track) => {
|
||||||
emit("playThis");
|
emit("playThis");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function addToFav(trackhash: string) {
|
||||||
|
favoriteHandler(
|
||||||
|
is_fav.value,
|
||||||
|
favType.track,
|
||||||
|
trackhash,
|
||||||
|
() => (is_fav.value = true),
|
||||||
|
() => (is_fav.value = false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.track.is_favorite,
|
||||||
|
(newValue) => {
|
||||||
|
is_fav.value = newValue;
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@@ -99,10 +127,22 @@ const playThis = (track: Track) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.remove-track {
|
.float-buttons {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|
||||||
|
.heart-button {
|
||||||
|
width: 2rem;
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
transition: all 0.25s ease;
|
transition: all 0.25s ease;
|
||||||
transform: scale(0.75) translateY(1rem) rotate(45deg);
|
transform: scale(1) translateY(-1rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.remove-track {
|
||||||
|
margin-top: $smaller;
|
||||||
|
transition: all 0.25s ease;
|
||||||
|
transform: scale(1) translateY(1rem) rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
opacity: 1 !important;
|
opacity: 1 !important;
|
||||||
@@ -110,8 +150,15 @@ const playThis = (track: Track) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
.float-buttons {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heart-button {
|
||||||
|
transform: scale(1) translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
.remove-track {
|
.remove-track {
|
||||||
opacity: 0.5;
|
|
||||||
transform: scale(1) translateY(0) rotate(45deg);
|
transform: scale(1) translateY(0) rotate(45deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -158,7 +158,7 @@ export default defineStore("Queue", {
|
|||||||
this.from = <fromFolder>{
|
this.from = <fromFolder>{
|
||||||
type: FromOptions.folder,
|
type: FromOptions.folder,
|
||||||
path: fpath,
|
path: fpath,
|
||||||
name: "Folder",
|
name: "Folder: " + fpath.split("/").pop(),
|
||||||
};
|
};
|
||||||
this.setNewQueue(tracks);
|
this.setNewQueue(tracks);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user