diff options
| author | RanXom <saiyedshizain@gmail.com> | 2026-06-13 17:12:24 +0530 |
|---|---|---|
| committer | RanXom <saiyedshizain@gmail.com> | 2026-06-13 17:12:24 +0530 |
| commit | cc27f9d8d97b9fedd6edfbe9985104f5c3999e07 (patch) | |
| tree | 92abbf4b47a3262094d43cb1bc36660ec7945ea0 /desktop | |
| parent | e3581344f734e0a61553863905e9d170dfb8eacf (diff) | |
| download | pomoru-cc27f9d8d97b9fedd6edfbe9985104f5c3999e07.tar.xz pomoru-cc27f9d8d97b9fedd6edfbe9985104f5c3999e07.zip | |
introduce Header, Session and Titlebar components
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/src/components/Header.tsx | 40 | ||||
| -rw-r--r-- | desktop/src/components/SessionDots.tsx | 32 | ||||
| -rw-r--r-- | desktop/src/components/Titlebar.tsx | 56 |
3 files changed, 128 insertions, 0 deletions
diff --git a/desktop/src/components/Header.tsx b/desktop/src/components/Header.tsx new file mode 100644 index 0000000..8d679cf --- /dev/null +++ b/desktop/src/components/Header.tsx @@ -0,0 +1,40 @@ +import type { TimerState } from "../lib/commands"; + +interface HeaderProps { + timer: TimerState; + activeTaskTitle: string | null; +} + +function modeLabel(mode: string): string { + switch (mode) { + case "work": return "Focus Session"; + case "short-break": return "Short Break"; + case "long-break": return "Long Break"; + default: return "Session"; + } +} + +function formatTime(secs: number): string { + const m = Math.floor(secs / 60); + const s = secs % 60; + return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`; +} + +export default function Header({ timer, activeTaskTitle }: HeaderProps) { + return ( + <div className="header" id="header"> + <div className="header-session"> + <span className={`session-badge ${timer.mode}`}> + {modeLabel(timer.mode)} + </span> + </div> + <div className="header-time">{formatTime(timer.time_remaining_secs)}</div> + {activeTaskTitle && ( + <div className="header-task"> + <span className="task-indicator" /> + {activeTaskTitle} + </div> + )} + </div> + ); +} diff --git a/desktop/src/components/SessionDots.tsx b/desktop/src/components/SessionDots.tsx new file mode 100644 index 0000000..de96f3c --- /dev/null +++ b/desktop/src/components/SessionDots.tsx @@ -0,0 +1,32 @@ +import type { TimerState } from "../lib/commands"; + +interface SessionDotsProps { + timer: TimerState; + onCycleMode: () => void; +} + +const modes: Array<{ key: string; label: string }> = [ + { key: "work", label: "Focus" }, + { key: "short-break", label: "Short Break" }, + { key: "long-break", label: "Long Break" }, +]; + +export default function SessionDots({ timer, onCycleMode }: SessionDotsProps) { + return ( + <div className="session-dots" id="session-dots"> + {modes.map((m) => ( + <button + key={m.key} + className={`session-dot ${timer.mode === m.key ? "active" : ""}`} + onClick={onCycleMode} + disabled={timer.is_running} + aria-label={`Switch to ${m.label}`} + title={timer.is_running ? "Pause to switch" : `Switch to ${m.label}`} + > + {timer.mode === m.key && <span className="dot-indicator" />} + {m.label} + </button> + ))} + </div> + ); +} diff --git a/desktop/src/components/Titlebar.tsx b/desktop/src/components/Titlebar.tsx new file mode 100644 index 0000000..70e43a9 --- /dev/null +++ b/desktop/src/components/Titlebar.tsx @@ -0,0 +1,56 @@ +import { getCurrentWindow } from "@tauri-apps/api/window"; +import logoUrl from "../assets/logo.svg"; + +interface TitlebarProps { + onToggleSidebar: () => void; + isSidebarOpen: boolean; +} + +export default function Titlebar({ onToggleSidebar, isSidebarOpen }: TitlebarProps) { + const appWindow = getCurrentWindow(); + + return ( + <div data-tauri-drag-region className="titlebar" id="titlebar"> + <div className="titlebar-left"> + <button + className={`titlebar-btn toggle-sidebar ${isSidebarOpen ? "open" : ""}`} + onClick={onToggleSidebar} + aria-label={isSidebarOpen ? "Close sidebar" : "Open sidebar"} + title="Toggle Tasks" + > + <svg className="menu-icon-svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"> + <line className="line-top" x1="3" y1="6" x2="21" y2="6" /> + <line className="line-middle" x1="3" y1="12" x2="21" y2="12" /> + <line className="line-bottom" x1="3" y1="18" x2="21" y2="18" /> + </svg> + </button> + </div> + <div data-tauri-drag-region className="titlebar-center"> + <img src={logoUrl} alt="Pomoru" className="titlebar-logo" /> + </div> + <div className="titlebar-right"> + <button + className="titlebar-btn minimize" + onClick={() => appWindow.minimize()} + aria-label="Minimize" + title="Minimize" + > + <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"> + <line x1="4" y1="12" x2="20" y2="12" /> + </svg> + </button> + <button + className="titlebar-btn close" + onClick={() => appWindow.close()} + aria-label="Close" + title="Close" + > + <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"> + <line x1="18" y1="6" x2="6" y2="18" /> + <line x1="6" y1="6" x2="18" y2="18" /> + </svg> + </button> + </div> + </div> + ); +} |