TypeScript
feat: make Invoice responsive
Vipul Kumar20c220e5789f
diff --git a/src/components/pages/invoice/invoice-editor.tsx b/src/components/pages/invoice/invoice-editor.tsxindex 7408ed7..4119fc3 100644--- a/src/components/pages/invoice/invoice-editor.tsx+++ b/src/components/pages/invoice/invoice-editor.tsx@@ -31,7 +31,7 @@ export function InvoiceEditor() {const closeEditor = useInvoiceUi((s) => s.closeEditor);return (<Dialog open={editor.open} onOpenChange={(v) => !v && closeEditor()}>- <DialogContent className="max-h-[calc(100dvh-48px)] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 p-0 sm:max-w-[720px]">+ <DialogContent className="max-h-[calc(100dvh-48px)] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 p-0 max-sm:overflow-hidden max-sm:pb-0 sm:max-w-[720px]"><EditorForm key={editor.session} invoiceId={editor.id} onDone={closeEditor} /></DialogContent></Dialog>@@ -129,16 +129,17 @@ function EditorForm({ invoiceId, onDone }: { invoiceId?: string; onDone: () => vsave(existing ? existing.status : "draft");}}>- <DialogHeader className="gap-1.5 border-b border-hairline px-5 pt-5 pb-4">+ <DialogHeader className="gap-1.5 border-b border-hairline px-5 pt-5 pb-4 max-sm:px-4 max-sm:pr-12 max-sm:text-left"><DialogTitle className="t-16">{existing ? `Edit ${existing.number}` : "New invoice"}</DialogTitle><DialogDescription className="t-14">{existing ? "Changes apply immediately to the invoice." : "Drafts stay private until you send them."}</DialogDescription></DialogHeader>- <div className="grid content-start gap-5 overflow-y-auto scroll-thin px-5 py-5">- <div className="grid grid-cols-[1.4fr_1fr_120px] gap-3">- <Field label="Client" htmlFor="inv-client">+ <div className="grid content-start gap-5 overflow-y-auto scroll-thin px-5 py-5 max-sm:px-4 max-sm:py-4">+ {/* Phones: client on its own row, number + currency share the next */}+ <div className="grid grid-cols-[minmax(0,1fr)_104px] gap-3 max-sm:gap-y-4 sm:grid-cols-[1.4fr_1fr_120px]">+ <Field label="Client" htmlFor="inv-client" className="max-sm:col-span-2"><Inputid="inv-client"list="inv-clients"@@ -177,7 +178,7 @@ function EditorForm({ invoiceId, onDone }: { invoiceId?: string; onDone: () => v</Select></Field></div>- <div className="grid grid-cols-2 gap-3">+ <div className="grid gap-4 sm:grid-cols-2 sm:gap-3"><Field label="Issue date" htmlFor="inv-issue"><Inputid="inv-issue"@@ -214,8 +215,9 @@ function EditorForm({ invoiceId, onDone }: { invoiceId?: string; onDone: () => v<div className="grid gap-2"><span className="t-12 text-fg-2">Line items</span>- <div className="overflow-hidden rounded-lg border border-hairline">- <div className="grid h-8 grid-cols-[1fr_72px_104px_104px_36px] items-center gap-2 bg-app px-2">+ {/* Phones: each line item is its own small card (description, then qty / rate / amount) */}+ <div className="grid gap-2 sm:gap-0 sm:overflow-hidden sm:rounded-lg sm:border sm:border-hairline">+ <div className="grid h-8 grid-cols-[1fr_72px_104px_104px_36px] items-center gap-2 bg-app px-2 max-sm:hidden"><span className="t-12 pl-0.5 text-fg-2">Description</span><span className="t-12 text-right text-fg-2">Qty</span><span className="t-12 text-right text-fg-2">Rate</span>@@ -225,42 +227,53 @@ function EditorForm({ invoiceId, onDone }: { invoiceId?: string; onDone: () => v{draft.items.map((l, idx) => (<divkey={l.id}- className="grid grid-cols-[1fr_72px_104px_104px_36px] items-center gap-2 border-t border-subtle px-2 py-1.5"+ className="grid grid-cols-[72px_minmax(0,1fr)_auto] items-end gap-2 rounded-lg border border-hairline p-3 sm:grid-cols-[1fr_72px_104px_104px_36px] sm:items-center sm:rounded-none sm:border-0 sm:border-t sm:border-subtle sm:px-2 sm:py-1.5"><Inputaria-label={`Line ${idx + 1} description`}placeholder="Service or product"+ className="max-sm:col-span-2 max-sm:row-start-1"value={l.description}onChange={(e) => setLine(l.id, { description: e.target.value })}/>- <Input- aria-label={`Line ${idx + 1} quantity`}- type="number"- inputMode="decimal"- min={0}- step="any"- className="text-right tabular-nums"- value={l.quantity}- onChange={(e) => setLine(l.id, { quantity: e.target.value })}- />- <Input- aria-label={`Line ${idx + 1} rate`}- type="number"- inputMode="decimal"- min={0}- step="any"- placeholder="0.00"- className="text-right tabular-nums"- value={l.rate}- onChange={(e) => setLine(l.id, { rate: e.target.value })}- />- <span className="t-14 truncate text-right text-table tabular-nums">- {formatMoney(lineTotal({ quantity: Number(l.quantity), rate: Number(l.rate) }), draft.currency)}+ <label className="grid gap-1.5">+ <span className="t-12 text-fg-2 sm:hidden">Qty</span>+ <Input+ aria-label={`Line ${idx + 1} quantity`}+ type="number"+ inputMode="decimal"+ min={0}+ step="any"+ className="text-right tabular-nums"+ value={l.quantity}+ onChange={(e) => setLine(l.id, { quantity: e.target.value })}+ />+ </label>+ <label className="grid gap-1.5">+ <span className="t-12 text-fg-2 sm:hidden">Rate</span>+ <Input+ aria-label={`Line ${idx + 1} rate`}+ type="number"+ inputMode="decimal"+ min={0}+ step="any"+ placeholder="0.00"+ className="text-right tabular-nums"+ value={l.rate}+ onChange={(e) => setLine(l.id, { rate: e.target.value })}+ />+ </label>+ <span className="grid min-w-0 gap-1.5 text-right max-sm:min-w-[88px]">+ <span className="t-12 text-fg-2 sm:hidden">Amount</span>+ <span className="t-14 truncate text-table tabular-nums max-sm:flex max-sm:h-8 max-sm:items-center max-sm:justify-end">+ {formatMoney(lineTotal({ quantity: Number(l.quantity), rate: Number(l.rate) }), draft.currency)}+ </span></span><Buttontype="button"variant="ghost"size="icon-sm"+ className="max-sm:col-start-3 max-sm:row-start-1 max-sm:size-8 max-sm:justify-self-end"aria-label={`Remove line ${idx + 1}`}disabled={draft.items.length === 1}onClick={() => set("items", draft.items.filter((x) => x.id !== l.id))}@@ -269,11 +282,16 @@ function EditorForm({ invoiceId, onDone }: { invoiceId?: string; onDone: () => v</Button></div>))}- <div className="flex items-center justify-between border-t border-subtle bg-app px-2 py-2">- <Button type="button" size="sm" onClick={() => set("items", [...draft.items, blankLine()])}>+ <div className="flex items-center justify-between gap-3 max-sm:items-start max-sm:pt-1 sm:border-t sm:border-subtle sm:bg-app sm:px-2 sm:py-2">+ <Button+ type="button"+ size="sm"+ className="max-sm:h-10 max-sm:px-3"+ onClick={() => set("items", [...draft.items, blankLine()])}+ ><PlusIcon /> Add line</Button>- <dl className="grid grid-cols-[auto_120px] items-center gap-x-4 gap-y-2 pr-[44px]">+ <dl className="grid grid-cols-[auto_minmax(0,120px)] items-center gap-x-4 gap-y-2 sm:pr-[44px]"><dt className="t-12 text-right text-fg-2">Subtotal</dt><dd className="t-14 text-right text-table tabular-nums">{formatMoney(total, draft.currency)}</dd><dt className="t-14 text-right text-fg">Total</dt>@@ -294,13 +312,14 @@ function EditorForm({ invoiceId, onDone }: { invoiceId?: string; onDone: () => v</Field></div>- <DialogFooter className="m-0 items-center rounded-b-xl border-t border-hairline bg-app px-5 py-3">+ <DialogFooter className="m-0 rounded-b-xl border-t border-hairline bg-app px-5 py-3 max-sm:rounded-none max-sm:px-4 max-sm:pb-[max(12px,env(safe-area-inset-bottom))] max-sm:flex-row max-sm:flex-wrap max-sm:[&_button]:h-10 max-sm:[&_button]:flex-1 sm:items-center">{touched && error ? (- <p className="t-12 mr-auto text-danger" role="alert">+ <p className="t-12 mr-auto leading-[1.3] text-danger max-sm:basis-full" role="alert">{error}</p>) : null}- <Button type="button" onClick={onDone}>+ {/* Phones close the sheet with its X or a swipe; the footer keeps just the save actions */}+ <Button type="button" className="max-sm:hidden" onClick={onDone}>Cancel</Button>{existing ? (diff --git a/src/components/pages/invoice/invoice-page.tsx b/src/components/pages/invoice/invoice-page.tsxindex 3f277f9..f8c7268 100644--- a/src/components/pages/invoice/invoice-page.tsx+++ b/src/components/pages/invoice/invoice-page.tsx@@ -3,6 +3,7 @@import { useMemo, useState } from "react";import { CheckIcon, CopyIcon, EyeIcon, PencilIcon, PlusIcon, ReceiptIcon, SendIcon, Trash2Icon, XIcon } from "lucide-react";import { toast } from "sonner";+import { FilterMenu } from "@/components/filter-menu";import { Icon } from "@/components/icon";import { Button } from "@/components/ui/button";import {@@ -66,56 +67,84 @@ export function InvoicePage() {return (<div className="flex min-h-0 flex-1 flex-col overflow-y-auto scroll-thin bg-app">- <header className="sticky top-0 z-10 flex h-[68px] shrink-0 items-center gap-3 border-b border-hairline bg-surface px-4">- <div className="flex min-w-0 flex-1 flex-col gap-1.5">- <h2 className="t-16 text-fg">Invoices</h2>- <p className="t-14 truncate text-fg-2">- {invoices.length} {invoices.length === 1 ? "invoice" : "invoices"} · {formatTotals(stats.outstanding)} outstanding- </p>+ {/* Phones: title + New on the first row, search + Filters on the second; the header scrolls away */}+ <header className="z-10 flex shrink-0 flex-col gap-3 border-b border-hairline bg-surface px-4 py-3 md:sticky md:top-0 md:h-[68px] md:flex-row md:items-center md:py-0">+ <div className="flex min-w-0 items-center gap-3 md:flex-1">+ <div className="flex min-w-0 flex-1 flex-col gap-1.5">+ <h2 className="t-16 text-fg">Invoices</h2>+ <p className="t-14 truncate text-fg-2">+ {invoices.length} {invoices.length === 1 ? "invoice" : "invoices"} · {formatTotals(stats.outstanding)} outstanding+ </p>+ </div>+ <Button variant="brand" size="icon" className="size-10 md:hidden" aria-label="New invoice" onClick={() => edit()}>+ <PlusIcon className="size-4" />+ </Button>+ </div>+ <div className="flex items-center gap-2 md:gap-3">+ <label className="flex h-10 min-w-0 flex-1 items-center gap-2 rounded-lg border border-control bg-surface px-2.5 transition-[border-color,box-shadow] duration-150 focus-within:border-brand/60 focus-within:ring-3 focus-within:ring-brand/15 md:h-[30px] md:w-56 md:flex-none">+ <Icon name="search" />+ <input+ type="search"+ placeholder="Search number or client"+ aria-label="Search invoices"+ className="t-14 min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-placeholder max-md:text-[16px] [&::-webkit-search-cancel-button]:hidden"+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ />+ {query && (+ <button+ type="button"+ aria-label="Clear search"+ className="-mr-1 rounded p-0.5 text-icon hover-fine:text-fg max-md:-mr-2 max-md:p-2"+ onClick={() => setQuery("")}+ >+ <XIcon className="size-3.5" />+ </button>+ )}+ </label>+ <div className="md:hidden">+ <FilterMenu+ className="h-10"+ groups={[+ {+ id: "status",+ label: "Status",+ type: "single",+ options: [+ { value: "all", label: "All statuses" },+ ...STATUSES.map((s) => ({ value: s, label: STATUS_LABELS[s] })),+ ],+ value: status,+ onChange: (v) => setStatus(v as StatusFilter),+ },+ ]}+ activeCount={status === "all" ? 0 : 1}+ onReset={() => setStatus("all")}+ />+ </div>+ <Select value={status} onValueChange={(v) => setStatus(v as StatusFilter)}>+ <SelectTrigger size="sm" className="h-[30px] w-[132px] max-md:hidden" aria-label="Filter by status">+ <Icon name="filter" />+ <SelectValue />+ </SelectTrigger>+ <SelectContent position="popper" align="end">+ <SelectItem value="all">All statuses</SelectItem>+ {STATUSES.map((s) => (+ <SelectItem key={s} value={s}>+ {STATUS_LABELS[s]}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <div className="h-4 w-px bg-hairline max-md:hidden" aria-hidden />+ <Button variant="brand" className="max-md:hidden" onClick={() => edit()}>+ <PlusIcon /> New invoice+ </Button></div>- <label className="flex h-[30px] w-56 items-center gap-2 rounded-lg border border-control bg-surface px-2.5 transition-[border-color,box-shadow] duration-150 focus-within:border-brand/60 focus-within:ring-3 focus-within:ring-brand/15">- <Icon name="search" />- <input- type="search"- placeholder="Search number or client"- aria-label="Search invoices"- className="t-14 min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-placeholder [&::-webkit-search-cancel-button]:hidden"- value={query}- onChange={(e) => setQuery(e.target.value)}- />- {query && (- <button- type="button"- aria-label="Clear search"- className="-mr-1 rounded p-0.5 text-icon hover-fine:text-fg"- onClick={() => setQuery("")}- >- <XIcon className="size-3.5" />- </button>- )}- </label>- <Select value={status} onValueChange={(v) => setStatus(v as StatusFilter)}>- <SelectTrigger size="sm" className="h-[30px] w-[132px]" aria-label="Filter by status">- <Icon name="filter" />- <SelectValue />- </SelectTrigger>- <SelectContent position="popper" align="end">- <SelectItem value="all">All statuses</SelectItem>- {STATUSES.map((s) => (- <SelectItem key={s} value={s}>- {STATUS_LABELS[s]}- </SelectItem>- ))}- </SelectContent>- </Select>- <div className="h-4 w-px bg-hairline" aria-hidden />- <Button variant="brand" onClick={() => edit()}>- <PlusIcon /> New invoice- </Button></header><div className="flex flex-col gap-4 p-4">- <div className="grid grid-cols-4 overflow-hidden rounded-xl border border-hairline bg-surface">+ <div className="grid grid-cols-2 overflow-hidden rounded-xl border border-hairline bg-surface md:grid-cols-4"><Stat label="Outstanding" value={formatTotals(stats.outstanding)} count={stats.outstanding.length} /><Statlabel="Overdue"@@ -156,64 +185,93 @@ export function InvoicePage() {)}</div>) : (- <table className="w-full table-fixed border-collapse">- <colgroup>- <col className="w-[160px]" />- <col />- <col className="w-[120px]" />- <col className="w-[120px]" />- <col className="w-[150px]" />- <col className="w-[120px]" />- <col className="w-[56px]" />- </colgroup>- <thead>- <tr className="h-10 bg-app text-left">- <th className="t-14 px-4 font-medium text-fg-2">Number</th>- <th className="t-14 px-2 font-medium text-fg-2">Client</th>- <th className="t-14 px-2 font-medium text-fg-2">Issued</th>- <th className="t-14 px-2 font-medium text-fg-2">Due</th>- <th className="t-14 px-2 text-right font-medium text-fg-2">Amount</th>- <th className="t-14 px-4 font-medium text-fg-2">Status</th>- <th className="pr-3">- <span className="sr-only">Actions</span>- </th>- </tr>- </thead>- <tbody>+ <>+ {/* Phones: a tappable list instead of the seven-column table */}+ <ul className="md:hidden">{visible.map(({ inv, status: st, total }) => (- <tr- key={inv.id}- onClick={() => view(inv.id)}- className="h-14 cursor-pointer border-b border-subtle transition-colors duration-150 last:border-b-0 hover-fine:bg-hover/50"- >- <td className="px-4">- <button- type="button"- className="t-14 rounded text-table outline-none focus-visible:ring-3 focus-visible:ring-brand/15"- onClick={(e) => {- e.stopPropagation();- view(inv.id);- }}- >- {inv.number}- </button>- </td>- <td className="t-14 truncate px-2 text-table">{inv.client}</td>- <td className="t-14 px-2 text-table">{formatShort(inv.issueDate)}, {inv.issueDate.slice(0, 4)}</td>- <td className={cn("t-14 px-2", st === "overdue" ? "text-danger" : "text-table")}>- {formatShort(inv.dueDate)}, {inv.dueDate.slice(0, 4)}- </td>- <td className="t-14 px-2 text-right text-table tabular-nums">{formatMoney(total, inv.currency)}</td>- <td className="px-4">- <InvoiceStatusBadge status={st} />- </td>- <td className="pr-3 text-right" onClick={(e) => e.stopPropagation()}>- <RowMenu invoice={inv} today={today} />- </td>- </tr>+ <li key={inv.id} className="flex items-center border-b border-subtle last:border-b-0">+ <button+ type="button"+ onClick={() => view(inv.id)}+ className="flex min-h-16 min-w-0 flex-1 flex-col gap-2 py-3 pl-4 text-left outline-none focus-visible:bg-hover"+ >+ <span className="flex w-full items-center gap-3">+ <span className="t-14 min-w-0 flex-1 truncate text-fg">{inv.client}</span>+ <span className="t-14 shrink-0 text-table tabular-nums">{formatMoney(total, inv.currency)}</span>+ </span>+ <span className="flex w-full items-center gap-3">+ <span className="t-12 min-w-0 flex-1 truncate text-fg-2">+ {inv.number} ·{" "}+ <span className={cn(st === "overdue" && "text-danger")}>Due {formatShort(inv.dueDate)}</span>+ </span>+ <InvoiceStatusBadge status={st} />+ </span>+ </button>+ <div className="px-1.5">+ <RowMenu invoice={inv} today={today} triggerClassName="size-10" />+ </div>+ </li>))}- </tbody>- </table>+ </ul>+ <table className="w-full table-fixed border-collapse max-md:hidden">+ <colgroup>+ <col className="w-[160px]" />+ <col />+ <col className="w-[120px]" />+ <col className="w-[120px]" />+ <col className="w-[150px]" />+ <col className="w-[120px]" />+ <col className="w-[56px]" />+ </colgroup>+ <thead>+ <tr className="h-10 bg-app text-left">+ <th className="t-14 px-4 font-medium text-fg-2">Number</th>+ <th className="t-14 px-2 font-medium text-fg-2">Client</th>+ <th className="t-14 px-2 font-medium text-fg-2">Issued</th>+ <th className="t-14 px-2 font-medium text-fg-2">Due</th>+ <th className="t-14 px-2 text-right font-medium text-fg-2">Amount</th>+ <th className="t-14 px-4 font-medium text-fg-2">Status</th>+ <th className="pr-3">+ <span className="sr-only">Actions</span>+ </th>+ </tr>+ </thead>+ <tbody>+ {visible.map(({ inv, status: st, total }) => (+ <tr+ key={inv.id}+ onClick={() => view(inv.id)}+ className="h-14 cursor-pointer border-b border-subtle transition-colors duration-150 last:border-b-0 hover-fine:bg-hover/50"+ >+ <td className="px-4">+ <button+ type="button"+ className="t-14 rounded text-table outline-none focus-visible:ring-3 focus-visible:ring-brand/15"+ onClick={(e) => {+ e.stopPropagation();+ view(inv.id);+ }}+ >+ {inv.number}+ </button>+ </td>+ <td className="t-14 truncate px-2 text-table">{inv.client}</td>+ <td className="t-14 px-2 text-table">{formatShort(inv.issueDate)}, {inv.issueDate.slice(0, 4)}</td>+ <td className={cn("t-14 px-2", st === "overdue" ? "text-danger" : "text-table")}>+ {formatShort(inv.dueDate)}, {inv.dueDate.slice(0, 4)}+ </td>+ <td className="t-14 px-2 text-right text-table tabular-nums">{formatMoney(total, inv.currency)}</td>+ <td className="px-4">+ <InvoiceStatusBadge status={st} />+ </td>+ <td className="pr-3 text-right" onClick={(e) => e.stopPropagation()}>+ <RowMenu invoice={inv} today={today} />+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </>)}</section></div>@@ -253,7 +311,8 @@ function Stat({</span></>);- const base = "flex min-w-0 flex-col gap-2.5 border-r border-hairline px-4 py-3.5 text-left last:border-r-0";+ const base =+ "flex min-w-0 flex-col gap-2.5 border-hairline px-4 py-3.5 text-left max-md:odd:border-r max-md:nth-[-n+2]:border-b md:border-r md:last:border-r-0";if (!onClick) return <div className={base}>{body}</div>;return (<button@@ -267,7 +326,7 @@ function Stat({);}-function RowMenu({ invoice, today }: { invoice: Invoice; today: string }) {+function RowMenu({ invoice, today, triggerClassName }: { invoice: Invoice; today: string; triggerClassName?: string }) {const invoices = useAppStore((s) => s.invoices);const saveInvoice = useAppStore((s) => s.saveInvoice);const setInvoiceStatus = useAppStore((s) => s.setInvoiceStatus);@@ -302,11 +361,11 @@ function RowMenu({ invoice, today }: { invoice: Invoice; today: string }) {return (<DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="ghost" size="icon-sm" aria-label={`Actions for ${invoice.number}`}>+ <Button variant="ghost" size="icon-sm" className={triggerClassName} aria-label={`Actions for ${invoice.number}`}><Icon name="more" /></Button></DropdownMenuTrigger>- <DropdownMenuContent align="end" className="w-48">+ <DropdownMenuContent align="end" className="w-48 max-md:[&_[role^=menuitem]]:min-h-10"><DropdownMenuItem onSelect={() => view(invoice.id)}><EyeIcon /> View</DropdownMenuItem>diff --git a/src/components/pages/invoice/invoice-view.tsx b/src/components/pages/invoice/invoice-view.tsxindex 9841868..b46635e 100644--- a/src/components/pages/invoice/invoice-view.tsx+++ b/src/components/pages/invoice/invoice-view.tsx@@ -2,9 +2,17 @@import { CheckIcon, DownloadIcon, PencilIcon, PrinterIcon, SendIcon } from "lucide-react";import { toast } from "sonner";+import { Icon } from "@/components/icon";import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";import { formatLong } from "@/lib/dates";+import { cn } from "@/lib/utils";import { useToday } from "@/hooks/use-today";import { useAppStore } from "@/stores/app-store";import { useInvoiceUi } from "./invoice-ui-store";@@ -24,81 +32,73 @@ export function InvoiceView() {const status = invoice ? effectiveStatus(invoice, today) : "draft";const total = invoice ? invoiceTotal(invoice) : 0;+ const download = () => {+ if (!invoice) return;+ downloadInvoice(invoice, profile);+ toast.success("Invoice downloaded", { description: `${invoice.number}.html` });+ };+ const send = () => {+ if (!invoice) return;+ setInvoiceStatus(invoice.id, "sent");+ toast.success("Invoice sent", { description: `${invoice.number} · ${invoice.client}` });+ };+ const markPaid = () => {+ if (!invoice) return;+ setInvoiceStatus(invoice.id, "paid");+ toast.success("Marked as paid", { description: `${invoice.number} · ${formatMoney(total, invoice.currency)}` });+ };+return (<Dialog open={open} onOpenChange={(v) => !v && closeView()}>- <DialogContent className="max-h-[calc(100dvh-48px)] grid-rows-[auto_minmax(0,1fr)] gap-0 overflow-hidden bg-app p-0 sm:max-w-[680px]">+ <DialogContent className="max-h-[calc(100dvh-48px)] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden bg-app p-0 max-sm:pb-0 sm:max-w-[680px]">{invoice && (<><div className="flex items-center gap-2 border-b border-hairline bg-surface py-3 pr-12 pl-4"><DialogTitle className="t-14 min-w-0 flex-1 truncate text-fg">{invoice.number}</DialogTitle><DialogDescription className="sr-only">Invoice for {invoice.client}</DialogDescription>- {invoice.status !== "paid" && (- <Button- size="sm"- className="px-2"- onClick={() => edit(invoice.id)}- >- <PencilIcon className="text-icon" /> Edit- </Button>- )}- <Button size="sm" className="px-2" onClick={() => printInvoice(invoice, profile)}>- <PrinterIcon className="text-icon" /> Print- </Button>- <Button- size="sm"- className="px-2"- onClick={() => {- downloadInvoice(invoice, profile);- toast.success("Invoice downloaded", { description: `${invoice.number}.html` });- }}- >- <DownloadIcon className="text-icon" /> Download- </Button>- {invoice.status === "draft" ? (- <Button- size="sm"- variant="brand"- className="px-2"- onClick={() => {- setInvoiceStatus(invoice.id, "sent");- toast.success("Invoice sent", { description: `${invoice.number} · ${invoice.client}` });- }}- >- <SendIcon /> Send+ {/* Phones move these into the bottom action bar */}+ <div className="flex items-center gap-2 max-sm:hidden">+ {invoice.status !== "paid" && (+ <Button size="sm" className="px-2" onClick={() => edit(invoice.id)}>+ <PencilIcon className="text-icon" /> Edit+ </Button>+ )}+ <Button size="sm" className="px-2" onClick={() => printInvoice(invoice, profile)}>+ <PrinterIcon className="text-icon" /> Print</Button>- ) : invoice.status !== "paid" ? (- <Button- size="sm"- variant="brand"- className="px-2"- onClick={() => {- setInvoiceStatus(invoice.id, "paid");- toast.success("Marked as paid", { description: `${invoice.number} · ${formatMoney(total, invoice.currency)}` });- }}- >- <CheckIcon /> Mark as paid+ <Button size="sm" className="px-2" onClick={download}>+ <DownloadIcon className="text-icon" /> Download</Button>- ) : null}+ {invoice.status === "draft" ? (+ <Button size="sm" variant="brand" className="px-2" onClick={send}>+ <SendIcon /> Send+ </Button>+ ) : invoice.status !== "paid" ? (+ <Button size="sm" variant="brand" className="px-2" onClick={markPaid}>+ <CheckIcon /> Mark as paid+ </Button>+ ) : null}+ </div></div>- <div className="overflow-y-auto scroll-thin p-4">+ <div className="overflow-y-auto scroll-thin p-4 max-sm:p-3">{/* The "paper": always reads like a printed document */}- <article className="flex flex-col gap-7 rounded-lg border border-hairline bg-surface p-8 shadow-[0_1px_2px_rgba(0,0,0,0.03)]">- <header className="flex items-start justify-between gap-6">+ <article className="flex flex-col gap-7 rounded-lg border border-hairline bg-surface p-8 shadow-[0_1px_2px_rgba(0,0,0,0.03)] max-sm:gap-6 max-sm:p-5">+ <header className="flex items-start justify-between gap-6 max-sm:flex-col max-sm:gap-5"><div className="flex flex-col gap-2.5"><h2 className="text-[24px] leading-none font-medium tracking-[-0.48px] text-heading">Invoice</h2><span className="t-14 text-fg-2">{invoice.number}</span><InvoiceStatusBadge status={status} className="mt-1 self-start" /></div>- <div className="flex flex-col items-end gap-1.5 text-right">+ <div className="flex flex-col items-end gap-1.5 text-right max-sm:items-start max-sm:text-left"><span className="t-14 text-fg">{profile.name}</span><span className="t-12 text-fg-2">{profile.email}</span><span className="t-12 max-w-[220px] leading-[1.35] text-fg-2">{profile.address}</span></div></header>- <dl className="grid grid-cols-3 gap-6 border-y border-hairline py-5">- <Meta label="Bill to" value={invoice.client} />+ <dl className="grid grid-cols-2 gap-x-6 gap-y-4 border-y border-hairline py-5 sm:grid-cols-3 sm:gap-6">+ <Meta label="Bill to" value={invoice.client} className="max-sm:col-span-2" /><Meta label="Issued" value={formatLong(invoice.issueDate)} /><Metalabel="Due"@@ -107,7 +107,21 @@ export function InvoiceView() {/></dl>- <table className="w-full border-collapse">+ {/* Phones: each line reads as description, then "qty × rate" and its amount */}+ <ul className="sm:hidden">+ {invoice.items.map((i) => (+ <li key={i.id} className="flex flex-col gap-2 border-b border-subtle py-3 first:pt-0">+ <span className="t-14 leading-[1.3] text-table">{i.description}</span>+ <span className="flex items-center justify-between gap-3">+ <span className="t-12 text-fg-2 tabular-nums">+ {i.quantity} × {formatMoney(i.rate, invoice.currency)}+ </span>+ <span className="t-14 text-table tabular-nums">{formatMoney(lineTotal(i), invoice.currency)}</span>+ </span>+ </li>+ ))}+ </ul>+ <table className="w-full border-collapse max-sm:hidden"><thead><tr className="border-b border-hairline"><th className="t-12 pb-2.5 text-left font-medium text-fg-2">Description</th>@@ -132,7 +146,7 @@ export function InvoiceView() {</tbody></table>- <dl className="ml-auto grid w-64 grid-cols-[1fr_auto] gap-x-4 gap-y-3">+ <dl className="ml-auto grid w-full grid-cols-[1fr_auto] gap-y-3 sm:w-64 sm:gap-x-4"><dt className="t-14 text-fg-2">Subtotal</dt><dd className="t-14 text-right text-table tabular-nums">{formatMoney(total, invoice.currency)}</dd><dt className="t-14 border-t border-hairline pt-3 text-fg">{status === "paid" ? "Total paid" : "Total due"}</dt>@@ -149,6 +163,50 @@ export function InvoiceView() {)}</article></div>++ {/* Phones: actions sit at the bottom of the sheet, within thumb reach */}+ <div className="flex items-center gap-2 border-t border-hairline bg-surface px-4 pt-3 pb-[max(12px,env(safe-area-inset-bottom))] sm:hidden">+ {invoice.status === "paid" ? (+ <>+ <Button className="h-10 flex-1" onClick={() => printInvoice(invoice, profile)}>+ <PrinterIcon className="text-icon" /> Print+ </Button>+ <Button className="h-10 flex-1" onClick={download}>+ <DownloadIcon className="text-icon" /> Download+ </Button>+ </>+ ) : (+ <>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button size="icon" className="size-10" aria-label="More actions">+ <Icon name="more" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" side="top" className="w-48 [&_[role^=menuitem]]:min-h-10">+ <DropdownMenuItem onSelect={() => edit(invoice.id)}>+ <PencilIcon /> Edit+ </DropdownMenuItem>+ <DropdownMenuItem onSelect={() => printInvoice(invoice, profile)}>+ <PrinterIcon /> Print+ </DropdownMenuItem>+ <DropdownMenuItem onSelect={download}>+ <DownloadIcon /> Download+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ {invoice.status === "draft" ? (+ <Button variant="brand" className="h-10 flex-1" onClick={send}>+ <SendIcon /> Send invoice+ </Button>+ ) : (+ <Button variant="brand" className="h-10 flex-1" onClick={markPaid}>+ <CheckIcon /> Mark as paid+ </Button>+ )}+ </>+ )}+ </div></>)}</DialogContent>@@ -156,9 +214,9 @@ export function InvoiceView() {);}-function Meta({ label, value, danger }: { label: string; value: string; danger?: boolean }) {+function Meta({ label, value, danger, className }: { label: string; value: string; danger?: boolean; className?: string }) {return (- <div className="flex flex-col gap-2">+ <div className={cn("flex min-w-0 flex-col gap-2", className)}><dt className="t-12 text-fg-2">{label}</dt><dd className={danger ? "t-14 text-danger" : "t-14 text-fg"}>{value}</dd></div>