2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-11-29 10:18:58 +00:00
|
|
|
<button :title="title" type="button" @click.stop="toggleLike">
|
|
|
|
<icon v-if="song.liked" :icon="faHeart"/>
|
|
|
|
<icon v-else :icon="faEmptyHeart"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-15 07:23:55 +00:00
|
|
|
import { faHeart } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import { faHeart as faEmptyHeart } from '@fortawesome/free-regular-svg-icons'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { computed, toRefs } from 'vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { favoriteStore } from '@/stores'
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const props = defineProps<{ song: Song }>()
|
|
|
|
const { song } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const title = computed(() => `${song.value.liked ? 'Unlike' : 'Like'} ${song.value.title} by ${song.value.artist_name}`)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const toggleLike = () => favoriteStore.toggleOne(song.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|