Skip to content

Commit

Permalink
[#124] refactor: HeaderMenu 버튼 애니메이션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
skid901 committed Dec 16, 2020
1 parent 07e0b49 commit 9a6dd0f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions frontend/src/components/organisms/HeaderMenu/HeaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ const AnimatedMenu = styled(animated.div)`
position: absolute;
display: inline-block;
`;
const buttonWrapper = css`
position: relative;
width: 16px;
height: 16px;
`;
const AnimatedButton = styled(animated.div)`
position: absolute;
`;

function HeaderMenu(): JSX.Element {
const [staticMenuToggle, setStaticMenuToggle] = useRecoilState(
Expand All @@ -49,6 +57,12 @@ function HeaderMenu(): JSX.Element {
opacity: hoveredMenuToggle || staticMenuToggle ? 1 : 0,
marginTop: staticMenuToggle ? 0 : 10,
});
const hamburgerMenuStyleProps = useSpring({
opacity: hoveredMenuToggle ? 0 : 1,
});
const doubleChevronRightStyleProps = useSpring({
opacity: hoveredMenuToggle ? 1 : 0,
});

return (
<div
Expand All @@ -57,8 +71,16 @@ function HeaderMenu(): JSX.Element {
onMouseLeave={() => setHoveredMenuToggle(false)}
>
<HeaderButton clickHandler={() => setStaticMenuToggle(!staticMenuToggle)}>
{staticMenuToggle ||
(!hoveredMenuToggle ? <HamburgerMenu /> : <DoubleChevronRight />)}
{staticMenuToggle || (
<div css={buttonWrapper}>
<AnimatedButton style={hamburgerMenuStyleProps}>
<HamburgerMenu />
</AnimatedButton>
<AnimatedButton style={doubleChevronRightStyleProps}>
<DoubleChevronRight />
</AnimatedButton>
</div>
)}
</HeaderButton>
<div css={hoverAreaCss} />
<AnimatedMenu style={menuStyleProps}>
Expand Down

0 comments on commit 9a6dd0f

Please sign in to comment.