-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppLayout.tsx
More file actions
59 lines (51 loc) · 1.43 KB
/
AppLayout.tsx
File metadata and controls
59 lines (51 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import styled from 'styled-components';
import React, { ReactNode, Suspense, useState } from 'react';
import BottomNavBar from '@/components/BottomNavBar';
import AddModal from './components/BottomNavBar/AddModal';
import Spinner from './components/Spinner';
const Layout = styled.div`
height: 100%; //BottomNavBar를 아래로 보내기 위함
display: flex;
flex-direction: column;
`;
const MainComponent = styled.div`
height: calc(100vh - 56px);
`;
interface BackgroundProps {
isOpen: Boolean;
}
const Background = styled.div<BackgroundProps>`
background-color: ${(props) => props.theme.color.grey_00};
display: ${(props) => (props.isOpen ? 'block' : 'none')};
opacity: 0.3;
z-index: 10;
width: 100vw;
height: calc(100vh - 56px);
position: fixed;
`;
interface AppLayoutProps {
children: ReactNode;
}
const AppLayout = ({ children }: AppLayoutProps) => {
const [addModalState, setAddModalState] = useState<Boolean>(false);
return (
<Layout>
<MainComponent>
<Background
onClick={() => setAddModalState(false)}
isOpen={addModalState}
/>
{children}
{addModalState && <AddModal />}
</MainComponent>
<Suspense fallback={<Spinner />}>
<BottomNavBar
addModalState={addModalState}
setAddModalState={setAddModalState}
/>
</Suspense>
</Layout>
);
};
export type { AppLayoutProps };
export default AppLayout;