@@ -7,29 +7,28 @@ import { HeaderMenu } from '@components/organisms';
7
7
import { useRecoilValue , useSetRecoilState } from 'recoil' ;
8
8
import { blockMapState , pageState , staticMenuToggleState } from '@/stores' ;
9
9
import { createBlock } from '@/utils' ;
10
+ import styled from '@emotion/styled' ;
11
+ import { animated , useSpring } from 'react-spring' ;
10
12
11
- const staticMenuAreaCss = ( ) => css `
13
+ const staticMenuAreaCss = css `
12
14
position : fixed;
13
15
z-index : 2 ;
14
16
` ;
15
- const staticHeaderAreaCss = ( staticMenuToggle : boolean ) => css `
17
+ const AnimatedStaticHeaderArea = styled ( animated . div ) `
16
18
position: fixed;
17
19
right: 0;
18
- left : ${ staticMenuToggle ? 240 : 0 } px;
19
- width : calc (100% - ${ staticMenuToggle ? 240 : 0 } px);
20
20
background-color: #ffffff;
21
21
z-index: 1;
22
22
` ;
23
- const staticScrollAreaCss = ( staticMenuToggle : boolean ) => css `
23
+ const AnimatedStaticScrollArea = styled ( animated . div ) `
24
24
position: fixed;
25
25
top: 45px;
26
26
right: 0;
27
- left : ${ staticMenuToggle ? 240 : 0 } px;
28
- width : calc (100% - ${ staticMenuToggle ? 240 : 0 } px);
27
+ background-color: #ffffff;
29
28
height: calc(100% - 45px);
30
29
overflow: auto;
31
30
` ;
32
- const bottomMarginCss = ( ) => css `
31
+ const bottomMarginCss = css `
33
32
display : inline-block;
34
33
width : 100% ;
35
34
height : calc (100% - 200px );
@@ -40,6 +39,10 @@ function PageComponent(): JSX.Element {
40
39
const staticMenuToggle = useRecoilValue ( staticMenuToggleState ) ;
41
40
const page = useRecoilValue ( pageState ) ;
42
41
const setBlockMap = useSetRecoilState ( blockMapState ) ;
42
+ const staticAreaStyleProps = useSpring ( {
43
+ left : staticMenuToggle ? 240 : 0 ,
44
+ width : `calc(100% - ${ staticMenuToggle ? 240 : 0 } px)` ,
45
+ } ) ;
43
46
44
47
const createBlockHandler = async ( ) => {
45
48
const { parent, block } = await createBlock ( { parentBlockId : page . rootId } ) ;
@@ -53,21 +56,21 @@ function PageComponent(): JSX.Element {
53
56
54
57
return (
55
58
< div >
56
- < div css = { staticMenuAreaCss ( ) } >
59
+ < div css = { staticMenuAreaCss } >
57
60
< HeaderMenu />
58
61
</ div >
59
- < div css = { staticHeaderAreaCss ( staticMenuToggle ) } >
62
+ < AnimatedStaticHeaderArea style = { staticAreaStyleProps } >
60
63
< Header />
61
- </ div >
62
- < div css = { staticScrollAreaCss ( staticMenuToggle ) } >
64
+ </ AnimatedStaticHeaderArea >
65
+ < AnimatedStaticScrollArea style = { staticAreaStyleProps } >
63
66
< Title />
64
67
< Editor />
65
68
< div
66
- css = { bottomMarginCss ( ) }
69
+ css = { bottomMarginCss }
67
70
onClick = { createBlockHandler }
68
71
onKeyUp = { createBlockHandler }
69
72
/>
70
- </ div >
73
+ </ AnimatedStaticScrollArea >
71
74
</ div >
72
75
) ;
73
76
}
0 commit comments