From c88df09d470e57ffe01b531f334427860cc7c1b5 Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Sun, 21 Dec 2025 15:38:49 -0500 Subject: [PATCH] fixes with countdown --- src/app.tsx | 2 +- src/components/CountdownCircleTimer.tsx | 9 +++--- src/components/DeletionForm.tsx | 16 +++++----- src/components/blog/EditCommentModal.tsx | 2 +- src/context/bars.tsx | 35 +++++++++++---------- src/lib/client-utils.ts | 10 ------ src/routes/contact.tsx | 4 +-- src/routes/index.tsx | 3 ++ src/routes/login/index.tsx | 4 +-- src/routes/login/password-reset.tsx | 16 +++++----- src/routes/login/request-password-reset.tsx | 4 +-- 11 files changed, 50 insertions(+), 55 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 620707c..8cd26b1 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -180,7 +180,7 @@ function AppLayout(props: { children: any }) {
any; + children: (props: { remainingTime: number }) => any; onComplete?: () => void; + isPlaying?: boolean; } const CountdownCircleTimer: Component = (props) => { @@ -15,7 +16,7 @@ const CountdownCircleTimer: Component = (props) => { const circumference = radius * 2 * Math.PI; const [remainingTime, setRemainingTime] = createSignal( - props.initialRemainingTime + props.initialRemainingTime ?? props.duration ); // Calculate progress (0 to 1) @@ -87,7 +88,7 @@ const CountdownCircleTimer: Component = (props) => { transform: "translate(-50%, -50%)" }} > - {props.children(remainingTime())} + {props.children({ remainingTime: remainingTime() })}
); diff --git a/src/components/DeletionForm.tsx b/src/components/DeletionForm.tsx index 04b52f1..e4983fc 100644 --- a/src/components/DeletionForm.tsx +++ b/src/components/DeletionForm.tsx @@ -36,7 +36,7 @@ export default function DeletionForm() { if (timer) { timerInterval = setInterval( () => calcRemainder(timer), - 1000, + 1000 ) as unknown as number; onCleanup(() => { if (timerInterval) { @@ -65,7 +65,7 @@ export default function DeletionForm() { const response = await fetch("/api/trpc/misc.sendDeletionRequestEmail", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ email }), + body: JSON.stringify({ email }) }); const result = await response.json(); @@ -79,7 +79,7 @@ export default function DeletionForm() { } timerInterval = setInterval( () => calcRemainder(timer), - 1000, + 1000 ) as unknown as number; } } else { @@ -96,10 +96,10 @@ export default function DeletionForm() { }; // Countdown timer render function - const renderTime = () => { + const renderTime = ({ remainingTime }: { remainingTime: number }) => { return (
-
{countDown().toFixed(0)}
+
{remainingTime.toFixed(0)}
); }; @@ -136,7 +136,7 @@ export default function DeletionForm() { loading() ? "bg-lavender" : "bg-maroon hover:brightness-125 active:scale-90" - } flex w-36 justify-center rounded py-3 font-light text-white shadow-lg shadow-maroon transition-all duration-300 ease-out`} + } shadow-maroon flex w-36 justify-center rounded py-3 font-light text-white shadow-lg transition-all duration-300 ease-out`} > @@ -162,8 +162,8 @@ export default function DeletionForm() { emailSent() ? "text-green" : error() !== "" - ? "text-red" - : "select-none opacity-0" + ? "text-red" + : "opacity-0 select-none" } mt-4 flex justify-center text-center italic transition-opacity duration-300 ease-in-out`} > diff --git a/src/components/blog/EditCommentModal.tsx b/src/components/blog/EditCommentModal.tsx index a8c7e20..3decb83 100644 --- a/src/components/blog/EditCommentModal.tsx +++ b/src/components/blog/EditCommentModal.tsx @@ -21,7 +21,7 @@ export default function EditCommentModal(props: EditCommentModalProps) { }; return ( -
+
; @@ -28,7 +27,8 @@ const BarsContext = createContext<{ setRightBarSize: () => {}, centerWidth: () => 0, setCenterWidth: () => {}, - leftBarVisible: () => true, + leftBarVisible: () => + typeof window !== "undefined" ? window.innerWidth >= 768 : true, setLeftBarVisible: () => {}, rightBarVisible: () => true, setRightBarVisible: () => {}, @@ -45,12 +45,13 @@ export function BarsProvider(props: { children: any }) { const [_rightBarNaturalSize, _setRightBarNaturalSize] = createSignal(0); const [syncedBarSize, setSyncedBarSize] = createSignal(0); const [centerWidth, setCenterWidth] = createSignal(0); - const [leftBarVisible, _setLeftBarVisible] = createSignal(true); - const [rightBarVisible, _setRightBarVisible] = createSignal(true); + const initialWindowWidth = + typeof window !== "undefined" ? window.innerWidth : 1024; + const isMobile = initialWindowWidth < 768; + const [leftBarVisible, setLeftBarVisible] = createSignal(!isMobile); + const [rightBarVisible, setRightBarVisible] = createSignal(true); const [barsInitialized, setBarsInitialized] = createSignal(false); - const [windowWidth, setWindowWidth] = createSignal( - typeof window !== "undefined" ? window.innerWidth : 1024 - ); + const [windowWidth, setWindowWidth] = createSignal(initialWindowWidth); let leftBarSized = false; let rightBarSized = false; @@ -82,6 +83,16 @@ export function BarsProvider(props: { children: any }) { } }; + // Initialize immediately on mobile if left bar starts hidden + onMount(() => { + const isMobile = typeof window !== "undefined" && window.innerWidth < 768; + if (isMobile && !leftBarVisible()) { + // Skip waiting for left bar size on mobile when it starts hidden + leftBarSized = true; + checkAndSync(); + } + }); + const wrappedSetRightBarSize = (size: number) => { if (!barsInitialized()) { // Before initialization, capture natural size @@ -124,16 +135,6 @@ export function BarsProvider(props: { children: any }) { return barsInitialized() ? syncedBarSize() : naturalSize; }); - // Wrap visibility setters with haptic feedback - const setLeftBarVisible = (visible: boolean) => { - hapticFeedback(50); - _setLeftBarVisible(visible); - }; - - const setRightBarVisible = (visible: boolean) => { - hapticFeedback(50); - _setRightBarVisible(visible); - }; return ( { + const renderTime = ({ remainingTime }: { remainingTime: number }) => { return (
-
{time.toFixed(0)}
+
{remainingTime.toFixed(0)}
); }; diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 8e24981..f8ed636 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -42,6 +42,9 @@ export default function Home() { here (github). + + If you want to get in touch, check to side bar for various links. +
Some of my recent projects:
diff --git a/src/routes/login/index.tsx b/src/routes/login/index.tsx index 32478e1..b0d4ffc 100644 --- a/src/routes/login/index.tsx +++ b/src/routes/login/index.tsx @@ -272,10 +272,10 @@ export default function LoginPage() { }; // Countdown timer render function - const renderTime = () => { + const renderTime = ({ remainingTime }: { remainingTime: number }) => { return (
-
{countDown().toFixed(0)}
+
{remainingTime.toFixed(0)}
); }; diff --git a/src/routes/login/password-reset.tsx b/src/routes/login/password-reset.tsx index 8c5f619..aa3ba90 100644 --- a/src/routes/login/password-reset.tsx +++ b/src/routes/login/password-reset.tsx @@ -181,8 +181,8 @@ export default function PasswordResetPage() { name="description" content="Set a new password for your account to regain access to your profile and personalized features." /> -
-
+
+
Set New Password
@@ -277,8 +277,8 @@ export default function PasswordResetPage() { class={`${ passwordChangeLoading() || !passwordsMatch() ? "cursor-not-allowed bg-zinc-400" - : "bg-blue-400 hover:bg-blue-500 active:scale-90 dark:bg-blue-600 dark:hover:bg-blue-700" - } my-6 flex justify-center rounded px-4 py-2 font-medium text-white transition-all duration-300 ease-out`} + : "bg-blue hover:brightness-125 active:scale-90" + } my-6 flex justify-center rounded px-4 py-2 text-base font-medium transition-all duration-300 ease-out`} > {passwordChangeLoading() ? "Setting..." : "Set New Password"} @@ -303,7 +303,7 @@ export default function PasswordResetPage() { {/* Error Message */}
-
{error()}
+
{error()}
@@ -311,11 +311,11 @@ export default function PasswordResetPage() {
Token has expired, request a new one{" "} here @@ -327,7 +327,7 @@ export default function PasswordResetPage() {
Back to Login diff --git a/src/routes/login/request-password-reset.tsx b/src/routes/login/request-password-reset.tsx index e9dfe43..612f6a0 100644 --- a/src/routes/login/request-password-reset.tsx +++ b/src/routes/login/request-password-reset.tsx @@ -111,10 +111,10 @@ export default function RequestPasswordResetPage() { } }; - const renderTime = () => { + const renderTime = ({ remainingTime }: { remainingTime: number }) => { return (
-
{countDown().toFixed(0)}
+
{remainingTime.toFixed(0)}
); };