@@ -12,29 +12,40 @@ import "../global-styles.css";
1212import { responsiveSizes } from "../screens/common/variables.js" ;
1313import SidenavLogo from "@/common/sidenav/SidenavLogo" ;
1414import { useRouter } from "next/router" ;
15- import { LinksSectionDetails , LinksSections } from "@/common/pagesList" ;
15+ import {
16+ LinksSectionDetails ,
17+ LinksSections ,
18+ themeGeneratorLinks ,
19+ } from "@/common/pagesList" ;
1620import Link from "next/link" ;
1721
1822type NextPageWithLayout = NextPage & {
1923 getLayout ?: ( page : ReactElement ) => ReactNode ;
2024} ;
21-
2225type AppPropsWithLayout = AppProps & {
2326 Component : NextPageWithLayout ;
2427} ;
28+ type ApplicationLayoutWrapperProps = {
29+ condition : boolean ;
30+ wrapper : ( children : React . ReactNode ) => JSX . Element ;
31+ children : ReactNode ;
32+ } ;
2533
26- function MyApp ( { Component, pageProps } : AppPropsWithLayout ) {
27- const getLayout = Component . getLayout || ( ( page ) => page ) ;
34+ const ApplicationLayoutWrapper = ( {
35+ condition,
36+ wrapper,
37+ children,
38+ } : ApplicationLayoutWrapperProps ) : JSX . Element => (
39+ < > { condition ? wrapper ( children ) : children } </ >
40+ ) ;
2841
42+ const MyApp = ( { Component, pageProps } : AppPropsWithLayout ) => {
43+ const getLayout = Component . getLayout || ( ( page ) => page ) ;
2944 const componentWithLayout = getLayout ( < Component { ...pageProps } /> ) ;
3045
3146 const [ filter , setFilter ] = useState ( "" ) ;
3247 const { asPath : currentPath } = useRouter ( ) ;
3348
34- const onFilterInputChange = ( { value } : { value : string } ) => {
35- setFilter ( value ) ;
36- } ;
37-
3849 const filteredLinks = useMemo ( ( ) => {
3950 const filtered : LinksSectionDetails [ ] = [ ] ;
4051 LinksSections . map ( ( section ) => {
@@ -47,64 +58,76 @@ function MyApp({ Component, pageProps }: AppPropsWithLayout) {
4758 } ) ;
4859 return filtered ;
4960 } , [ filter ] ) ;
61+
62+ const onFilterInputChange = ( { value } : { value : string } ) => {
63+ setFilter ( value ) ;
64+ } ;
65+
5066 return (
5167 < >
5268 < Head >
5369 < link rel = "icon" type = "image/png" sizes = "32x32" href = "/favicon.png" />
5470 </ Head >
55- < HalstackProvider advancedTheme = { { } } >
56- < DxcApplicationLayout
57- visibilityToggleLabel = "Menu"
58- sidenav = {
59- < DxcApplicationLayout . SideNav title = { < SidenavLogo /> } >
60- < DxcApplicationLayout . SideNav . Section >
61- < DxcTextInput
62- placeholder = "Search docs"
63- value = { filter }
64- onChange = { onFilterInputChange }
65- size = "fillParent"
66- clearable
67- margin = { {
68- top : "small" ,
69- bottom : "small" ,
70- right : "xsmall" ,
71- left : "xsmall" ,
72- } }
73- />
74- </ DxcApplicationLayout . SideNav . Section >
75- { filteredLinks ?. map ( ( { label, links } ) => {
76- return (
77- < DxcApplicationLayout . SideNav . Section key = { label } >
78- < DxcApplicationLayout . SideNav . Group title = { label } >
79- { links . map ( ( { label, path } ) => (
80- < Link key = { `${ label } -${ path } ` } href = { path } passHref >
81- < DxcApplicationLayout . SideNav . Link
82- selected = {
83- currentPath . slice ( 0 , - 1 ) === path ||
84- currentPath . slice ( 0 , - 1 ) ===
85- path + "/specifications" ||
86- currentPath . slice ( 0 , - 1 ) === path + "/usage"
87- }
88- >
89- { label }
90- </ DxcApplicationLayout . SideNav . Link >
91- </ Link >
92- ) ) }
93- </ DxcApplicationLayout . SideNav . Group >
71+ < HalstackProvider >
72+ < ApplicationLayoutWrapper
73+ condition = { ! themeGeneratorLinks . includes ( currentPath ) }
74+ wrapper = { ( children ) => (
75+ < DxcApplicationLayout
76+ visibilityToggleLabel = "Menu"
77+ sidenav = {
78+ < DxcApplicationLayout . SideNav title = { < SidenavLogo /> } >
79+ < DxcApplicationLayout . SideNav . Section >
80+ < DxcTextInput
81+ placeholder = "Search docs"
82+ value = { filter }
83+ onChange = { onFilterInputChange }
84+ size = "fillParent"
85+ clearable
86+ margin = { {
87+ top : "small" ,
88+ bottom : "small" ,
89+ right : "xsmall" ,
90+ left : "xsmall" ,
91+ } }
92+ />
9493 </ DxcApplicationLayout . SideNav . Section >
95- ) ;
96- } ) }
97- </ DxcApplicationLayout . SideNav >
98- }
94+ { filteredLinks ?. map ( ( { label, links } ) => {
95+ return (
96+ < DxcApplicationLayout . SideNav . Section key = { label } >
97+ < DxcApplicationLayout . SideNav . Group title = { label } >
98+ { links . map ( ( { label, path } ) => (
99+ < Link key = { `${ label } -${ path } ` } href = { path } passHref >
100+ < DxcApplicationLayout . SideNav . Link
101+ selected = {
102+ currentPath . slice ( 0 , - 1 ) === path ||
103+ currentPath . slice ( 0 , - 1 ) ===
104+ path + "/specifications" ||
105+ currentPath . slice ( 0 , - 1 ) === path + "/usage"
106+ }
107+ >
108+ { label }
109+ </ DxcApplicationLayout . SideNav . Link >
110+ </ Link >
111+ ) ) }
112+ </ DxcApplicationLayout . SideNav . Group >
113+ </ DxcApplicationLayout . SideNav . Section >
114+ ) ;
115+ } ) }
116+ </ DxcApplicationLayout . SideNav >
117+ }
118+ >
119+ < DxcApplicationLayout . Main >
120+ < MainContainer > { children } </ MainContainer >
121+ </ DxcApplicationLayout . Main >
122+ </ DxcApplicationLayout >
123+ ) }
99124 >
100- < DxcApplicationLayout . Main >
101- < MainContainer > { componentWithLayout } </ MainContainer >
102- </ DxcApplicationLayout . Main >
103- </ DxcApplicationLayout >
125+ { componentWithLayout }
126+ </ ApplicationLayoutWrapper >
104127 </ HalstackProvider >
105128 </ >
106129 ) ;
107- }
130+ } ;
108131
109132const MainContainer = styled . div `
110133 margin: 80px auto;
0 commit comments