1- import React , { useEffect , useState , lazy , Suspense } from 'react' ;
1+ import React , { useEffect , useState , lazy , Suspense } from 'react' ;
22import { BrowserRouter as Router , Routes , Route } from "react-router-dom" ;
33
44import Navbar from './Navbar'
55import Bookmarks from './pages/Bookmarks.jsx' ;
66import Loader from './components/Loader' ;
77import NotFound from './components/NotFound.jsx' ;
88import './App.css' ;
9+ import ReadingMode from './components/ReadingMode.jsx' ;
10+ import { useGlobalContext } from './Context.jsx' ;
911
1012const Home = lazy ( ( ) => import ( './pages/Home.jsx' ) ) ;
1113
1214export const App = ( ) => {
1315 const [ theme , setTheme ] = useState ( 'light' ) ;
16+ const { readingMode } = useGlobalContext ( ) ;
1417
1518 useEffect ( ( ) => {
1619 document . body . classList . toggle ( 'darkmode' , theme === 'dark' ) ;
@@ -21,43 +24,58 @@ export const App = () => {
2124 setTheme ( newTheme ) ;
2225 } ;
2326
27+ useEffect ( ( ) => {
28+ if ( readingMode === true ) {
29+ document . body . classList . add ( 'scroll-none' ) ;
30+ } else {
31+ document . body . classList . remove ( 'scroll-none' ) ;
32+ }
33+ } , [ readingMode ] ) ;
34+
2435 return (
2536 < Router >
26- < Navbar />
37+ {
38+ readingMode !== true && < Navbar />
39+ }
2740 < Suspense fallback = { < Loader /> } >
2841 { /* Navbar */ }
2942
30- { /* Theme toggle button */ }
31- < button className = "theme-switch" onClick = { handleClick } aria-label = "Toggle Theme"
32- aria-pressed = { theme === 'dark' } aria-labelledby = "theme-switch-label"
33- >
34- < svg
35- xmlns = "http://www.w3.org/2000/svg"
36- height = "40px"
37- viewBox = "0 -960 960 960"
38- width = "40px"
39- fill = "#e3e3e3"
40- >
41- < path d = "M480-346.67q55.33 0 94.33-39t39-94.33q0-55.33-39-94.33t-94.33-39q-55.33 0-94.33 39t-39 94.33q0 55.33 39 94.33t94.33 39Zm0 66.67q-83 0-141.5-58.5T280-480q0-83 58.5-141.5T480-680q83 0 141.5 58.5T680-480q0 83-58.5 141.5T480-280ZM200-446.67H40v-66.66h160v66.66Zm720 0H760v-66.66h160v66.66ZM446.67-760v-160h66.66v160h-66.66Zm0 720v-160h66.66v160h-66.66ZM260-655.33l-100.33-97 47.66-49 96 100-43.33 46Zm493.33 496-97.66-100.34 45-45.66 99.66 97.66-47 48.34Zm-98.66-541.34 97.66-99.66 49 47L702-656l-47.33-44.67ZM159.33-207.33 259-305l46.33 45.67-97.66 99.66-48.34-47.66ZM480-480Z" />
42- </ svg >
43- < svg
44- xmlns = "http://www.w3.org/2000/svg"
45- height = "40px"
46- viewBox = "0 -960 960 960"
47- width = "40px"
48- fill = "#e3e3e3"
49- >
50- < path d = "M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q10 0 20.5.67 10.5.66 24.17 2-37.67 31-59.17 77.83T444-660q0 90 63 153t153 63q53 0 99.67-20.5 46.66-20.5 77.66-56.17 1.34 12.34 2 21.84.67 9.5.67 18.83 0 150-105 255T480-120Zm0-66.67q102 0 179.33-61.16Q736.67-309 760.67-395.67q-23.34 9-49.11 13.67-25.78 4.67-51.56 4.67-117.46 0-200.06-82.61-82.61-82.6-82.61-200.06 0-22.67 4.34-47.67 4.33-25 14.66-55-91.33 28.67-150.5 107-59.16 78.34-59.16 175.67 0 122 85.66 207.67Q358-186.67 480-186.67Zm-6-288Z" />
51- </ svg >
52- </ button >
43+ < ReadingMode >
44+ { /* Theme toggle button */ }
45+ {
46+ readingMode !== true &&
47+ < button className = "theme-switch" onClick = { handleClick } aria-label = "Toggle Theme"
48+ aria-pressed = { theme === 'dark' } aria-labelledby = "theme-switch-label"
49+ >
50+ < svg
51+ xmlns = "http://www.w3.org/2000/svg"
52+ height = "40px"
53+ viewBox = "0 -960 960 960"
54+ width = "40px"
55+ fill = "#e3e3e3"
56+ >
57+ < path d = "M480-346.67q55.33 0 94.33-39t39-94.33q0-55.33-39-94.33t-94.33-39q-55.33 0-94.33 39t-39 94.33q0 55.33 39 94.33t94.33 39Zm0 66.67q-83 0-141.5-58.5T280-480q0-83 58.5-141.5T480-680q83 0 141.5 58.5T680-480q0 83-58.5 141.5T480-280ZM200-446.67H40v-66.66h160v66.66Zm720 0H760v-66.66h160v66.66ZM446.67-760v-160h66.66v160h-66.66Zm0 720v-160h66.66v160h-66.66ZM260-655.33l-100.33-97 47.66-49 96 100-43.33 46Zm493.33 496-97.66-100.34 45-45.66 99.66 97.66-47 48.34Zm-98.66-541.34 97.66-99.66 49 47L702-656l-47.33-44.67ZM159.33-207.33 259-305l46.33 45.67-97.66 99.66-48.34-47.66ZM480-480Z" />
58+ </ svg >
59+ < svg
60+ xmlns = "http://www.w3.org/2000/svg"
61+ height = "40px"
62+ viewBox = "0 -960 960 960"
63+ width = "40px"
64+ fill = "#e3e3e3"
65+ >
66+ < path d = "M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q10 0 20.5.67 10.5.66 24.17 2-37.67 31-59.17 77.83T444-660q0 90 63 153t153 63q53 0 99.67-20.5 46.66-20.5 77.66-56.17 1.34 12.34 2 21.84.67 9.5.67 18.83 0 150-105 255T480-120Zm0-66.67q102 0 179.33-61.16Q736.67-309 760.67-395.67q-23.34 9-49.11 13.67-25.78 4.67-51.56 4.67-117.46 0-200.06-82.61-82.61-82.6-82.61-200.06 0-22.67 4.34-47.67 4.33-25 14.66-55-91.33 28.67-150.5 107-59.16 78.34-59.16 175.67 0 122 85.66 207.67Q358-186.67 480-186.67Zm-6-288Z" />
67+ </ svg >
68+ </ button >
69+ }
5370
54- { /* Routes for different sections */ }
55- < Routes >
56- < Route path = "/" element = { < Home /> } />
57- < Route path = "/bookmarks" element = { < Bookmarks /> } />
58- < Route path = "*" element = { < NotFound /> } />
59- </ Routes >
71+ { /* Routes for different sections */ }
72+ < Routes >
73+ < Route path = "/" element = { < Home /> } />
74+ < Route path = "/bookmarks" element = { < Bookmarks /> } />
75+ < Route path = "*" element = { < NotFound /> } />
76+ </ Routes >
6077
78+ </ ReadingMode >
6179 </ Suspense >
6280 </ Router >
6381 ) ;
0 commit comments