Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 940 Bytes
dd7ec11 e8410db 48bc121 e8410db f91a1ec e8410db f91a1ec e8410db dd7ec11 f05d33c 3d344de f05d33c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<script lang="ts">
export let emoji: string;
export let count: number;
export let gallery_id: string;
export let liked: boolean;
export let onReact: (emoji: string, id: string, deleted: boolean) => void;
const handleReaction = async (emoji: string) => {
await fetch(`/api/community/${gallery_id}/reaction`, {
method: "POST",
body: JSON.stringify({ emoji }),
headers: {
"Content-Type": "application/json",
},
})
.then(res => res.json())
.then(data => {
onReact(emoji, data.id, data.delete);
})
}
</script>
<button
class="rounded-full bg-white text-neutral-800 font-bold flex items-center justify-start gap-1.5 px-3 py-1 border border-white hover:bg-neutral-200 text-sm"
class:bg-opacity-60={!liked}
on:click={(e) => {
e.preventDefault();
e.stopPropagation();
handleReaction(emoji)
}}
>
<span class="text-base">{emoji}</span>
{count}
</button>
|