oweme/apps/web/src/components/GroupHeader.svelte
agent b3b57c156e Group page redesign and visual bug fixes
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
2026-11-06 20:36:33 +00:00

74 lines
4 KiB
Svelte

<script lang="ts">
// Top of the group page: your balance as the headline number, the group's
// total, and round quick actions. Reports whether the actions are on
// screen so the page can show the floating Add button only when they aren't.
import { inBase } from '@oweme/core';
import { router } from '../lib/router.svelte.ts';
import type { GroupSession } from '../lib/session.svelte.ts';
import { t } from '../lib/settings.svelte.ts';
import Icon from './Icon.svelte';
import Money from './Money.svelte';
let { session, onactionsvisible }: { session: GroupSession; onactionsvisible: (visible: boolean) => void } = $props();
const base = $derived(`/g/${session.id}`);
const total = $derived(
Object.values(session.state.expenses)
.filter((r) => !r.deleted && r.expense.kind === 'expense')
.reduce((a, r) => a + inBase(r.expense, session.base).total, 0),
);
const mine = $derived(session.me ? (session.balances[session.me] ?? 0) : null);
function go(e: MouseEvent, path: string, replace = false) {
e.preventDefault();
router.go(path, { replace });
}
let actions: HTMLElement;
$effect(() => {
const io = new IntersectionObserver(([entry]) => onactionsvisible(entry.isIntersecting));
io.observe(actions);
return () => io.disconnect();
});
</script>
<section class="hero" aria-label={t('summary')}>
{#if mine === null}
<div class="lbl">{t('total_spent')}</div>
<div class="big"><Money minor={total} currency={session.base} /></div>
{:else}
<div class="lbl">{mine > 0 ? t('hero_owed') : mine < 0 ? t('hero_owe') : t('hero_settled')}</div>
<div class="big {mine > 0 ? 'pos' : mine < 0 ? 'neg' : ''}"><Money minor={Math.abs(mine)} currency={session.base} /></div>
<div class="meta"><span class="dot" aria-hidden="true"></span>{t('total_spent')} <Money minor={total} currency={session.base} /></div>
{/if}
</section>
<nav class="actions" bind:this={actions} aria-label={t('quick_actions')}>
<a class="act primary" href="{base}/e/new" onclick={(e) => go(e, `${base}/e/new`)} aria-label={t('add_expense')}><span class="c"><Icon name="plus" /></span>{t('add')}</a>
<a class="act" href="{base}/e/new?kind=transfer" onclick={(e) => go(e, `${base}/e/new?kind=transfer`)} aria-label={t('add_payment')}><span class="c"><Icon name="swap" /></span>{t('payment_short')}</a>
<a class="act" href="{base}/balances" onclick={(e) => go(e, `${base}/balances`, true)}><span class="c"><Icon name="scale" /></span>{t('settle_up')}</a>
<a class="act" href="{base}/settings" onclick={(e) => go(e, `${base}/settings`)}><span class="c"><Icon name="share" /></span>{t('share_short')}</a>
</nav>
<style>
.hero { text-align: center; padding: 8px 0 0; }
.lbl { color: var(--muted); font-size: 0.92rem; font-weight: 500; }
.big { font-size: 2.75rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.15; margin: 2px 0; overflow-wrap: anywhere; }
.big :global(.cur), .big :global(.frac) { font-size: 0.55em; letter-spacing: -0.01em; }
.meta {
display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 12px; border-radius: 999px;
background: var(--surface); color: var(--muted); font-size: 0.84rem; font-weight: 500;
}
.meta :global(.money), .meta :global(.money .cur), .meta :global(.money .frac) { color: var(--text); font-size: 1em; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.actions { display: flex; justify-content: center; gap: 8px; padding: 14px 0 4px; }
.act {
flex: 0 1 84px; display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center;
font-size: 0.8rem; font-weight: 600; color: var(--text); text-decoration: none; line-height: 1.2;
}
.act .c { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; }
.act.primary .c { background: var(--accent); color: var(--accent-ink); }
.act:hover .c { filter: brightness(1.12); }
.act:focus-visible { outline: none; }
.act:focus-visible .c { outline: 2px solid var(--accent); outline-offset: 2px; }
</style>