-
Notifications
You must be signed in to change notification settings - Fork 1
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
[3주차-ts] 이상형 with TS #6
base: main
Are you sure you want to change the base?
Changes from 1 commit
66e2629
8aeeaa6
fb0aeac
234f415
207dae4
fd2218a
bd9c992
9b64008
18a5293
622fd34
f150cc0
a51386f
673fbe0
1bf2548
9d18660
aa82b6a
9b14518
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||||||||||||||||||||||
import { HandsomeGuy } from "@/assets/images"; | ||||||||||||||||||||||||||
import styled from "styled-components"; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
interface MainHeaderProps { | ||||||||||||||||||||||||||
round: string; | ||||||||||||||||||||||||||
matchWinners: React.MutableRefObject<HandsomeGuy[]>; | ||||||||||||||||||||||||||
fighterList: HandsomeGuy[]; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
export default function MainHeader(props: MainHeaderProps) { | ||||||||||||||||||||||||||
const { round, matchWinners, fighterList } = props; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// 현재 몇 라운드인지 | ||||||||||||||||||||||||||
const countRoundNum = (): number => { | ||||||||||||||||||||||||||
return matchWinners.current.length + 1; | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
// 이번 강에는 총 몇 번의 라운드가 있는지 | ||||||||||||||||||||||||||
const totalRoundNum = (): number => { | ||||||||||||||||||||||||||
return Math.ceil((fighterList.length + matchWinners.current.length * 2) / 2); | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 단순 리턴 함수를 선언하신 이유가 무엇인가요??! 😲😲
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그러게!! 나도 궁금하다!!!!!!!!!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 화살표 함수를 사용해야한다는 생각을 계속 갖고 있어서 그런 거 같습니다 짚어주셔서 감자합니다 |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||
<> | ||||||||||||||||||||||||||
<GameTitle>내가 사랑하는 남성 월드컵 {round}</GameTitle> | ||||||||||||||||||||||||||
<GameRound> | ||||||||||||||||||||||||||
{countRoundNum()}/{totalRoundNum()} | ||||||||||||||||||||||||||
</GameRound> | ||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
export const GameTitle = styled.header` | ||||||||||||||||||||||||||
font-size: 4rem; | ||||||||||||||||||||||||||
margin: 2rem 0; | ||||||||||||||||||||||||||
`; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
export const GameRound = styled.div` | ||||||||||||||||||||||||||
font-size: 4rem; | ||||||||||||||||||||||||||
margin: 1.5rem 0; | ||||||||||||||||||||||||||
color: purple; | ||||||||||||||||||||||||||
font-weight: bold; | ||||||||||||||||||||||||||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { HandsomeGuy } from "@/assets/images"; | ||
import { useEffect } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import styled from "styled-components"; | ||
|
||
interface TournamentProps { | ||
matchWinners: React.MutableRefObject<HandsomeGuy[]>; | ||
fighterList: HandsomeGuy[]; | ||
setFighterList: React.Dispatch<React.SetStateAction<HandsomeGuy[]>>; | ||
} | ||
|
||
export default function Tournament(props: TournamentProps) { | ||
const { matchWinners, fighterList, setFighterList } = props; | ||
|
||
// 승자를 골랐을 때 | ||
const getSelectWinner = (pos: number) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아여기썻넹 ㅎㅎ |
||
matchWinners.current.push(fighterList[pos]); | ||
setFighterList(fighterList.slice(2)); | ||
}; | ||
|
||
return ( | ||
<GameSection> | ||
{fighterList.map((fighter, index) => { | ||
if (index < 2) { | ||
return ( | ||
<article onClick={() => getSelectWinner(index)}> | ||
<img src={fighter.url} /> | ||
<div>{fighter.name}</div> | ||
</article> | ||
); | ||
} | ||
})} | ||
<p>VS</p> | ||
</GameSection> | ||
); | ||
} | ||
|
||
export const GameSection = styled.section` | ||
display: flex; | ||
justify-content: center; | ||
height: 80%; | ||
article { | ||
width: 100%; | ||
height: 100%; | ||
cursor: pointer; | ||
position: relative; | ||
display: flex; | ||
justify-content: center; | ||
|
||
img { | ||
width: 100%; | ||
} | ||
div { | ||
position: absolute; | ||
top: 75%; | ||
left: 50%; | ||
font-size: 5rem; | ||
color: white; | ||
transform: translate(-50%, -50%); | ||
text-shadow: -0.2rem 0 black, 0 0.2rem black, 0.2rem 0 black, 0 -0.2rem black; | ||
} | ||
} | ||
p { | ||
position: absolute; | ||
top: 57%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
|
||
font-size: 10rem; | ||
font-weight: bold; | ||
color: #ffffff; | ||
text-shadow: -0.4rem 0 purple, 0 0.2rem purple, 0.2rem 0 purple, 0 -0.2rem purple; | ||
font-style: italic; | ||
} | ||
`; |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구조분해할당 져아여 ㅎㅎㅎ