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

23 lines
773 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">
<Icon v-if="playable.liked" :icon="faHeart" />
2023-11-10 13:16:06 +00:00
<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
const props = defineProps<{ playable: Playable }>()
const { playable } = toRefs(props)
2022-04-15 14:24:30 +00:00
const title = computed(() => playable.value.liked ? 'Unlike' : 'Like')
2022-04-15 14:24:30 +00:00
const toggleLike = () => favoriteStore.toggleOne(playable.value)
2022-04-15 14:24:30 +00:00
</script>