Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 14 additions & 27 deletions packages/lib/src/layout/ApplicationLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const BodyContainer = styled.div<{ hasSidenav?: boolean }>`
}
`;

const SidenavContainer = styled.div<{ headerHeight: string; footerHeight: string }>`
const SidenavContainer = styled.div<{ headerHeight: string }>`
width: fit-content;
height: 100%;
z-index: var(--z-app-layout-sidenav);
Expand All @@ -45,7 +45,7 @@ const SidenavContainer = styled.div<{ headerHeight: string; footerHeight: string
max-height: ${({ headerHeight }) => `calc(100vh - ${headerHeight || "0"})`};
@media (max-width: ${responsiveSizes.medium}rem) {
width: 100%;
max-height: ${({ headerHeight, footerHeight }) => `calc(100vh - ${headerHeight || "0"} - ${footerHeight || "0"})`};
max-height: ${({ headerHeight }) => `calc(100vh - ${headerHeight || "0"})`};
}
`;

Expand All @@ -65,7 +65,6 @@ const Main = ({ children }: AppLayoutMainPropsType): JSX.Element => <div>{childr

const DxcApplicationLayout = ({ logo, header, sidenav, footer, children }: ApplicationLayoutPropsType): JSX.Element => {
const [headerHeight, setHeaderHeight] = useState("0px");
const [footerHeight, setFooterHeight] = useState("0px");
const [hideMainContent, setHideMainContent] = useState(false);
const handleHeaderHeight = useCallback(
(headerElement: HTMLDivElement | null) => {
Expand All @@ -77,16 +76,6 @@ const DxcApplicationLayout = ({ logo, header, sidenav, footer, children }: Appli
[header]
);

const handleFooterHeight = useCallback(
(footerElement: HTMLDivElement | null) => {
if (footerElement) {
const height = footerElement.offsetHeight;
setFooterHeight(`${height}px`);
}
},
[footer]
);

const contextValue = useMemo(() => {
return {
logo,
Expand All @@ -101,22 +90,20 @@ const DxcApplicationLayout = ({ logo, header, sidenav, footer, children }: Appli
<ApplicationLayoutContext.Provider value={contextValue}>
{header && <HeaderContainer ref={handleHeaderHeight}>{header}</HeaderContainer>}
<BodyContainer hasSidenav={!!sidenav}>
{sidenav && (
<SidenavContainer headerHeight={headerHeight} footerHeight={footerHeight}>
{sidenav}
</SidenavContainer>
)}
{sidenav && <SidenavContainer headerHeight={headerHeight}>{sidenav}</SidenavContainer>}
{!hideMainContent && <MainContainer>{findChildType(children, Main)}</MainContainer>}
</BodyContainer>
<FooterContainer ref={handleFooterHeight}>
{footer ?? (
<DxcFooter
copyright={`© DXC Technology ${year}. All rights reserved.`}
bottomLinks={bottomLinks}
socialLinks={socialLinks}
/>
)}
</FooterContainer>
{!hideMainContent && (
<FooterContainer>
{footer ?? (
<DxcFooter
copyright={`© DXC Technology ${year}. All rights reserved.`}
bottomLinks={bottomLinks}
socialLinks={socialLinks}
/>
)}
</FooterContainer>
)}
</ApplicationLayoutContext.Provider>
</ApplicationLayoutContainer>
);
Expand Down