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

[3주차 기본/심화/생각 과제] Would You Like Something to Drink? #3

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 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
12 changes: 12 additions & 0 deletions node_modules/.yarn-integrity

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dependencies": {}
}
Binary file added week3/.DS_Store
Binary file not shown.
24 changes: 24 additions & 0 deletions week3/World-Cup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 8 additions & 0 deletions week3/World-Cup/README.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,,,나 이거 지웠는데 이 파일은 남겨두는 게 좋나,,,,,?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지워두 될듯,, 나두 지워야징😅

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
181 changes: 181 additions & 0 deletions week3/World-Cup/components/FirstStage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import styled from "styled-components";

import React from "react";

const FirstStage = (FirstStageProps) => {
const {
tournamentStage,
setTournamentStage,
firstChoice,
setFirstChoice,
setSecondChoice,
setThirdChoice,
} = FirstStageProps;

return (
<FirstStageContainer>
<StageTitle>Choose your preference</StageTitle>
<ChoiceBox>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 ChoiceBox 내부도,,,!! ChoiceBox 컴포넌트 내부에서 mapping 돌려주면 더 이쁠 거 같긴 하다🤭

뜽희가 재훈 오빠 코드에 달아준 리뷰를 참고했습니다 ㅎㅎㅎㅎ

<Choice
type="button"
value="Coffee"
onClick={() => {
setFirstChoice("coffee");
}}
className={firstChoice === "coffee" && "selected"}
>
Coffee
</Choice>
<Choice
type="button"
value="Tea"
onClick={() => {
setFirstChoice("tea");
}}
className={firstChoice === "tea" && "selected"}
>
Tea
</Choice>
<Choice
type="button"
value="Halmi Latte"
onClick={() => {
setFirstChoice("halmi");
}}
className={firstChoice === "halmi" && "selected"}
>
Halmi Latte
</Choice>
</ChoiceBox>
<ButtonBox>
<Button
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ButtonBox 컴포넌트 내부의 자식들을 포함한 내용이 First, Second, Third Stage 모두 똑같이 작동 및 구성되는 것 같은데 아예 이걸 컴포넌트로 빼는 게 어떨까요?? 매 컴포넌트에서 재사용되는 부분이니까 충분히 컴포넌트로 빼도? 가능할 것 같다는 생각-!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

22!!!!! 가형이 의견에 동의합니당!!! 나두 재사용하도록 고칠 거 옴총 많은데 😮‍💨

type="button"
onClick={() => {
setTournamentStage(tournamentStage - 1);
setFirstChoice("");
setSecondChoice("");
setThirdChoice("");
}}
>
Previous
</Button>
{firstChoice === "" ? (
<Button
type="button"
onClick={() => {
setTournamentStage(tournamentStage + 1);
}}
disabled
>
Next
</Button>
) : (
<Button
type="button"
onClick={() => {
setTournamentStage(tournamentStage + 1);
}}
>
Next
</Button>
)}
</ButtonBox>
</FirstStageContainer>
);
};

export default FirstStage;

const FirstStageContainer = styled.section`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시맨틱하게 div 말고 section 디테일 좋다 👍🏻👍🏻👍🏻

display: flex;
flex-direction: column;
align-items: center;

width: calc(100vw - 20rem);
height: calc(100vh - 20rem);

border-radius: 2rem;

background-color: ${({ theme }) => theme.colors.blue};
color: ${({ theme }) => theme.colors.white};
Comment on lines +99 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme 적용한곤가?? GlobalStyle밖에 사용 안 해봤는데 나도 적용해봐야겠다!!!

`;

const StageTitle = styled.p`
display: flex;
justify-content: center;
align-items: center;

width: 40rem;
height: 3rem;

border-radius: 0.5rem;
margin: 3rem 0;

background-color: ${({ theme }) => theme.colors.cream};
color: ${({ theme }) => theme.colors.navy};

${({ theme }) => theme.fonts.subtitle};
`;

