Skip to content

Commit 8485558

Browse files
committed
[#124] refactor: PageComponent 컴포넌트 애니메이션 추가
1 parent 200f4c2 commit 8485558

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

frontend/src/components/pages/PageComponent/PageComponent.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,28 @@ import { HeaderMenu } from '@components/organisms';
77
import { useRecoilValue, useSetRecoilState } from 'recoil';
88
import { blockMapState, pageState, staticMenuToggleState } from '@/stores';
99
import { createBlock } from '@/utils';
10+
import styled from '@emotion/styled';
11+
import { animated, useSpring } from 'react-spring';
1012

11-
const staticMenuAreaCss = () => css`
13+
const staticMenuAreaCss = css`
1214
position: fixed;
1315
z-index: 2;
1416
`;
15-
const staticHeaderAreaCss = (staticMenuToggle: boolean) => css`
17+
const AnimatedStaticHeaderArea = styled(animated.div)`
1618
position: fixed;
1719
right: 0;
18-
left: ${staticMenuToggle ? 240 : 0}px;
19-
width: calc(100% - ${staticMenuToggle ? 240 : 0}px);
2020
background-color: #ffffff;
2121
z-index: 1;
2222
`;
23-
const staticScrollAreaCss = (staticMenuToggle: boolean) => css`
23+
const AnimatedStaticScrollArea = styled(animated.div)`
2424
position: fixed;
2525
top: 45px;
2626
right: 0;
27-
left: ${staticMenuToggle ? 240 : 0}px;
28-
width: calc(100% - ${staticMenuToggle ? 240 : 0}px);
27+
background-color: #ffffff;
2928
height: calc(100% - 45px);
3029
overflow: auto;
3130
`;
32-
const bottomMarginCss = () => css`
31+
const bottomMarginCss = css`
3332
display: inline-block;
3433
width: 100%;
3534
height: calc(100% - 200px);
@@ -40,6 +39,10 @@ function PageComponent(): JSX.Element {
4039
const staticMenuToggle = useRecoilValue(staticMenuToggleState);
4140
const page = useRecoilValue(pageState);
4241
const setBlockMap = useSetRecoilState(blockMapState);
42+
const staticAreaStyleProps = useSpring({
43+
left: staticMenuToggle ? 240 : 0,
44+
width: `calc(100% - ${staticMenuToggle ? 240 : 0}px)`,
45+
});
4346

4447
const createBlockHandler = async () => {
4548
const { parent, block } = await createBlock({ parentBlockId: page.rootId });
@@ -53,21 +56,21 @@ function PageComponent(): JSX.Element {
5356

5457
return (
5558
<div>
56-
<div css={staticMenuAreaCss()}>
59+
<div css={staticMenuAreaCss}>
5760
<HeaderMenu />
5861
</div>
59-
<div css={staticHeaderAreaCss(staticMenuToggle)}>
62+
<AnimatedStaticHeaderArea style={staticAreaStyleProps}>
6063
<Header />
61-
</div>
62-
<div css={staticScrollAreaCss(staticMenuToggle)}>
64+
</AnimatedStaticHeaderArea>
65+
<AnimatedStaticScrollArea style={staticAreaStyleProps}>
6366
<Title />
6467
<Editor />
6568
<div
66-
css={bottomMarginCss()}
69+
css={bottomMarginCss}
6770
onClick={createBlockHandler}
6871
onKeyUp={createBlockHandler}
6972
/>
70-
</div>
73+
</AnimatedStaticScrollArea>
7174
</div>
7275
);
7376
}

0 commit comments

Comments
 (0)