From 0606f56dc242aa68213858ee299940add5e40d52 Mon Sep 17 00:00:00 2001 From: RanXom Date: Sat, 13 Jun 2026 20:18:24 +0530 Subject: update timer animation and update edition in Cargo.toml --- desktop/src-tauri/Cargo.toml | 2 +- desktop/src/App.css | 24 ++++++----- desktop/src/components/Header.tsx | 6 +-- desktop/src/components/PixelTimer.tsx | 77 ++++++++++++++++++----------------- 4 files changed, 57 insertions(+), 52 deletions(-) (limited to 'desktop') diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index 6c93b26..9adfb69 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -3,7 +3,7 @@ name = "pomoru-desktop" version = "2.0.0" description = "Pomoru Desktop — A minimal Pomodoro timer" authors = ["RanXom"] -edition = "2026" +edition = "2024" [lib] name = "desktop_lib" 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) {
{formatTime(timer.time_remaining_secs)}
- {activeTaskTitle && ( +
- {activeTaskTitle} + {activeTaskTitle || "No task"}
- )} +
); } 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 = { ":": [" ", " █ ", " ", " █ ", " "], }; -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 ( +
+ {isAnimating && prev && ( +
+          {prevAscii}
+        
+ )} +
+        {ascii}
+      
+
+ ); +} + 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(); }} > -
- {isFading && ( -
-            {prevAscii}
-          
- )} -
-          {currentAscii}
-        
+
+ {timeStr.split("").map((char, index) => ( + + ))}
); -- cgit v1.2.3