implement track favoriting

update img route
This commit is contained in:
geoffrey45
2022-12-17 22:42:11 +03:00
committed by Mungai Njoroge
parent 35a8446f8b
commit c7cc687286
12 changed files with 141 additions and 31 deletions
+5 -2
View File
@@ -18,6 +18,7 @@ import ErrorSvg from "../assets/icons/toast/error.svg";
import InfoSvg from "../assets/icons/toast/info.svg";
import SuccessSvg from "../assets/icons/toast/ok.svg";
import WorkingSvg from "../assets/icons/toast/working.svg";
import HeartSvg from "../assets/icons/heart.svg";
const notifStore = useNotifStore();
@@ -31,6 +32,8 @@ function getSvg(notif: NotifType) {
return SuccessSvg;
case NotifType.Working:
return WorkingSvg;
case NotifType.Favorite:
return HeartSvg;
}
}
</script>
@@ -70,7 +73,7 @@ function getSvg(notif: NotifType) {
background-image: linear-gradient(275deg, $bg, $bg1 74%);
}
.new-notif.info {
.new-notif.info, .new-notif.favorite {
$bg: rgb(28, 102, 238);
$bg1: rgba(31, 144, 236, 0.15);
background-image: linear-gradient(275deg, $bg, $bg1 74%);
@@ -78,7 +81,7 @@ function getSvg(notif: NotifType) {
.new-notif.success {
$bg: rgb(5, 167, 53);
$bg1: rgba(5, 167, 54, .15);
$bg1: rgba(5, 167, 54, 0.15);
background-image: linear-gradient(275deg, $bg, $bg1 74%);
}
@@ -1,6 +1,6 @@
<template>
<div class="artist-discography-nav">
<h1 class="ellip">Creedence Clearwater Revival</h1>
<h1 class="ellip">{{ store.artistname }}</h1>
<div class="buttons">
<div class="select rounded-sm" v-auto-animate="{ duration: 10 }">
<button class="selected" @click.prevent="showDropDown = !showDropDown">
@@ -21,7 +21,6 @@
</div>
</div>
</div>
<button class="rounded-sm"><GridSvg /></button>
</div>
</div>
</template>
@@ -69,7 +68,6 @@ onClickOutside(dropOptionsRef, (e) => {
.buttons {
display: flex;
gap: $small;
}
.selected {
@@ -86,7 +84,7 @@ onClickOutside(dropOptionsRef, (e) => {
.select {
position: relative;
width: 7rem;
width: 8rem;
display: flex;
align-items: center;
font-size: calc($medium + 2px);
@@ -103,7 +101,7 @@ onClickOutside(dropOptionsRef, (e) => {
.option {
padding: $small;
border-bottom: 1px solid $gray4;
width: 6.5rem;
width: 7.5rem;
&:hover {
border-radius: $smaller;
+46 -13
View File
@@ -5,11 +5,18 @@
@dblclick.prevent="emitUpdate"
@contextmenu.prevent="showMenu"
>
<div class="index t-center ellip" @dblclick.prevent.stop="() => {}">
<span class="text">
<div
class="index t-center ellip"
@click.prevent="addToFav(track.trackhash)"
@dblclick.prevent.stop="() => {}"
>
<div class="text">
{{ index }}
</span>
<HeartSvg />
</div>
<div class="heart-icon">
<HeartFillSvg v-if="fav" />
<HeartSvg v-else />
</div>
</div>
<div class="flex">
<div @click.prevent="emitUpdate" class="thumbnail">
@@ -71,10 +78,13 @@ import { Track } from "@/interfaces";
import { formatSeconds } from "@/utils";
import HeartSvg from "@/assets/icons/heart.svg";
import HeartFillSvg from "@/assets/icons/heart.fill.svg";
import OptionSvg from "@/assets/icons/more.svg";
import ArtistName from "./ArtistName.vue";
import useQueueStore from "@/stores/queue";
import { addFavorite, removeFavorite } from "@/composables/fetch/favorite";
import { favType } from "@/composables/enums";
const imguri = paths.images.thumb.small;
const context_menu_showing = ref(false);
@@ -107,6 +117,26 @@ function isCurrent() {
function isCurrentPlaying() {
return isCurrent() && queue.playing;
}
const fav = ref(props.track.is_favorite);
async function addToFav(trackhash: string) {
if (fav.value) {
const removed = await removeFavorite(favType.track, trackhash);
if (removed) {
fav.value = false;
}
return;
}
const added = await addFavorite(favType.track, trackhash);
if (added) {
fav.value = true;
}
}
</script>
<style lang="scss">
@@ -137,7 +167,6 @@ function isCurrentPlaying() {
}
cursor: pointer;
// outline: solid 1px;
.title {
margin-bottom: 2px;
@@ -149,11 +178,15 @@ function isCurrentPlaying() {
.index {
.text {
transition-delay: 500ms;
transform: translateX($smaller);
opacity: 0;
}
svg {
.heart-icon {
transition-delay: 500ms;
transform: translateX(0);
opacity: 1;
}
@@ -189,17 +222,17 @@ function isCurrentPlaying() {
display: block;
margin: auto 0;
transition: all 0.25s;
transform: translateX(0);
width: 100%;
}
svg {
.heart-icon {
position: absolute;
left: 0;
left: -2px;
display: grid;
height: 100%;
align-content: center;
transition: all 0.2s;
top: $medium;
opacity: 0;
transform: translateX(-1rem);
cursor: pointer;
transform: translateX(-1.5rem);
}
}