@@ -96,7 +96,8 @@ const classes = {
9696 subHeading : `${ PREFIX } -subHeading` ,
9797 homeIcon : `${ PREFIX } -homeIcon` ,
9898 mobileHeading : `${ PREFIX } -mobileHeading` ,
99- mobileMenu : `${ PREFIX } -mobileMenu`
99+ mobileMenu : `${ PREFIX } -mobileMenu` ,
100+ disableNav : `${ PREFIX } -disableNav` ,
100101} ;
101102
102103
@@ -152,7 +153,7 @@ const Template: React.FC<PropsWithChildren<LayoutProps & TemplateProps>> = ({
152153 } , [ ] )
153154
154155 return (
155- < div className = { classes . root } >
156+ < StyledTemplate className = { classes . root } >
156157 < Helmet
157158 htmlAttributes = { {
158159 lang : "en" ,
@@ -163,7 +164,12 @@ const Template: React.FC<PropsWithChildren<LayoutProps & TemplateProps>> = ({
163164 < link rel = "canonical" href = "https://ga-dev-tools.google/" />
164165 < title > { title } </ title >
165166 </ Helmet >
166- < AppBar position = "static" className = { classes . appBarNav } >
167+ < AppBar
168+ position = "static"
169+ className = { clsx ( classes . appBarNav , {
170+ [ classes . disableNav ] : disableNav ,
171+ } ) }
172+ >
167173 < IconButton
168174 edge = "start"
169175 onClick = { ( ) => setOpen ( true ) }
@@ -183,7 +189,7 @@ const Template: React.FC<PropsWithChildren<LayoutProps & TemplateProps>> = ({
183189 userStatus = { userStatus ! }
184190 />
185191 ) }
186- < Drawer open = { open } onClose = { ( ) => setOpen ( false ) } >
192+ < StyledDrawer open = { open } onClose = { ( ) => setOpen ( false ) } >
187193 < List className = { classes . mobileNav } >
188194 < Link
189195 to = { gaVersion === GAVersion . UniversalAnalytics ? "/" : "/ga4/" }
@@ -223,7 +229,7 @@ const Template: React.FC<PropsWithChildren<LayoutProps & TemplateProps>> = ({
223229 )
224230 } ) }
225231 </ List >
226- </ Drawer >
232+ </ StyledDrawer >
227233 </ AppBar >
228234 < nav className = { classes . nav } >
229235 < ol >
@@ -326,10 +332,74 @@ const Template: React.FC<PropsWithChildren<LayoutProps & TemplateProps>> = ({
326332 < BugReport />
327333 </ footer >
328334 </ main >
329- </ div >
335+ </ StyledTemplate >
330336 )
331337}
332338
339+ const navItemStyles = ( theme : Theme ) => ( {
340+ [ `& .${ classes . noColor } ` ] : {
341+ color : "unset" ,
342+ } ,
343+
344+ [ `& .${ classes . innerNav } ` ] : {
345+ padding : theme . spacing ( 1 ) ,
346+ paddingLeft : theme . spacing ( 4 ) ,
347+ [ mobile ( theme ) ] : {
348+ paddingLeft : theme . spacing ( 2 ) ,
349+ paddingRight : theme . spacing ( 2 ) ,
350+ } ,
351+ } ,
352+
353+ [ `& .${ classes . navLinkBackgroundHover } ` ] : {
354+ "&:hover" : {
355+ backgroundColor : theme . palette . grey [ 100 ] ,
356+ color : theme . palette . getContrastText ( theme . palette . grey [ 100 ] ) ,
357+ } ,
358+ } ,
359+
360+ [ `& .${ classes . home } ` ] : {
361+ margin : "unset" ,
362+ color : "unset" ,
363+ display : "flex" ,
364+ alignItems : "center" ,
365+ paddingLeft : theme . spacing ( 2 ) ,
366+ [ notMobile ( theme ) ] : {
367+ "&:hover" : {
368+ color : theme . palette . primary . main ,
369+ } ,
370+ } ,
371+ } ,
372+
373+ [ `& .${ classes . subHeading } ` ] : {
374+ width : "100%" ,
375+ borderTop : `1px solid ${ theme . palette . grey [ 600 ] } ` ,
376+ marginTop : theme . spacing ( 2 ) ,
377+ paddingTop : theme . spacing ( 2 ) ,
378+ marginBottom : theme . spacing ( 1 ) ,
379+ paddingLeft : theme . spacing ( 4 ) ,
380+ [ mobile ( theme ) ] : {
381+ paddingLeft : theme . spacing ( 2 ) ,
382+ } ,
383+ } ,
384+
385+ [ `& .${ classes . homeIcon } ` ] : {
386+ marginLeft : theme . spacing ( - 0.5 ) ,
387+ paddingRight : theme . spacing ( 1 ) ,
388+ fontSize : "1.5em" ,
389+ } ,
390+ } )
391+
392+ // The Drawer renders in a portal outside of StyledTemplate, so it needs its own
393+ // styles.
394+ const StyledDrawer = styled ( Drawer ) ( ( { theme } ) => ( {
395+ [ `& .${ classes . mobileNav } ` ] : {
396+ color : theme . palette . getContrastText ( theme . palette . grey [ 800 ] ) ,
397+ backgroundColor : theme . palette . grey [ 800 ] ,
398+ minHeight : "100%" ,
399+ } ,
400+ ...navItemStyles ( theme ) ,
401+ } ) )
402+
333403const StyledTemplate = styled ( 'div' ) ( (
334404 {
335405 theme
@@ -357,7 +427,7 @@ const StyledTemplate = styled('div')((
357427 alignItems : "center" ,
358428 } ,
359429
360- [ `& .${ classes . root } ` ] : {
430+ [ `&.${ classes . root } ` ] : {
361431 display : "flex" ,
362432 minHeight : "100%" ,
363433 [ notMobile ( theme ) ] : {
@@ -421,7 +491,7 @@ const StyledTemplate = styled('div')((
421491
422492 [ `& .${ classes . appBarNav } ` ] : {
423493
424- [ theme . breakpoints . up ( "md" ) ] :
494+ [ notMobile ( theme ) ] :
425495 {
426496 display : "none" ,
427497 } ,
@@ -430,10 +500,8 @@ const StyledTemplate = styled('div')((
430500 paddingLeft : theme . spacing ( 1 ) ,
431501 } ,
432502
433- [ `& .${ classes . mobileNav } ` ] : {
434- color : theme . palette . getContrastText ( theme . palette . grey [ 800 ] ) ,
435- backgroundColor : theme . palette . grey [ 800 ] ,
436- minHeight : "100%" ,
503+ [ `& .${ classes . appBarNav } .${ classes . disableNav } ` ] : {
504+ display : "none" ,
437505 } ,
438506
439507 [ `& .${ classes . nav } ` ] : {
@@ -462,56 +530,7 @@ const StyledTemplate = styled('div')((
462530 } ,
463531 } ,
464532
465- [ `& .${ classes . noColor } ` ] : {
466- color : "unset" ,
467- } ,
468-
469- [ `& .${ classes . innerNav } ` ] : {
470- padding : theme . spacing ( 1 ) ,
471- paddingLeft : theme . spacing ( 4 ) ,
472- [ mobile ( theme ) ] : {
473- paddingLeft : theme . spacing ( 2 ) ,
474- paddingRight : theme . spacing ( 2 ) ,
475- } ,
476- } ,
477-
478- [ `& .${ classes . navLinkBackgroundHover } ` ] : {
479- "&:hover" : {
480- backgroundColor : theme . palette . grey [ 100 ] ,
481- color : theme . palette . getContrastText ( theme . palette . grey [ 100 ] ) ,
482- } ,
483- } ,
484-
485- [ `& .${ classes . home } ` ] : {
486- margin : "unset" ,
487- color : "unset" ,
488- display : "flex" ,
489- alignItems : "center" ,
490- paddingLeft : theme . spacing ( 2 ) ,
491- [ notMobile ( theme ) ] : {
492- "&:hover" : {
493- color : theme . palette . primary . main ,
494- } ,
495- } ,
496- } ,
497-
498- [ `& .${ classes . subHeading } ` ] : {
499- width : "100%" ,
500- borderTop : `1px solid ${ theme . palette . grey [ 600 ] } ` ,
501- marginTop : theme . spacing ( 2 ) ,
502- paddingTop : theme . spacing ( 2 ) ,
503- marginBottom : theme . spacing ( 1 ) ,
504- paddingLeft : theme . spacing ( 4 ) ,
505- [ mobile ( theme ) ] : {
506- paddingLeft : theme . spacing ( 2 ) ,
507- } ,
508- } ,
509-
510- [ `& .${ classes . homeIcon } ` ] : {
511- marginLeft : theme . spacing ( - 0.5 ) ,
512- paddingRight : theme . spacing ( 1 ) ,
513- fontSize : "1.5em" ,
514- } ,
533+ ...navItemStyles ( theme ) ,
515534
516535 [ `& .${ classes . mobileHeading } ` ] : {
517536 color : theme . palette . getContrastText ( theme . palette . primary . main ) ,
@@ -530,10 +549,10 @@ const Layout2: React.FC<PropsWithChildren<LayoutProps>> = props => {
530549 return (
531550 < Loadable
532551 request = { request }
533- renderNotStarted = { ( ) => < StyledTemplate > < Template { ...props } notStarted /> </ StyledTemplate > }
534- renderInProgress = { ( ) => < StyledTemplate > < Template { ...props } inProgress /> </ StyledTemplate > }
552+ renderNotStarted = { ( ) => < Template { ...props } notStarted /> }
553+ renderInProgress = { ( ) => < Template { ...props } inProgress /> }
535554 renderSuccessful = { successProps => (
536- < StyledTemplate > < Template { ...props } { ...successProps } successful /> </ StyledTemplate >
555+ < Template { ...props } { ...successProps } successful />
537556 ) }
538557 renderFailed = { ( ) => < Template { ...props } failed /> }
539558 />
0 commit comments