diff --git a/frontend/benefit/applicant/src/components/header/useHeader.ts b/frontend/benefit/applicant/src/components/header/useHeader.ts index 38440ca0c8..7a7d0cf224 100644 --- a/frontend/benefit/applicant/src/components/header/useHeader.ts +++ b/frontend/benefit/applicant/src/components/header/useHeader.ts @@ -42,6 +42,7 @@ const useHeader = (): ExtendedComponentProps => { >(null); const [isMessagesDrawerVisible, setMessagesDrawerVisiblity] = useState(openDrawer); + const { setIsSidebarVisible } = React.useContext(AppContext); const { pathname, asPath, query } = router; const languageOptions = React.useMemo( @@ -84,6 +85,13 @@ const useHeader = (): ExtendedComponentProps => { application?.status || APPLICATION_STATUSES.DRAFT, [application] ); + + useEffect(() => { + if (isMessagesDrawerVisible !== null) { + setIsSidebarVisible(isMessagesDrawerVisible); + } + }, [isMessagesDrawerVisible, setIsSidebarVisible]); + useEffect(() => { setHasMessenger( [ diff --git a/frontend/benefit/applicant/src/components/layout/Layout.sc.ts b/frontend/benefit/applicant/src/components/layout/Layout.sc.ts index b09b603012..54daa9379e 100644 --- a/frontend/benefit/applicant/src/components/layout/Layout.sc.ts +++ b/frontend/benefit/applicant/src/components/layout/Layout.sc.ts @@ -2,13 +2,16 @@ import styled, { DefaultTheme } from 'styled-components'; interface MainProps { $backgroundColor: keyof DefaultTheme['colors']; + $isSidebarVisible: boolean; } export const $Main = styled.main` + width: calc(100% - ${(props) => (props.$isSidebarVisible ? '520px' : '0px')}); background-color: ${(props) => props.$backgroundColor ? props.$backgroundColor : props.theme.colors.white}; display: flex; flex-direction: column; height: 100%; min-height: 100vh; + transition: width 0.225s ease-out; `; diff --git a/frontend/benefit/applicant/src/components/layout/Layout.tsx b/frontend/benefit/applicant/src/components/layout/Layout.tsx index 64359359d1..64a3f755c6 100644 --- a/frontend/benefit/applicant/src/components/layout/Layout.tsx +++ b/frontend/benefit/applicant/src/components/layout/Layout.tsx @@ -1,6 +1,7 @@ import Header from 'benefit/applicant/components/header/Header'; import TermsOfService from 'benefit/applicant/components/termsOfService/TermsOfService'; import { IS_CLIENT, LOCAL_STORAGE_KEYS } from 'benefit/applicant/constants'; +import AppContext from 'benefit/applicant/context/AppContext'; import dynamic from 'next/dynamic'; import { useRouter } from 'next/router'; import * as React from 'react'; @@ -43,6 +44,8 @@ const Layout: React.FC = ({ children, ...rest }) => { const bgColor = selectBgColor(router.pathname); + const { isSidebarVisible } = React.useContext(AppContext); + const isTermsRoute = ![ ROUTES.ACCESSIBILITY_STATEMENT, ROUTES.COOKIE_SETTINGS, @@ -59,7 +62,11 @@ const Layout: React.FC = ({ children, ...rest }) => { }, []); return ( - <$Main $backgroundColor={bgColor} {...rest}> + <$Main + $backgroundColor={bgColor} + $isSidebarVisible={isSidebarVisible} + {...rest} + >
{isAuthenticated && isTermsRoute && !isTermsOfServiceApproved ? ( void; + setIsSidebarVisible: (value: boolean) => void; }; const AppContext = React.createContext({ isNavigationVisible: false, + isSidebarVisible: false, setIsNavigationVisible: noop, + setIsSidebarVisible: noop, }); export default AppContext; diff --git a/frontend/benefit/applicant/src/context/AppContextProvider.tsx b/frontend/benefit/applicant/src/context/AppContextProvider.tsx index 7445d84d11..5f3842efcc 100644 --- a/frontend/benefit/applicant/src/context/AppContextProvider.tsx +++ b/frontend/benefit/applicant/src/context/AppContextProvider.tsx @@ -7,12 +7,16 @@ const AppContextProvider = ({ }: React.PropsWithChildren

): JSX.Element => { const [isNavigationVisible, setIsNavigationVisible] = React.useState(false); + const [isSidebarVisible, setIsSidebarVisible] = + React.useState(false); return ( {children} diff --git a/frontend/benefit/handler/src/layout/Layout.sc.ts b/frontend/benefit/handler/src/layout/Layout.sc.ts index 91cfe8f07c..aae902d925 100644 --- a/frontend/benefit/handler/src/layout/Layout.sc.ts +++ b/frontend/benefit/handler/src/layout/Layout.sc.ts @@ -1,14 +1,14 @@ import styled from 'styled-components'; type MainProps = { - isSidebarVisible: boolean; + $isSidebarVisible: boolean; }; export const $Main = styled.main` + width: calc(100% - ${(props) => (props.$isSidebarVisible ? '520px' : '0px')}); display: flex; flex-direction: column; height: 100%; min-height: 100vh; - width: calc(100% - ${(props) => (props.isSidebarVisible ? '520px' : '0px')}); transition: width 0.225s ease-out; `; diff --git a/frontend/benefit/handler/src/layout/Layout.tsx b/frontend/benefit/handler/src/layout/Layout.tsx index bc407c4569..5de0a36ff3 100644 --- a/frontend/benefit/handler/src/layout/Layout.tsx +++ b/frontend/benefit/handler/src/layout/Layout.tsx @@ -9,7 +9,7 @@ const Layout: React.FC = ({ children, ...rest }) => { const { isSidebarVisible } = React.useContext(AppContext); return ( - <$Main {...rest} isSidebarVisible={isSidebarVisible}> + <$Main {...rest} $isSidebarVisible={isSidebarVisible}> {children} );