pleroma-fe/src/components/status_action_buttons/action_button.vue

107 lines
3 KiB
Vue
Raw Normal View History

2025-01-12 18:49:44 +02:00
<template>
<div
class="action-button"
:class="buttonClass"
>
2025-01-12 18:49:44 +02:00
<component
:is="getComponent(button)"
class="action-button-inner"
:class="buttonInnerClass"
2025-01-12 18:49:44 +02:00
role="menuitem"
2025-01-18 19:31:20 +02:00
type="button"
target="_blank"
2025-01-12 18:49:44 +02:00
:tabindex="0"
2025-01-13 22:32:39 +02:00
:disabled="buttonClass.disabled"
2025-01-21 10:45:11 +02:00
:href="getComponent(button) == 'a' ? button.link?.(funcArg) || remoteInteractionLink : undefined"
2025-01-18 19:31:20 +02:00
@click="doActionWrap(button, close)"
2025-01-12 18:49:44 +02:00
>
<FALayers>
<FAIcon
class="fa-scale-110"
:icon="button.icon(funcArg)"
2025-01-21 10:45:11 +02:00
:spin="!extra && getComponent(button) == 'button' && button.animated?.() && animationState"
2025-01-21 10:38:53 +02:00
:style="{ '--fa-animation-duration': '750ms' }"
2025-01-13 22:32:39 +02:00
fixed-width
2025-01-12 18:49:44 +02:00
/>
2025-01-13 22:32:39 +02:00
<template v-if="!buttonClass.disabled && button.toggleable?.(funcArg) && button.active">
2025-01-12 18:49:44 +02:00
<FAIcon
v-if="button.active(funcArg)"
class="active-marker"
2025-01-13 22:32:39 +02:00
transform="shrink-6 up-9 right-15"
2025-01-12 18:49:44 +02:00
:icon="button.activeIndicator?.(funcArg) || 'check'"
/>
<FAIcon
v-if="!button.active(funcArg)"
class="focus-marker"
2025-01-13 22:32:39 +02:00
transform="shrink-6 up-9 right-15"
2025-01-12 18:49:44 +02:00
:icon="button.openIndicator?.(funcArg) || 'plus'"
/>
<FAIcon
v-else
class="focus-marker"
2025-01-13 22:32:39 +02:00
transform="shrink-6 up-9 right-15"
2025-01-12 18:49:44 +02:00
:icon="button.closeIndicator?.(funcArg) || 'minus'"
/>
</template>
</FALayers>
<span
v-if="extra"
class="action-label"
>
{{ $t(button.label(funcArg)) }}
</span>
2025-01-12 18:49:44 +02:00
<FAIcon
v-if="button.dropdown?.()"
2025-01-12 18:49:44 +02:00
class="chevron-icon"
size="lg"
:icon="extra ? 'chevron-right' : 'chevron-up'"
2025-01-12 22:32:30 +02:00
fixed-width
2025-01-12 18:49:44 +02:00
/>
</component>
2025-01-26 22:51:11 +02:00
<span
v-if="!extra && button.counter?.(funcArg) > 0"
class="action-counter"
>
{{ button.counter?.(funcArg) }}
</span>
<span
v-if="!extra && button.name === 'bookmark'"
class="separator"
2025-01-20 16:22:41 +02:00
/>
<Popover
2025-01-20 16:22:41 +02:00
v-if="button.name === 'bookmark'"
2025-01-26 22:51:11 +02:00
:trigger="extra ? 'hover' : 'click'"
:placement="extra ? 'right' : 'top'"
2025-01-26 22:51:11 +02:00
:offset="extra ? { x: 10 } : { y: 10 }"
:trigger-attrs="{ class: 'extra-button' }"
>
<template #trigger>
<FAIcon
class="chevron-icon"
size="lg"
:icon="extra ? 'chevron-right' : 'chevron-up'"
fixed-width
/>
</template>
<template #content>
2025-01-20 16:22:41 +02:00
<StatusBookmarkFolderMenu
v-if="button.name === 'bookmark'"
:status="status"
/>
</template>
</Popover>
2025-01-14 22:02:30 +02:00
<EmojiPicker
v-if="button.name === 'emoji'"
2025-01-20 16:22:41 +02:00
ref="picker"
2025-01-14 22:02:30 +02:00
:enable-sticker-picker="false"
:hide-custom-emoji="hideCustomEmoji"
class="emoji-picker-panel"
@emoji="addReaction"
/>
2025-01-12 18:49:44 +02:00
</div>
</template>
2025-01-20 16:22:41 +02:00
<script src="./action_button.js" />
2025-01-13 22:32:39 +02:00
2025-01-20 16:22:41 +02:00
<style lang="scss" src="./action_button.scss" />