-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnavBar.tsx
115 lines (108 loc) · 3.12 KB
/
navBar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import styled from "@emotion/styled";
import { css } from "@emotion/css";
import React, { useEffect, useState } from "react";
import logo from "/image/logo.svg";
import { Link, useLocation } from "react-router-dom";
import useIsMobile from "../../hooks/useIsMobile.tsx";
import { IoClose, IoMenu } from "react-icons/io5";
import Space from "./Space.tsx";
import { Menu, MobileMenu } from "./Menu.tsx";
import logowhite from "/image/logowhite.svg";
const NavBar: React.FC = () => {
const [isMove, setIsMove] = useState(false);
const location = useLocation();
const isMobile = useIsMobile();
const [isOpen, setIsOpen] = useState(false);
useEffect(() => {
const handleScroll = () => {
setIsMove(window.scrollY > 0);
};
window.addEventListener("scroll", handleScroll);
return () => {
window.removeEventListener("scroll", handleScroll);
};
}, []);
return (
<Menu isMove={isMove} isOpen={isOpen} isHome={location.pathname === "/"}>
<div
className={css`
margin: auto;
@media (max-width: 768px) {
margin-left: 30px;
}
`}
style={{ cursor: "pointer" }}
>
<Link to="/">
{!isMove && location.pathname === "/" && !isOpen ? (
<img
className={css`
width: 80px;
`}
src={logowhite}
alt="logo"
/>
) : (
<img
className={css`
width: 80px;
`}
src={logo}
alt="logo"
/>
)}
</Link>
</div>
{!isMobile ? (
<div
className={css`
display: flex;
gap: 25px;
margin: auto;
`}
>
<Link to="/recruit">
<Space isActive={location.pathname === "/recruit"}>지원하기</Space>
</Link>
<Link to="/contact">
<Space isActive={location.pathname === "/contact"}>문의하기</Space>
</Link>
<Link to="/book">
<Space isActive={location.pathname === "/book"}>my keun</Space>
</Link>
</div>
) : (
<>
<Button onClick={() => setIsOpen(!isOpen)}>
{!isMove && !isOpen && location.pathname === "/" ? (
<IoMenu size="30" stroke="#ffffff" />
) : !isOpen ? (
<IoMenu size="30" stroke="#919191" />
) : (
<IoClose size="30" fill="#919191" />
)}
</Button>
<MobileMenu isOpened={isOpen} isSmall={true}>
<Link to="/recruit">
<Space isActive={false}>지원하기</Space>
</Link>
<Link to="/contact">
<Space isActive={false}>문의하기</Space>
</Link>
<Link to="/book">
<Space isActive={false}>my keun</Space>
</Link>
</MobileMenu>
</>
)}
</Menu>
);
};
export default NavBar;
const Button = styled.button`
background-color: transparent;
border: none;
cursor: pointer;
font-size: 16px;
margin-right: 10px;
`;