From a638b150890ab502b782dc8c5c17b9368ba1f154 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 18 Dec 2022 02:52:44 -0600 Subject: [PATCH] Place dark mode switch in top right with icons, Fix footer dark mode color --- package.json | 1 + src/components/DarkModeSwitch.tsx | 26 +++++++++++++++++--------- src/components/Page.tsx | 5 +++-- yarn.lock | 5 +++++ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index f4320da..213ac22 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "start": "next start" }, "dependencies": { + "@heroicons/react": "^2.0.13", "@tanstack/react-query": "^4.16.0", "@trpc/client": "^10.0.0", "@trpc/next": "^10.0.0", diff --git a/src/components/DarkModeSwitch.tsx b/src/components/DarkModeSwitch.tsx index 3a9da76..44a9cb3 100644 --- a/src/components/DarkModeSwitch.tsx +++ b/src/components/DarkModeSwitch.tsx @@ -1,8 +1,7 @@ import React, {FunctionComponent, useEffect, useState} from "react"; - -interface SwitchProps { -} +import {MoonIcon, SunIcon} from "@heroicons/react/24/outline"; +import {classNames} from "@/utils/helpers"; function setMode(dark: boolean) { if (dark) @@ -15,14 +14,21 @@ function prefersDark(): boolean { return window.matchMedia('(prefers-color-scheme: dark)').matches } -const DarkModeSwitch: FunctionComponent = ({}: SwitchProps) => { - const [, setDark] = useState(null); +interface SwitchProps { + className?: string; +} + +const DarkModeSwitch: FunctionComponent = ({className}: SwitchProps) => { + const [dark, setDark] = useState(null); useEffect(() => { - setMode(prefersDark()) - }) + if (prefersDark()) { + setDark(true); + setMode(true); + } + }, []) return + }> + {dark ? : } + } export default DarkModeSwitch; \ No newline at end of file diff --git a/src/components/Page.tsx b/src/components/Page.tsx index 9087b51..7cb0db2 100644 --- a/src/components/Page.tsx +++ b/src/components/Page.tsx @@ -10,12 +10,13 @@ interface PageProps { const Page: FunctionComponent = ({children}: PageProps) => { return ( <> -
+
+

100Prisoners.com

- + {children}
diff --git a/yarn.lock b/yarn.lock index 3dc4033..aa2e4be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -32,6 +32,11 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" +"@heroicons/react@^2.0.13": + version "2.0.13" + resolved "https://registry.yarnpkg.com/@heroicons/react/-/react-2.0.13.tgz#9b1cc54ff77d6625c9565efdce0054a4bcd9074c" + integrity sha512-iSN5XwmagrnirWlYEWNPdCDj9aRYVD/lnK3JlsC9/+fqGF80k8C7rl+1HCvBX0dBoagKqOFBs6fMhJJ1hOg1EQ== + "@humanwhocodes/config-array@^0.11.8": version "0.11.8" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9"