generated from ConductionNL/product-website-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from ConductionNL/feature/XW-111/koophulpje
Feature/xw 111/koophulpje
- Loading branch information
Showing
20 changed files
with
277 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as React from "react"; | ||
import { getConfig } from "../services/getConfig"; | ||
import { uniqueId } from "lodash"; | ||
|
||
export const useEnvironment = () => { | ||
const [, setSessionStorageUpdatedId] = React.useState("-1"); | ||
|
||
const handleStorageChange = () => { | ||
setSessionStorageUpdatedId(uniqueId()); | ||
themeSwitcherMiddleware(); | ||
}; | ||
|
||
const updateSessionStorage = () => { | ||
window.dispatchEvent(new Event("sessionStorageChange")); | ||
}; | ||
|
||
React.useEffect(() => { | ||
window.addEventListener("sessionStorageChange", handleStorageChange); | ||
|
||
return () => { | ||
window.removeEventListener("sessionStorageChange", handleStorageChange); | ||
}; | ||
}, []); | ||
|
||
const initiateFromEnv = () => { | ||
window.sessionStorage.setItem("SHOW_THEME_SWITCHER", process.env.GATSBY_SHOW_THEME_SWITCHER ?? ""); | ||
window.sessionStorage.setItem("API_BASE_URL", process.env.GATSBY_API_BASE_URL ?? ""); | ||
window.sessionStorage.setItem("NL_DESIGN_THEME_CLASSNAME", process.env.GATSBY_NL_DESIGN_THEME_CLASSNAME ?? ""); | ||
window.sessionStorage.setItem("FAVICON_URL", process.env.GATSBY_FAVICON_URL ?? ""); | ||
window.sessionStorage.setItem("ORGANISATION_NAME", process.env.GATSBY_ORGANISATION_NAME ?? ""); | ||
window.sessionStorage.setItem("JUMBOTRON_IMAGE_URL", process.env.GATSBY_JUMBOTRON_IMAGE_URL ?? ""); | ||
window.sessionStorage.setItem("FOOTER_LOGO_HREF", process.env.GATSBY_FOOTER_LOGO_HREF ?? ""); | ||
window.sessionStorage.setItem("FOOTER_CONTENT", process.env.GATSBY_FOOTER_CONTENT ?? ""); | ||
window.sessionStorage.setItem("FOOTER_CONTENT_HEADER", process.env.GATSBY_FOOTER_CONTENT_HEADER ?? ""); | ||
window.sessionStorage.setItem("OIDN_NUMBER", process.env.GATSBY_OIDN_NUMBER ?? ""); | ||
|
||
updateSessionStorage(); | ||
}; | ||
|
||
const initiateFromJSON = (themeOrDomainName: string) => { | ||
const config = getConfig(themeOrDomainName); | ||
|
||
if (!config) return; // no config found, nothing else to do | ||
|
||
window.sessionStorage.setItem("SHOW_THEME_SWITCHER", config.GATSBY_SHOW_THEME_SWITCHER ?? ""); | ||
window.sessionStorage.setItem("API_BASE_URL", config.GATSBY_API_BASE_URL ?? ""); | ||
window.sessionStorage.setItem("NL_DESIGN_THEME_CLASSNAME", config.GATSBY_NL_DESIGN_THEME_CLASSNAME ?? ""); | ||
window.sessionStorage.setItem("FAVICON_URL", config.GATSBY_FAVICON_URL ?? ""); | ||
window.sessionStorage.setItem("ORGANISATION_NAME", config.GATSBY_ORGANISATION_NAME ?? ""); | ||
window.sessionStorage.setItem("JUMBOTRON_IMAGE_URL", config.GATSBY_JUMBOTRON_IMAGE_URL ?? ""); | ||
window.sessionStorage.setItem("FOOTER_LOGO_HREF", config.GATSBY_FOOTER_LOGO_HREF ?? ""); | ||
window.sessionStorage.setItem("FOOTER_CONTENT", config.GATSBY_FOOTER_CONTENT ?? ""); | ||
window.sessionStorage.setItem("FOOTER_CONTENT_HEADER", config.GATSBY_FOOTER_CONTENT_HEADER ?? ""); | ||
window.sessionStorage.setItem("OIDN_NUMBER", config.GATSBY_OIDN_NUMBER ?? ""); | ||
|
||
updateSessionStorage(); | ||
}; | ||
|
||
const themeSwitcherMiddleware = () => { | ||
switch (window.location.hostname) { | ||
case "koophulpje.nl": | ||
// case "localhost": // development purposes | ||
window.sessionStorage.setItem("SHOW_THEME_SWITCHER", "true"); | ||
break; | ||
} | ||
|
||
if (process.env.GATSBY_SHOW_THEME_SWITCHER === "true") window.sessionStorage.setItem("SHOW_THEME_SWITCHER", "true"); | ||
}; | ||
|
||
return { initiateFromEnv, initiateFromJSON }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
pwa/src/templates/templateParts/themeSwitcherTopBar/ThemeSwitcherTopBar.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.container { | ||
top: 12px; | ||
width: 80%; | ||
z-index: 100; | ||
padding: 12px 32px; | ||
display: flex; | ||
position: sticky; | ||
border-radius: 5px; | ||
align-items: center; | ||
margin: 0 auto 24px; | ||
background-color: white; | ||
justify-content: space-between; | ||
box-shadow: rgb(0, 0, 0, 0.1) 0px 0px 11px 0px; | ||
} | ||
|
||
.container > * { | ||
flex: 1; | ||
} | ||
|
||
.label { | ||
font-weight: 700 !important; | ||
} |
Oops, something went wrong.