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

[7주차 기본 과제] 🌈 카드게임 리팩토링 #8

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

Conversation

SynthiaLee
Copy link
Contributor

✨ 구현 기능 명세

  • jsx → tsx 로 변환하기
  • recoil로 상태 관리

🌼 PR Point

  • atom 으로 state 관리🌐

    import { atom } from "recoil";
    
    export const totalCards = atom<string[]>({
      key: "totalCards",
      default: [],
    });
    
    export const currentCards = atom<number[]>({
      key: "currentCards",
      default: [],
    });
    
    export const matchedCards = atom<number[]>({
      key: "matchedCard",
      default: [],
    });
  • recoil 폴더와 atom폴더를 새로 만들어서 atom을 따로 정리해뒀습니다!🗂️

스크린샷 2023-06-10 오후 1 33 33

🥺 소요 시간, 어려웠던 점

  • 타스의 타입지정에 익숙해지는 중〰️

🌈 구현 결과물

cat match
cat reset button

@SynthiaLee SynthiaLee self-assigned this Jun 10, 2023
Copy link

@iamphj3 iamphj3 left a comment

Choose a reason for hiding this comment

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

헉 언니 너어ㅓ어어어무 잘했는데....?!!????!!!! 진짜 클린코드 그잡채!!!!!!!!!!
컴포넌트 분리도 넘 잘했구 카드 랜덤배치, 전역상태관리, 구조분해할당 등등등 진짜 깔끔하다!!! 3D 속성까지 쓰구!! 나도 언니 코드 보고 배워가 ㅎㅎㅎ
언니 갈수록 진짜 처음보다 완전완전 짱많이 성장한거가타!!!!!!! 나도 완전 자극 받아써 +_+
마지막 과제까지 넘 수고 많았어!!! ㅜㅜ 앱잼도 화이팅이야💙💙

Comment on lines +4 to +27
interface CardProps {
imageSrc?: string;
imageName: string;
onClick: () => void;
isOpen: boolean;
}

function Card({ imageSrc, onClick, isOpen, imageName }: CardProps) {
return (
<CardWrapper isOpen={isOpen} onClick={onClick}>
<CardInner isOpen={isOpen}>
<FrontArticle>
<Image src={imageSrc} alt={imageName} isOpen={isOpen} />
</FrontArticle>
<BackArticle>
<Image
src="https://www.svgrepo.com/show/454281/cat-halloween-kitty.svg"
alt="default cat"
/>
</BackArticle>
</CardInner>
</CardWrapper>
);
}
Copy link

Choose a reason for hiding this comment

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

머야 넘 깔꼼쓰!!

cursor: pointer;
}
&.open {
box-shadow: 7px 7px papayawhip;
Copy link

Choose a reason for hiding this comment

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

이색깔 처음봥 ㅋㅋㅋㅋㅋ 이름 귀엽다 ㅜㅜ

export default Card;

const CardWrapper = styled.section`
perspective: 1000px;
Copy link

Choose a reason for hiding this comment

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

옹 3D요소 원근효과 주는 속성!!!!! 첨 알았땅!!!

height: 240px;
padding: 5px;
transform: rotateY(180deg);
backface-visibility: hidden;
Copy link

Choose a reason for hiding this comment

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

헐 일케 앞뒷면 보이게 구현한거구나....... 대박 이것도 첨알았어 너무신기해!!!!!3D!!!!!!!!!!

const CardInner = styled.article`
position: relative;
transition: transform 0.6s;
transform-style: preserve-3d;
Copy link

Choose a reason for hiding this comment

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

폼 미쳤다... 이런거 대체 어디서!!!!! 찾는거야!!!!!!!

return (
<Section>
{modes.map((eachMode) => (
<Button
Copy link

Choose a reason for hiding this comment

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

type도 넣어주장!!

function Reset({ resetGame }: ResetProps) {
return (
<Section>
<Button onClick={resetGame}>Reset</Button>
Copy link

Choose a reason for hiding this comment

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

요기두 type ㅎㅎㅎ

import React from "react";

interface ResetProps {
resetGame: () => void;
Copy link

Choose a reason for hiding this comment

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

위에는 handle~ 이런식으루 함수 네이밍햇는데 요긴 그냥 resetGame 으로 한 이유가 이써!?

Comment on lines +36 to +42
if (mode === "EASY") {
setTotalCardCount(5);
} else if (mode === "NORMAL") {
setTotalCardCount(7);
} else if (mode === "HARD") {
setTotalCardCount(9);
}
Copy link

Choose a reason for hiding this comment

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

요거 switch-case 써두 되겠당!!!ㅎㅎ

Comment on lines +71 to +78
const allCatsRandom: string[] = cat
.sort(() => Math.random() - 0.5)
.slice(0, totalCardCount)
.map((eachCat) => eachCat.name);

setTotalCard(
[...allCatsRandom, ...allCatsRandom].sort(() => Math.random() - 0.5)
);
Copy link

Choose a reason for hiding this comment

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

크 넘조타

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

Successfully merging this pull request may close these issues.

2 participants