Skip to content

Commit

Permalink
ADD middleware to keep theme switcher in different themes
Browse files Browse the repository at this point in the history
  • Loading branch information
lencodes committed Nov 21, 2023
1 parent 55b6232 commit 5ac5500
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions pwa/src/hooks/useEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const useEnvironment = () => {

const handleStorageChange = () => {
setSessionStorageUpdatedId(uniqueId());
themeSwitcherMiddleware();
};

const updateSessionStorage = () => {
Expand Down Expand Up @@ -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 };
};
2 changes: 1 addition & 1 deletion pwa/src/services/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const getConfig = (themeOrDomainName: string): Record<string, any> | unde
return Xxllnc;
case "koophulpje.nl":
case "open-webconcept-theme":
case "localhost":
// case "localhost": // development purposes
return OpenWebconcept;
default:
return Conduction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pwa/static/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 5ac5500

Please sign in to comment.