1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
import { useEffect, useState } from "react";
import { useTimer } from "./hooks/useTimer";
import { useTasks } from "./hooks/useTasks";
import { commands } from "./lib/commands";
import Titlebar from "./components/Titlebar";
import Header from "./components/Header";
import PixelTimer from "./components/PixelTimer";
import SessionDots from "./components/SessionDots";
import Controls from "./components/Controls";
import TaskList from "./components/TaskList";
import "./App.css";
export default function App() {
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
const {
timer,
toggleRunning,
reset,
skip,
cycleMode,
toggleAutoSwitch,
setDuration,
} = useTimer();
const {
tasks,
activeTaskTitle,
addTask,
editTask,
deleteTask,
toggleTask,
reorderTask,
moveTask,
} = useTasks();
// Load theme on mount
useEffect(() => {
commands.getTheme().then((theme) => {
const root = document.documentElement;
root.style.setProperty("--primary", theme.primary);
root.style.setProperty("--overlay", theme.overlay0);
root.style.setProperty("--surface", theme.surface0);
root.style.setProperty("--text", theme.text);
});
}, []);
// Global keyboard shortcuts
useEffect(() => {
function handleKeyDown(e: KeyboardEvent) {
// Don't capture when typing in inputs
const target = e.target as HTMLElement;
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA") return;
switch (e.code) {
case "Space":
e.preventDefault();
toggleRunning();
break;
case "KeyR":
reset();
break;
case "KeyS":
skip();
break;
case "Tab":
e.preventDefault();
cycleMode();
break;
case "KeyA":
toggleAutoSwitch();
break;
}
}
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [toggleRunning, reset, skip, cycleMode, toggleAutoSwitch]);
if (!timer) {
return (
<div className="app loading">
<div className="loading-text">Loading...</div>
</div>
);
}
return (
<div className="app" id="app">
<Titlebar
isSidebarOpen={isSidebarOpen}
onToggleSidebar={() => setIsSidebarOpen(!isSidebarOpen)}
/>
<main className="app-layout">
{/* Sliding Sidebar for Tasks */}
<section className={`sidebar ${isSidebarOpen ? "open" : ""}`} aria-label="Tasks Sidebar">
<TaskList
tasks={tasks}
onAdd={addTask}
onEdit={editTask}
onDelete={deleteTask}
onToggle={toggleTask}
onReorder={reorderTask}
onMove={moveTask}
/>
</section>
{/* Main Timer View */}
<section className="main-view" aria-label="Timer">
<div className="timer-content">
<Header timer={timer} activeTaskTitle={activeTaskTitle} />
<PixelTimer timer={timer} onSetDuration={setDuration} />
<SessionDots timer={timer} onCycleMode={cycleMode} />
<Controls
timer={timer}
onToggle={toggleRunning}
onReset={reset}
onSkip={skip}
/>
</div>
<div className="timer-footer">
<button
className={`auto-switch-toggle ${timer.auto_switch_sessions ? "active" : ""}`}
onClick={toggleAutoSwitch}
aria-label="Toggle auto-switch"
title="Toggle auto-switch (A)"
>
{timer.auto_switch_sessions ? "Auto" : "Manual"}
</button>
<span className="shortcut-hints">
Space · R · S · Tab · A
</span>
</div>
</section>
</main>
</div>
);
}
|