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주차 기본 / 생각과제 ] 🍚 점메추 🍚  #3

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

doyn511
Copy link
Contributor

@doyn511 doyn511 commented Nov 10, 2023

✨ 구현 기능 명세

✨ 구현 기능 명세

🌱 기본 조건

  • 기본조건1

✅ 선택 과정은 총 3단계입니다. ( 3개 → 3개 → 2개)

✅ 아이템은 총 18개 이상입니다. (3 x 3 x 2 = 18)

위는 “최소”기준이며 그 이상의 개수는 가능합니다.

  • 기본조건2

✅ 전역상태관리 라이브러리, context 사용 금지 ❌

✅ Router 사용 금지 ❌


🧩 기본 과제

  1. 추천 종류 선택
    • 취향대로 추천 / 랜덤 추천 중 선택합니다.
    • 선택시 다음화면으로 넘어갑니다.

[취향대로 추천]

  1. 답변 선택
    • 호버시 스타일 변화가 있습니다.
    • 클릭시(선택시) 스타일 변화가 있습니다.
  2. 이전으로, 다음으로(결과보기) 버튼
    • 아무것도 선택되지 않았을 시 버튼을 비활성화 시킵니다.

      → 눌러도 아무 동작 X

      → 비활성화일 때 스타일을 다르게 처리합니다.

    • 이전으로 버튼을 누르면 이전 단계로 이동합니다.

    • 다음으로 / 결과보기 버튼을 누르면 다음 단계로 이동합니다.

    • 버튼 호버시 스타일 변화가 있습니다.

  3. 결과
    • 선택한 정보들에 맞는 결과를 보여줍니다.

[ 랜덤 추천 ]

  1. 숫자 카운트 다운
    • 3 → 2 → 1 숫자 카운트 다운 후 결과를 보여줍니다.
    • 추천 결과는 반드시 랜덤으로 지정합니다.

[ 공통 ]

  1. 결과 화면
    • 다시하기 버튼

      → 랜덤추천이면 랜덤 추천 start 화면으로, 취향대로 추천이면 취향대로 추천 start 화면으로 돌아갑니다.

      → 모든 선택 기록은 리셋됩니다.


🌠 심화 과제

  1. theme + Globalstyle 적용
    • 전역으로 스타일을 사용할 수 있도록 적용해보세요
  2. 애니메이션
    • 랜덤 추천 - 카운트다운에 효과를 넣어서 더 다채롭게 만들어주세요!
  3. 헤더
    • 처음으로 버튼

      → 추천 종류 선택 화면일시 해당 버튼이 보이지 않습니다.

      → 처음 추천 종류 선택 화면으로 돌아갑니다.

      → 모든 선택 기록은 리셋됩니다.

[ 취향대로 추천 ]

  1. 단계 노출
    • 3단계의 진행 단계를 보여줍니다.
  2. 이전으로 버튼
    • 이전으로 돌아가도 선택했던 항목이 선택되어 있습니다.
  • 6. useReducer , useMemo , useCallback 을 사용하여 로직 및 성능을 최적화합니다.

생각과제

  • 리액트에 대하여

컴포넌트는 어떤 기준과 방법으로 분리하는 것이 좋을까?좋은 상태 관리란 무엇일까?렌더링을 효과적으로 관리하는 방법은 무엇이 있을까?Props Drilling이란 무엇이고 이를 어떻게 해결할 수 있는가?


💎 PR Point

  • DATA.js 를 따로 밖에 빼서 데이터를 불러와 사용하도록 했습니다.
  • 취향대로 추천하기 단계에서 선택한 데이터 카테고리에 대한 값들을 js 배열 내장 함수로 불러와 해당 값을 찾아왔습니다.
  • styled-component 를 처음 사용해보았습니다..! 그래서 그런가 중복되는 스타일은 대부분이지만 살짝씩 다르게 구현하기 위해 또 다른 컴포넌트를 만들어야 했던 점이 아쉬운거 같습니다..
  • 삼항연산자, 이항연산자를 사용해보도록 노력했습니다..

🥺 소요 시간, 어려웠던 점

  • 2days....
  • props drilling이 심하게 이루어지는거 같아요.. 그래서 이걸 어떻게 처리해야하나 공부를 해보았지만 결국 해결하지 못했습니다ㅜ 더 찾아보도록 할게요
  • state를 변경하는 과정에서 여러 컴포넌트 간에 state를 유기적으로 사용해야 했던 것이 어려웠습니다.
  • 무엇보다 리액트를 처음 써보아서.. 리액트의 이점을 전혀 사용하지 못한거 같아요. 컴포넌트의 재사용이 이점이지만 중복되는 코드와 스타일이 아주 많다는 점이 아쉽습니다. 리팩토링 해볼게요…!

