aboutsummaryrefslogtreecommitdiff
path: root/desktop/src
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/src')
-rw-r--r--desktop/src/App.css24
-rw-r--r--desktop/src/components/Header.tsx6
-rw-r--r--desktop/src/components/PixelTimer.tsx77
3 files changed, 56 insertions, 51 deletions
diff --git a/desktop/src/App.css b/desktop/src/App.css
index 5d91f30..fc05349 100644
--- a/desktop/src/App.css
+++ b/desktop/src/App.css
@@ -346,7 +346,9 @@
font-weight: 700;
white-space: pre;
text-align: center;
- transition: color 0.3s ease, text-shadow 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
+ margin: 0;
+ padding: 0;
+ transition: color 0.3s ease, text-shadow 0.3s ease, transform 0.3s ease;
}
.ascii-art-timer.work {
@@ -364,22 +366,22 @@
text-shadow: 0 0 10px var(--long-break-dim);
}
-.crossfade-in {
- animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
+.scroll-in {
+ animation: scrollIn 0.3s ease-in-out forwards;
}
-.crossfade-out {
- animation: fadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
+.scroll-out {
+ animation: scrollOut 0.3s ease-in-out forwards;
}
-@keyframes fadeIn {
- from { opacity: 0; filter: blur(2px); transform: scale(0.98); }
- to { opacity: 1; filter: blur(0); transform: scale(1); }
+@keyframes scrollIn {
+ from { transform: translateY(105%); }
+ to { transform: translateY(0); }
}
-@keyframes fadeOut {
- from { opacity: 1; filter: blur(0); transform: scale(1); }
- to { opacity: 0; filter: blur(2px); transform: scale(1.02); }
+@keyframes scrollOut {
+ from { transform: translateY(0); }
+ to { transform: translateY(-105%); }
}
/* Timer Edit Input */
diff --git a/desktop/src/components/Header.tsx b/desktop/src/components/Header.tsx
index 8d679cf..5ddb1f0 100644
--- a/desktop/src/components/Header.tsx
+++ b/desktop/src/components/Header.tsx
@@ -29,12 +29,12 @@ export default function Header({ timer, activeTaskTitle }: HeaderProps) {
</span>
</div>
<div className="header-time">{formatTime(timer.time_remaining_secs)}</div>
- {activeTaskTitle && (
+ <div className={`header-task-wrapper ${activeTaskTitle ? "visible" : ""}`}>
<div className="header-task">
<span className="task-indicator" />
- {activeTaskTitle}
+ {activeTaskTitle || "No task"}
</div>
- )}
+ </div>
</div>
);
}
diff --git a/desktop/src/components/PixelTimer.tsx b/desktop/src/components/PixelTimer.tsx
index b3310d1..5ad2904 100644
--- a/desktop/src/components/PixelTimer.tsx
+++ b/desktop/src/components/PixelTimer.tsx
@@ -20,19 +20,10 @@ const ASCII_MAP: Record<string, string[]> = {
":": [" ", " █ ", " ", " █ ", " "],
};
-function formatMonolithicAscii(timeStr: string): string {
- const lines = ["", "", "", "", ""];
- for (let i = 0; i < timeStr.length; i++) {
- const char = timeStr[i];
- const art = ASCII_MAP[char] || ASCII_MAP[":"];
- for (let j = 0; j < 5; j++) {
- lines[j] += art[j];
- if (i < timeStr.length - 1) {
- lines[j] += " ";
- }
- }
- }
- return lines.join("\n");
+function formatCharAscii(char: string): string {
+ if (!char) return "";
+ const art = ASCII_MAP[char] || ASCII_MAP[":"];
+ return art.join("\n");
}
function formatTimeStr(secs: number): string {
@@ -41,6 +32,38 @@ function formatTimeStr(secs: number): string {
return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
}
+function AnimatedDigit({ char, mode }: { char: string; mode: string }) {
+ const [current, setCurrent] = useState(char);
+ const [prev, setPrev] = useState("");
+ const [isAnimating, setIsAnimating] = useState(false);
+
+ useEffect(() => {
+ if (char !== current) {
+ setPrev(current);
+ setCurrent(char);
+ setIsAnimating(true);
+ const timeout = setTimeout(() => setIsAnimating(false), 300);
+ return () => clearTimeout(timeout);
+ }
+ }, [char, current]);
+
+ const ascii = formatCharAscii(current);
+ const prevAscii = formatCharAscii(prev);
+
+ return (
+ <div style={{ position: "relative", overflow: "hidden", display: "inline-block" }}>
+ {isAnimating && prev && (
+ <pre key={`${prev}-prev`} className={`ascii-art-timer ${mode} scroll-out`} style={{ position: "absolute", top: 0, left: 0, right: 0 }}>
+ {prevAscii}
+ </pre>
+ )}
+ <pre key={current} className={`ascii-art-timer ${mode} ${isAnimating ? "scroll-in" : ""}`}>
+ {ascii}
+ </pre>
+ </div>
+ );
+}
+
export default function PixelTimer({ timer, onSetDuration }: PixelTimerProps) {
const [isEditing, setIsEditing] = useState(false);
const [editValue, setEditValue] = useState("");
@@ -53,21 +76,6 @@ export default function PixelTimer({ timer, onSetDuration }: PixelTimerProps) {
}, [isEditing]);
const timeStr = formatTimeStr(timer.time_remaining_secs);
- const asciiArt = formatMonolithicAscii(timeStr);
-
- const [currentAscii, setCurrentAscii] = useState(asciiArt);
- const [prevAscii, setPrevAscii] = useState("");
- const [isFading, setIsFading] = useState(false);
-
- useEffect(() => {
- if (asciiArt !== currentAscii) {
- setPrevAscii(currentAscii);
- setCurrentAscii(asciiArt);
- setIsFading(true);
- const timeout = setTimeout(() => setIsFading(false), 300);
- return () => clearTimeout(timeout);
- }
- }, [asciiArt, currentAscii]);
function handleStartEdit() {
setEditValue(String(Math.floor(timer.time_remaining_secs / 60)));
@@ -121,15 +129,10 @@ export default function PixelTimer({ timer, onSetDuration }: PixelTimerProps) {
if (e.key === "Enter" || e.key === " ") handleStartEdit();
}}
>
- <div style={{ position: "relative" }}>
- {isFading && (
- <pre key={`${prevAscii}-prev`} className={`ascii-art-timer ${timer.mode} fade-out`} style={{ position: "absolute", top: 0, left: 0, right: 0 }}>
- {prevAscii}
- </pre>
- )}
- <pre key={currentAscii} className={`ascii-art-timer ${timer.mode} ${isFading ? "fade-in" : ""}`}>
- {currentAscii}
- </pre>
+ <div style={{ display: "flex", gap: "12px", alignItems: "center" }}>
+ {timeStr.split("").map((char, index) => (
+ <AnimatedDigit key={index} char={char} mode={timer.mode} />
+ ))}
</div>
</div>
);