Skip to content

Commit 07e0b49

Browse files
committed
[#124] refactor: Menu 내 버튼 애니메이션 추가
1 parent 8485558 commit 07e0b49

File tree

1 file changed

+26
-23
lines changed
  • frontend/src/components/molecules/Menu

1 file changed

+26
-23
lines changed

frontend/src/components/molecules/Menu/Menu.tsx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { HeaderButton } from '@atoms/index';
1616
import { ReactComponent as DoubleChevronLeft } from '@assets/doubleChevronLeft.svg';
1717
import { ReactComponent as PlusPage } from '@assets/plusPage.svg';
1818
import { MenuItem } from '@molecules/index';
19+
import { animated, useSpring } from 'react-spring';
20+
import styled from '@emotion/styled';
1921

2022
const wrapperCss = (staticMenuToggle: boolean) => css`
2123
position: relative;
@@ -34,7 +36,16 @@ const workspaceCss = () => css`
3436
width: 100%;
3537
color: rgba(55, 53, 47, 0.6);
3638
`;
37-
const buttonsCss = () => css`
39+
const plusCss = (staticMenuToggle: boolean) => css`
40+
margin-right: ${staticMenuToggle ? 5 : 0}px;
41+
border: 1px solid rgba(55, 53, 47, 0.16);
42+
border-radius: 3px;
43+
`;
44+
const menuListCss = () => css`
45+
overflow-y: auto;
46+
height: calc(100% - 44px);
47+
`;
48+
const AnimatedButtons = styled(animated.div)`
3849
position: absolute;
3950
top: 7px;
4051
right: 0;
@@ -46,15 +57,6 @@ const buttonsCss = () => css`
4657
margin-right: 14px;
4758
min-width: 0;
4859
`;
49-
const plusCss = (staticMenuToggle: boolean) => css`
50-
margin-right: ${staticMenuToggle ? 5 : 0}px;
51-
border: 1px solid rgba(55, 53, 47, 0.16);
52-
border-radius: 3px;
53-
`;
54-
const menuListCss = () => css`
55-
overflow-y: auto;
56-
height: calc(100% - 44px);
57-
`;
5860

5961
function Menu(): JSX.Element {
6062
const [pages, setPages] = useRecoilState(pagesState);
@@ -66,6 +68,9 @@ function Menu(): JSX.Element {
6668
hoveredMenuToggleState,
6769
);
6870
const setBlockMap = useSetRecoilState(blockMapState);
71+
const buttonStyleProps = useSpring({
72+
opacity: hoveredMenuToggle ? 1 : 0,
73+
});
6974

7075
const CreatingPageHandler = async () => {
7176
const { pages: updated, page: created } = await createPage();
@@ -82,20 +87,18 @@ function Menu(): JSX.Element {
8287

8388
return (
8489
<div css={wrapperCss(staticMenuToggle)}>
85-
{hoveredMenuToggle && (
86-
<div css={buttonsCss()}>
87-
<div css={plusCss(staticMenuToggle)}>
88-
<HeaderButton clickHandler={CreatingPageHandler}>
89-
<PlusPage />
90-
</HeaderButton>
91-
</div>
92-
{staticMenuToggle && (
93-
<HeaderButton clickHandler={clickCloseHandler}>
94-
<DoubleChevronLeft />
95-
</HeaderButton>
96-
)}
90+
<AnimatedButtons style={buttonStyleProps}>
91+
<div css={plusCss(staticMenuToggle)}>
92+
<HeaderButton clickHandler={CreatingPageHandler}>
93+
<PlusPage />
94+
</HeaderButton>
9795
</div>
98-
)}
96+
{staticMenuToggle && (
97+
<HeaderButton clickHandler={clickCloseHandler}>
98+
<DoubleChevronLeft />
99+
</HeaderButton>
100+
)}
101+
</AnimatedButtons>
99102
<div css={workspaceCss()}>WORKSPACE</div>
100103
<div css={menuListCss()}>
101104
<Suspense fallback={<div>Loading...</div>}>

0 commit comments

Comments
 (0)