🌈 구현 결과물

https://six-puppy-7ec.notion.site/3-538a02bcd97c49b692392ac8841876b1?pvs=4

Copy link

@hae2ni hae2ni left a comment

Choose a reason for hiding this comment

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

하나하나 고민한 흔적이 보이는 코드였어! 너무 수고했어요!! 짱짱!

// 3초부터 카운트다운 하기 때문에 초기값 3
const [time, setTime] = useState(3);

// eslint-disable-next-line react/prop-types
Copy link

Choose a reason for hiding this comment

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

요 esLint 에러는 eslintrc.cjs에서 해결할 수 있습니다! (props drilling이 넘 많은데 하나하나 주석 달아주기엔 넘 빡세잖아효,,,ㅠ)
요거 참고!

time > 0 && setTimeout(() => setTime(time - 1), 1000);
});

/* 3,2,1 카운트다운 렌더링
Copy link

Choose a reason for hiding this comment

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

하나하나 주석 달아준 당신 칭찬해,,,

const { isStart, isStartHandler } = props;

useEffect(() => {
time > 0 && setTimeout(() => setTime(time - 1), 1000);
Copy link

Choose a reason for hiding this comment

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

엄청 간단하게 해줬네요!!!! 배우고 간다!

Copy link
Member

Choose a reason for hiding this comment

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

헉 그로게,, 대박


const RandomBtn = (props) => {
// eslint-disable-next-line react/prop-types
const { isStart, TypeSelect, RandomSelect, isStartHandler, randomHandler } =
Copy link

Choose a reason for hiding this comment

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

구조분해할당 낭낭하게 써주는 당신 체고야,,,, ❤️

Copy link

Choose a reason for hiding this comment

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

도유니 데이식스 좋아하는구낰ㅋㅎㅋㅎ 나도,,,, ㅎㅎㅎㅎ 노래만 듣긴하지만!

Copy link

Choose a reason for hiding this comment

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

근데 혹시 이거를 public에 놓은 이유가 있을까요? assets에 들어가는게 조금 더 깔끔할 것 같아서!

Choose a reason for hiding this comment

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

오호.. 사진이 어디에나 있어도 괜찮은가 했는데 그래도 assets에 있는게 더 낫구나

const handleNext = () => {
setCurrentStep(currentStep + 1);
setIsStart(true);
console.log(currentStep + 1);
Copy link

Choose a reason for hiding this comment

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

여기두 콘솔!

))}
</SoloOrGroupBtnWrapper>

{/* <PrevNextBtnWrapper>
Copy link

Choose a reason for hiding this comment

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

주석 지워주세요! 둘이 똑같은 거 같은디,,! 혹시 남겨둔 이유가 따로 있나용?

const { isStart, isStartHandler, initStartHandler, initIsStart, setIsStart } =
props;
const [isPrevSelected, setIsPrevSelected] = useState(false);
console.log("TypeBtnStart - isStart ", isStart);
Copy link

Choose a reason for hiding this comment

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

콘솔 지워주기!

return (
<div className="Header">
<HeaderWrapper>
<HeaderText>🐻🦊🐰🐶 DAY6 노래 취향 월드컵🐶🐰🦊🐻</HeaderText>
Copy link

Choose a reason for hiding this comment

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

귀여워,,


ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<Reset />
Copy link

Choose a reason for hiding this comment

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

나중에 심화과제로 GlobalStyle이랑 Theme도 적용해보기!

Copy link
Member

@binllionaire binllionaire left a comment

Choose a reason for hiding this comment

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

파일 분리가 잘 되어있어서 보기 너무너무 편했어 🖤 컴포넌트 재사용도 꼭꼭 해보면 좋을 듯 !! 🤓

Comment on lines +15 to +16
const resetState = () => {};
const backToFront = () => {};
Copy link
Member

Choose a reason for hiding this comment

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

이 부분 선언만 해놓고 사용하지 않고 있는 것 같네용?!!


const RandomResult = (props) => {
// eslint-disable-next-line react/prop-types
const { isStart, isStartHandler } = props;
Copy link
Member

Choose a reason for hiding this comment

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

인졍.... 이렇게 하니까 짱 깔끔하다

Comment on lines +10 to +16
const moodList = [...new Set(DATA.map((elm) => elm.mood))];
const [selectedMood, setSelectedMood] = useState("");

const [isMoodSelected, setIsMoodSelected] = useState(false);
const [isNextSelected, setIsNextSelected] = useState(false);

const [currentStep, setCurrentStep] = useState(1); // Assuming MoodSelect is the first step
Copy link
Member

Choose a reason for hiding this comment

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

개행 너무 좋다!!

Comment on lines +25 to +28
const handleNextBtn = () => {
setIsNextSelected(!isNextSelected);
};

Copy link
Member

Choose a reason for hiding this comment

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

요고도 안쓰는것 같은데?!!!

Comment on lines +54 to +55
{currentStep < 4 && (
<PrevNextBtn
Copy link
Member

Choose a reason for hiding this comment

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

currentStep < 4 로 표현하는 이유가 무엇인가요?!

<DegreeBtn
key={degree}
value={degree}
className={degree === selectedDegree ? "active" : ""}
Copy link
Member

Choose a reason for hiding this comment

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

마쟈 아니면 스타일드 컴포넌트의 props로도 가능할 듯!!

const DegreeBtn = styled.button`
...
    background-color: ${({ selectedDegree }) => (degree === selectedDegree ? "#00897b" : "")}
    color: ${({ selectedDegree }) => (degree === selectedDegree ? "#fff" : "")}
  }
`;

대충 이런식......? https://styled-components.com/docs/basics 이거나 https://react.vlpt.us/styling/03-styled-components.html 요고 확인해봐!

Comment on lines +17 to +20
{/* 어느 버튼도 눌리지 않았을 때 : 취향대로 추천 버튼 보여지기 */}
{!TypeSelect && !RandomSelect ? (
<Type onClick={typeHandler}>취향대로 추천</Type>
) : null}
Copy link
Member

