elk/components/status/StatusActions.vue

109 lines
2.8 KiB
Vue
Raw Normal View History

2022-11-13 08:34:43 +03:00
<script setup lang="ts">
2023-01-08 09:21:09 +03:00
import type { mastodon } from 'masto'
2022-11-13 08:34:43 +03:00
2022-12-01 09:46:26 +03:00
const props = defineProps<{
2023-01-08 09:21:09 +03:00
status: mastodon.v1.Status
details?: boolean
command?: boolean
2022-11-13 08:34:43 +03:00
}>()
2022-11-15 15:08:49 +03:00
const focusEditor = inject<typeof noop>('focus-editor', noop)
2022-12-01 09:46:26 +03:00
const { details, command } = $(props)
2022-11-24 11:34:05 +03:00
2022-12-01 09:46:26 +03:00
const {
status,
isLoading,
canReblog,
2022-12-01 09:46:26 +03:00
toggleBookmark,
toggleFavourite,
toggleReblog,
} = $(useStatusActions(props))
2022-11-24 14:35:26 +03:00
const reply = () => {
2022-12-02 05:18:57 +03:00
if (!checkLogin())
return
if (details)
focusEditor()
else
navigateToStatus({ status, focusReply: true })
2022-11-24 14:35:26 +03:00
}
2022-11-13 08:34:43 +03:00
</script>
<template>
<div flex justify-between>
2022-11-27 18:11:34 +03:00
<div flex-1>
2022-11-26 02:46:25 +03:00
<StatusActionButton
2022-11-30 02:25:29 +03:00
:content="$t('action.reply')"
2022-12-13 23:01:04 +03:00
:text="status.repliesCount || ''"
2022-11-26 02:46:25 +03:00
color="text-blue" hover="text-blue" group-hover="bg-blue/10"
2023-01-08 12:03:23 +03:00
icon="i-ri:chat-1-line"
:command="command"
@click="reply"
>
<template v-if="status.repliesCount" #text>
<CommonLocalizedNumber
keypath="action.reply_count"
:count="status.repliesCount"
/>
</template>
</StatusActionButton>
2022-11-27 18:11:34 +03:00
</div>
2022-11-24 11:34:05 +03:00
2022-11-27 18:11:34 +03:00
<div flex-1>
2022-11-24 11:34:05 +03:00
<StatusActionButton
2022-11-30 02:25:29 +03:00
:content="$t('action.boost')"
2022-12-13 23:01:04 +03:00
:text="status.reblogsCount || ''"
2022-11-24 11:34:05 +03:00
color="text-green" hover="text-green" group-hover="bg-green/10"
icon="i-ri:repeat-line"
active-icon="i-ri:repeat-fill"
2023-01-05 19:48:20 +03:00
:active="!!status.reblogged"
:disabled="isLoading.reblogged || !canReblog"
:command="command"
2022-11-24 11:34:05 +03:00
@click="toggleReblog()"
>
<template v-if="status.reblogsCount" #text>
<CommonLocalizedNumber
keypath="action.boost_count"
:count="status.reblogsCount"
/>
</template>
</StatusActionButton>
2022-11-27 18:11:34 +03:00
</div>
2022-11-24 11:34:05 +03:00
2022-11-27 18:11:34 +03:00
<div flex-1>
2022-11-24 11:34:05 +03:00
<StatusActionButton
2022-11-30 02:25:29 +03:00
:content="$t('action.favourite')"
2022-12-13 23:01:04 +03:00
:text="status.favouritesCount || ''"
2022-11-24 11:34:05 +03:00
color="text-rose" hover="text-rose" group-hover="bg-rose/10"
icon="i-ri:heart-3-line"
active-icon="i-ri:heart-3-fill"
2023-01-05 19:48:20 +03:00
:active="!!status.favourited"
2022-11-24 11:34:05 +03:00
:disabled="isLoading.favourited"
:command="command"
2022-11-24 11:34:05 +03:00
@click="toggleFavourite()"
>
<template v-if="status.favouritesCount" #text>
<CommonLocalizedNumber
keypath="action.favourite_count"
:count="status.favouritesCount"
/>
</template>
</StatusActionButton>
2022-11-27 18:11:34 +03:00
</div>
2022-11-24 11:34:05 +03:00
2022-11-27 18:11:34 +03:00
<div flex-none>
2022-11-24 08:04:20 +03:00
<StatusActionButton
2022-11-30 02:25:29 +03:00
:content="$t('action.bookmark')"
2022-11-24 11:34:05 +03:00
color="text-yellow" hover="text-yellow" group-hover="bg-yellow/10"
icon="i-ri:bookmark-line"
active-icon="i-ri:bookmark-fill"
2023-01-05 19:48:20 +03:00
:active="!!status.bookmarked"
2022-11-24 11:34:05 +03:00
:disabled="isLoading.bookmarked"
:command="command"
2022-11-24 11:34:05 +03:00
@click="toggleBookmark()"
2022-11-24 08:04:20 +03:00
/>
2022-11-27 18:11:34 +03:00
</div>
2022-11-13 08:34:43 +03:00
</div>
</template>