diff --git a/SparkyFitnessFrontend/src/layouts/MainLayout.tsx b/SparkyFitnessFrontend/src/layouts/MainLayout.tsx index 4db2ba97f..1b158e6d0 100644 --- a/SparkyFitnessFrontend/src/layouts/MainLayout.tsx +++ b/SparkyFitnessFrontend/src/layouts/MainLayout.tsx @@ -1,5 +1,11 @@ import type React from 'react'; -import { useState, useMemo, useCallback, useEffect } from 'react'; +import { + useState, + useMemo, + useCallback, + useEffect, + useSyncExternalStore, +} from 'react'; import { useTranslation } from 'react-i18next'; import { useLocation, Outlet, useNavigate } from 'react-router-dom'; import { debug, info, error } from '@/utils/logging'; @@ -80,6 +86,15 @@ const MainLayout: React.FC = ({ const [isAddCompOpen, setIsAddCompOpen] = useState(false); const [isMealTypeSelectOpen, setIsMealTypeSelectOpen] = useState(false); + const minimalTopBar = useSyncExternalStore( + (callback) => { + window.addEventListener('minimalTopBarChanged', callback); + return () => window.removeEventListener('minimalTopBarChanged', callback); + }, + () => localStorage.getItem('minimalTopBar') === 'true', + () => false + ); + // Fetch meal types for quick log menu const { data: mealTypes } = useMealTypes(); @@ -436,18 +451,23 @@ const MainLayout: React.FC = ({ return (
-
+
SparkyFitness Logo -

+

SparkyFitness

- {!isMobile && ( + {!isMobile && !minimalTopBar && ( <> diff --git a/SparkyFitnessFrontend/src/pages/Settings/PreferenceSettings.tsx b/SparkyFitnessFrontend/src/pages/Settings/PreferenceSettings.tsx index 045600434..9437a0a6c 100644 --- a/SparkyFitnessFrontend/src/pages/Settings/PreferenceSettings.tsx +++ b/SparkyFitnessFrontend/src/pages/Settings/PreferenceSettings.tsx @@ -62,12 +62,21 @@ export const PreferenceSettings = () => { } = usePreferences(); const [localLoggingLevel, setLocalLoggingLevel] = useState(loggingLevel); + const [minimalTopBar, setMinimalTopBar] = useState( + () => localStorage.getItem('minimalTopBar') === 'true' + ); const [loading, setLoading] = useState(false); useEffect(() => { setLocalLoggingLevel(loggingLevel); }, [loggingLevel]); + const handleMinimalTopBarToggle = (checked: boolean) => { + setMinimalTopBar(checked); + localStorage.setItem('minimalTopBar', String(checked)); + window.dispatchEvent(new Event('minimalTopBarChanged')); + }; + const handlePreferencesUpdate = async () => { if (!user) return; setLoading(true); @@ -443,7 +452,7 @@ export const PreferenceSettings = () => {
-
+
+
+
+ +

+ {t( + 'settings.preferences.minimalTopBarHint', + 'Hide the GitHub star and sponsor buttons, and use a smaller logo and title.' + )} +

+
+ +