Choose a reason for hiding this comment

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

오옹 조건부 렌더링 빈 값넣을 때 맨날 <></>이걸로 했었는데 찾아보니 null을 많이 쓰는구낭!!

Choose a reason for hiding this comment

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

나는 잘 몰라가지구 찾아봤오! 요기!

Comment on lines +14 to +19
<SectionWrapper>
<Question>오늘의 추천 노래는 바로!</Question>
<Img src={AlbumCover} alt="랜덤 노래 커버 이미지"></Img>
<Title>{SongTitle}</Title>
<RetryBtn onClick={isStartHandler}>다시하기</RetryBtn>
</SectionWrapper>
Copy link
Member

Choose a reason for hiding this comment

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

ByTypeResult 와 동일해서 컴포넌트 재사용도 해보면 좋을 것 같아 🤓

const { isStart, isStartHandler } = props;

useEffect(() => {
time > 0 && setTimeout(() => setTime(time - 1), 1000);
Copy link
Member

Choose a reason for hiding this comment

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

헉 그로게,, 대박

degree: "상",
teamOrSolo: "팀",
img: "/img/Gravity.jpeg",
title: "한 페이지가 될 수 있게 - DAY6",

Choose a reason for hiding this comment

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

데이식스 노래 예뻤어랑 두개밖에 모르지만 이거 요새 꽂힘.. 넘나 좋은것 힣

Comment on lines +11 to +16
{/* 어느 버튼도 눌리지 않았을 때 : 랜덤으로 추천 버튼 보여지기 */}
{!RandomSelect && !TypeSelect ? (
<Random onClick={randomHandler}>랜덤으로 추천</Random>
) : null}
{/* Random 버튼이 눌렸을 때 : 랜덤으로 추천, 시작하기 버튼 있는 페이지로 이동 */}
{RandomSelect && !TypeSelect ? (

Choose a reason for hiding this comment

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

도윤이도 주석 잘 달아주는구나,, 나도 이번엔 노력해볼겡!

Comment on lines +23 to +27

const Random = styled.button`
padding: 8rem;
border: none;
border-radius: 1rem;

Choose a reason for hiding this comment

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

style을 넣을때는 import styled from "styled-components"; 하고
이런식으로 써주면 되는건가 ?!

Comment on lines +17 to +21

const handleBtnChange = (e) => {
setSelectedDegree(e.target.value);
setIsDegreeSelected(true);
};

Choose a reason for hiding this comment

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

요기서 e가 뭔지 잘 모르겠어용,,,ㅠ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants