elk/components/account/AccountCard.vue

35 lines
881 B
Vue
Raw Normal View History

<script setup lang="ts">
import type { Account } from 'masto'
2022-11-21 23:59:51 +01:00
const { account, following } = defineProps<{
account: Account
2022-11-21 23:59:51 +01:00
following?: boolean
}>()
2022-11-21 23:59:51 +01:00
const masto = await useMasto()
let isFollowing = $ref<boolean | undefined>(following)
watch($$(following), () => {
isFollowing = following
})
function unfollow() {
masto.accounts.unfollow(account.id)
isFollowing = false
}
function follow() {
masto.accounts.follow(account.id)
isFollowing = true
}
</script>
<template>
<div flex justify-between>
<AccountInfo :account="account" p3 />
<div h-full p5>
2022-11-21 23:59:51 +01:00
<div v-if="isFollowing === true" color-purple hover:color-gray hover:cursor-pointer i-ri:user-unfollow-fill @click="unfollow" />
<div v-else-if="isFollowing === false" color-gray hover:color-purple hover:cursor-pointer i-ri:user-follow-fill @click="follow" />
</div>
</div>
</template>