From 5ac55004270cd5e7daebaadcd7cef1a4907ffc68 Mon Sep 17 00:00:00 2001 From: Lencodes Date: Tue, 21 Nov 2023 14:20:35 +0100 Subject: [PATCH] ADD middleware to keep theme switcher in different themes --- pwa/src/hooks/useEnvironment.ts | 10 ++++++++++ pwa/src/services/getConfig.ts | 2 +- .../themeSwitcherTopBar/ThemeSwitcherTopBar.module.css | 3 ++- pwa/static/.env.development | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pwa/src/hooks/useEnvironment.ts b/pwa/src/hooks/useEnvironment.ts index f465fc48..9713db71 100644 --- a/pwa/src/hooks/useEnvironment.ts +++ b/pwa/src/hooks/useEnvironment.ts @@ -7,6 +7,7 @@ export const useEnvironment = () => { const handleStorageChange = () => { setSessionStorageUpdatedId(uniqueId()); + themeSwitcherMiddleware(); }; const updateSessionStorage = () => { @@ -55,5 +56,14 @@ export const useEnvironment = () => { updateSessionStorage(); }; + const themeSwitcherMiddleware = () => { + switch (window.location.hostname) { + case "koophulpje.nl": + // case "localhost.nl": // development purposes + window.sessionStorage.setItem("SHOW_THEME_SWITCHER", "true"); + break; + } + }; + return { initiateFromEnv, initiateFromJSON }; }; diff --git a/pwa/src/services/getConfig.ts b/pwa/src/services/getConfig.ts index 5b2752be..bf1d97b6 100644 --- a/pwa/src/services/getConfig.ts +++ b/pwa/src/services/getConfig.ts @@ -33,7 +33,7 @@ export const getConfig = (themeOrDomainName: string): Record | unde return Xxllnc; case "koophulpje.nl": case "open-webconcept-theme": - case "localhost": + // case "localhost": // development purposes return OpenWebconcept; default: return Conduction; diff --git a/pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.module.css b/pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.module.css index 3d5e7e0a..44e80d74 100644 --- a/pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.module.css +++ b/pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.module.css @@ -2,9 +2,10 @@ top: 12px; width: 80%; z-index: 100; - padding: 18px; + padding: 12px 32px; display: flex; position: sticky; + border-radius: 5px; align-items: center; margin: 0 auto 24px; background-color: white; diff --git a/pwa/static/.env.development b/pwa/static/.env.development index 16781e08..1d253f00 100644 --- a/pwa/static/.env.development +++ b/pwa/static/.env.development @@ -28,4 +28,4 @@ GATSBY_OIDN_NUMBER="" GATSBY_SHOW_THEME_SWITCHER="false" # Deployment option, if you're using this .env file DO NOT REMOVE OR EDIT THIS -# GATSBY_ENV_VARS_SET="true" +GATSBY_ENV_VARS_SET="true"