11import { useState } from "react" ;
22import { Link } from "react-router-dom" ;
3- import logo from "../assets/logo_light_160.png" ;
3+ import logo_light from "../assets/logo_light_160.png" ;
4+ import logo_dark from "../assets/logo_dark_160.png" ;
45import { SideSheet } from "@douyinfe/semi-ui" ;
56import { IconMenu } from "@douyinfe/semi-icons" ;
67import { socials } from "../data/socials" ;
8+ import ThemeToggle from "./ThemeToggle" ;
9+ import { useTheme } from "../context/ThemeContext" ;
710
811export default function Navbar ( ) {
912 const [ openMenu , setOpenMenu ] = useState ( false ) ;
13+ const { theme } = useTheme ( ) ;
1014
1115 return (
1216 < >
13- < div className = "py-4 px-12 sm:px-4 flex justify-between items-center" >
17+ < div className = "py-4 px-12 sm:px-4 flex justify-between items-center dark:bg-gray-900 dark:text-white " >
1418 < div className = "flex items-center justify-between w-full" >
1519 < Link to = "/" >
16- < img src = { logo } alt = "logo" className = "h-[48px] sm:h-[32px]" />
20+ < img src = { theme === "dark" ? logo_dark : logo_light } alt = "logo" className = "h-[48px] sm:h-[32px]" />
1721 </ Link >
1822 < div className = "md:hidden flex gap-12" >
1923 < Link
20- className = "text-lg font-semibold hover:text-sky-800 transition-colors duration-300"
24+ className = "text-lg font-semibold hover:text-sky-800 dark:hover:text-sky-400 transition-colors duration-300"
2125 onClick = { ( ) =>
2226 document
2327 . getElementById ( "features" )
@@ -28,24 +32,25 @@ export default function Navbar() {
2832 </ Link >
2933 < Link
3034 to = "/editor"
31- className = "text-lg font-semibold hover:text-sky-800 transition-colors duration-300"
35+ className = "text-lg font-semibold hover:text-sky-800 dark:hover:text-sky-400 transition-colors duration-300"
3236 >
3337 Editor
3438 </ Link >
3539 < Link
3640 to = "/templates"
37- className = "text-lg font-semibold hover:text-sky-800 transition-colors duration-300"
41+ className = "text-lg font-semibold hover:text-sky-800 dark:hover:text-sky-400 transition-colors duration-300"
3842 >
3943 Templates
4044 </ Link >
4145 < Link
4246 to = { socials . docs }
43- className = "text-lg font-semibold hover:text-sky-800 transition-colors duration-300"
47+ className = "text-lg font-semibold hover:text-sky-800 dark:hover:text-sky-400 transition-colors duration-300"
4448 >
4549 Docs
4650 </ Link >
4751 </ div >
48- < div className = "md:hidden block space-x-3 ms-12" >
52+ < div className = "md:hidden flex items-center space-x-3 ms-12" >
53+ < ThemeToggle />
4954 < a
5055 title = "Jump to Github"
5156 className = "px-2 py-2 hover:opacity-60 transition-all duration-300 rounded-full text-2xl"
@@ -85,14 +90,19 @@ export default function Navbar() {
8590 < hr />
8691 < SideSheet
8792 title = {
88- < img src = { logo } alt = "logo" className = "sm:h-[32px] md:h-[42px]" />
93+ < img src = { theme === "dark" ? logo_dark : logo_light } alt = "logo" className = "sm:h-[32px] md:h-[42px]" />
8994 }
9095 visible = { openMenu }
9196 onCancel = { ( ) => setOpenMenu ( false ) }
9297 width = { window . innerWidth }
9398 >
99+ < div className = "flex justify-between items-center p-3" >
100+ < span className = "text-base font-semibold" > Theme</ span >
101+ < ThemeToggle />
102+ </ div >
103+ < hr />
94104 < Link
95- className = "hover:bg-zinc-100 block p-3 text-base font-semibold"
105+ className = "hover:bg-zinc-100 dark:hover:bg-gray-800 block p-3 text-base font-semibold"
96106 onClick = { ( ) => {
97107 document
98108 . getElementById ( "features" )
@@ -105,21 +115,21 @@ export default function Navbar() {
105115 < hr />
106116 < Link
107117 to = "/editor"
108- className = "hover:bg-zinc-100 block p-3 text-base font-semibold"
118+ className = "hover:bg-zinc-100 dark:hover:bg-gray-800 block p-3 text-base font-semibold"
109119 >
110120 Editor
111121 </ Link >
112122 < hr />
113123 < Link
114124 to = "/templates"
115- className = "hover:bg-zinc-100 block p-3 text-base font-semibold"
125+ className = "hover:bg-zinc-100 dark:hover:bg-gray-800 block p-3 text-base font-semibold"
116126 >
117127 Templates
118128 </ Link >
119129 < hr />
120130 < Link
121131 to = { socials . docs }
122- className = "hover:bg-zinc-100 block p-3 text-base font-semibold"
132+ className = "hover:bg-zinc-100 dark:hover:bg-gray-800 block p-3 text-base font-semibold"
123133 >
124134 Docs
125135 </ Link >
0 commit comments