oweme/apps/web/src/components/IdentityPicker.svelte
agent 8fbbb4933e Add Svelte web client and service worker
Mobile-first PWA: groups via key-in-fragment links, encrypted outbox and
sync over SSE, all split modes, currencies with ECB rate prefill, photos,
comments, history and rewind, stats, recurring expenses, CSV and backup,
EN/CS, dark/light theme, Web Push decrypted in the service worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
2026-10-09 19:59:16 +00:00

50 lines
1.8 KiB
Svelte

<script lang="ts">
import { randomId } from '../lib/crypto.ts';
import { MEMBER_COLORS } from '../lib/format.ts';
import type { GroupSession } from '../lib/session.svelte.ts';
import { t } from '../lib/settings.svelte.ts';
import Avatar from './Avatar.svelte';
import Sheet from './Sheet.svelte';
let { session, onskip }: { session: GroupSession; onskip: () => void } = $props();
let newName = $state('');
let adding = $state(false);
const members = $derived(session.state.members.filter((m) => !m.archived));
async function pick(id: string) {
await session.setMe(id);
}
async function addMe(e: SubmitEvent) {
e.preventDefault();
const name = newName.trim();
if (!name) return;
const id = randomId(9);
await session.emit({ type: 'member.added', data: { id, name, color: MEMBER_COLORS[session.state.members.length % MEMBER_COLORS.length] } });
await session.setMe(id);
}
</script>
<Sheet title={t('who_are_you')} onclose={onskip}>
<div class="stack">
<p class="muted">{t('who_are_you_hint')}</p>
<div class="list">
{#each members as m, i (m.id)}
<button class="item" onclick={() => pick(m.id)}>
<Avatar member={m} index={i} />
<span class="grow title">{m.name}</span>
</button>
{/each}
</div>
{#if adding}
<form class="row" onsubmit={addMe}>
<input bind:value={newName} placeholder={t('your_name')} maxlength="60" aria-label={t('your_name')} />
<button class="btn primary" type="submit" disabled={!newName.trim()}>{t('save')}</button>
</form>
{:else}
<button class="btn" onclick={() => (adding = true)}>{t('im_new')}</button>
{/if}
<button class="btn ghost" onclick={onskip}>{t('just_looking')}</button>
</div>
</Sheet>