Skip to content

Commit

Permalink
[#20] refact : SideMenuBar MouseEnter, Leave 이벤트로 트랜지션 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
choibumsu committed Feb 22, 2021
1 parent 0eca3df commit 30f30ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
15 changes: 13 additions & 2 deletions src/components/SideMenuBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useState } from 'react'
import { useStore } from '@/store'
import { Bookmark } from '@/components/common/Bookmark'
import './style.scss'
Expand All @@ -7,9 +7,20 @@ export const SideMenuBar: React.FC = () => {
const {
store: { sideBookmarkList },
} = useStore()
const [isShow, setIsShow] = useState(false)

return (
<div className="side-menu-bar">
<div
className={'side-menu-bar ' + (isShow ? 'show' : '')}
data-component=""
onMouseEnter={() => {
setIsShow(true)
}}
onMouseLeave={() => {
setIsShow(false)
document.body.click()
}}
>
<div className="bookmark-container">
{sideBookmarkList.map((bookmark) => (
<Bookmark {...bookmark} key={bookmark.id}></Bookmark>
Expand Down
4 changes: 2 additions & 2 deletions src/components/SideMenuBar/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@use '@/style/package' as *;

.side-menu-bar {
.side-menu-bar[data-component] {
position: absolute;
top: 50%;
transition: 0.6s;
Expand All @@ -9,7 +9,7 @@
border-radius: 0 0.8rem 0.8rem 0;
background-color: $color-close;

&:hover {
&.show {
transform: translateX(0) translateY(-50%);
background-color: $color-open;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/TodoContainer/TodoSection/Todo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Todo: React.FC<TodoProps> = ({
window.removeEventListener('click', closeMenu)
}, [])

const toggleMenu = (e) => {
const toggleMenu = () => {
if (!isShowMenu) {
window.addEventListener('click', closeMenu)
} else {
Expand Down

0 comments on commit 30f30ab

Please sign in to comment.