diff --git a/public/js/toggleTheme.js b/public/js/toggleTheme.js new file mode 100644 index 0000000..fb4997b --- /dev/null +++ b/public/js/toggleTheme.js @@ -0,0 +1,29 @@ +function applyTheme() { + if (!("theme" in localStorage)) { + if (window.matchMedia("(prefers-color-scheme: dark)").matches) { + localStorage.theme = "dark"; + } else { + localStorage.theme = "light"; + } + } + + if (localStorage.theme === "dark") { + document.documentElement.classList.add("dark"); + document.querySelector("#themeButtonIcon").innerHTML = "light_mode"; + } else { + document.documentElement.classList.remove("dark"); + document.querySelector("#themeButtonIcon").innerHTML = "dark_mode"; + } +} + +function toggleTheme() { + if (localStorage.theme === "dark") { + localStorage.theme = "light"; + } else { + localStorage.theme = "dark"; + } + applyTheme(); +} + +applyTheme(); +document.querySelector("#themeButton").onclick = () => toggleTheme(); diff --git a/src/components/AppLayout.tsx b/src/components/AppLayout.tsx index e6220d8..8a4bd8c 100644 --- a/src/components/AppLayout.tsx +++ b/src/components/AppLayout.tsx @@ -16,6 +16,7 @@ import { } from "redux/appLayoutSlice"; import { RootState } from "redux/store"; import ReactTooltip from "react-tooltip"; +import Script from "next/script"; type AppLayoutProps = { subPanel?: React.ReactNode; @@ -44,7 +45,7 @@ export default function AppLayout(props: AppLayoutProps): JSX.Element { const subPanelOpen = useSelector( (state: RootState) => state.appLayout.subPanelOpen ); - + const sensibilitySwipe = 1.1; const handlers = useSwipeable({ @@ -135,7 +136,7 @@ export default function AppLayout(props: AppLayoutProps): JSX.Element { {/* Background when navbar is opened */}
@@ -226,8 +227,10 @@ export default function AppLayout(props: AppLayoutProps): JSX.Element { delayShow={300} delayHide={100} disable={!mainPanelReduced || isMobile || isCoarse} - className="drop-shadow-dark-xl !opacity-100 !bg-light !rounded-lg after:!border-r-light text-left" + className="drop-shadow-shade-xl !opacity-100 !bg-light !rounded-lg after:!border-r-light text-left !text-black" /> + +