File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import Contact from './pages/Contact';
9
9
10
10
function App ( ) {
11
11
return (
12
- < div className = "App " >
12
+ < div className = " bg-secondary-light dark:bg-primary-dark transition duration-500 " >
13
13
< Router >
14
14
< AppHeader > </ AppHeader >
15
15
< Routes >
Original file line number Diff line number Diff line change 1
1
import { FiMoon , FiSun } from 'react-icons/fi' ;
2
2
import { Link } from 'react-router-dom' ;
3
+ import ThemeSwitcher from '../hooks/ThemeSwitcher' ;
3
4
4
5
// import logoLight from '../images/logo-light.svg';
5
6
import logoDark from '../images/logo-dark.svg' ;
6
7
7
8
const AppHeader = ( ) => {
9
+ const [ activeTheme , setTheme ] = ThemeSwitcher ( ) ;
10
+
8
11
return (
9
12
< div >
10
13
< nav id = "nav" className = "sm:container sm:mx-auto" >
11
14
{ /* Header start */ }
12
- < div className = "z-10 max-w-screen-lg xl:max-w-screen-xl block sm:flex sm:justify-between sm:items-center my -6" >
15
+ < div className = "z-10 max-w-screen-lg xl:max-w-screen-xl block sm:flex sm:justify-between sm:items-center py -6" >
13
16
{ /* Header menu links and small screen hamburger menu start */ }
14
17
< div className = "flex justify-between items-center px-4 sm:px-0" >
15
18
< div >
@@ -103,12 +106,15 @@ const AppHeader = () => {
103
106
104
107
{ /* Theme switcher large screen */ }
105
108
< div
106
- onClick = "toggleTheme"
109
+ onClick = { ( ) => setTheme ( activeTheme ) }
107
110
aria-label = "Theme Switcher"
108
111
className = "ml-8 bg-primary-light dark:bg-ternary-dark px-3 py-2 shadow-sm rounded-xl cursor-pointer"
109
112
>
110
- < FiMoon class = "text-liText-ternary-dark hover:text-gray-400 dark:text-liText-ternary-light dark:hover:text-liBorder-primary-light w-5" />
111
- < FiSun class = "text-gray-200 hover:text-gray-50 w-5" />
113
+ { activeTheme === 'dark' ? (
114
+ < FiMoon class = "text-liText-ternary-dark hover:text-gray-400 dark:text-liText-ternary-light dark:hover:text-liBorder-primary-light w-5" />
115
+ ) : (
116
+ < FiSun class = "text-gray-200 hover:text-gray-50 w-5" />
117
+ ) }
112
118
</ div >
113
119
</ div >
114
120
</ div >
You can’t perform that action at this time.
0 commit comments