mirror of
https://github.com/koel/koel
synced 2024-12-25 20:13:06 +00:00
20 lines
783 B
Vue
20 lines
783 B
Vue
<template>
|
|
<button :title="title" data-testid="like-btn" type="button" @click.stop="toggleLike">
|
|
<icon v-if="song.liked" :icon="faHeart" data-testid="btn-like-liked"/>
|
|
<icon v-else :icon="faEmptyHeart" data-testid="btn-like-unliked"/>
|
|
</button>
|
|
</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'
|
|
|
|
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>
|