🌍 locale-aware notification dates and a real pomodoro countdown
Browse files at this commit6cb863c7c2665d9531d2f83149fd816f09e50131Parent: 083afa3- fix
- 🌍 locale-aware notification dates and a real pomodoro countdown
5 changed files +147 -36
- src/components/layout/notification-center.tsx +13 -12
- src/components/layout/shell-unread-badge.test.tsx +1 -1
- src/i18n/messages.ts +24 -0
- src/pages/exam-detail-page.tsx +1 -1
- src/pages/pomodoro-page.tsx +108 -22
src/components/layout/notification-center.tsxmodified+13 -12
| @@ -20,11 +20,12 @@ import { | |||
| 20 | getDismissedNotificationIds, | 20 | getDismissedNotificationIds, |
| 21 | type NotificationItem, | 21 | type NotificationItem, |
| 22 | } from "@/lib/notifications"; | 22 | } from "@/lib/notifications"; |
| 23 | -import { useT } from "@/stores/preferences-context"; | 23 | +import { usePreferences } from "@/stores/preferences-context"; |
| 24 | import { useShellFeed } from "@/stores/shell-feed-context"; | 24 | import { useShellFeed } from "@/stores/shell-feed-context"; |
| 25 | 25 | ||
| 26 | export function NotificationCenter() { | 26 | export function NotificationCenter() { |
| 27 | - const t = useT(); | 27 | + const { t, locale } = usePreferences(); |
| 28 | + const dateLocale = () => (locale() === "tr" ? "tr-TR" : "en-US"); | ||
| 28 | const navigate = useNavigate(); | 29 | const navigate = useNavigate(); |
| 29 | const feed = useShellFeed(); | 30 | const feed = useShellFeed(); |
| 30 | const [open, setOpen] = createSignal(false); | 31 | const [open, setOpen] = createSignal(false); |
| @@ -76,7 +77,7 @@ export function NotificationCenter() { | |||
| 76 | type: "event", | 77 | type: "event", |
| 77 | title: e.title, | 78 | title: e.title, |
| 78 | description: e.starts_at | 79 | description: e.starts_at |
| 79 | - ? new Date(e.starts_at).toLocaleString([], { | 80 | + ? new Date(e.starts_at).toLocaleString(dateLocale(), { |
| 80 | month: "short", | 81 | month: "short", |
| 81 | day: "numeric", | 82 | day: "numeric", |
| 82 | hour: "2-digit", | 83 | hour: "2-digit", |
| @@ -100,7 +101,7 @@ export function NotificationCenter() { | |||
| 100 | type: "exam", | 101 | type: "exam", |
| 101 | title: ex.title, | 102 | title: ex.title, |
| 102 | description: ex.starts_at | 103 | description: ex.starts_at |
| 103 | - ? new Date(ex.starts_at).toLocaleString([], { | 104 | + ? new Date(ex.starts_at).toLocaleString(dateLocale(), { |
| 104 | month: "short", | 105 | month: "short", |
| 105 | day: "numeric", | 106 | day: "numeric", |
| 106 | hour: "2-digit", | 107 | hour: "2-digit", |
| @@ -123,7 +124,7 @@ export function NotificationCenter() { | |||
| 123 | type: "homework", | 124 | type: "homework", |
| 124 | title: hw.title, | 125 | title: hw.title, |
| 125 | description: hw.due_at | 126 | description: hw.due_at |
| 126 | - ? `${t("homework.dueAt")}: ${new Date(hw.due_at).toLocaleDateString([], { | 127 | + ? `${t("homework.dueAt")}: ${new Date(hw.due_at).toLocaleDateString(dateLocale(), { |
| 127 | month: "short", | 128 | month: "short", |
| 128 | day: "numeric", | 129 | day: "numeric", |
| 129 | })}` | 130 | })}` |
| @@ -203,8 +204,8 @@ export function NotificationCenter() { | |||
| 203 | "topbar-control relative flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-xl outline-hidden focus-visible:ring-2 focus-visible:ring-ring", | 204 | "topbar-control relative flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-xl outline-hidden focus-visible:ring-2 focus-visible:ring-ring", |
| 204 | open() && "bg-muted text-foreground" | 205 | open() && "bg-muted text-foreground" |
| 205 | )} | 206 | )} |
| 206 | - title={t("rightPanel.messagesTitle")} | 207 | + title={t("notifications.title")} |
| 207 | - aria-label="Bildirimler" | 208 | + aria-label={t("notifications.title")} |
| 208 | > | 209 | > |
| 209 | <IconBell class="h-4 w-4" /> | 210 | <IconBell class="h-4 w-4" /> |
| 210 | <Show when={unreadCount() > 0}> | 211 | <Show when={unreadCount() > 0}> |
| @@ -219,7 +220,7 @@ export function NotificationCenter() { | |||
| 219 | <div class="flex items-center justify-between border-b border-border/80 px-4 py-3 bg-muted/40"> | 220 | <div class="flex items-center justify-between border-b border-border/80 px-4 py-3 bg-muted/40"> |
| 220 | <div class="flex items-center gap-2"> | 221 | <div class="flex items-center gap-2"> |
| 221 | <IconBell class="h-4 w-4 text-primary" /> | 222 | <IconBell class="h-4 w-4 text-primary" /> |
| 222 | - <h3 class="text-xs font-bold text-foreground">Bildirimler</h3> | 223 | + <h3 class="text-xs font-bold text-foreground">{t("notifications.title")}</h3> |
| 223 | <Show when={unreadCount() > 0}> | 224 | <Show when={unreadCount() > 0}> |
| 224 | <span class="rounded-full bg-primary/15 px-2 py-0.5 font-mono text-[10px] font-bold text-primary"> | 225 | <span class="rounded-full bg-primary/15 px-2 py-0.5 font-mono text-[10px] font-bold text-primary"> |
| 225 | {unreadCount()} | 226 | {unreadCount()} |
| @@ -234,10 +235,10 @@ export function NotificationCenter() { | |||
| 234 | size="sm" | 235 | size="sm" |
| 235 | class="h-7 px-2 text-[11px] font-semibold text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-lg" | 236 | class="h-7 px-2 text-[11px] font-semibold text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-lg" |
| 236 | onClick={handleDismissAll} | 237 | onClick={handleDismissAll} |
| 237 | - title="Tüm Bildirimleri Temizle" | 238 | + title={t("notifications.clearAll")} |
| 238 | > | 239 | > |
| 239 | <IconTrash class="mr-1 h-3 w-3" /> | 240 | <IconTrash class="mr-1 h-3 w-3" /> |
| 240 | - Tümünü Sil | 241 | + {t("notifications.clearAll")} |
| 241 | </Button> | 242 | </Button> |
| 242 | </Show> | 243 | </Show> |
| 243 | </div> | 244 | </div> |
| @@ -259,7 +260,7 @@ export function NotificationCenter() { | |||
| 259 | <IconBell class="h-5 w-5" /> | 260 | <IconBell class="h-5 w-5" /> |
| 260 | </div> | 261 | </div> |
| 261 | <p class="text-xs font-medium text-muted-foreground"> | 262 | <p class="text-xs font-medium text-muted-foreground"> |
| 262 | - Henüz yeni bir bildiriminiz yok. | 263 | + {t("notifications.empty")} |
| 263 | </p> | 264 | </p> |
| 264 | </div> | 265 | </div> |
| 265 | } | 266 | } |
| @@ -302,7 +303,7 @@ export function NotificationCenter() { | |||
| 302 | <button | 303 | <button |
| 303 | type="button" | 304 | type="button" |
| 304 | class="absolute right-2 top-2.5 flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/60 opacity-80 sm:opacity-0 group-hover:opacity-100 hover:bg-destructive/10 hover:text-destructive transition-all" | 305 | class="absolute right-2 top-2.5 flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/60 opacity-80 sm:opacity-0 group-hover:opacity-100 hover:bg-destructive/10 hover:text-destructive transition-all" |
| 305 | - title="Sil" | 306 | + title={t("notifications.dismiss")} |
| 306 | onClick={(e) => handleDismissSingle(e, item.id)} | 307 | onClick={(e) => handleDismissSingle(e, item.id)} |
| 307 | > | 308 | > |
| 308 | <IconX class="h-3.5 w-3.5" /> | 309 | <IconX class="h-3.5 w-3.5" /> |
src/components/layout/shell-unread-badge.test.tsxmodified+1 -1
| @@ -84,7 +84,7 @@ test("dismiss all clears the badge, a later message raises it again", () => { | |||
| 84 | 84 | ||
| 85 | expect(badges()).toEqual(["9+"]); | 85 | expect(badges()).toEqual(["9+"]); |
| 86 | 86 | ||
| 87 | - fireEvent.click(screen.getByTitle("Tüm Bildirimleri Temizle")); | 87 | + fireEvent.click(screen.getByTitle("Clear all")); |
| 88 | expect(badges()).toEqual([]); | 88 | expect(badges()).toEqual([]); |
| 89 | 89 | ||
| 90 | // A genuinely new message pushes the oldest listed one off the page. | 90 | // A genuinely new message pushes the oldest listed one off the page. |
src/i18n/messages.tsmodified+24 -0
| @@ -116,6 +116,10 @@ export type MessageKey = | |||
| 116 | | "rightPanel.noUnread" | 116 | | "rightPanel.noUnread" |
| 117 | | "rightPanel.noUpcoming" | 117 | | "rightPanel.noUpcoming" |
| 118 | | "rightPanel.unreadBadge" | 118 | | "rightPanel.unreadBadge" |
| 119 | + | "notifications.title" | ||
| 120 | + | "notifications.clearAll" | ||
| 121 | + | "notifications.dismiss" | ||
| 122 | + | "notifications.empty" | ||
| 119 | | "nav.myStudents" | 123 | | "nav.myStudents" |
| 120 | | "parents.title" | 124 | | "parents.title" |
| 121 | | "parents.subtitle" | 125 | | "parents.subtitle" |
| @@ -622,6 +626,10 @@ export type MessageKey = | |||
| 622 | | "pomodoro.runningSince" | 626 | | "pomodoro.runningSince" |
| 623 | | "pomodoro.lastSession" | 627 | | "pomodoro.lastSession" |
| 624 | | "pomodoro.noRecentSession" | 628 | | "pomodoro.noRecentSession" |
| 629 | + | "pomodoro.remaining" | ||
| 630 | + | "pomodoro.overtime" | ||
| 631 | + | "pomodoro.targetReached" | ||
| 632 | + | "pomodoro.customMinutes" | ||
| 625 | | "attempt.title" | 633 | | "attempt.title" |
| 626 | | "attempt.openRoom" | 634 | | "attempt.openRoom" |
| 627 | | "attempt.start" | 635 | | "attempt.start" |
| @@ -1341,6 +1349,10 @@ const en: Dict = { | |||
| 1341 | "rightPanel.noUnread": "No unread messages", | 1349 | "rightPanel.noUnread": "No unread messages", |
| 1342 | "rightPanel.noUpcoming": "No upcoming events or exams", | 1350 | "rightPanel.noUpcoming": "No upcoming events or exams", |
| 1343 | "rightPanel.unreadBadge": "Unread", | 1351 | "rightPanel.unreadBadge": "Unread", |
| 1352 | + "notifications.title": "Notifications", | ||
| 1353 | + "notifications.clearAll": "Clear all", | ||
| 1354 | + "notifications.dismiss": "Dismiss", | ||
| 1355 | + "notifications.empty": "No new notifications yet.", | ||
| 1344 | "nav.pomodoro": "Pomodoro", | 1356 | "nav.pomodoro": "Pomodoro", |
| 1345 | "nav.attendance": "Attendance", | 1357 | "nav.attendance": "Attendance", |
| 1346 | "nav.questions": "Question Pool", | 1358 | "nav.questions": "Question Pool", |
| @@ -1954,6 +1966,10 @@ const en: Dict = { | |||
| 1954 | "pomodoro.runningSince": "Started {time}", | 1966 | "pomodoro.runningSince": "Started {time}", |
| 1955 | "pomodoro.lastSession": "Last finished {time}", | 1967 | "pomodoro.lastSession": "Last finished {time}", |
| 1956 | "pomodoro.noRecentSession": "No completed session yet.", | 1968 | "pomodoro.noRecentSession": "No completed session yet.", |
| 1969 | + "pomodoro.remaining": "Time remaining", | ||
| 1970 | + "pomodoro.overtime": "Overtime", | ||
| 1971 | + "pomodoro.targetReached": "Time's up! Wrap up or keep going.", | ||
| 1972 | + "pomodoro.customMinutes": "Custom (min)", | ||
| 1957 | "attempt.title": "Exam room", | 1973 | "attempt.title": "Exam room", |
| 1958 | "attempt.openRoom": "Open exam room", | 1974 | "attempt.openRoom": "Open exam room", |
| 1959 | "attempt.start": "Start exam", | 1975 | "attempt.start": "Start exam", |
| @@ -2610,6 +2626,10 @@ const tr: Dict = { | |||
| 2610 | "rightPanel.noUnread": "Okunmamış mesaj yok", | 2626 | "rightPanel.noUnread": "Okunmamış mesaj yok", |
| 2611 | "rightPanel.noUpcoming": "Yaklaşan etkinlik veya sınav yok", | 2627 | "rightPanel.noUpcoming": "Yaklaşan etkinlik veya sınav yok", |
| 2612 | "rightPanel.unreadBadge": "Okunmamış", | 2628 | "rightPanel.unreadBadge": "Okunmamış", |
| 2629 | + "notifications.title": "Bildirimler", | ||
| 2630 | + "notifications.clearAll": "Tümünü sil", | ||
| 2631 | + "notifications.dismiss": "Sil", | ||
| 2632 | + "notifications.empty": "Henüz yeni bir bildiriminiz yok.", | ||
| 2613 | "nav.pomodoro": "Pomodoro", | 2633 | "nav.pomodoro": "Pomodoro", |
| 2614 | "nav.attendance": "Yoklama", | 2634 | "nav.attendance": "Yoklama", |
| 2615 | "nav.questions": "Soru Havuzu", | 2635 | "nav.questions": "Soru Havuzu", |
| @@ -3223,6 +3243,10 @@ const tr: Dict = { | |||
| 3223 | "pomodoro.runningSince": "Başlangıç: {time}", | 3243 | "pomodoro.runningSince": "Başlangıç: {time}", |
| 3224 | "pomodoro.lastSession": "Son bitiş: {time}", | 3244 | "pomodoro.lastSession": "Son bitiş: {time}", |
| 3225 | "pomodoro.noRecentSession": "Henüz tamamlanmış oturum yok.", | 3245 | "pomodoro.noRecentSession": "Henüz tamamlanmış oturum yok.", |
| 3246 | + "pomodoro.remaining": "Kalan süre", | ||
| 3247 | + "pomodoro.overtime": "Ek süre", | ||
| 3248 | + "pomodoro.targetReached": "Süre doldu! Bitirebilir ya da devam edebilirsin.", | ||
| 3249 | + "pomodoro.customMinutes": "Özel (dk)", | ||
| 3226 | "attempt.title": "Sınav odası", | 3250 | "attempt.title": "Sınav odası", |
| 3227 | "attempt.openRoom": "Sınav odasını aç", | 3251 | "attempt.openRoom": "Sınav odasını aç", |
| 3228 | "attempt.start": "Sınava başla", | 3252 | "attempt.start": "Sınava başla", |
src/pages/exam-detail-page.tsxmodified+1 -1
| @@ -704,7 +704,7 @@ function ExamDetailContent() { | |||
| 704 | </Button> | 704 | </Button> |
| 705 | </div> | 705 | </div> |
| 706 | </div> | 706 | </div> |
| 707 | - <Suspense fallback={<PageSpinner />}> | 707 | + <Suspense fallback={<DataTableSkeleton />}> |
| 708 | <Show | 708 | <Show |
| 709 | when={(results()?.items ?? []).length > 0} | 709 | when={(results()?.items ?? []).length > 0} |
| 710 | fallback={<EmptyState kind="exams" title={t("exams.noResults")} />} | 710 | fallback={<EmptyState kind="exams" title={t("exams.noResults")} />} |
src/pages/pomodoro-page.tsxmodified+108 -22
| @@ -1,4 +1,4 @@ | |||
| 1 | -import { Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; | 1 | +import { For, Show, Suspense, createEffect, createMemo, createResource, createSignal } from "solid-js"; |
| 2 | import type { ColumnDef } from "@tanstack/solid-table"; | 2 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 3 | import { getPomodoroMe } from "@/api/pomodoro"; | 3 | import { getPomodoroMe } from "@/api/pomodoro"; |
| 4 | import { postPomodoroFinish } from "@/api/pomodoro"; | 4 | import { postPomodoroFinish } from "@/api/pomodoro"; |
| @@ -9,9 +9,9 @@ import { PageHeader } from "@/components/layout/page-header"; | |||
| 9 | import { Alert } from "@/components/ui/alert"; | 9 | 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, DataTableSkeleton } from "@/components/ui/data-table"; |
| 13 | import { IconCheck, IconClock } from "@/components/ui/icons"; | 13 | import { IconCheck, IconClock } from "@/components/ui/icons"; |
| 14 | -import { PageSpinner } from "@/components/ui/page-spinner"; | 14 | +import { Input } from "@/components/ui/input"; |
| 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"; |
| 17 | import { triggerConfetti } from "@/lib/confetti"; | 17 | import { triggerConfetti } from "@/lib/confetti"; |
| @@ -19,6 +19,20 @@ import { cn } from "@/lib/cn"; | |||
| 19 | import { formatDateTime, formatDurationClock } from "@/lib/format"; | 19 | import { formatDateTime, formatDurationClock } from "@/lib/format"; |
| 20 | import { usePreferences, useT } from "@/stores/preferences-context"; | 20 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 21 | 21 | ||
| 22 | +const DURATION_KEY = "hezarfen.pomodoro.targetMinutes"; | ||
| 23 | +const PRESET_MINUTES = [15, 25, 45, 60]; | ||
| 24 | +const DEFAULT_MINUTES = 25; | ||
| 25 | +const MAX_MINUTES = 180; | ||
| 26 | + | ||
| 27 | +function readTargetMinutes(): number { | ||
| 28 | + try { | ||
| 29 | + const saved = Number(localStorage.getItem(DURATION_KEY)); | ||
| 30 | + return Number.isFinite(saved) && saved > 0 && saved <= MAX_MINUTES ? saved : DEFAULT_MINUTES; | ||
| 31 | + } catch { | ||
| 32 | + return DEFAULT_MINUTES; | ||
| 33 | + } | ||
| 34 | +} | ||
| 35 | + | ||
| 22 | export default function PomodoroPage() { | 36 | export default function PomodoroPage() { |
| 23 | return ( | 37 | return ( |
| 24 | <RouteGuard exactRole="student"> | 38 | <RouteGuard exactRole="student"> |
| @@ -40,6 +54,41 @@ function PomodoroContent() { | |||
| 40 | const current = running(); | 54 | const current = running(); |
| 41 | return current ? now() - current.started_at : null; | 55 | return current ? now() - current.started_at : null; |
| 42 | }); | 56 | }); |
| 57 | + | ||
| 58 | + // Pomodoro-style countdown: purely a client-side display target — the | ||
| 59 | + // backend session is still just an open-ended start/finish stopwatch, so | ||
| 60 | + // this only changes what the clock shows, not what gets recorded. | ||
| 61 | + const [targetMinutes, setTargetMinutes] = createSignal(readTargetMinutes()); | ||
| 62 | + createEffect(() => { | ||
| 63 | + try { | ||
| 64 | + localStorage.setItem(DURATION_KEY, String(targetMinutes())); | ||
| 65 | + } catch { | ||
| 66 | + // Duration just won't be remembered next visit. | ||
| 67 | + } | ||
| 68 | + }); | ||
| 69 | + const targetMs = () => targetMinutes() * 60_000; | ||
| 70 | + const remainingMs = createMemo(() => { | ||
| 71 | + const dur = runningDuration(); | ||
| 72 | + return dur == null ? null : Math.max(0, targetMs() - dur); | ||
| 73 | + }); | ||
| 74 | + const overtimeMs = createMemo(() => { | ||
| 75 | + const dur = runningDuration(); | ||
| 76 | + return dur == null ? 0 : Math.max(0, dur - targetMs()); | ||
| 77 | + }); | ||
| 78 | + const isOvertime = () => overtimeMs() > 0; | ||
| 79 | + | ||
| 80 | + // One flash when the countdown crosses zero, not one per tick. | ||
| 81 | + const [targetNotified, setTargetNotified] = createSignal(false); | ||
| 82 | + createEffect(() => { | ||
| 83 | + if (!running()) { | ||
| 84 | + setTargetNotified(false); | ||
| 85 | + return; | ||
| 86 | + } | ||
| 87 | + if (isOvertime() && !targetNotified()) { | ||
| 88 | + setTargetNotified(true); | ||
| 89 | + setFlash(t("pomodoro.targetReached")); | ||
| 90 | + } | ||
| 91 | + }); | ||
| 43 | const finishedSessions = createMemo(() => (log()?.items ?? []).filter((item) => item.finished_at != null)); | 92 | const finishedSessions = createMemo(() => (log()?.items ?? []).filter((item) => item.finished_at != null)); |
| 44 | const todayFocus = createMemo(() => { | 93 | const todayFocus = createMemo(() => { |
| 45 | const start = new Date(now()); | 94 | const start = new Date(now()); |
| @@ -91,8 +140,7 @@ function PomodoroContent() { | |||
| 91 | const progressPercent = createMemo(() => { | 140 | const progressPercent = createMemo(() => { |
| 92 | const dur = runningDuration(); | 141 | const dur = runningDuration(); |
| 93 | if (!dur) return 0; | 142 | if (!dur) return 0; |
| 94 | - const targetMs = 25 * 60 * 1000; | 143 | + return Math.min(1, dur / targetMs()); |
| 95 | - return Math.min(1, dur / targetMs); | ||
| 96 | }); | 144 | }); |
| 97 | 145 | ||
| 98 | const dashOffset = createMemo(() => { | 146 | const dashOffset = createMemo(() => { |
| @@ -157,27 +205,65 @@ function PomodoroContent() { | |||
| 157 | </div> | 205 | </div> |
| 158 | 206 | ||
| 159 | <div> | 207 | <div> |
| 160 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{running() ? t("pomodoro.current") : t("pomodoro.total")}</p> | 208 | + <p class={cn("text-xs font-medium uppercase tracking-[0.08em]", running() && isOvertime() ? "text-destructive" : "text-muted-foreground")}> |
| 161 | - <p class="mono mt-2 text-5xl font-semibold leading-none tracking-tight tabular-nums sm:text-6xl"> | 209 | + {running() ? (isOvertime() ? t("pomodoro.overtime") : t("pomodoro.remaining")) : t("pomodoro.total")} |
| 162 | - {formatDurationClock(running() ? runningDuration() : log()?.total_focus_ms)} | 210 | + </p> |
| 211 | + <p class={cn("mono mt-2 text-5xl font-semibold leading-none tracking-tight tabular-nums sm:text-6xl", running() && isOvertime() && "text-destructive")}> | ||
| 212 | + {running() && isOvertime() && "+"} | ||
| 213 | + {formatDurationClock(running() ? (isOvertime() ? overtimeMs() : remainingMs()) : log()?.total_focus_ms)} | ||
| 163 | </p> | 214 | </p> |
| 164 | </div> | 215 | </div> |
| 165 | </div> | 216 | </div> |
| 166 | 217 | ||
| 167 | - <Show | 218 | + <div class="flex flex-col items-center gap-3 md:items-end"> |
| 168 | - when={running()} | 219 | + <Show |
| 169 | - fallback={ | 220 | + when={running()} |
| 170 | - <Button type="button" size="sm" class="h-10 min-w-40 rounded-md text-base" disabled={pending()} onClick={() => void run(postPomodoroStart, t("pomodoro.started"))}> | 221 | + fallback={ |
| 171 | - <IconClock class="h-4 w-4" /> | 222 | + <Button type="button" size="sm" class="h-10 min-w-40 rounded-md text-base" disabled={pending()} onClick={() => void run(postPomodoroStart, t("pomodoro.started"))}> |
| 172 | - {t("pomodoro.start")} | 223 | + <IconClock class="h-4 w-4" /> |
| 224 | + {t("pomodoro.start")} | ||
| 225 | + </Button> | ||
| 226 | + } | ||
| 227 | + > | ||
| 228 | + <Button type="button" size="sm" variant="outline" class="h-10 min-w-40 rounded-md text-base" disabled={pending()} onClick={() => void run(postPomodoroFinish, t("pomodoro.finished"))}> | ||
| 229 | + <IconCheck class="h-4 w-4" /> | ||
| 230 | + {t("pomodoro.finish")} | ||
| 173 | </Button> | 231 | </Button> |
| 174 | - } | 232 | + </Show> |
| 175 | - > | 233 | + |
| 176 | - <Button type="button" size="sm" variant="outline" class="h-10 min-w-40 rounded-md text-base" disabled={pending()} onClick={() => void run(postPomodoroFinish, t("pomodoro.finished"))}> | 234 | + {/* Session length: like the classic Pomodoro technique, this is |
| 177 | - <IconCheck class="h-4 w-4" /> | 235 | + configurable — locked once a session is running so it can't |
| 178 | - {t("pomodoro.finish")} | 236 | + drift mid-focus. */} |
| 179 | - </Button> | 237 | + <div class="flex flex-wrap items-center justify-center gap-1.5 md:justify-end"> |
| 180 | - </Show> | 238 | + <For each={PRESET_MINUTES}> |
| 239 | + {(minutes) => ( | ||
| 240 | + <Button | ||
| 241 | + type="button" | ||
| 242 | + size="sm" | ||
| 243 | + variant={targetMinutes() === minutes ? "default" : "outline"} | ||
| 244 | + class="h-7 min-w-11 rounded-lg px-2 text-xs" | ||
| 245 | + disabled={!!running()} | ||
| 246 | + onClick={() => setTargetMinutes(minutes)} | ||
| 247 | + > | ||
| 248 | + {minutes} | ||
| 249 | + </Button> | ||
| 250 | + )} | ||
| 251 | + </For> | ||
| 252 | + <Input | ||
| 253 | + type="number" | ||
| 254 | + min="1" | ||
| 255 | + max={MAX_MINUTES} | ||
| 256 | + value={targetMinutes()} | ||
| 257 | + disabled={!!running()} | ||
| 258 | + class="h-7 w-16 rounded-lg px-2 text-xs" | ||
| 259 | + title={t("pomodoro.customMinutes")} | ||
| 260 | + onInput={(event) => { | ||
| 261 | + const value = Number(event.currentTarget.value); | ||
| 262 | + if (Number.isFinite(value) && value > 0 && value <= MAX_MINUTES) setTargetMinutes(value); | ||
| 263 | + }} | ||
| 264 | + /> | ||
| 265 | + </div> | ||
| 266 | + </div> | ||
| 181 | </div> | 267 | </div> |
| 182 | </div> | 268 | </div> |
| 183 | 269 | ||
| @@ -208,7 +294,7 @@ function PomodoroContent() { | |||
| 208 | </p> | 294 | </p> |
| 209 | </div> | 295 | </div> |
| 210 | </div> | 296 | </div> |
| 211 | - <Suspense fallback={<PageSpinner />}> | 297 | + <Suspense fallback={<DataTableSkeleton />}> |
| 212 | <DataTable columns={columns()} data={log()?.items ?? []} empty={t("pomodoro.empty")} enablePagination pageSize={10} /> | 298 | <DataTable columns={columns()} data={log()?.items ?? []} empty={t("pomodoro.empty")} enablePagination pageSize={10} /> |
| 213 | </Suspense> | 299 | </Suspense> |
| 214 | </section> | 300 | </section> |