koel/resources/assets/js/components/song/SongLikeButton.vue

23 lines
753 B
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
2024-04-04 22:20:42 +00:00
<FooterExtraControlBtn :title="title" @click.stop="toggleLike">
2023-11-10 13:16:06 +00:00
<Icon v-if="song.liked" :icon="faHeart" />
<Icon v-else :icon="faEmptyHeart" />
2024-04-04 22:20:42 +00:00
</FooterExtraControlBtn>
2022-04-15 14:24:30 +00:00
</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'
2024-05-19 05:49:42 +00:00
2024-04-04 22:20:42 +00:00
import FooterExtraControlBtn from '@/components/layout/app-footer/FooterButton.vue'
2022-04-15 14:24:30 +00:00
2024-05-19 05:49:42 +00:00
const props = defineProps<{ song: Playable }>()
2022-04-15 17:00:08 +00:00
const { song } = toRefs(props)
2022-04-15 14:24:30 +00:00
2024-05-19 05:49:42 +00:00
const title = computed(() => song.value.liked ? 'Unlike' : 'Like')
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>