chadtmiller.com/spaces-bookclub
Book club: a Svelte demo app for atproto spaces (@atproto/lex-space)
0
0
<script lang="ts">
import type { IconName } from '../atoms/Icon.svelte'
import Input from '../atoms/Input.svelte'
import Textarea from '../atoms/Textarea.svelte'
import Field from '../molecules/Field.svelte'
import ActionDialog from './ActionDialog.svelte'
import type { ClubInfo } from '../../lib/atproto.ts'
/** Names a new club, or edits an existing one's name and description. */
let {
open = $bindable(false),
title,
description,
submitLabel,
submitIcon,
initial,
onsubmit,
}: {
open?: boolean
title: string
description: string
submitLabel: string
submitIcon: IconName
initial?: ClubInfo | null
onsubmit: (info: ClubInfo) => Promise<void>
} = $props()
let name = $state('')
let about = $state('')
$effect(() => {
if (open) {
name = initial?.name ?? ''
about = initial?.description ?? ''
}
})
</script>
<ActionDialog
bind:open
{title}
{description}
{submitLabel}
{submitIcon}
onsubmit={() => onsubmit({ name: name.trim(), description: about.trim() || undefined })}
>
<Field label="Name">
{#snippet children(id)}
<Input {id} bind:value={name} placeholder="Sci-fi Sundays" required maxlength={64} />
{/snippet}
</Field>
<Field label="Description" hint="Optional. Members see it at the top of the club.">
{#snippet children(id)}
<Textarea
{id}
bind:value={about}
placeholder="We read one science fiction novel a month."
maxlength={300}
rows={3}
/>
{/snippet}
</Field>
</ActionDialog>