From 29c11fcaa52f943033c9c496426f1a6f1b177c35 Mon Sep 17 00:00:00 2001 From: Avery Felts Date: Sun, 25 Jan 2026 18:27:02 -0700 Subject: [PATCH] feat: Add PWA auto-prompt and header edge blur effect - Usage prompt auto-shows when app accessed as home screen shortcut (PWA mode) - Added blur gradient overlay below header for smooth scroll fade effect --- src/components/Dashboard.tsx | 9 +- src/components/UserHeader.tsx | 395 ++++++++++++++++++---------------- 2 files changed, 214 insertions(+), 190 deletions(-) diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index 8a76e51..b150975 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -106,7 +106,14 @@ export function Dashboard({ user }: DashboardProps) { // Check for achievements await checkAndUnlockAchievements(usage, prefs, achvs); - if (shouldShowUsagePrompt()) { + // Check if running as PWA (home screen shortcut) + const isStandalone = window.matchMedia('(display-mode: standalone)').matches || + (window.navigator as Navigator & { standalone?: boolean }).standalone === true; + + // Always show usage prompt when accessed as PWA shortcut + if (isStandalone) { + setShowUsagePrompt(true); + } else if (shouldShowUsagePrompt()) { setShowUsagePrompt(true); markPromptShown(); } diff --git a/src/components/UserHeader.tsx b/src/components/UserHeader.tsx index 8216e89..60ef08e 100644 --- a/src/components/UserHeader.tsx +++ b/src/components/UserHeader.tsx @@ -90,196 +90,213 @@ export function UserHeader({ user, preferences }: UserHeaderProps) { }; return ( -
-
-
-

handleNavigate('/')} - style={{ - background: 'linear-gradient(135deg, #a78bfa 0%, #818cf8 50%, #6366f1 100%)', - WebkitBackgroundClip: 'text', - WebkitTextFillColor: 'transparent', - backgroundClip: 'text', - }} - > - QuitTraq -

- {userName && ( -

- Welcome {userName}, you got this! -

- )} -
- -
- - - - - {/* Main Navigation Menu */} - - - - - - handleNavigate('/')}> - - Dashboard - - - handleNavigate('/track/nicotine')}> - - Track Nicotine Usage - - handleNavigate('/track/marijuana')}> - - Track Marijuana Usage - - - - - - - - - - - - - Sign out - - - -
-
- {userName && ( -
-

- Welcome {userName}, you got this! -

-
- )} - - {/* Reminder Settings Dialog */} - - - - - - Daily Reminders - - - -
- - - {/* Enable/Disable Toggle */} -
-
- {reminderSettings.enabled ? ( - - ) : ( - - )} - - {reminderSettings.enabled ? 'Reminders On' : 'Reminders Off'} - -
- -
- - {/* Time Picker */} - {reminderSettings.enabled && ( -
- - handleTimeChange(e.target.value)} - /> -

- You'll receive a reminder at this time each day -

-
- )} - - {/* Request Permission Button */} - {isSupported && permission === 'default' && ( - - )} - - {/* Denied Message */} - {permission === 'denied' && ( -
-

- Notifications are blocked. Please enable them in your browser settings to receive reminders. -

-
+ <> +
+ {/* Edge blur overlay - fades content into header */} +
+
+
+

handleNavigate('/')} + style={{ + background: 'linear-gradient(135deg, #a78bfa 0%, #818cf8 50%, #6366f1 100%)', + WebkitBackgroundClip: 'text', + WebkitTextFillColor: 'transparent', + backgroundClip: 'text', + }} + > + QuitTraq +

+ {userName && ( +

+ Welcome {userName}, you got this! +

)}
- -
-
+ +
+ + + + + {/* Main Navigation Menu */} + + + + + + handleNavigate('/')}> + + Dashboard + + + handleNavigate('/track/nicotine')}> + + Track Nicotine Usage + + handleNavigate('/track/marijuana')}> + + Track Marijuana Usage + + + + + + + + + + + + + Sign out + + + +
+ + {userName && ( +
+

+ Welcome {userName}, you got this! +

+
+ )} + + {/* Reminder Settings Dialog */} + + + + + + Daily Reminders + + + +
+ + + {/* Enable/Disable Toggle */} +
+
+ {reminderSettings.enabled ? ( + + ) : ( + + )} + + {reminderSettings.enabled ? 'Reminders On' : 'Reminders Off'} + +
+ +
+ + {/* Time Picker */} + {reminderSettings.enabled && ( +
+ + handleTimeChange(e.target.value)} + /> +

+ You'll receive a reminder at this time each day +

+
+ )} + + {/* Request Permission Button */} + {isSupported && permission === 'default' && ( + + )} + + {/* Denied Message */} + {permission === 'denied' && ( +
+

+ Notifications are blocked. Please enable them in your browser settings to receive reminders. +

+
+ )} +
+
+
+ + ); }