chadtmiller.com/spaces-bookclub
Book club: a Svelte demo app for atproto spaces (@atproto/lex-space)
0
0
<script lang="ts">
import Input from '../atoms/Input.svelte'
import Textarea from '../atoms/Textarea.svelte'
import Field from '../molecules/Field.svelte'
import StarRating from '../molecules/StarRating.svelte'
import ActionDialog from './ActionDialog.svelte'
let {
open = $bindable(false),
onpost,
}: {
open?: boolean
onpost: (review: { book: string; stars: number; text: string }) => Promise<void>
} = $props()
let book = $state('')
let stars = $state(4)
let text = $state('')
$effect(() => {
if (open) {
book = ''
stars = 4
text = ''
}
})
</script>
<ActionDialog
bind:open
title="Write a review"
description="Only members of this club can read it."
submitLabel="Post review"
submitIcon="pen"
onsubmit={() => onpost({ book, stars, text })}
>
<Field label="Book">
{#snippet children(id)}
<Input {id} bind:value={book} placeholder="The Left Hand of Darkness" required maxlength={100} />
{/snippet}
</Field>
<div class="rating">
<span>Rating</span>
<StarRating bind:value={stars} size={20} />
</div>
<Field label="Review">
{#snippet children(id)}
<Textarea {id} bind:value={text} placeholder="What did you think?" required maxlength={1000} rows={5} />
{/snippet}
</Field>
</ActionDialog>
<style>
.rating {
display: grid;
gap: var(--space-1);
font-size: var(--text-sm);
font-weight: var(--weight-medium);
}
</style>