1
0
mirror of https://github.com/elk-zone/elk synced 2024-12-12 05:38:04 +09:00
elk/components/status/StatusActions.vue

117 lines
3.7 KiB
Vue
Raw Normal View History

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