@@ -3,7 +3,6 @@ import { ApolloProvider } from "@apollo/client"
33import { Flex } from "@chakra-ui/react"
44
55import Footer from "./Footer"
6- import ZenMode from "./ZenMode"
76import Nav from "./Nav"
87import SideNav from "./SideNav"
98import SideNavMobile from "./SideNavMobile"
@@ -12,14 +11,10 @@ import TranslationBannerLegal from "./TranslationBannerLegal"
1211import FeedbackWidget from "./FeedbackWidget"
1312import { SkipLink } from "./SkipLink"
1413
15- import { ZenModeContext } from "../contexts/ZenModeContext"
1614import { lightTheme as oldTheme } from "../theme"
1715
18- import { useKeyPress } from "../hooks/useKeyPress"
19-
2016import { isLangRightToLeft } from "../utils/translations"
2117import { scrollIntoView } from "../utils/scrollIntoView"
22- import { isMobile } from "../utils/isMobile"
2318
2419import type { Context } from "../types"
2520
@@ -51,23 +46,11 @@ const Layout: React.FC<IProps> = ({
5146 pageContext,
5247 children,
5348} ) => {
54- const [ isZenMode , setIsZenMode ] = useState < boolean > ( false )
5549 const [ shouldShowSideNav , setShouldShowSideNav ] = useState < boolean > ( false )
5650
57- // Exit Zen Mode on 'esc' click
58- useKeyPress ( `Escape` , ( ) => handleZenModeChange ( false ) )
59-
6051 useEffect ( ( ) => {
6152 if ( path . includes ( "/docs/" ) ) {
6253 setShouldShowSideNav ( true )
63-
64- if ( localStorage . getItem ( "zen-mode" ) !== null ) {
65- setIsZenMode ( localStorage . getItem ( "zen-mode" ) === "true" && ! isMobile ( ) )
66- }
67- } else {
68- // isZenMode and shouldShowSideNav only applicable in /docs pages
69- setIsZenMode ( false )
70- setShouldShowSideNav ( false )
7154 }
7255
7356 if ( location . hash && ! location . hash . includes ( "gatsby" ) ) {
@@ -76,16 +59,6 @@ const Layout: React.FC<IProps> = ({
7659 }
7760 } , [ path , location ] )
7861
79- const handleZenModeChange = ( val ?: boolean ) : void => {
80- // Use 'val' param if provided. Otherwise toggle
81- const newVal = val !== undefined ? val : ! isZenMode
82-
83- setIsZenMode ( newVal )
84- if ( localStorage ) {
85- localStorage . setItem ( "zen-mode" , String ( newVal ) )
86- }
87- }
88-
8962 const isPageLanguageEnglish = pageContext . isDefaultLang
9063 const isPageContentEnglish = ! ! pageContext . isContentEnglish
9164 const isLegal = ! ! pageContext . isLegal
@@ -101,61 +74,51 @@ const Layout: React.FC<IProps> = ({
10174
10275 return (
10376 < ApolloProvider client = { client } >
104- < ZenModeContext . Provider value = { { isZenMode, handleZenModeChange } } >
105- < SkipLink hrefId = "#main-content" />
106- < TranslationBanner
107- shouldShow = { shouldShowTranslationBanner }
108- isPageContentEnglish = { isPageContentEnglish }
109- isPageRightToLeft = { isPageRightToLeft }
110- originalPagePath = { pageContext . i18n . originalPath || "" }
111- />
112- < TranslationBannerLegal
113- shouldShow = { isLegal }
114- isPageRightToLeft = { isPageRightToLeft }
115- originalPagePath = { pageContext . i18n . originalPath || "" }
116- />
117-
77+ < SkipLink hrefId = "#main-content" />
78+ < TranslationBanner
79+ shouldShow = { shouldShowTranslationBanner }
80+ isPageContentEnglish = { isPageContentEnglish }
81+ isPageRightToLeft = { isPageRightToLeft }
82+ originalPagePath = { pageContext . i18n . originalPath || "" }
83+ />
84+ < TranslationBannerLegal
85+ shouldShow = { isLegal }
86+ isPageRightToLeft = { isPageRightToLeft }
87+ originalPagePath = { pageContext . i18n . originalPath || "" }
88+ />
89+
90+ < Flex
91+ position = "relative"
92+ margin = "0px auto"
93+ minHeight = "100vh"
94+ flexFlow = "column"
95+ maxW = { {
96+ lg : oldTheme . variables . maxPageWidth ,
97+ } }
98+ >
99+ < Nav path = { path } />
100+ { shouldShowSideNav && < SideNavMobile path = { path } /> }
118101 < Flex
119- position = "relative"
120- margin = "0px auto"
121- minHeight = "100vh"
122- flexFlow = "column"
123- maxW = { {
124- lg : oldTheme . variables . maxPageWidth ,
125- } }
102+ flexDirection = { { base : "column" , lg : "row" } }
103+ id = "main-content"
104+ scrollMarginTop = { 20 }
126105 >
127- < ZenMode >
128- < Nav path = { path } />
129- { shouldShowSideNav && < SideNavMobile path = { path } /> }
130- </ ZenMode >
131- < Flex
132- flexDirection = { { base : "column" , lg : "row" } }
133- id = "main-content"
134- scrollMarginTop = { 20 }
135- >
136- { shouldShowSideNav && (
137- < ZenMode >
138- < SideNav path = { path } />
139- </ ZenMode >
140- ) }
141- < Flex flexDirection = "column" width = "100%" >
142- < Flex
143- justifyContent = "space-around"
144- alignItems = "flex-start"
145- overflow = "visible"
146- width = "100%"
147- flexGrow = "1"
148- >
149- { children }
150- </ Flex >
106+ { shouldShowSideNav && < SideNav path = { path } /> }
107+ < Flex flexDirection = "column" width = "100%" >
108+ < Flex
109+ justifyContent = "space-around"
110+ alignItems = "flex-start"
111+ overflow = "visible"
112+ width = "100%"
113+ flexGrow = "1"
114+ >
115+ { children }
151116 </ Flex >
152117 </ Flex >
153- < ZenMode >
154- < Footer />
155- </ ZenMode >
156- < FeedbackWidget location = { path } />
157118 </ Flex >
158- </ ZenModeContext . Provider >
119+ < Footer />
120+ < FeedbackWidget location = { path } />
121+ </ Flex >
159122 </ ApolloProvider >
160123 )
161124}
0 commit comments