pleroma-fe/src/components/emoji_reactions/emoji_reactions.vue

200 lines
4.5 KiB
Vue
Raw Normal View History

2020-01-14 09:06:14 +01:00
<template>
<div class="EmojiReactions">
2023-05-23 04:02:22 +02:00
<span
v-for="(reaction) in emojiReactions"
2022-12-18 20:04:58 +01:00
:key="reaction.url || reaction.name"
2023-05-23 04:02:22 +02:00
class="emoji-reaction-container btn-group"
2020-01-14 09:06:14 +01:00
>
<component
:is="loggedIn ? 'button' : 'a'"
v-bind="!loggedIn ? { href: remoteInteractionLink } : {}"
role="button"
class="emoji-reaction btn button-default"
:class="{ '-picked-reaction': reactedWith(reaction.name) }"
2023-05-23 04:18:42 +02:00
:title="reaction.url ? reaction.name : undefined"
:aria-pressed="reactedWith(reaction.name)"
@click="emojiOnClick(reaction.name, $event)"
>
2022-12-18 20:04:58 +01:00
<span
class="reaction-emoji"
>
<img
v-if="reaction.url"
2022-12-18 20:04:58 +01:00
:src="reaction.url"
class="reaction-emoji-content"
width="1em"
>
<span
v-else
class="reaction-emoji reaction-emoji-content"
>{{ reaction.name }}</span>
2022-12-18 20:04:58 +01:00
</span>
2023-05-23 04:02:22 +02:00
<FALayers>
2023-05-23 04:20:09 +02:00
<FAIcon
v-if="reactedWith(reaction.name)"
class="active-marker"
transform="shrink-6 up-9"
icon="check"
/>
<FAIcon
v-if="!reactedWith(reaction.name)"
class="focus-marker"
transform="shrink-6 up-9"
icon="plus"
/>
<FAIcon
v-else
class="focus-marker"
transform="shrink-6 up-9"
icon="minus"
/>
2023-05-23 04:02:22 +02:00
</FALayers>
</component>
2023-05-23 04:20:09 +02:00
<UserListPopover
:users="accountsForEmoji[reaction.name]"
class="emoji-reaction-popover"
2023-05-23 04:30:54 +02:00
:trigger-attrs="counterTriggerAttrs(reaction)"
2023-05-23 04:20:09 +02:00
@show="fetchEmojiReactionsByIfMissing()"
>
<span class="emoji-reaction-counts">{{ reaction.count }}</span>
</UserListPopover>
2023-05-23 04:02:22 +02:00
</span>
<a
2020-02-28 17:39:47 +01:00
v-if="tooManyReactions"
class="emoji-reaction-expand faint"
href="javascript:void(0)"
@click="toggleShowAll"
>
{{ showAll ? $t('general.show_less') : showMoreString }}
</a>
2020-01-14 09:06:14 +01:00
</div>
</template>
2022-07-31 11:35:48 +02:00
<script src="./emoji_reactions.js"></script>
2020-01-14 09:06:14 +01:00
<style lang="scss">
2023-05-23 04:02:22 +02:00
@import "../../mixins";
2020-01-14 09:06:14 +01:00
.EmojiReactions {
2020-01-14 09:06:14 +01:00
display: flex;
margin-top: 0.25em;
flex-wrap: wrap;
--emoji-size: calc(1.25em * var(--emojiReactionsScale, 1));
2023-05-23 04:02:22 +02:00
.emoji-reaction-container {
display: flex;
align-items: stretch;
margin-top: 0.5em;
2023-05-23 04:02:22 +02:00
margin-right: 0.5em;
.emoji-reaction-popover {
padding: 0;
.emoji-reaction-count-button {
margin: 0;
2023-05-23 04:02:22 +02:00
height: 100%;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
box-sizing: border-box;
min-width: 2em;
display: inline-flex;
justify-content: center;
align-items: center;
&.-picked-reaction {
2024-03-04 18:45:42 +01:00
border: 1px solid var(--accent);
2023-05-23 04:02:22 +02:00
margin-right: -1px;
}
}
}
}
.emoji-reaction {
padding-left: 0.5em;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
margin: 0;
.reaction-emoji {
width: var(--emoji-size);
height: var(--emoji-size);
margin-right: 0.25em;
line-height: var(--emoji-size);
display: flex;
justify-content: center;
align-items: center;
}
2022-12-18 20:04:58 +01:00
.reaction-emoji-content {
max-width: 100%;
max-height: 100%;
2022-12-18 20:04:58 +01:00
width: auto;
height: auto;
line-height: inherit;
2022-12-18 20:04:58 +01:00
overflow: hidden;
font-size: calc(var(--emoji-size) * 0.8);
margin: 0;
2022-12-18 20:04:58 +01:00
}
&:focus {
outline: none;
}
2023-05-23 04:14:44 +02:00
.svg-inline--fa {
2024-03-04 18:45:42 +01:00
color: var(--text);
2023-05-23 04:14:44 +02:00
}
&.-picked-reaction {
2024-03-04 18:45:42 +01:00
border: 1px solid var(--accent);
margin-left: -1px; // offset the border, can't use inset shadows either
2023-05-23 04:02:22 +02:00
margin-right: -1px;
.svg-inline--fa {
2024-03-04 18:45:42 +01:00
color: var(--accent);
2023-05-23 04:02:22 +02:00
}
}
@include unfocused-style {
.focus-marker {
visibility: hidden;
}
.active-marker {
visibility: visible;
}
}
@include focused-style {
.svg-inline--fa {
2024-03-04 18:45:42 +01:00
color: var(--accent);
2023-05-23 04:02:22 +02:00
}
.focus-marker {
visibility: visible;
}
.active-marker {
visibility: hidden;
}
}
}
.emoji-reaction-expand {
padding: 0 0.5em;
margin-right: 0.5em;
margin-top: 0.5em;
display: flex;
align-items: center;
justify-content: center;
2023-01-09 19:02:16 +01:00
&:hover {
text-decoration: underline;
}
}
2020-02-17 21:28:14 +01:00
}
2020-01-14 09:06:14 +01:00
</style>