-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from 100-hours-a-week/feature/elle
Fix : 이슈 해결
- Loading branch information
Showing
12 changed files
with
242 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useEffect, useRef, useState } from "react"; | ||
import { CgMenuGridO } from "react-icons/cg"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { ListBox, Restart, IconDiv } from "./bentoStyle"; | ||
|
||
const BentoBar = () => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const outsideRef = useRef<HTMLDivElement>(null); | ||
const iconRef = useRef<HTMLDivElement>(null); | ||
const navigate = useNavigate(); | ||
|
||
const Nav = (location: string) => { | ||
if (location === "game") { | ||
navigate("/game"); | ||
localStorage.removeItem("hasSeenTutorial"); | ||
} else if (location === "rank") { | ||
navigate("/game/rank"); | ||
} else { | ||
navigate("/home"); | ||
} | ||
}; | ||
|
||
// 슬라이드 토글 | ||
const toggleSlide = () => { | ||
setIsOpen((prev) => !prev); | ||
}; | ||
|
||
// 외부 클릭 감지 및 메뉴 닫기 | ||
useEffect(() => { | ||
const handleClickOutside = (e: any) => { | ||
if ( | ||
outsideRef.current && | ||
!outsideRef.current.contains(e.target as Node) && | ||
iconRef.current && | ||
!iconRef.current.contains(e.target as Node) | ||
) { | ||
setIsOpen(false); | ||
} | ||
}; | ||
|
||
document.addEventListener("mousedown", handleClickOutside); | ||
|
||
return () => { | ||
document.removeEventListener("mousedown", handleClickOutside); | ||
}; | ||
}, [outsideRef]); | ||
|
||
return ( | ||
<> | ||
<IconDiv | ||
ref={iconRef} | ||
style={{ | ||
position: "absolute", | ||
top: "750px", | ||
left: "420px", | ||
minWidth: "25px", | ||
}} | ||
onClick={toggleSlide} | ||
> | ||
<CgMenuGridO style={{ width: "25px", height: "25px" }} /> | ||
|
||
{isOpen ? ( | ||
<ListBox ref={outsideRef}> | ||
<Restart onClick={() => Nav("game")}>게임 재시작</Restart> | ||
<Restart onClick={() => Nav("rank")}>랭킹</Restart> | ||
<Restart onClick={() => Nav("home")}>홈</Restart> | ||
</ListBox> | ||
) : ( | ||
<></> | ||
)} | ||
</IconDiv> | ||
</> | ||
); | ||
}; | ||
|
||
export default BentoBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import styled, { keyframes } from "styled-components"; | ||
import { Colors } from "../../../Styles/Colors"; | ||
|
||
export const Restart = styled.div` | ||
display: flex; | ||
width: 90px; | ||
height: 40px; | ||
border: 1px solid #615efc; | ||
border-radius: 20px; | ||
font-size: 12px; | ||
align-items: center; | ||
justify-content: center; | ||
margin-bottom: 0.5rem; | ||
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px; | ||
background-color: white; | ||
color: black; | ||
`; | ||
|
||
const fadeIn = keyframes` | ||
from{ | ||
opacity:0; | ||
transform: translateY(10px) | ||
} | ||
to{ | ||
opacity:1; | ||
transform: translateY(0) | ||
} | ||
`; | ||
|
||
export const ListBox = styled.div` | ||
position: absolute; | ||
bottom: 50px; | ||
width: 100px; | ||
height: 150px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin-top: 0.5rem; | ||
animation: ${fadeIn} 0.5s ease-out forwards; | ||
opacity: 0; | ||
`; | ||
|
||
export const IconDiv = styled.div` | ||
border-radius: 25px; | ||
width: 50px; | ||
height: 50px; | ||
position: relative; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
color: ${Colors.main}; | ||
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.