From 2ea10a2e69ef30d94cab330a95a945a706f370f7 Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 18 Oct 2022 23:03:37 +0200 Subject: [PATCH] change theme by clicking on the logo --- components/Navbar.tsx | 2 +- components/Title.tsx | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/Navbar.tsx b/components/Navbar.tsx index 3bb3bcb..9160918 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -7,7 +7,7 @@ const Navbar = () => { <>
- <ThemeToggle /> + {/* <ThemeToggle /> */} </div> </> ); diff --git a/components/Title.tsx b/components/Title.tsx index 8704303..ba53cec 100644 --- a/components/Title.tsx +++ b/components/Title.tsx @@ -1,14 +1,22 @@ import Image from "next/image"; import styles from "styles/Title.module.sass"; import { useTheme } from 'next-themes' +function the(t) { + switch (t) { + case "light": + return "dark"; + case "dark": + return "light"; + } +} const Title = () => { - const { resolvedTheme: theme } = useTheme() - const logo_size = 150; - + const { resolvedTheme: theme, setTheme: set } = useTheme(); + const logo_size = 150; + return ( <> - <Image + <Image onClick={() => set(the(theme))} src={`/logos/${theme || "dark"}.svg`} width={logo_size} height={logo_size / 4}