Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] 헤더 클릭 라우팅 추가 및 수정 #74

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions client/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import { Link, useLocation } from "react-router-dom";
import ButtonHeader from "../ButtonHeader";
import { backgroundBlurVariants, logoVariants } from "./index.style";

Expand All @@ -9,7 +9,7 @@ export interface HeaderProps {

const EVENT_TYPE = {
LOTTERY: "lottery",
FIRST_COME: "first-come",
RUSH: "rush",
};
type EventType = (typeof EVENT_TYPE)[keyof typeof EVENT_TYPE];

Expand All @@ -21,8 +21,8 @@ export default function Header({ type }: HeaderProps) {
const pathname = location.pathname;
const selectedEventType = pathname.startsWith(`/${EVENT_TYPE.LOTTERY}`)
? EVENT_TYPE.LOTTERY
: pathname === "/balance"
? EVENT_TYPE.FIRST_COME
: pathname.startsWith(`/${EVENT_TYPE.RUSH}`)
? EVENT_TYPE.RUSH
: "";
setSelectedEvent(selectedEventType);
}, [location]);
Expand All @@ -31,7 +31,9 @@ export default function Header({ type }: HeaderProps) {
<header className="flex justify-center fixed top-0 w-full h-16 overflow-hidden z-20">
<div className={backgroundBlurVariants({ type })}></div>
<div className="w-[1200px] flex justify-between">
<h1 className={logoVariants({ type })}>CASPER Electric Event</h1>
<Link to="/" className={logoVariants({ type })}>
CASPER Electric Event
</Link>
<div className="flex gap-700">
<ButtonHeader
isSelected={selectedEvent === EVENT_TYPE.LOTTERY}
Expand All @@ -41,9 +43,9 @@ export default function Header({ type }: HeaderProps) {
나만의 캐스퍼 일렉트릭 봇 만들기
</ButtonHeader>
<ButtonHeader
isSelected={selectedEvent === EVENT_TYPE.FIRST_COME}
isSelected={selectedEvent === EVENT_TYPE.RUSH}
type={type}
url="/balance"
url={`/${EVENT_TYPE.RUSH}`}
>
선착순 밸런스 게임
</ButtonHeader>
Expand Down
Loading