@@ -34,7 +34,7 @@ const BodyContainer = styled.div<{ hasSidenav?: boolean }>`
3434 }
3535` ;
3636
37- const SidenavContainer = styled . div < { headerHeight : string } > `
37+ const SidenavContainer = styled . div < { headerHeight : string ; footerHeight : string } > `
3838 width: fit-content;
3939 height: 100%;
4040 z-index: var(--z-app-layout-sidenav);
@@ -44,6 +44,7 @@ const SidenavContainer = styled.div<{ headerHeight: string }>`
4444 max-height: ${ ( { headerHeight } ) => `calc(100vh - ${ headerHeight || "0" } )` } ;
4545 @media (max-width: ${ responsiveSizes . medium } rem) {
4646 width: 100%;
47+ max-height: ${ ( { headerHeight, footerHeight } ) => `calc(100vh - ${ headerHeight || "0" } - ${ footerHeight || "0" } )` } ;
4748 }
4849` ;
4950
@@ -63,7 +64,8 @@ const Main = ({ children }: AppLayoutMainPropsType): JSX.Element => <div>{childr
6364
6465const DxcApplicationLayout = ( { logo, header, sidenav, footer, children } : ApplicationLayoutPropsType ) : JSX . Element => {
6566 const [ headerHeight , setHeaderHeight ] = useState ( "0px" ) ;
66-
67+ const [ footerHeight , setFooterHeight ] = useState ( "0px" ) ;
68+ const [ hideMainContent , setHideMainContent ] = useState ( false ) ;
6769 const handleHeaderHeight = useCallback (
6870 ( headerElement : HTMLDivElement | null ) => {
6971 if ( headerElement ) {
@@ -74,10 +76,21 @@ const DxcApplicationLayout = ({ logo, header, sidenav, footer, children }: Appli
7476 [ header ]
7577 ) ;
7678
79+ const handleFooterHeight = useCallback (
80+ ( footerElement : HTMLDivElement | null ) => {
81+ if ( footerElement ) {
82+ const height = footerElement . offsetHeight ;
83+ setFooterHeight ( `${ height } px` ) ;
84+ }
85+ } ,
86+ [ footer ]
87+ ) ;
88+
7789 const contextValue = useMemo ( ( ) => {
7890 return {
7991 logo,
8092 headerExists : ! ! header ,
93+ setHideMainContent,
8194 } ;
8295 } , [ header , logo ] ) ;
8396 const ref = useRef ( null ) ;
@@ -87,10 +100,14 @@ const DxcApplicationLayout = ({ logo, header, sidenav, footer, children }: Appli
87100 < ApplicationLayoutContext . Provider value = { contextValue } >
88101 { header && < HeaderContainer ref = { handleHeaderHeight } > { header } </ HeaderContainer > }
89102 < BodyContainer hasSidenav = { ! ! sidenav } >
90- { sidenav && < SidenavContainer headerHeight = { headerHeight } > { sidenav } </ SidenavContainer > }
91- < MainContainer > { findChildType ( children , Main ) } </ MainContainer >
103+ { sidenav && (
104+ < SidenavContainer headerHeight = { headerHeight } footerHeight = { footerHeight } >
105+ { sidenav }
106+ </ SidenavContainer >
107+ ) }
108+ { ! hideMainContent && < MainContainer > { findChildType ( children , Main ) } </ MainContainer > }
92109 </ BodyContainer >
93- < FooterContainer >
110+ < FooterContainer ref = { handleFooterHeight } >
94111 { footer ?? (
95112 < DxcFooter
96113 copyright = { `© DXC Technology ${ year } . All rights reserved.` }
0 commit comments