mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
56 lines
1.3 KiB
Svelte
56 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
import type { Comment } from "@httpd-client";
|
|
|
|
import IconButton from "./IconButton.svelte";
|
|
|
|
export let reactions: Comment["reactions"];
|
|
export let handleReaction:
|
|
| ((
|
|
authors: Comment["reactions"][0]["authors"],
|
|
reaction: string,
|
|
) => Promise<void>)
|
|
| undefined;
|
|
|
|
function authorsToTooltip(authors: Comment["reactions"][0]["authors"]) {
|
|
return authors.map(a => a.alias ?? a.id).join("\n");
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.reactions {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
}
|
|
.reaction {
|
|
display: inline-flex;
|
|
flex-direction: row;
|
|
gap: 0.5rem;
|
|
}
|
|
</style>
|
|
|
|
<div class="reactions">
|
|
{#each reactions as { emoji, authors }}
|
|
<div title={authorsToTooltip(authors)}>
|
|
{#if handleReaction}
|
|
<IconButton
|
|
on:click={async () => {
|
|
if (handleReaction) {
|
|
await handleReaction(authors, emoji);
|
|
}
|
|
}}>
|
|
<div class="reaction txt-tiny">
|
|
<span>{emoji}</span>
|
|
<span>{authors.length}</span>
|
|
</div>
|
|
</IconButton>
|
|
{:else}
|
|
<div class="reaction txt-tiny" style="padding: 2px 4px;">
|
|
<span>{emoji}</span>
|
|
<span>{authors.length}</span>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/each}
|
|
</div>
|