koel/resources/assets/js/components/song/SongLikeButton.vue
2024-07-06 17:44:57 +02:00

21 lines
802 B
Vue

<template>
<FooterExtraControlBtn :title="title" @click.stop="toggleLike">
<Icon v-if="song.liked" :icon="faHeart" />
<Icon v-else :icon="faEmptyHeart" />
</FooterExtraControlBtn>
</template>
<script lang="ts" setup>
import { faHeart } from '@fortawesome/free-solid-svg-icons'
import { faHeart as faEmptyHeart } from '@fortawesome/free-regular-svg-icons'
import { computed, toRefs } from 'vue'
import { favoriteStore } from '@/stores'
import FooterExtraControlBtn from '@/components/layout/app-footer/FooterButton.vue'
const props = defineProps<{ song: Song }>()
const { song } = toRefs(props)
const title = computed(() => `${song.value.liked ? 'Unlike' : 'Like'} ${song.value.title} by ${song.value.artist_name}`)
const toggleLike = () => favoriteStore.toggleOne(song.value)
</script>