-
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์ฃผ์ฐจ JS ๐ TS ] ๐ ๊บ์ใ ใ ๋๋ฏ ๊ท์ฌ์ ๐ #9
Conversation
์ค๋๋ ํ ํ ๋๋์ ๋ชธ์ ์ค์ฒ ์ค์ธ ์นํํธ์ ! ํ์ดํ
:) |
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.
์ด๊ธฐ์ธํ ์์ฃผ ๋ฟ๋ฏใ ํ๋ค๋ฃ,~~ ์ธ์จํ์ฒด๊ณ ๐ฅ๐ฅ
test('renders learn react link', () => { | ||
render(<App />); | ||
const linkElement = screen.getByText(/learn react/i); | ||
expect(linkElement).toBeInTheDocument(); | ||
}); |
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.
๐คฉ๐คฉ๐คฉ๐คฉ
interface HeaderProps { | ||
title?: string; | ||
round?: number[]; | ||
} | ||
export default function Header(props: HeaderProps) { |
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.
Header ์ฌ์ฌ์ฉ ์ข๋ค !!
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.
๊ทธ์น๊ทธ์น๊ทธ์น!!!!!!!!!!!! ํค๋ ์ฌ์ฌ์ฉ ์กฐ์~>.<
const handleClick = () => navigate('/worldCup'); | ||
return ( | ||
<StIntroWrapper> | ||
<StContentImg imgUrl={mainImageUrl} /> | ||
<StGameButton onClick={handleClick}>GAME START</StGameButton> |
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.
navigate ๋ฐ์ ๊ธฐ๋ฅ์ด ์๋ค๋ฉด, Link
ํ๊ทธ๋ฅผ ์ฌ์ฉํ๋๊ฒ ์ข ๋ ์นํ์ค์ ์ ํฉํ ๊ฒ ๊ฐ๋น
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.
์นํ์ค์ ์ ํฉํ๋ค๋ ๋ง์ด ์ด๋ค ๋ป์ธ์ง ์ค๋ช ํด์ค์์๋์?!
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.
์นํ์ค์ HTML, CSS ๋ฑ์ ๋ํ WC3๊ท๊ฒฉ(๋ฌธ๋ฒ) ์ค์ ๋ฑ์ ๋งํ๊ณ , ์น์ ์ฌ์ฉ์ฑ ๋ฐ ์ ๊ทผ์ฑ์ ๋ณด์ฅํด์ค ์ ์๋ค๊ณ ์ค๋ช ํ ์ ์์ ๊ฒ ๊ฐ๋ค-
navigate์ ๋์์ ํจ์๋ ๋ถ๊ตฌํ๊ณ ๊ธฐ๋ณธ button
ํ๊ทธ๋ฅผ ์ฌ์ฉํ ๊ฑด HTML์ ๋ฌธ๋ฒ์ ์ ํฉํ์ง ์๋๋ค๊ณ ์๊ฐํด
a ํ๊ทธ์ ์ด์ ๋ง๋ Link ํ๊ทธ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ์น์ ์ฌ์ฉ์ฑ์ ๋์ผ ์ ์์ผ๋๊น ๋ง์ด์ง!!
const navigate = useNavigate(); | ||
|
||
const handleClickImage = (emoticon: EmoticonItem) => (event: React.MouseEvent<HTMLDivElement>) => { | ||
const image = event.target as HTMLDivElement; |
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.
as ๋ง๊ณ ๋ด๋ก์์ ์์ผ์ฃผ๋ ๊ฑด ์ด๋จ๊น์ฅ!
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.
if (event.target instanceof HTMLDivElement) {
const image = event.target;
image.classList.add('imageClick');
setTimeout(() => {
image.classList.remove('imageClick');
if (emoticons.length > 2) {
handleWinners([...winners, emoticon]);
handleEmoticons(emoticons.slice(2));
handleRound([round[0] + 1, round[1]]);
} else {
if (winners.length === 0) {
navigate('/result', { state: emoticon });
} else {
const nextStepEmoticon = [...winners, emoticon];
handleEmoticons(nextStepEmoticon);
handleWinners([]);
handleRound([1, round[1] / 2]);
if (round[1] / 2 === 2) handleTitle('์ค๊ฒฐ์น');
if (round[1] / 2 === 1) handleTitle('๊ฒฐ์น');
}
}
}, 1000);
}
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.
๋ฐ๊บผ๋ฐ ใ ใ ใ
<StFirecrackerImg imgUrl={leftFirecracker} position={'20%'} /> | ||
|
||
<StArticleImg imgUrl={state.url}> | ||
<StArticleTitle>{state.name}</StArticleTitle> | ||
</StArticleImg> | ||
<StFirecrackerImg imgUrl={rightFirecracker} position={'80%'} /> |
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.
'20%', '80%' ๋ก position ๊ฐ์ ์ง์ ์ง์ ํ ์ ์๊ฒ ๋๋ฉด, css ์ฝ๋์ ๋ถ๋ฆฌ๊ฐ ๋์ง ์๊ฒ ๋๋ ๊ฒ ๊ฐ์
๊ทธ๋์ ๋๊ฐ์ผ๋ฉด position
๋ณด๋ค isright
boolean ์ ๋๋ก ์ค์,
background-position: ${(props) => props.isright ? "80%" : "20%"} center;
์ ๋๋ก ์์ฑํ ๊ฒ ๊ฐ๋ค!
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.
WoW~
interface ResultLocation { | ||
state: EmoticonItem; | ||
} | ||
export default function ResultMain() { | ||
const { state } = useLocation() as ResultLocation; |
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.
๐๐
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.
์ด๋ฐ๋ฐ์๋ as๋ก ์ง์ ํ๋๊ฒ ๋ง๋๊ฑฐ์ง? ์ฐ๋ฆฌ๊ฐ ์ค์ ํ ๊ฑฐ๋๊น?!!
๊ทธ๊ฒ ์๋๋ผ๋ฉฐ๋ ๋ค๋ก์์ด ์ ํฉํ๊ฑฐ๊ตฌ?!
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.
๊ทธ๋ ๊ฒ ๊ธฐ์ค์ ๋๋ ์๋ ์์ ๊ฒ ๊ฐ๋ค !!
๋ค๋ฅธ ๋ฐฉ๋ฒ์ด ์๋ค๊ธฐ๋ณด๋ค useLocation
ํ
์ ํ์
๋ช
์๋ฅผ ํด์ฃผ๋ ๊ฒ ๋ฐ๋ก ์ ๊ณต๋์ง ์์์ as ์ฌ์ฉํ๋ ๋ด์ฉ๋ค๋ฐ์ ๋ชป์ฐพ๋ ๊ฒ๋ ์๊ฒ ๊ตฌ!
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.
๋ฐฐ์๊ฐ๋๋ค์ ~
{title !== undefined ? `${title}` : ''} | ||
{round !== undefined ? ` ${round[0]}/${round[1]}` : ''} |
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.
{title !== undefined ? `${title}` : ''} | |
{round !== undefined ? ` ${round[0]}/${round[1]}` : ''} | |
{title && `${title}`} | |
{round && ` ${round[0]}/${round[1]}`} |
์ ๋๋ก ๋ ์ ์์ผ๋ ค๋-
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.
ํค์ผ์คํค
์ค๋๋ ํ ํ ๋๋์ ๋ชธ์ ์ค์ฒ ์ค์ธ ์นํํธ์ ! ํ์ดํ
:) |
์ธ์ฌํ ์ฝ๋๋ฆฌ๋ทฐ ๊ฐ์ํฉ๋๋ค ใ ใ ใ ๋๋ถ๋ค ํ์ฐ ๊ธ๋ฐฉ์ ๊ธ์๋ฃ์ค |
์ค๋๋ ํ ํ ๋๋์ ๋ชธ์ ์ค์ฒ ์ค์ธ ์นํํธ์ ! ํ์ดํ
:) |
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.
ํด๋๊ตฌ์กฐ ๊น๋.. ์๋ก์ด๊ฑฐ ํญ์ ๊ผญ์๋ํจ... ์ง์ง ์ต๊ณ ๋ค ํ์ํ~~~ ๐ฐ
render(<App />); | ||
const linkElement = screen.getByText(/learn react/i); | ||
expect(linkElement).toBeInTheDocument(); | ||
}); |
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.
test ์ฝ๋ !!!!! ์งฑ์ธ๋ฐ~ ~
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.
ใ ใ ใ ใ ์น์ฌํ์์ ๋ฐฐ์ ์ง ใ ใ
declare module '*.jpg'; | ||
declare module '*.png'; | ||
declare module '*.jpeg'; | ||
declare module '*.gif'; |
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.
ํ์ค์์๋ .d.ts ํ์ผ์ ๋ง๋ค์ด์ค์ผํ๋ค ๋ฌด์ข๊ฑด ๋ช ์ฌ..
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.
๋๋ ๋ช .์ฌ.
name: string; | ||
url: string; | ||
} | ||
export const emoticonItems: EmoticonItem[] = [ |
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.
์ด ๋ถ๋ถ ์ฃผํจ์ด ๋ด ์ฝ๋๋ฆฌ๋ทฐํ ๋ ์๊ธฐํ๋ ๊ฒ์ฒ๋ผ ๋ค๋ฅธ ํด๋์ ์ ์ํด์ export ์ํค๋๊ฒ ์๋ฏธ ๋ถ๋ฆฌ์ ๋ ์ข์ ๊ฑฐ ๊ฐ์์ฉ!
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.
๋ง์๋ง์ ใ
ใ
ใ
๋ฆฌ๋ทฐ๋๋๊ณ ์์ ํด๋ณผ๋ผ๊ตฌ ใ
ใ
๋ค์ ํ๋ฒ ์ง์ด์ค์ ๊ณ ๋ง์ ใ
ใ
<StHeader>๐ ๊บ์ใ ใ ๋๋ฏ ๊ท์ฌ์ ๐</StHeader> | ||
<StSubHeader> | ||
{title && `${title}`} | ||
{round && ` ${round[0]}/${round[1]}`} |
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.
์ด๋ฐ์์ผ๋ก Header๋ฅผ Intro์์๋ ์ฌ์ฌ์ฉ์ด ๊ฐ๋ฅํ๊ฒ ํ๊พธ๋ง!! ์งฑ์งฑ~
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.
๋ง์์ฌ!!!!!>.<
round?: number[]; | ||
} | ||
export default function Header(props: HeaderProps) { | ||
const { title, round } = props; |
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.
๊ตฌ์กฐ๋ถํดํ ๋น ์งฑ~
overflow: hidden; | ||
|
||
.imageClick { | ||
animation: ${imageClick} 0.4s infinite linear alternate; |
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.
์ ๋๋ฉ์ด์ ์งฑ~
animation: ${imageClick} 0.4s infinite linear alternate; | ||
} | ||
`; | ||
const StArticleImg = styled.div<{ imgUrl: string }>` |
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.
์ด๋ฏธ์ง props ์ด๋ ๊ฒ ๋ฐ์์์ ์ฐ๋๊ตฌ๋ง!! ๋งน์ฌํ๊ฒ ์ด
interface ResultLocation { | ||
state: EmoticonItem; | ||
} | ||
export default function ResultMain() { | ||
const { state } = useLocation() as ResultLocation; |
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.
๋ฐฐ์๊ฐ๋๋ค์ ~
<StFirecrackerImg imgUrl={leftFirecracker} position={'20%'} /> | ||
|
||
<StArticleImg imgUrl={state.url}> | ||
<StArticleTitle>{state.name}</StArticleTitle> | ||
</StArticleImg> | ||
<StFirecrackerImg imgUrl={rightFirecracker} position={'80%'} /> |
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.
WoW~
declare module 'styled-components' { | ||
export interface DefaultTheme { | ||
fonts: { | ||
header: ThemedCssFunction; |
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.
ํ ๊ธฐํด์ฌ!!!
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.
์ด๋ฐ ํ์ ๋ช ๋ ์๊ตฌ๋
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.
๋๋ ์ฑ๊ธฐํด >.<
โจ ๊ตฌํ ๊ธฐ๋ฅ ๋ช ์ธ
JS ๐ TS ๋ก ๋ณํํ์์ต๋๋ค!
๐ PR Point
page ๋๋๋,
Error404
,Intro
,WorldCup
,Result
์ด 4๊ฐ๋ก ์ค์ ํ์์ด๋styled.d.ts์ ์ ์ํ ๋, fonts ๋ css๋ฅผ ๋ฐํํด์
ThemedCssFunction
๋ก ํ์ ์ ์ํ์์ด๋๊ณตํต์ ์ธ
Header
๋ฅผ์ ์ธํ ๋ถ๋ถ๋ค์ component๋ก ๋ถ๋ฆฌํ์์ต๋๋!handler๋ฅผ ์์ ์ปดํฌ๋ํธ์์ ๋๊ฒจ์ฃผ๋ ๋ฐฉ๋ฒ์ ์ ๊ทนํ์ฉํ์์ต๋๋ค!!
-
EmoticonItem
์ interface๋ก ์ ์ํด ์ฌ์ฉํ์์ต๋๋!๐ญ ์ด๋ ค์ ๋ ์
ํฉ์ธ๋ ํ์ฐ๋ก ํด์ ์ด์ ์ด์ง ์ด๋์ ๋ ์ตํ์ง๊ฒ๊ฐ์์ฌ!!!
ํ์ง๋ง,,,๋ถ๋ช ํ์ ์ด ์์๊ฑฐ๋ผ ์๊ฐํ๊ธฐ์,,,, ํผ๋๋ฐฑ ๋คใ ใ ใ ๋ฐ๊ณ ์ถ์ด๋๋คใ ใ ใ กใ ใ กใ