waffle/frontend/src/components/Message.svelte

59 lines
1.4 KiB
Svelte
Raw Normal View History

<script>
2022-04-26 23:15:49 +03:00
import { MoreVerticalIcon } from "svelte-feather-icons";
import { overlayStore, userInfoStore } from "../stores";
2022-04-26 23:15:49 +03:00
export let message;
</script>
<style>
.message {
display: flex;
align-items: flex-start;
overflow-x: none;
word-break: break-all;
padding: var(--space-xxs) var(--space-normplus) var(--space-xxs) var(--space-normplus);
}
2022-04-26 23:15:49 +03:00
.message .edit-message {
visibility: hidden;
}
.message:hover {
background-color: var(--background-color-2);
}
.message:hover .edit-message {
visibility: visible;
}
.message-content {
color: var(--foreground-color-2);
2022-05-07 16:50:04 +03:00
white-space: pre-wrap;
}
.pending {
color: var(--foreground-color-3);
}
.author {
flex-shrink: 0;
font-weight: bold;
margin-right: var(--space-xs);
}
2022-04-26 23:15:49 +03:00
.edit-message {
flex-shrink: 0;
2022-04-26 23:15:49 +03:00
float: right;
}
</style>
<div class="message">
<span class="author">{ message.author_username }</span>
<span class="message-content" class:pending={ message._isPending }>{ message.content }</span>
2022-05-05 15:33:22 +03:00
{#if userInfoStore.value && message.author_id === userInfoStore.value.id}
<button class="icon-button icon-button-auto edit-message" on:click="{ () => overlayStore.open('editMessage', { message }) }">
<MoreVerticalIcon />
</button>
{/if}
</div>