Layout, from the approved mock: - Group header on Expenses/Balances: my balance as the headline number (Money component de-emphasises currency and decimals), total spent, and round quick actions Add / Payment / Settle up / Share. The floating + shows only once those scroll off screen. - Expense rows on two lines (title | amount, payer | my part) with round icons tinted per category; sentence-case section headings. - Balances: larger avatars, paired avatars on settle-up rows, tinted button. Bugs found in a screenshot pass (phone 320/390, desktop 1280; dark, black, light; English and Czech): - A long title or member name widened the group page past the screen and phones zoomed out (grid tracks without minmax(0, ...)); same in Stats. - Long titles were clipped mid-word with no ellipsis. - Category emoji nearly invisible on its grey circle in the light theme. - Stats period labels wrapped (en) or ran off screen (cs); shortened. - Icons next to wrapping text were squashed (lock on Home/App settings). - Dialogs opened with a focus ring on the close button after a tap. - New expenses always defaulted to Food & drink; now the group's default category (settable in group settings), else Other. e2e: the Balances check now targets the Settle up heading, which the new quick action shares its text with. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HA82gVKYyo9BHLHPW4qr4x
148 lines
5.8 KiB
Svelte
148 lines
5.8 KiB
Svelte
<script lang="ts">
|
|
import { onDestroy, untrack } from 'svelte';
|
|
import { forgetGroup } from '../lib/idb.ts';
|
|
import { router } from '../lib/router.svelte.ts';
|
|
import { closeSession, openSession, type GroupSession } from '../lib/session.svelte.ts';
|
|
import { t } from '../lib/settings.svelte.ts';
|
|
import Activity from './Activity.svelte';
|
|
import Balances from './Balances.svelte';
|
|
import ExpenseDetail from './ExpenseDetail.svelte';
|
|
import ExpenseEditor from './ExpenseEditor.svelte';
|
|
import ExpenseList from './ExpenseList.svelte';
|
|
import GroupHeader from './GroupHeader.svelte';
|
|
import GroupSettings from './GroupSettings.svelte';
|
|
import Icon from './Icon.svelte';
|
|
import IdentityPicker from './IdentityPicker.svelte';
|
|
import Stats from './Stats.svelte';
|
|
|
|
// Keyed by group id in App.svelte, so reading it once is enough.
|
|
const props: { id: string } = $props();
|
|
const id = untrack(() => props.id);
|
|
let session = $state<GroupSession | null | undefined>(undefined);
|
|
let skippedIdentity = $state(false);
|
|
// The floating Add button only appears once the header's actions scroll away.
|
|
// Starts true so the button doesn't flash before the observer reports.
|
|
let actionsVisible = $state(true);
|
|
|
|
openSession(id).then((s) => (session = s));
|
|
onDestroy(() => closeSession(id));
|
|
|
|
const route = $derived(router.route);
|
|
const tab = $derived(route.name === 'group' ? route.tab : 'expenses');
|
|
const withHeader = $derived(tab === 'expenses' || tab === 'balances');
|
|
const base = `/g/${id}`;
|
|
const tabs = [
|
|
{ key: 'expenses', path: base, icon: 'list', label: 'expenses' },
|
|
{ key: 'balances', path: `${base}/balances`, icon: 'scale', label: 'balances' },
|
|
{ key: 'stats', path: `${base}/stats`, icon: 'chart', label: 'stats' },
|
|
{ key: 'activity', path: `${base}/activity`, icon: 'clock', label: 'activity' },
|
|
] as const;
|
|
|
|
function nav(e: MouseEvent, path: string, replace = false) {
|
|
e.preventDefault();
|
|
router.go(path, { replace });
|
|
}
|
|
|
|
const needsIdentity = $derived(
|
|
!!session && session.status !== 'loading' && session.state.members.length > 0 && !session.me && !skippedIdentity,
|
|
);
|
|
|
|
async function remove() {
|
|
await forgetGroup(id);
|
|
router.go('/', { replace: true });
|
|
}
|
|
</script>
|
|
|
|
{#if session === undefined}
|
|
<main class="page"><p class="empty">{t('loading')}</p></main>
|
|
{:else if session === null}
|
|
<header class="topbar">
|
|
<button class="icon-btn" onclick={() => router.go('/')} aria-label={t('back')}><Icon name="back" /></button>
|
|
<h1>{t('app_name')}</h1>
|
|
</header>
|
|
<main class="page"><p class="card">{t('group_not_on_device')}</p></main>
|
|
{:else if route.name === 'group-settings'}
|
|
<GroupSettings {session} />
|
|
{:else}
|
|
{@const s = session}
|
|
<header class="topbar">
|
|
<button class="icon-btn" onclick={() => router.go('/')} aria-label={t('back')}><Icon name="back" /></button>
|
|
{#if s.state.group?.icon}<span class="group-icon" aria-hidden="true">{s.state.group.icon}</span>{/if}
|
|
<h1>{s.state.group?.name ?? s.local.name}</h1>
|
|
<a class="icon-btn" href="{base}/settings" onclick={(e) => nav(e, `${base}/settings`)} aria-label={t('group_settings')}><Icon name="settings" /></a>
|
|
</header>
|
|
|
|
<main class="page wide stack">
|
|
{#if s.status === 'gone'}
|
|
<div class="banner danger stack">
|
|
<p>{t('not_found_group')}</p>
|
|
<button class="btn small danger" onclick={remove}>{t('remove_from_device')}</button>
|
|
</div>
|
|
{:else if s.status === 'offline'}
|
|
<p class="banner">{t('offline')}</p>
|
|
{/if}
|
|
{#if s.pending.length && s.status !== 'online'}
|
|
<p class="muted small">{t('pending', { n: s.pending.length })}</p>
|
|
{/if}
|
|
{#if s.rollback}<p class="banner warn">{t('rollback_warning')}</p>{/if}
|
|
|
|
{#if withHeader && s.status !== 'gone'}
|
|
<GroupHeader session={s} onactionsvisible={(v) => (actionsVisible = v)} />
|
|
{/if}
|
|
|
|
<nav class="tabbar" aria-label={s.state.group?.name}>
|
|
{#each tabs as tb}
|
|
<a href={tb.path} aria-current={tab === tb.key ? 'page' : undefined} onclick={(e) => nav(e, tb.path, true)}>
|
|
<Icon name={tb.icon} size={20} />
|
|
{t(tb.label)}
|
|
</a>
|
|
{/each}
|
|
</nav>
|
|
|
|
<div class="layout" class:with-side={tab === 'expenses'}>
|
|
<div class="main-col">
|
|
{#if tab === 'expenses'}
|
|
<ExpenseList session={s} />
|
|
{:else if tab === 'balances'}
|
|
<Balances session={s} />
|
|
{:else if tab === 'stats'}
|
|
<Stats session={s} />
|
|
{:else}
|
|
<Activity session={s} />
|
|
{/if}
|
|
</div>
|
|
{#if tab === 'expenses'}
|
|
<aside class="side-col"><Balances session={s} compact /></aside>
|
|
{/if}
|
|
</div>
|
|
</main>
|
|
|
|
{#if s.status !== 'gone' && withHeader && !actionsVisible}
|
|
<a class="fab" href="{base}/e/new" onclick={(e) => nav(e, `${base}/e/new`)} aria-label={t('add_expense')}><Icon name="plus" size={28} /></a>
|
|
{/if}
|
|
|
|
{#if route.name === 'expense'}
|
|
<ExpenseDetail session={s} eid={route.eid} />
|
|
{:else if route.name === 'expense-edit'}
|
|
{#key route.eid}
|
|
<ExpenseEditor session={s} eid={route.eid} params={route.params} />
|
|
{/key}
|
|
{:else if needsIdentity}
|
|
<IdentityPicker session={s} onskip={() => (skippedIdentity = true)} />
|
|
{/if}
|
|
{/if}
|
|
|
|
<style>
|
|
.group-icon {
|
|
display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
|
|
background: var(--surface-2); font-size: 1.1rem;
|
|
}
|
|
/* minmax(0, …): without it a long title or name (nowrap + ellipsis) widens
|
|
the column past the screen and phones zoom out. */
|
|
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
|
|
.side-col { display: none; }
|
|
@media (min-width: 960px) {
|
|
.layout.with-side { grid-template-columns: minmax(0, 1fr) 340px; }
|
|
.side-col { display: block; position: sticky; top: 80px; align-self: start; }
|
|
}
|
|
</style>
|