2022-11-29 05:46:04 +09:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { Tag } from 'masto'
|
|
|
|
|
|
|
|
const { tag } = defineProps<{
|
|
|
|
tag: Tag
|
|
|
|
}>()
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(event: 'change'): void
|
|
|
|
}>()
|
|
|
|
|
|
|
|
const { tags } = useMasto()
|
|
|
|
|
|
|
|
const toggleFollowTag = async () => {
|
|
|
|
if (tag.following)
|
|
|
|
await tags.unfollow(tag.name)
|
|
|
|
else
|
|
|
|
await tags.follow(tag.name)
|
|
|
|
|
|
|
|
emit('change')
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<button
|
|
|
|
rounded group focus:outline-none
|
|
|
|
hover:text-primary focus-visible:text-primary
|
2023-01-03 09:16:33 +09:00
|
|
|
:aria-label="tag.following ? $t('tag.unfollow_label', [tag.name]) : $t('tag.follow_label', [tag.name])"
|
2022-11-29 05:46:04 +09:00
|
|
|
@click="toggleFollowTag()"
|
|
|
|
>
|
2023-01-03 09:16:33 +09:00
|
|
|
<CommonTooltip placement="bottom" :content="tag.following ? $t('tag.unfollow') : $t('tag.follow')">
|
2022-11-29 05:46:04 +09:00
|
|
|
<div rounded-full p2 group-hover="bg-orange/10" group-focus-visible="bg-orange/10" group-focus-visible:ring="2 current">
|
|
|
|
<div :class="[tag.following ? 'i-ri:star-fill' : 'i-ri:star-line']" />
|
|
|
|
</div>
|
|
|
|
</CommonTooltip>
|
|
|
|
</button>
|
|
|
|
</template>
|