diff --git a/website/src/components/Navigation/Navigation.astro b/website/src/components/Navigation/Navigation.astro index c767fcf8a8..b5e944c3a4 100644 --- a/website/src/components/Navigation/Navigation.astro +++ b/website/src/components/Navigation/Navigation.astro @@ -18,7 +18,7 @@ const isLoggedIn = Astro.locals.session?.isLoggedIn ?? false; const loginUrl = await getAuthUrl(Astro.url.toString()); --- -
+
-
- +
+
diff --git a/website/src/components/Navigation/SandwichMenu.tsx b/website/src/components/Navigation/SandwichMenu.tsx index c6ec6da74a..cb0f927ca6 100644 --- a/website/src/components/Navigation/SandwichMenu.tsx +++ b/website/src/components/Navigation/SandwichMenu.tsx @@ -7,33 +7,35 @@ import { OffCanvasOverlay } from '../OffCanvasOverlay'; import { SandwichIcon } from '../SandwichIcon'; type SandwichMenuProps = { - top: number; - right: number; organism: Organism | undefined; isLoggedIn: boolean; loginUrl: string | undefined; }; -export const SandwichMenu: FC = ({ top, right, organism, isLoggedIn, loginUrl }) => { +export const SandwichMenu: FC = ({ organism, isLoggedIn, loginUrl }) => { const { isOpen, toggle: toggleMenu, close: closeMenu } = useOffCanvas(); return (
- - - {isOpen && } + {!isOpen ? ( + + ) : ( + + )}
+
diff --git a/website/src/components/common/Banner.tsx b/website/src/components/common/Banner.tsx index e2ce8b1674..698fa39954 100644 --- a/website/src/components/common/Banner.tsx +++ b/website/src/components/common/Banner.tsx @@ -2,16 +2,45 @@ import React from 'react'; interface BannerProps { message?: string; + lastTimeBannerWasClosed: number | undefined; + serverTime: number; } -export const Banner: React.FC = ({ message }) => { - if (message === undefined) { +export const Banner: React.FC = ({ message, lastTimeBannerWasClosed, serverTime }) => { + const timeToKeepBannerClosed = 1000 * 60 * 60 * 24 * 365; + + if ( + message === undefined || + (lastTimeBannerWasClosed !== undefined && lastTimeBannerWasClosed + timeToKeepBannerClosed > serverTime) + ) { return null; } + const initialClientTime = Date.now(); + const serverClientOffset = serverTime - initialClientTime; + + const setBannerClosed = () => { + document.cookie = `lastTimeBannerWasClosed=${Date.now() + serverClientOffset}; max-age=${60 * 60 * 24 * 365}`; + window.location.reload(); + }; return ( -
-

{message}

+
+

+ {message} +

+
); }; diff --git a/website/src/layouts/BaseLayout.astro b/website/src/layouts/BaseLayout.astro index 39844f6b7d..410a9bc710 100644 --- a/website/src/layouts/BaseLayout.astro +++ b/website/src/layouts/BaseLayout.astro @@ -22,6 +22,8 @@ interface Props { const { title, implicitOrganism, noHorizontalPadding } = Astro.props; const backendIsInDebugMode = await BackendClient.create().isInDebugMode(); + +const lastTimeBannerWasClosed = Astro.cookies.get('lastTimeBannerWasClosed')?.value; --- @@ -36,7 +38,14 @@ const backendIsInDebugMode = await BackendClient.create().isInDebugMode(); {backendIsInDebugMode &&
Backend is in debug mode
} - +