1
0
mirror of https://github.com/elk-zone/elk synced 2024-12-29 22:17:59 +09:00
elk/components/account/AccountFollowButton.vue
2022-11-24 23:48:58 +08:00

38 lines
1.3 KiB
Vue

<script setup lang="ts">
import type { Account } from 'masto'
const { account } = defineProps<{
account: Account
}>()
const isSelf = $computed(() => currentUser.value?.account.id === account.id)
const relationship = $(useRelationship(account))
async function toggleFollow() {
relationship!.following = !relationship!.following
await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
}
</script>
<template>
<button
v-if="!isSelf && relationship"
flex gap-1 items-center h-fit rounded hover="op100 text-white b-orange" group
@click="toggleFollow"
>
<div rounded w-28 p2 :group-hover="relationship?.following ? 'bg-red/75' : 'bg-orange/40'" :class="!relationship?.following ? relationship?.followedBy ? 'bg-orange/20' : 'bg-white/10' : relationship?.followedBy ? ' bg-orange/70' : 'bg-orange/50'">
<template v-if="relationship?.following">
<span group-hover="hidden">{{ relationship?.followedBy ? 'Mutual' : 'Following' }}</span>
<span hidden group-hover="inline">Unfollow</span>
</template>
<template v-else-if="relationship?.followedBy">
<span group-hover="hidden">Follows you</span>
<span hidden group-hover="inline">Follow back</span>
</template>
<template v-else>
<span>Follow</span>
</template>
</div>
</button>
</template>