From b92c7654ead93fb37b0f212050cff977ec56336a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Wed, 22 Jul 2026 11:21:29 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8D=85=20pomodoro=20page=20redesi?= =?UTF-8?q?gn=20with=20focus=20console=20and=20today=20stats=20-=20replace?= =?UTF-8?q?=20metric=20cards=20with=20a=20focus=20console=20card=20(curren?= =?UTF-8?q?t=20timer=20+=20start/finish)=20-=20add=20today,=20average,=20a?= =?UTF-8?q?nd=20session=20count=20stat=20cards=20-=20show=20last=20finishe?= =?UTF-8?q?d=20session=20and=20idle=20help=20text=20-=20move=20start/finis?= =?UTF-8?q?h=20button=20from=20page=20header=20into=20the=20console=20card?= =?UTF-8?q?=20-=20add=20i18n=20keys=20for=20new=20labels=20and=20help=20te?= =?UTF-8?q?xt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/messages.ts | 27 +++++++++ src/pages/pomodoro-page.tsx | 115 ++++++++++++++++++++++++------------ 2 files changed, 104 insertions(+), 38 deletions(-) diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 41db7f5..c497472 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -413,6 +413,15 @@ export type MessageKey = | "pomodoro.startedAt" | "pomodoro.finishedAt" | "pomodoro.duration" + | "pomodoro.focusConsole" + | "pomodoro.current" + | "pomodoro.today" + | "pomodoro.average" + | "pomodoro.sessions" + | "pomodoro.idleHelp" + | "pomodoro.runningSince" + | "pomodoro.lastSession" + | "pomodoro.noRecentSession" | "attempt.title" | "attempt.openRoom" | "attempt.start" @@ -1141,6 +1150,15 @@ const en: Dict = { "pomodoro.startedAt": "Started", "pomodoro.finishedAt": "Finished", "pomodoro.duration": "Duration", + "pomodoro.focusConsole": "Focus console", + "pomodoro.current": "Current focus", + "pomodoro.today": "Today", + "pomodoro.average": "Average", + "pomodoro.sessions": "Sessions", + "pomodoro.idleHelp": "Ready when you are. Start one focused study block.", + "pomodoro.runningSince": "Started {time}", + "pomodoro.lastSession": "Last finished {time}", + "pomodoro.noRecentSession": "No completed session yet.", "attempt.title": "Exam room", "attempt.openRoom": "Open exam room", "attempt.start": "Start exam", @@ -1874,6 +1892,15 @@ const tr: Dict = { "pomodoro.startedAt": "Başlangıç", "pomodoro.finishedAt": "Bitiş", "pomodoro.duration": "Süre", + "pomodoro.focusConsole": "Odak paneli", + "pomodoro.current": "Mevcut odak", + "pomodoro.today": "Bugün", + "pomodoro.average": "Ortalama", + "pomodoro.sessions": "Oturum", + "pomodoro.idleHelp": "Hazır olduğunda tek bir odaklı çalışma bloğu başlat.", + "pomodoro.runningSince": "Başlangıç: {time}", + "pomodoro.lastSession": "Son bitiş: {time}", + "pomodoro.noRecentSession": "Henüz tamamlanmış oturum yok.", "attempt.title": "Sınav odası", "attempt.openRoom": "Sınav odasını aç", "attempt.start": "Sınava başla", diff --git a/src/pages/pomodoro-page.tsx b/src/pages/pomodoro-page.tsx index af9226e..4099af9 100644 --- a/src/pages/pomodoro-page.tsx +++ b/src/pages/pomodoro-page.tsx @@ -10,7 +10,7 @@ import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { DataTable } from "@/components/ui/data-table"; -import { IconClock } from "@/components/ui/icons"; +import { IconCheck, IconClock } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; import { createFlash } from "@/lib/flash"; import { createNow } from "@/lib/create-now"; @@ -38,6 +38,19 @@ function PomodoroContent() { const current = running(); return current ? now() - current.started_at : null; }); + const finishedSessions = createMemo(() => (log()?.items ?? []).filter((item) => item.finished_at != null)); + const todayFocus = createMemo(() => { + const start = new Date(now()); + start.setHours(0, 0, 0, 0); + const startMs = start.getTime(); + return finishedSessions().reduce((total, item) => item.started_at >= startMs ? total + (item.duration_ms ?? 0) : total, 0); + }); + const averageFocus = createMemo(() => { + const items = finishedSessions(); + if (items.length === 0) return null; + return Math.round(items.reduce((total, item) => total + (item.duration_ms ?? 0), 0) / items.length); + }); + const lastFinished = createMemo(() => finishedSessions()[0]?.finished_at ?? null); const columns = createMemo>["items"][number]>[]>(() => [ { accessorKey: "started_at", @@ -77,20 +90,6 @@ function PomodoroContent() { eyebrow={t("nav.pomodoro")} title={t("pomodoro.title")} description={t("pomodoro.subtitle")} - actions={ - void run(postPomodoroStart, t("pomodoro.started"))}> - {t("pomodoro.start")} - - } - > - - - } /> @@ -98,38 +97,78 @@ function PomodoroContent() { {error() && {error()}} -
- -

{t("pomodoro.total")}

-

{formatDurationClock(log()?.total_focus_ms)}

- - } - > -
-
- - +
+
+
+
+ + - {t("pomodoro.running")} +
+

{t("pomodoro.focusConsole")}

+

+ + {(session) => t("pomodoro.runningSince", { time: formatDateTime(session().started_at, locale()) })} + +

+
-

{formatDurationClock(runningDuration())}

-
- -
-

{t("attempt.status")}

-
- + {running() ? t("pomodoro.running") : t("pomodoro.idle")}
+ +
+
+

{running() ? t("pomodoro.current") : t("pomodoro.total")}

+

+ {formatDurationClock(running() ? runningDuration() : log()?.total_focus_ms)} +

+
+ void run(postPomodoroStart, t("pomodoro.started"))}> + + {t("pomodoro.start")} + + } + > + + +
+
+ +
+
+

{t("pomodoro.today")}

+

{formatDurationClock(todayFocus())}

+
+
+

{t("pomodoro.average")}

+

{formatDurationClock(averageFocus())}

+
+
+

{t("pomodoro.sessions")}

+

{log()?.total ?? 0}

+
-

{t("pomodoro.history")}

+
+
+

{t("pomodoro.history")}

+

+ + {(at) => t("pomodoro.lastSession", { time: formatDateTime(at(), locale()) })} + +

+
+
}>