const ChoiceBox = styled.div`
display: flex;
align-items: center;
gap: 5rem;
`;

const Choice = styled.button`
display: flex;
justify-content: center;
align-items: center;

width: calc((100vw - 60rem) / 2);
height: 20rem;

background-color: ${({ theme }) => theme.colors.cream};
color: ${({ theme }) => theme.colors.navy};

border: none;
border-radius: 1rem;

${({ theme }) => theme.fonts.body_bold};

&:hover,
&.selected {
background-color: ${({ theme }) => theme.colors.orange};
color: ${({ theme }) => theme.colors.white};
}
`;

const ButtonBox = styled.span`
display: flex;
gap: 5rem;
`;

const Button = styled.button`
display: flex;
justify-content: center;
align-items: center;

width: 8rem;
height: 2rem;

margin-top: 2rem;

border-radius: 0.5rem;

background-color: ${({ theme }) => theme.colors.cream};
color: ${({ theme }) => theme.colors.navy};

${({ theme }) => theme.fonts.body_bold};

&:hover {
background-color: ${({ theme }) => theme.colors.orange};
color: ${({ theme }) => theme.colors.white};
}

&:disabled {
background-color: ${({ theme }) => theme.colors.disabled_button};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme 진짜 좋은 것 같아... 가독성도 좋고 엄청 편리해보여!!!!!

color: ${({ theme }) => theme.colors.navy};
cursor: not-allowed;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음 보는 속성값이다!!! 찾아보니까 금지 표시 커서가 뜬다구 하네 신기신기!!

}
`;
104 changes: 104 additions & 0 deletions week3/World-Cup/components/Random.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import styled from "styled-components";
import React, { useState } from "react";
import RandomResult from "./RandomResult";

const Random = () => {
const [showResult, setShowResult] = useState(false);

const renderRandom = () => {
return showResult ? (
<RandomResult setShowResult={setShowResult} />
) : (
<>
<HomeTitle>How would you like to choose your drink?</HomeTitle>
<RandomBox>Random!</RandomBox>
<StartBtn
type="button"
onClick={() => {
setShowResult(true);
}}
>
Start!
</StartBtn>
</>
);
};

return <RandomContainer>{renderRandom()}</RandomContainer>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return ( <RandomContainer> <renderRandom/> </RandomContainer>);
이렇게 적어주는 거랑 차이가 있어? (단순 궁금 🤔)

};

export default Random;

const RandomContainer = styled.section`
display: flex;
flex-direction: column;
align-items: center;

width: calc(100vw - 20rem);
height: calc(100vh - 20rem);

border-radius: 2rem;

background-color: ${({ theme }) => theme.colors.blue};
color: ${({ theme }) => theme.colors.white};
`;

const HomeTitle = styled.p`
display: flex;
justify-content: center;
align-items: center;

width: 40rem;
height: 3rem;

border-radius: 0.5rem;
margin: 3rem 0;

background-color: ${({ theme }) => theme.colors.cream};
color: ${({ theme }) => theme.colors.navy};

user-select: none;

${({ theme }) => theme.fonts.subtitle};
`;

const RandomBox = styled.div`
display: flex;
justify-content: center;
align-items: center;

width: calc((100vw - 60rem));
height: 20rem;

background-color: ${({ theme }) => theme.colors.cream};
color: ${({ theme }) => theme.colors.navy};

border-radius: 1rem;

user-select: none;

${({ theme }) => theme.fonts.body_bold};
`;

const StartBtn = styled.button`
display: flex;
justify-content: center;
align-items: center;

width: 8rem;
height: 2rem;

margin-top: 2rem;

border-radius: 0.5rem;

background-color: ${({ theme }) => theme.colors.cream};
color: ${({ theme }) => theme.colors.navy};

${({ theme }) => theme.fonts.body_bold};

&:hover {
background-color: ${({ theme }) => theme.colors.orange};
color: ${({ theme }) => theme.colors.white};
}
`;
Loading