diff --git a/docusaurus.config.js b/docusaurus.config.js index 25d9980f..897f83e5 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -57,6 +57,8 @@ const config = { }, ], + clientModules: [require.resolve("./src/clientModules/cloud-communication.ts")], + plugins: [ "docusaurus-plugin-sass", [ diff --git a/src/clientModules/cloud-communication.ts b/src/clientModules/cloud-communication.ts new file mode 100644 index 00000000..feefd8c4 --- /dev/null +++ b/src/clientModules/cloud-communication.ts @@ -0,0 +1,25 @@ +import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment"; + +const globalParams = { + cookie: { + hide: true, + }, +}; + +if (ExecutionEnvironment.canUseDOM) { + document.addEventListener("DOMContentLoaded", function () { + console.log("Test DOM loaded"); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + window.globalParams = globalParams; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + console.log("window.globalParams", window.globalParams); + const cookieBannerElem = document.querySelector(".react-cookie-banner"); + console.log("cookieBannerElem", cookieBannerElem); + if (cookieBannerElem) { + console.log("Cookie banner exist"); + cookieBannerElem.style.display = "none"; + } + }); +} diff --git a/src/components/CookieBanner/index.module.scss b/src/components/CookieBanner/index.module.scss index 25aa971d..5ca611a4 100644 --- a/src/components/CookieBanner/index.module.scss +++ b/src/components/CookieBanner/index.module.scss @@ -34,6 +34,10 @@ } } +.bannerHide { + display: none; +} + @media (max-width: $infimaBP) { .banner { flex-flow: column wrap; diff --git a/src/components/CookieBanner/index.tsx b/src/components/CookieBanner/index.tsx index e9c19098..c187dbd0 100644 --- a/src/components/CookieBanner/index.tsx +++ b/src/components/CookieBanner/index.tsx @@ -6,7 +6,9 @@ import styles from "./index.module.scss"; export const CookiesMessageBanner: FC = () => { const cookies = new Cookies(); - if (!cookies || cookies.get("accepts-cookies")) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + if (!cookies || cookies.get("accepts-cookies") || window.globalParams?.cookie?.hide) { return null; }