Skip to content

Commit 33889f9

Browse files
feat: 메인페이지 네비게이션
1 parent 0beb609 commit 33889f9

File tree

5 files changed

+93
-15
lines changed

5 files changed

+93
-15
lines changed

src/pages/Main/Achievements/Achievements.styles.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const AchievementsContainer = styled.div`
66
padding: 60px 0;
77
text-align: center;
88
overflow-x: hidden;
9+
position: relative;
10+
z-index: 0;
911
`;
1012
export const Title = styled.h2`
1113
font-size: 48px;
@@ -25,6 +27,7 @@ export const SliderWrapper = styled.div`
2527
width: 100vw;
2628
position: relative; /* 블러 효과 위치 */
2729
overflow: visible;
30+
z-index: 0;
2831
2932
.slick-list {
3033
width: 100vw;
@@ -50,9 +53,9 @@ export const SliderWrapper = styled.div`
5053
content: "";
5154
position: absolute;
5255
top: 0;
53-
width: 400px; /* 블러 영역 너비 -> 뷰 포인트에 따라 조절 필요*/
56+
width: 400px; //블러 영역 너비 -> 뷰 포인트에 따라 조절 필요
5457
height: 100%;
55-
z-index: 2;
58+
z-index: 1;
5659
pointer-events: none;
5760
}
5861
Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import styled from 'styled-components';
22

3+
interface FixedNavProps {
4+
isVisible: boolean;
5+
}
6+
7+
export const FixedNavWrapper = styled.div<FixedNavProps>`
8+
position: fixed;
9+
top: ${({ isVisible }) => (isVisible ? "10px" : "-50px")};
10+
right: 20px;
11+
transition: top 0.3s ease-in-out;
12+
z-index: 1000;
13+
`;
14+
315
export const Navbar = styled.nav`
4-
background-color: #216D35;
16+
background-color: #216D35;
517
padding: 10px 20px;
6-
border-radius: 20px;
18+
border-radius: 17px;
719
display: flex;
820
align-items: center;
921
gap: 20px;
@@ -14,7 +26,18 @@ export const NavItem = styled.a`
1426
font-size: 14px;
1527
text-decoration: none;
1628
font-weight: 500;
17-
29+
display: flex;
30+
align-items: center;
31+
1832
&:first-child {
19-
font-weight: bold;
33+
font-weight: bold;
34+
}
35+
`;
36+
37+
export const Circle = styled.div`
38+
width: 5px;
39+
height: 5px;
40+
background-color: white;
41+
border-radius: 50%;
42+
margin-right: 8px;
2043
`;
Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,52 @@
11
import * as S from './FarmSystemNav.styled';
2+
import { useState, useEffect } from 'react';
23

34
export default function FarmSystemNav() {
5+
const [isVisible, setIsVisible] = useState(false);
6+
7+
useEffect(() => {
8+
const handleScroll = () => {
9+
if (window.scrollY > 200) {
10+
setIsVisible(true);
11+
} else {
12+
setIsVisible(false);
13+
}
14+
};
15+
16+
window.addEventListener("scroll", handleScroll);
17+
return () => {
18+
window.removeEventListener("scroll", handleScroll);
19+
};
20+
}, []);
21+
22+
const handleSmoothScroll = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>, targetId: string) => {
23+
event.preventDefault();
24+
const targetElement = document.querySelector(targetId);
25+
if (targetElement) {
26+
window.scrollTo({
27+
top: targetElement.getBoundingClientRect().top + window.scrollY,
28+
behavior: "smooth",
29+
});
30+
}
31+
};
32+
33+
434
return (
5-
<S.Navbar>
6-
<S.NavItem href="#about">● Farm System이란?</S.NavItem>
7-
<S.NavItem href="#tracks">● 트랙 및 커리큘럼</S.NavItem>
8-
<S.NavItem href="#achievements">● 활동 및 성과</S.NavItem>
9-
<S.NavItem href="#eligibility">● 지원 요건</S.NavItem>
10-
</S.Navbar>
35+
<S.FixedNavWrapper isVisible={isVisible}>
36+
<S.Navbar>
37+
<S.NavItem href="#about" onClick={(e) => handleSmoothScroll(e, "#about")}>
38+
<S.Circle /> Farm System이란?
39+
</S.NavItem>
40+
<S.NavItem href="#tracks" onClick={(e) => handleSmoothScroll(e, "#tracks")}>
41+
<S.Circle /> 트랙 및 커리큘럼
42+
</S.NavItem>
43+
<S.NavItem href="#achievements" onClick={(e) => handleSmoothScroll(e, "#achievements")}>
44+
<S.Circle /> 활동 및 성과
45+
</S.NavItem>
46+
<S.NavItem href="#eligibility" onClick={(e) => handleSmoothScroll(e, "#eligibility")}>
47+
<S.Circle /> 지원 요건
48+
</S.NavItem>
49+
</S.Navbar>
50+
</S.FixedNavWrapper>
1151
);
12-
}
52+
}

src/pages/Main/Tracks/Tracks.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@ import OrangeArrow from '@/assets/Icons/OrangeArrow.svg';
77
export default function Tracks() {
88
const [selectedTrack, setSelectedTrack] = useState(TracksData[0]);
99

10+
const handleSmoothScroll = (event: React.MouseEvent<HTMLSpanElement, MouseEvent>, targetId: string) => {
11+
event.preventDefault();
12+
const offset = 80;
13+
const targetElement = document.querySelector(targetId);
14+
if (targetElement) {
15+
window.scrollTo({
16+
top: targetElement.getBoundingClientRect().top + window.scrollY + offset,
17+
behavior: "smooth",
18+
});
19+
}
20+
};
21+
1022
return (
1123
<S.Container id="tracks">
1224
<S.CenterContainer>
1325
<S.Title>트랙 및 커리큘럼</S.Title>
14-
<S.GoToUnion>
26+
<S.GoToUnion onClick={(e) => handleSmoothScroll(e, "#union")}>
1527
<S.GoToUnionText>
1628
트랙 선택이 고민된다면 <S.OrangeHighlight>Union</S.OrangeHighlight>으로!
1729
</S.GoToUnionText>

src/pages/Main/Union/Union.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default function Union() {
66
const { isMobile } = useMediaQueries();
77

88
return (
9-
<S.Container $isMobile={isMobile}>
9+
<S.Container $isMobile={isMobile} id="union">
1010
<S.IntroduceText $isMobile={isMobile}>
1111
<p>신입생이라서</p>
1212
<p>어떤 트랙을 선택할지 고민되나요?</p>

0 commit comments

Comments
 (0)