diff --git a/src/UI/Navigation.js b/src/UI/Navigation.js index f274b80..f7f9a64 100644 --- a/src/UI/Navigation.js +++ b/src/UI/Navigation.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useEffect, useState} from 'react'; import {Link} from 'react-router-dom'; import './Navigation.css'; @@ -7,12 +7,27 @@ import './Navigation.css'; let section = window.location.pathname.split('/')[2]; let chapter = window.location.pathname.split('/')[3]; -const Navigation = (props) => { +const Navigation = () => { + const [theme, setTheme] = useState( + localStorage.getItem('theme') || 'light' + ); + + useEffect(() => { + localStorage.setItem('theme', theme); + document.body.className = theme; + }, [theme]); + + + + const toggleTheme = () => { + setTheme((theme === 'light') ? 'dark' : 'light'); + } + return ( -