🍅 pomodoro page redesign with focus console and today stats
Browse files at this commitb92c7654ead93fb37b0f212050cff977ec56336aParent: b6bbea6- feat
- 🍅 pomodoro page redesign with focus console and today stats
2 changed files +104 -38
- src/i18n/messages.ts +27 -0
- src/pages/pomodoro-page.tsx +77 -38
src/i18n/messages.tsmodified+27 -0
| @@ -413,6 +413,15 @@ export type MessageKey = | |||
| 413 | | "pomodoro.startedAt" | 413 | | "pomodoro.startedAt" |
| 414 | | "pomodoro.finishedAt" | 414 | | "pomodoro.finishedAt" |
| 415 | | "pomodoro.duration" | 415 | | "pomodoro.duration" |
| 416 | + | "pomodoro.focusConsole" | ||
| 417 | + | "pomodoro.current" | ||
| 418 | + | "pomodoro.today" | ||
| 419 | + | "pomodoro.average" | ||
| 420 | + | "pomodoro.sessions" | ||
| 421 | + | "pomodoro.idleHelp" | ||
| 422 | + | "pomodoro.runningSince" | ||
| 423 | + | "pomodoro.lastSession" | ||
| 424 | + | "pomodoro.noRecentSession" | ||
| 416 | | "attempt.title" | 425 | | "attempt.title" |
| 417 | | "attempt.openRoom" | 426 | | "attempt.openRoom" |
| 418 | | "attempt.start" | 427 | | "attempt.start" |
| @@ -1141,6 +1150,15 @@ const en: Dict = { | |||
| 1141 | "pomodoro.startedAt": "Started", | 1150 | "pomodoro.startedAt": "Started", |
| 1142 | "pomodoro.finishedAt": "Finished", | 1151 | "pomodoro.finishedAt": "Finished", |
| 1143 | "pomodoro.duration": "Duration", | 1152 | "pomodoro.duration": "Duration", |
| 1153 | + "pomodoro.focusConsole": "Focus console", | ||
| 1154 | + "pomodoro.current": "Current focus", | ||
| 1155 | + "pomodoro.today": "Today", | ||
| 1156 | + "pomodoro.average": "Average", | ||
| 1157 | + "pomodoro.sessions": "Sessions", | ||
| 1158 | + "pomodoro.idleHelp": "Ready when you are. Start one focused study block.", | ||
| 1159 | + "pomodoro.runningSince": "Started {time}", | ||
| 1160 | + "pomodoro.lastSession": "Last finished {time}", | ||
| 1161 | + "pomodoro.noRecentSession": "No completed session yet.", | ||
| 1144 | "attempt.title": "Exam room", | 1162 | "attempt.title": "Exam room", |
| 1145 | "attempt.openRoom": "Open exam room", | 1163 | "attempt.openRoom": "Open exam room", |
| 1146 | "attempt.start": "Start exam", | 1164 | "attempt.start": "Start exam", |
| @@ -1874,6 +1892,15 @@ const tr: Dict = { | |||
| 1874 | "pomodoro.startedAt": "Başlangıç", | 1892 | "pomodoro.startedAt": "Başlangıç", |
| 1875 | "pomodoro.finishedAt": "Bitiş", | 1893 | "pomodoro.finishedAt": "Bitiş", |
| 1876 | "pomodoro.duration": "Süre", | 1894 | "pomodoro.duration": "Süre", |
| 1895 | + "pomodoro.focusConsole": "Odak paneli", | ||
| 1896 | + "pomodoro.current": "Mevcut odak", | ||
| 1897 | + "pomodoro.today": "Bugün", | ||
| 1898 | + "pomodoro.average": "Ortalama", | ||
| 1899 | + "pomodoro.sessions": "Oturum", | ||
| 1900 | + "pomodoro.idleHelp": "Hazır olduğunda tek bir odaklı çalışma bloğu başlat.", | ||
| 1901 | + "pomodoro.runningSince": "Başlangıç: {time}", | ||
| 1902 | + "pomodoro.lastSession": "Son bitiş: {time}", | ||
| 1903 | + "pomodoro.noRecentSession": "Henüz tamamlanmış oturum yok.", | ||
| 1877 | "attempt.title": "Sınav odası", | 1904 | "attempt.title": "Sınav odası", |
| 1878 | "attempt.openRoom": "Sınav odasını aç", | 1905 | "attempt.openRoom": "Sınav odasını aç", |
| 1879 | "attempt.start": "Sınava başla", | 1906 | "attempt.start": "Sınava başla", |
src/pages/pomodoro-page.tsxmodified+77 -38
| @@ -10,7 +10,7 @@ import { Alert } from "@/components/ui/alert"; | |||
| 10 | import { Badge } from "@/components/ui/badge"; | 10 | import { Badge } from "@/components/ui/badge"; |
| 11 | import { Button } from "@/components/ui/button"; | 11 | import { Button } from "@/components/ui/button"; |
| 12 | import { DataTable } from "@/components/ui/data-table"; | 12 | import { DataTable } from "@/components/ui/data-table"; |
| 13 | -import { IconClock } from "@/components/ui/icons"; | 13 | +import { IconCheck, IconClock } from "@/components/ui/icons"; |
| 14 | import { PageSpinner } from "@/components/ui/page-spinner"; | 14 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 15 | import { createFlash } from "@/lib/flash"; | 15 | import { createFlash } from "@/lib/flash"; |
| 16 | import { createNow } from "@/lib/create-now"; | 16 | import { createNow } from "@/lib/create-now"; |
| @@ -38,6 +38,19 @@ function PomodoroContent() { | |||
| 38 | const current = running(); | 38 | const current = running(); |
| 39 | return current ? now() - current.started_at : null; | 39 | return current ? now() - current.started_at : null; |
| 40 | }); | 40 | }); |
| 41 | + const finishedSessions = createMemo(() => (log()?.items ?? []).filter((item) => item.finished_at != null)); | ||
| 42 | + const todayFocus = createMemo(() => { | ||
| 43 | + const start = new Date(now()); | ||
| 44 | + start.setHours(0, 0, 0, 0); | ||
| 45 | + const startMs = start.getTime(); | ||
| 46 | + return finishedSessions().reduce((total, item) => item.started_at >= startMs ? total + (item.duration_ms ?? 0) : total, 0); | ||
| 47 | + }); | ||
| 48 | + const averageFocus = createMemo(() => { | ||
| 49 | + const items = finishedSessions(); | ||
| 50 | + if (items.length === 0) return null; | ||
| 51 | + return Math.round(items.reduce((total, item) => total + (item.duration_ms ?? 0), 0) / items.length); | ||
| 52 | + }); | ||
| 53 | + const lastFinished = createMemo(() => finishedSessions()[0]?.finished_at ?? null); | ||
| 41 | const columns = createMemo<ColumnDef<NonNullable<ReturnType<typeof log>>["items"][number]>[]>(() => [ | 54 | const columns = createMemo<ColumnDef<NonNullable<ReturnType<typeof log>>["items"][number]>[]>(() => [ |
| 42 | { | 55 | { |
| 43 | accessorKey: "started_at", | 56 | accessorKey: "started_at", |
| @@ -77,20 +90,6 @@ function PomodoroContent() { | |||
| 77 | eyebrow={t("nav.pomodoro")} | 90 | eyebrow={t("nav.pomodoro")} |
| 78 | title={t("pomodoro.title")} | 91 | title={t("pomodoro.title")} |
| 79 | description={t("pomodoro.subtitle")} | 92 | description={t("pomodoro.subtitle")} |
| 80 | - actions={ | ||
| 81 | - <Show | ||
| 82 | - when={running()} | ||
| 83 | - fallback={ | ||
| 84 | - <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" disabled={pending()} onClick={() => void run(postPomodoroStart, t("pomodoro.started"))}> | ||
| 85 | - {t("pomodoro.start")} | ||
| 86 | - </Button> | ||
| 87 | - } | ||
| 88 | - > | ||
| 89 | - <Button type="button" size="sm" variant="outline" class="min-w-[7.5rem] rounded-lg" disabled={pending()} onClick={() => void run(postPomodoroFinish, t("pomodoro.finished"))}> | ||
| 90 | - {t("pomodoro.finish")} | ||
| 91 | - </Button> | ||
| 92 | - </Show> | ||
| 93 | - } | ||
| 94 | /> | 93 | /> |
| 95 | 94 | ||
| 96 | <Show when={flash()}> | 95 | <Show when={flash()}> |
| @@ -98,38 +97,78 @@ function PomodoroContent() { | |||
| 98 | </Show> | 97 | </Show> |
| 99 | {error() && <Alert variant="destructive">{error()}</Alert>} | 98 | {error() && <Alert variant="destructive">{error()}</Alert>} |
| 100 | 99 | ||
| 101 | - <section class="grid gap-3 sm:grid-cols-2"> | 100 | + <section class="grid gap-4 xl:grid-cols-[minmax(0,1.45fr)_minmax(18rem,0.55fr)]"> |
| 102 | - <Show | 101 | + <div class="overflow-hidden rounded-2xl border border-border bg-card shadow-sm"> |
| 103 | - when={running()} | 102 | + <div class="flex flex-wrap items-center justify-between gap-3 border-b border-border/70 px-5 py-4"> |
| 104 | - fallback={ | 103 | + <div class="flex min-w-0 items-center gap-3"> |
| 105 | - <div class="detail-metric-card"> | 104 | + <span class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border bg-muted/40 text-muted-foreground"> |
| 106 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("pomodoro.total")}</p> | 105 | + <IconClock class="h-5 w-5" /> |
| 107 | - <p class="mono mt-2 text-3xl font-semibold tabular-nums">{formatDurationClock(log()?.total_focus_ms)}</p> | ||
| 108 | - </div> | ||
| 109 | - } | ||
| 110 | - > | ||
| 111 | - <div class="detail-metric-card overflow-hidden border-emerald-500/25 bg-[radial-gradient(circle_at_top_right,rgba(16,185,129,0.16),transparent_38%)]"> | ||
| 112 | - <div class="flex items-center gap-2 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground"> | ||
| 113 | - <span class="flex h-7 w-7 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"> | ||
| 114 | - <IconClock class="h-3.5 w-3.5" /> | ||
| 115 | </span> | 106 | </span> |
| 116 | - {t("pomodoro.running")} | 107 | + <div class="min-w-0"> |
| 108 | + <p class="text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground">{t("pomodoro.focusConsole")}</p> | ||
| 109 | + <p class="mt-1 truncate text-sm text-muted-foreground"> | ||
| 110 | + <Show when={running()} fallback={t("pomodoro.idleHelp")}> | ||
| 111 | + {(session) => t("pomodoro.runningSince", { time: formatDateTime(session().started_at, locale()) })} | ||
| 112 | + </Show> | ||
| 113 | + </p> | ||
| 114 | + </div> | ||
| 117 | </div> | 115 | </div> |
| 118 | - <p class="mono mt-4 text-5xl font-semibold leading-none tracking-tight tabular-nums sm:text-6xl">{formatDurationClock(runningDuration())}</p> | 116 | + <Badge variant={running() ? "default" : "secondary"} class="rounded-lg px-3 py-1 text-sm"> |
| 119 | - </div> | ||
| 120 | - </Show> | ||
| 121 | - <div class="detail-metric-card"> | ||
| 122 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("attempt.status")}</p> | ||
| 123 | - <div class="mt-2 flex flex-wrap items-center gap-2"> | ||
| 124 | - <Badge variant={running() ? "default" : "secondary"} class="rounded-md px-3 py-1 text-sm"> | ||
| 125 | {running() ? t("pomodoro.running") : t("pomodoro.idle")} | 117 | {running() ? t("pomodoro.running") : t("pomodoro.idle")} |
| 126 | </Badge> | 118 | </Badge> |
| 127 | </div> | 119 | </div> |
| 120 | + | ||
| 121 | + <div class="grid gap-4 p-5 md:grid-cols-[minmax(0,1fr)_auto] md:items-end"> | ||
| 122 | + <div> | ||
| 123 | + <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{running() ? t("pomodoro.current") : t("pomodoro.total")}</p> | ||
| 124 | + <p class="mono mt-3 text-6xl font-semibold leading-none tracking-tight tabular-nums sm:text-7xl"> | ||
| 125 | + {formatDurationClock(running() ? runningDuration() : log()?.total_focus_ms)} | ||
| 126 | + </p> | ||
| 127 | + </div> | ||
| 128 | + <Show | ||
| 129 | + when={running()} | ||
| 130 | + fallback={ | ||
| 131 | + <Button type="button" size="sm" class="h-12 min-w-[10rem] rounded-xl text-base" disabled={pending()} onClick={() => void run(postPomodoroStart, t("pomodoro.started"))}> | ||
| 132 | + <IconClock class="h-4 w-4" /> | ||
| 133 | + {t("pomodoro.start")} | ||
| 134 | + </Button> | ||
| 135 | + } | ||
| 136 | + > | ||
| 137 | + <Button type="button" size="sm" variant="outline" class="h-12 min-w-[10rem] rounded-xl text-base" disabled={pending()} onClick={() => void run(postPomodoroFinish, t("pomodoro.finished"))}> | ||
| 138 | + <IconCheck class="h-4 w-4" /> | ||
| 139 | + {t("pomodoro.finish")} | ||
| 140 | + </Button> | ||
| 141 | + </Show> | ||
| 142 | + </div> | ||
| 143 | + </div> | ||
| 144 | + | ||
| 145 | + <div class="grid gap-3 sm:grid-cols-3 xl:grid-cols-1"> | ||
| 146 | + <div class="detail-metric-card"> | ||
| 147 | + <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("pomodoro.today")}</p> | ||
| 148 | + <p class="mono mt-2 text-2xl font-semibold tabular-nums">{formatDurationClock(todayFocus())}</p> | ||
| 149 | + </div> | ||
| 150 | + <div class="detail-metric-card"> | ||
| 151 | + <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("pomodoro.average")}</p> | ||
| 152 | + <p class="mono mt-2 text-2xl font-semibold tabular-nums">{formatDurationClock(averageFocus())}</p> | ||
| 153 | + </div> | ||
| 154 | + <div class="detail-metric-card"> | ||
| 155 | + <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("pomodoro.sessions")}</p> | ||
| 156 | + <p class="mono mt-2 text-2xl font-semibold tabular-nums">{log()?.total ?? 0}</p> | ||
| 157 | + </div> | ||
| 128 | </div> | 158 | </div> |
| 129 | </section> | 159 | </section> |
| 130 | 160 | ||
| 131 | <section class="data-shell space-y-4 p-4"> | 161 | <section class="data-shell space-y-4 p-4"> |
| 132 | - <h2 class="font-display text-lg font-semibold">{t("pomodoro.history")}</h2> | 162 | + <div class="flex flex-wrap items-end justify-between gap-2"> |
| 163 | + <div> | ||
| 164 | + <h2 class="font-display text-lg font-semibold">{t("pomodoro.history")}</h2> | ||
| 165 | + <p class="mt-1 text-sm text-muted-foreground"> | ||
| 166 | + <Show when={lastFinished()} fallback={t("pomodoro.noRecentSession")}> | ||
| 167 | + {(at) => t("pomodoro.lastSession", { time: formatDateTime(at(), locale()) })} | ||
| 168 | + </Show> | ||
| 169 | + </p> | ||
| 170 | + </div> | ||
| 171 | + </div> | ||
| 133 | <Suspense fallback={<PageSpinner />}> | 172 | <Suspense fallback={<PageSpinner />}> |
| 134 | <DataTable columns={columns()} data={log()?.items ?? []} empty={t("pomodoro.empty")} enablePagination pageSize={10} /> | 173 | <DataTable columns={columns()} data={log()?.items ?? []} empty={t("pomodoro.empty")} enablePagination pageSize={10} /> |
| 135 | </Suspense> | 174 | </Suspense> |