TypeScript
feat: make Time tracking responsive
Vipul Kumar7d7c8e5288c8
diff --git a/src/components/pages/time-tracking/entry-dialog.tsx b/src/components/pages/time-tracking/entry-dialog.tsxindex 26491e7..a817b09 100644--- a/src/components/pages/time-tracking/entry-dialog.tsx+++ b/src/components/pages/time-tracking/entry-dialog.tsx@@ -30,7 +30,7 @@ type Props = {export function EntryDialog({ open, session, onClose, entry, defaultDate, projects }: Props) {return (<Dialog open={open} onOpenChange={(v) => !v && onClose()}>- <DialogContent className="gap-5 p-5 sm:max-w-[440px]">+ <DialogContent className="gap-5 p-5 max-sm:pb-0 sm:max-w-[440px]"><EntryForm key={session} entry={entry} defaultDate={defaultDate} projects={projects} onDone={onClose} /></DialogContent></Dialog>@@ -81,7 +81,7 @@ function EntryForm({</DialogHeader><div className="grid gap-4">- <div className="grid grid-cols-2 gap-3">+ <div className="grid gap-4 sm:grid-cols-2 sm:gap-3"><Field label="Date" htmlFor="te-date"><Input id="te-date" type="date" required value={date} onChange={(e) => setDate(e.target.value)} /></Field>@@ -150,7 +150,7 @@ function EntryForm({) : null}</div>- <DialogFooter className="-mx-5 -mb-5 bg-app px-5 py-3">+ <DialogFooter className="-mx-5 -mb-5 bg-app px-5 py-3 max-sm:mb-0 max-sm:pb-[max(12px,env(safe-area-inset-bottom))] max-sm:[&_button]:h-10"><Button type="button" onClick={onDone}>Cancel</Button>diff --git a/src/components/pages/time-tracking/time-tracking-page.tsx b/src/components/pages/time-tracking/time-tracking-page.tsxindex b6544d5..f7ba68a 100644--- a/src/components/pages/time-tracking/time-tracking-page.tsx+++ b/src/components/pages/time-tracking/time-tracking-page.tsx@@ -4,6 +4,14 @@ import { useMemo, useState } from "react";import { ClockIcon, PencilIcon, PlayIcon, PlusIcon, Trash2Icon } from "lucide-react";import { Icon } from "@/components/icon";import { Button } from "@/components/ui/button";+import {+ DropdownMenu,+ DropdownMenuCheckboxItem,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";import { Switch } from "@/components/ui/switch";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { addDays, formatRange, formatShort, formatWeekday, isoWeek, startOfWeek } from "@/lib/dates";@@ -12,7 +20,7 @@ import { useToday } from "@/hooks/use-today";import { useAppStore } from "@/stores/app-store";import { EntryDialog } from "./entry-dialog";import { BILLABLE_COLOR, formatHours, NON_BILLABLE_COLOR, projectColor, sumMinutes } from "./shared";-import { TimerCard } from "./timer-card";+import { TimerBar, TimerCard } from "./timer-card";import { ChartLegend, WeekChart, type DayTotal } from "./week-chart";type DialogState = { open: boolean; session: number; entry?: TimeEntry };@@ -65,51 +73,69 @@ export function TimeTrackingPage() {const billablePct = totals.total ? Math.round((totals.billable / totals.total) * 100) : 0;const openDialog = (entry?: TimeEntry) => setDialog((d) => ({ open: true, session: d.session + 1, entry }));+ // The table (md+) and the phone list each carry a day anchor; scroll to whichever is rendered.const scrollToDay = (date: string) =>- document.getElementById(`tt-day-${date}`)?.scrollIntoView({ behavior: "smooth", block: "start" });+ [`tt-day-${date}`, `tt-mday-${date}`]+ .map((id) => document.getElementById(id))+ .find((el) => el && el.offsetParent !== null)+ ?.scrollIntoView({ behavior: "smooth", block: "start" });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">+ {/* Phones: title above the week switcher; the header scrolls away to give the list room */}+ <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 flex-1 flex-col gap-1.5"><h2 className="t-16 text-fg">{isCurrentWeek ? "This week" : `Week ${isoWeek(weekStart)}`}</h2>- <p className="t-14 text-fg-2">+ <p className="t-14 truncate text-fg-2">{formatRange(weekStart, weekEnd)} · {formatHours(totals.total)} logged</p></div>- <div className="flex items-center gap-1">- <Button size="icon" aria-label="Previous week" onClick={() => setOffset((o) => o - 1)}>- <Icon name="arrow-left" />- </Button>- <Button disabled={isCurrentWeek} onClick={() => setOffset(0)}>- This week- </Button>- <Button size="icon" aria-label="Next week" onClick={() => setOffset((o) => o + 1)}>- <Icon name="arrow-left" className="rotate-180" />+ <div className="flex items-center gap-3">+ <div className="flex items-center gap-1">+ <Button+ size="icon"+ className="max-md:size-10"+ aria-label="Previous week"+ onClick={() => setOffset((o) => o - 1)}+ >+ <Icon name="arrow-left" />+ </Button>+ <Button className="max-md:h-10" disabled={isCurrentWeek} onClick={() => setOffset(0)}>+ This week+ </Button>+ <Button+ size="icon"+ className="max-md:size-10"+ aria-label="Next week"+ onClick={() => setOffset((o) => o + 1)}+ >+ <Icon name="arrow-left" className="rotate-180" />+ </Button>+ </div>+ <div className="h-4 w-px bg-hairline max-md:hidden" aria-hidden />+ <Button variant="brand" className="max-md:ml-auto max-md:h-10" onClick={() => openDialog()}>+ <PlusIcon /> Add entry</Button></div>- <div className="h-4 w-px bg-hairline" aria-hidden />- <Button variant="brand" onClick={() => openDialog()}>- <PlusIcon /> Add entry- </Button></header>- <div className="flex flex-col gap-4 p-4">+ <div className="flex flex-1 flex-col gap-4 p-4"><TimerCard projects={projects} todayMinutes={todayMinutes} />- <section className="grid grid-cols-[1fr_260px] overflow-hidden rounded-xl border border-hairline bg-surface">- <div className="flex flex-col gap-5 p-4">- <div className="flex items-center justify-between">+ <section className="grid grid-cols-1 overflow-hidden rounded-xl border border-hairline bg-surface md:grid-cols-[1fr_260px]">+ <div className="flex min-w-0 flex-col gap-5 p-4">+ <div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-2"><h3 className="t-14 text-fg">Hours per day</h3><ChartLegend /></div><WeekChart days={days} today={today} onSelectDay={scrollToDay} /></div>- <dl className="flex flex-col border-l border-hairline">+ {/* Phones: the three totals sit in a row under the chart */}+ <dl className="grid grid-cols-3 border-t border-hairline md:flex md:flex-col md:border-t-0 md:border-l"><Stat label="Total" value={formatHours(totals.total)} /><Stat label="Billable" value={formatHours(totals.billable)} color={BILLABLE_COLOR} /><Stat label="Non-billable" value={formatHours(totals.nonBillable)} color={NON_BILLABLE_COLOR} />- <div className="mt-auto flex flex-col gap-2 border-t border-hairline p-4">+ <div className="col-span-3 mt-auto flex flex-col gap-2 border-t border-hairline p-4"><div className="flex items-center justify-between"><span className="t-12 text-fg-2">Billable ratio</span><span className="t-12 text-fg tabular-nums">{billablePct}%</span>@@ -147,87 +173,145 @@ export function TimeTrackingPage() {</Button></div>) : (- <table className="w-full table-fixed border-collapse">- <colgroup>- <col />- <col className="w-[200px]" />- <col className="w-[110px]" />- <col className="w-[100px]" />- <col className="w-[112px]" />- </colgroup>- <thead>- <tr className="h-10 bg-app text-left">- <th className="t-14 px-4 font-medium text-fg-2">Task</th>- <th className="t-14 px-2 font-medium text-fg-2">Project</th>- <th className="t-14 px-2 font-medium text-fg-2">Billable</th>- <th className="t-14 px-2 text-right font-medium text-fg-2">Duration</th>- <th className="px-4">- <span className="sr-only">Actions</span>- </th>- </tr>- </thead>- {groups.map(([date, list]) => (- <tbody key={date}>- <tr id={`tt-day-${date}`} className="h-9 scroll-mt-[76px] border-y border-subtle bg-surface">- <th colSpan={3} className="px-4 text-left font-medium">- <span className="t-12 text-fg">{formatWeekday(date)}</span>- <span className="t-12 ml-1.5 text-fg-2">- {formatShort(date)}- {date === today && " · Today"}+ <>+ <ul className="md:hidden">+ {groups.map(([date, list]) => (+ <li key={date}>+ <div+ id={`tt-mday-${date}`}+ className="flex h-9 scroll-mt-3 items-center justify-between border-b border-subtle bg-app px-4"+ >+ <span className="t-12">+ <span className="text-fg">{formatWeekday(date)}</span>+ <span className="ml-1.5 text-fg-2">+ {formatShort(date)}+ {date === today && " · Today"}+ </span>+ </span>+ <span className="t-12 text-fg-2 tabular-nums">+ {formatHours(list.reduce((n, e) => n + e.minutes, 0))}</span>+ </div>+ <ul>+ {list.map((e) => (+ <li key={e.id} className="flex items-center border-b border-subtle">+ <button+ type="button"+ aria-label={`Edit ${e.task}`}+ className="flex min-h-14 min-w-0 flex-1 items-center gap-3 py-2.5 pl-4 text-left outline-none focus-visible:bg-hover"+ onClick={() => openDialog(e)}+ >+ <span className="flex min-w-0 flex-1 flex-col gap-1.5">+ <span className="t-14 truncate text-table">{e.task}</span>+ <span className="t-12 flex min-w-0 items-center gap-1.5 text-fg-2">+ <span+ className="size-2 shrink-0 rounded-full"+ style={{ background: `var(--event-${projectColor(e.project)}-fg)` }}+ />+ <span className="truncate">{e.project}</span>+ <span className="shrink-0">· {e.billable ? "Billable" : "Non-billable"}</span>+ </span>+ </span>+ <span className="t-14 shrink-0 text-table tabular-nums">{formatHours(e.minutes)}</span>+ </button>+ <EntryMenu+ entry={e}+ timerRunning={timerRunning}+ onResume={() => startTimer(e.project, e.task)}+ onEdit={() => openDialog(e)}+ onToggleBillable={(v) => saveTimeEntry({ ...e, billable: v })}+ onDelete={() => deleteTimeEntry(e.id)}+ />+ </li>+ ))}+ </ul>+ </li>+ ))}+ </ul>+ <table className="w-full table-fixed border-collapse max-md:hidden">+ <colgroup>+ <col />+ <col className="w-[200px]" />+ <col className="w-[110px]" />+ <col className="w-[100px]" />+ <col className="w-[112px]" />+ </colgroup>+ <thead>+ <tr className="h-10 bg-app text-left">+ <th className="t-14 px-4 font-medium text-fg-2">Task</th>+ <th className="t-14 px-2 font-medium text-fg-2">Project</th>+ <th className="t-14 px-2 font-medium text-fg-2">Billable</th>+ <th className="t-14 px-2 text-right font-medium text-fg-2">Duration</th>+ <th className="px-4">+ <span className="sr-only">Actions</span></th>- <td className="t-12 px-2 text-right text-fg-2 tabular-nums">- {formatHours(list.reduce((n, e) => n + e.minutes, 0))}- </td>- <td /></tr>- {list.map((e) => (- <tr key={e.id} className="h-14 border-b border-subtle transition-colors duration-150 hover-fine:bg-hover/50">- <td className="t-14 truncate px-4 text-table">{e.task}</td>- <td className="px-2">- <span className="t-14 flex min-w-0 items-center gap-2 text-table">- <span- className="size-2 shrink-0 rounded-full"- style={{ background: `var(--event-${projectColor(e.project)}-fg)` }}- />- <span className="truncate">{e.project}</span>+ </thead>+ {groups.map(([date, list]) => (+ <tbody key={date}>+ <tr id={`tt-day-${date}`} className="h-9 scroll-mt-[76px] border-y border-subtle bg-surface">+ <th colSpan={3} className="px-4 text-left font-medium">+ <span className="t-12 text-fg">{formatWeekday(date)}</span>+ <span className="t-12 ml-1.5 text-fg-2">+ {formatShort(date)}+ {date === today && " · Today"}</span>+ </th>+ <td className="t-12 px-2 text-right text-fg-2 tabular-nums">+ {formatHours(list.reduce((n, e) => n + e.minutes, 0))}</td>- <td className="px-2">- <Switch- size="sm"- checked={e.billable}- aria-label={`Billable: ${e.task}`}- onCheckedChange={(v) => saveTimeEntry({ ...e, billable: v })}- />- </td>- <td className="t-14 px-2 text-right text-table tabular-nums">{formatHours(e.minutes)}</td>- <td className="px-4">- <div className="flex items-center justify-end gap-0.5">- <RowAction- label="Resume timer"- disabled={timerRunning}- onClick={() => startTimer(e.project, e.task)}- >- <PlayIcon />- </RowAction>- <RowAction label="Edit entry" onClick={() => openDialog(e)}>- <PencilIcon />- </RowAction>- <RowAction label="Delete entry" onClick={() => deleteTimeEntry(e.id)}>- <Trash2Icon />- </RowAction>- </div>- </td>+ <td /></tr>- ))}- </tbody>- ))}- </table>+ {list.map((e) => (+ <tr key={e.id} className="h-14 border-b border-subtle transition-colors duration-150 hover-fine:bg-hover/50">+ <td className="t-14 truncate px-4 text-table">{e.task}</td>+ <td className="px-2">+ <span className="t-14 flex min-w-0 items-center gap-2 text-table">+ <span+ className="size-2 shrink-0 rounded-full"+ style={{ background: `var(--event-${projectColor(e.project)}-fg)` }}+ />+ <span className="truncate">{e.project}</span>+ </span>+ </td>+ <td className="px-2">+ <Switch+ size="sm"+ checked={e.billable}+ aria-label={`Billable: ${e.task}`}+ onCheckedChange={(v) => saveTimeEntry({ ...e, billable: v })}+ />+ </td>+ <td className="t-14 px-2 text-right text-table tabular-nums">{formatHours(e.minutes)}</td>+ <td className="px-4">+ <div className="flex items-center justify-end gap-0.5">+ <RowAction+ label="Resume timer"+ disabled={timerRunning}+ onClick={() => startTimer(e.project, e.task)}+ >+ <PlayIcon />+ </RowAction>+ <RowAction label="Edit entry" onClick={() => openDialog(e)}>+ <PencilIcon />+ </RowAction>+ <RowAction label="Delete entry" onClick={() => deleteTimeEntry(e.id)}>+ <Trash2Icon />+ </RowAction>+ </div>+ </td>+ </tr>+ ))}+ </tbody>+ ))}+ </table>+ </>)}</section></div>+ <TimerBar todayMinutes={todayMinutes} />+<EntryDialogopen={dialog.open}session={dialog.session}@@ -242,9 +326,10 @@ export function TimeTrackingPage() {function Stat({ label, value, color }: { label: string; value: string; color?: string }) {return (- <div className="flex flex-col gap-2 border-b border-hairline px-4 py-3.5 last:border-b-0">- <dt className="t-12 flex items-center gap-1.5 text-fg-2">- {color && <span className="size-2 rounded-[2px]" style={{ background: color }} />}+ <div className="flex min-w-0 flex-col gap-2 border-hairline px-4 py-3.5 not-nth-3:border-r max-md:px-3 md:border-b md:not-nth-3:border-r-0">+ <dt className="t-12 flex items-center gap-1.5 whitespace-nowrap text-fg-2">+ {/* The chart legend already maps colours; the narrowest phones drop the swatch to keep labels on one line */}+ {color && <span className="size-2 shrink-0 rounded-[2px] max-[359px]:hidden" style={{ background: color }} />}{label}</dt><dd className="text-[20px] leading-none font-medium tracking-[-0.4px] text-fg tabular-nums">{value}</dd>@@ -274,3 +359,45 @@ function RowAction({</Tooltip>);}++/** Phone row actions: everything the table's inline buttons and switch do. */+function EntryMenu({+ entry,+ timerRunning,+ onResume,+ onEdit,+ onToggleBillable,+ onDelete,+}: {+ entry: TimeEntry;+ timerRunning: boolean;+ onResume: () => void;+ onEdit: () => void;+ onToggleBillable: (billable: boolean) => void;+ onDelete: () => void;+}) {+ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="ghost" size="icon" className="mx-1.5 size-10 shrink-0" aria-label={`Actions for ${entry.task}`}>+ <Icon name="more" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-52 [&_[role^=menuitem]]:min-h-10">+ <DropdownMenuItem disabled={timerRunning} onSelect={onResume}>+ <PlayIcon /> Resume timer+ </DropdownMenuItem>+ <DropdownMenuItem onSelect={onEdit}>+ <PencilIcon /> Edit+ </DropdownMenuItem>+ <DropdownMenuCheckboxItem checked={entry.billable} onCheckedChange={onToggleBillable}>+ Billable+ </DropdownMenuCheckboxItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem variant="destructive" onSelect={onDelete}>+ <Trash2Icon /> Delete+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+}diff --git a/src/components/pages/time-tracking/timer-card.tsx b/src/components/pages/time-tracking/timer-card.tsxindex 05bf834..0f7ad8f 100644--- a/src/components/pages/time-tracking/timer-card.tsx+++ b/src/components/pages/time-tracking/timer-card.tsx@@ -8,6 +8,9 @@ import { cn } from "@/lib/utils";import { useAppStore } from "@/stores/app-store";import { formatClock, formatHours } from "./shared";+/** The phone bar submits the card's form from outside it via the `form` attribute. */+const FORM_ID = "tt-timer-form";+/** Ticks once a second while the timer runs; `useNow()` only refreshes every 30s. */function useElapsed(running: boolean, startedAt: number | null): number {const [now, setNow] = useState(0);@@ -30,7 +33,6 @@ export function TimerCard({ projects, todayMinutes }: { projects: string[]; todaconst startTimer = useAppStore((s) => s.startTimer);const stopTimer = useAppStore((s) => s.stopTimer);const updateTimer = useAppStore((s) => s.updateTimer);- const elapsed = useElapsed(timer.running, timer.startedAt);const start = () => startTimer(timer.project.trim() || "General", timer.task.trim());@@ -43,7 +45,8 @@ export function TimerCard({ projects, todayMinutes }: { projects: string[]; toda)}><form- className="flex min-w-0 flex-1 items-center gap-2"+ id={FORM_ID}+ className="flex min-w-0 flex-1 flex-col gap-2 md:flex-row md:items-center"onSubmit={(e) => {e.preventDefault();if (timer.running) stopTimer();@@ -54,14 +57,14 @@ export function TimerCard({ projects, todayMinutes }: { projects: string[]; todaaria-label="Project"placeholder="Project"list="tt-projects"- className="h-[30px] w-52"+ className="h-10 text-[16px] md:h-[30px] md:w-52 md:text-[14px]"value={timer.project}onChange={(e) => updateTimer({ project: e.target.value })}/><Inputaria-label="Task"placeholder="What are you working on?"- className="h-[30px] min-w-0 flex-1"+ className="h-10 min-w-0 text-[16px] md:h-[30px] md:flex-1 md:text-[14px]"value={timer.task}onChange={(e) => updateTimer({ task: e.target.value })}/>@@ -70,40 +73,69 @@ export function TimerCard({ projects, todayMinutes }: { projects: string[]; toda<option key={p} value={p} />))}</datalist>- <div className="flex shrink-0 items-center gap-3 pl-2">- <div className="flex flex-col items-end gap-1.5">- <span- className={cn(- "text-[22px] leading-none font-medium tracking-[-0.44px] tabular-nums",- timer.running ? "text-fg" : "text-placeholder",- )}- role="timer"- aria-live="off"- >- {formatClock(elapsed)}- </span>- <span className="t-12 flex items-center gap-1.5 text-fg-2">- {timer.running ? (- <>- <span className="size-1.5 animate-pulse rounded-full bg-danger" aria-hidden />- Recording- </>- ) : (- <>Today · {formatHours(todayMinutes)}</>- )}- </span>- </div>+ {/* Phones get the clock and Start/Stop in the sticky bottom bar instead */}+ <TimerControls todayMinutes={todayMinutes} className="max-md:hidden" />+ </form>+ </section>+ );+}++/** Sticky bottom bar on phones: elapsed time and Start/Stop within thumb reach. */+export function TimerBar({ todayMinutes }: { todayMinutes: number }) {+ return (+ <div className="sticky bottom-0 z-10 border-t border-hairline bg-surface px-4 pt-3 pb-[max(12px,env(safe-area-inset-bottom))] md:hidden">+ <TimerControls todayMinutes={todayMinutes} variant="bar" />+ </div>+ );+}++function TimerControls({+ todayMinutes,+ variant = "card",+ className,+}: {+ todayMinutes: number;+ variant?: "card" | "bar";+ className?: string;+}) {+ const timer = useAppStore((s) => s.timer);+ const elapsed = useElapsed(timer.running, timer.startedAt);+ const bar = variant === "bar";+ const label = [timer.project.trim(), timer.task.trim()].filter(Boolean).join(" · ");++ return (+ <div className={cn("flex shrink-0 items-center gap-3", bar ? "w-full" : "pl-2", className)}>+ <div className={cn("flex min-w-0 flex-col gap-1.5", bar ? "flex-1 items-start" : "items-end")}>+ <span+ className={cn(+ "text-[22px] leading-none font-medium tracking-[-0.44px] tabular-nums",+ timer.running ? "text-fg" : "text-placeholder",+ )}+ role={bar ? undefined : "timer"}+ aria-live="off"+ >+ {formatClock(elapsed)}+ </span>+ <span className="t-12 flex max-w-full min-w-0 items-center gap-1.5 text-fg-2">{timer.running ? (- <Button type="submit" variant="destructive" className="w-[84px]">- <SquareIcon className="fill-current" /> Stop- </Button>+ <>+ <span className="size-1.5 shrink-0 animate-pulse rounded-full bg-danger" aria-hidden />+ <span className="truncate">{bar && label ? label : "Recording"}</span>+ </>) : (- <Button type="submit" variant="brand" className="w-[84px]">- <PlayIcon className="fill-current" /> Start- </Button>+ <>Today · {formatHours(todayMinutes)}</>)}- </div>- </form>- </section>+ </span>+ </div>+ {timer.running ? (+ <Button type="submit" form={FORM_ID} variant="destructive" className={bar ? "h-10 w-[104px]" : "w-[84px]"}>+ <SquareIcon className="fill-current" /> Stop+ </Button>+ ) : (+ <Button type="submit" form={FORM_ID} variant="brand" className={bar ? "h-10 w-[104px]" : "w-[84px]"}>+ <PlayIcon className="fill-current" /> Start+ </Button>+ )}+ </div>);}diff --git a/src/components/pages/time-tracking/week-chart.tsx b/src/components/pages/time-tracking/week-chart.tsxindex b1c8222..4b9ed62 100644--- a/src/components/pages/time-tracking/week-chart.tsx+++ b/src/components/pages/time-tracking/week-chart.tsx@@ -35,7 +35,7 @@ export function WeekChart({<span className="t-12 absolute -top-2 right-0 bg-surface pl-1.5 text-section">8h</span></div><div aria-hidden className="absolute inset-x-0 bottom-0 border-t border-hairline" />- <div className="relative grid h-full grid-cols-7 gap-2 pr-6">+ <div className="relative grid h-full grid-cols-7 gap-1 pr-6 sm:gap-2">{days.map((d) => {const total = d.billable + d.nonBillable;const bH = px(d.billable);@@ -51,11 +51,13 @@ export function WeekChart({className="group flex h-full flex-col items-center justify-end rounded-md outline-none focus-visible:ring-3 focus-visible:ring-brand/15 disabled:cursor-default">{total > 0 && (- <span className="t-12 mb-1.5 text-fg-2 tabular-nums transition-colors duration-150 group-hover:text-fg">- {formatHours(total)}+ <span className="t-12 mb-1.5 whitespace-nowrap text-fg-2 tabular-nums transition-colors duration-150 hover-fine:group-hover:text-fg">+ {/* Phones: "7.5h" keeps seven labels inside their columns */}+ <span className="sm:hidden">{compactHours(total)}</span>+ <span className="max-sm:hidden">{formatHours(total)}</span></span>)}- <span className="flex w-7 flex-col justify-end gap-[2px]">+ <span className="flex w-full max-w-7 flex-col justify-end gap-[2px]">{nH > 0 && (<spanclassName="block w-full rounded-t-[4px]"@@ -87,7 +89,7 @@ export function WeekChart({})}</div></div>- <div className="grid grid-cols-7 gap-2 pr-6">+ <div className="grid grid-cols-7 gap-1 pr-6 sm:gap-2">{days.map((d) => {const isToday = d.date === today;return (@@ -111,6 +113,11 @@ export function WeekChart({);}+/** 450 → "7.5h", 480 → "8h", 25 → "25m" */+function compactHours(minutes: number): string {+ return minutes < 60 ? `${minutes}m` : `${Math.round((minutes / 60) * 10) / 10}h`;+}+export function ChartLegend() {return (<div className="flex items-center gap-3">