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

127 lines
2.8 KiB
Vue
Raw Normal View History

2025-01-12 18:49:44 +02:00
<template>
<div>
<component
:is="getComponent(button)"
2025-01-13 22:32:39 +02:00
class="main-button action-button"
:class="buttonClass"
2025-01-12 18:49:44 +02:00
role="menuitem"
:tabindex="0"
2025-01-13 22:32:39 +02:00
:disabled="buttonClass.disabled"
2025-01-12 18:49:44 +02:00
:href="getComponent(button) == 'a' ? button.link?.(funcArg) || getRemoteInteractionLink : undefined"
@click.stop="getComponent(button) === 'button' && doAction(button)"
@click="close"
>
<FALayers>
<FAIcon
class="fa-scale-110"
:icon="button.icon(funcArg)"
:spin="!extra && button.animated?.() && animationState[button.name]"
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>{{ $t(button.label(funcArg)) }}</span>
<FAIcon
2025-01-12 22:20:02 +02:00
v-if="button.name === 'mute'"
2025-01-12 18:49:44 +02:00
class="chevron-icon"
size="lg"
icon="chevron-right"
2025-01-12 22:32:30 +02:00
fixed-width
2025-01-12 18:49:44 +02:00
/>
</component>
</div>
</template>
<script>
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faPlus,
faMinus,
faCheck,
faTimes,
faWrench,
faReply,
faRetweet,
faStar,
faSmileBeam,
faEllipsisH,
faBookmark,
faEyeSlash,
faThumbtack,
faShareAlt,
faExternalLinkAlt,
faHistory
} from '@fortawesome/free-solid-svg-icons'
import {
faStar as faStarRegular
} from '@fortawesome/free-regular-svg-icons'
library.add(
faPlus,
faMinus,
faCheck,
faTimes,
faWrench,
faReply,
faRetweet,
faStar,
faStarRegular,
faSmileBeam,
faEllipsisH,
faBookmark,
faEyeSlash,
faThumbtack,
faShareAlt,
faExternalLinkAlt,
faHistory
)
export default {
props: [
'button',
'extra',
'status',
'funcArg',
'animationState',
'getClass',
'getComponent',
'doAction',
'close'
2025-01-13 22:32:39 +02:00
],
computed: {
buttonClass () {
return {
[this.button.name + '-button']: true,
'-extra': this.extra,
'-quick': !this.extra,
'-active': this.button.active?.(this.funcArg),
disabled: this.button.interactive ? !this.button.interactive(this.funcArg) : false
}
}
}
2025-01-12 18:49:44 +02:00
}
</script>
2025-01-13 22:32:39 +02:00
<style lang="scss" src="./action_button.scss"/>