Skip to content

Commit

Permalink
Merge pull request #16 from Chanwoo-Jeong/Week3/matchCardsGame
Browse files Browse the repository at this point in the history
Week3/match cards game
  • Loading branch information
Chanwoo-Jeong authored Apr 29, 2023
2 parents 6bc8e7f + 264aed5 commit 265186f
Show file tree
Hide file tree
Showing 9 changed files with 1,756 additions and 1,679 deletions.
Empty file.
1 change: 0 additions & 1 deletion Week3-0422/MatchCardsGame/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react";
import "./App.css";
import MatchCardsGame from "./Pages/MatchCardsGame";
import { createGlobalStyle } from "styled-components";
import { ThemeProvider } from "styled-components";
Expand Down
31 changes: 18 additions & 13 deletions Week3-0422/MatchCardsGame/src/Pages/layout/DifficultySection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,34 @@ const Wrapper = styled.section`
flex-direction: row;
justify-content: center;
padding: 1rem 0;
height: 10rem;
padding: 1rem 0;
`;

const DifficultyType = ["Easy", "Normal", "Hard"];

const DifficultySection = (props) => {
const { currentDifficulty , setDifficulty ,reset} = props;
const { currentDifficulty, setDifficulty, reset } = props;

return (
<Wrapper>
{DifficultyType.map((difficulty, i) => (
<DifficultyButton
key={i}
difficulty={difficulty}
setDifficulty={setDifficulty}
currentDifficulty={currentDifficulty}
reset={reset}
/>
))}
{DifficultyType.map((difficulty, i) => {
return (
<DifficultyButton
key={i}
onClick={() => {
setDifficulty(difficulty);
reset();
}}
difficulty={difficulty}
currentDifficulty={currentDifficulty}
>
{difficulty}
</DifficultyButton>
);
})}
</Wrapper>
);
};

export default DifficultySection;
export default DifficultySection;
20 changes: 10 additions & 10 deletions Week3-0422/MatchCardsGame/src/Pages/layout/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from "styled-components";
import { ChangeThemeBtn, ResetButton } from "../../components/Buttons";
import { useEffect, useState } from "react";
import { BigButton } from "../../components/Buttons";
import { useEffect } from "react";
import { ProgressBar } from "react-progressbar-fancy";

const Wrapper = styled.header`
Expand Down Expand Up @@ -32,10 +32,10 @@ const ScoreBoard = styled.div`

const StyledProgressBar = styled(ProgressBar)`
width: 60%;
.number{
.number {
display: none;
}
`
`;

const ButtonBox = styled.div`
display: flex;
Expand All @@ -62,13 +62,15 @@ const Header = (props) => {
if (goalCount === howManyCorrect) setIsModalOpen(true);
}, [howManyCorrect, setIsModalOpen, goalCount]);

const percent = howManyCorrect / goalCount * 100
const percent = (howManyCorrect / goalCount) * 100;

return (
<>
<Wrapper>
<ButtonBox>
<ChangeThemeBtn setIsDark={setIsDark} />
<BigButton onClick={() => setIsDark((prev) => !prev)}>
Theme
</BigButton>
</ButtonBox>
<MainCenterBox>
<h1>πŸ£ν¬μΌ“λͺ¬ μΉ΄λ“œ λ§žμΆ”κΈ° κ²Œμž„πŸ£</h1>
Expand All @@ -82,12 +84,10 @@ const Header = (props) => {
}[currentDifficulty]
}
</ScoreBoard>
<StyledProgressBar
score={percent}
/>
<StyledProgressBar score={percent} />
</MainCenterBox>
<ButtonBox>
<ResetButton allReset={allReset} />
<BigButton onClick={allReset}>AllReset</BigButton>
</ButtonBox>
</Wrapper>
</>
Expand Down
1 change: 0 additions & 1 deletion Week3-0422/MatchCardsGame/src/assets/react.svg

This file was deleted.

47 changes: 6 additions & 41 deletions Week3-0422/MatchCardsGame/src/components/Buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,9 @@ const ResetBtnWrapper = styled.button`
}
`;


/** 전체 리셋 λ²„νŠΌ **/
const ResetButton = (props) => {
const { allReset } = props;

return <ResetBtnWrapper onClick={allReset}>RESET</ResetBtnWrapper>;
};

const ChangeThemeWrapper = styled(ResetBtnWrapper)``;


/** ν…Œλ§ˆ λ³€κ²½ λ²„νŠΌ **/
const ChangeThemeBtn = (props) => {
const { setIsDark } = props;

return (
<ChangeThemeWrapper onClick={() => setIsDark((prev) => !prev)}>
Theme
</ChangeThemeWrapper>
);
/** 헀더에 λ“€μ–΄κ°€λŠ” 큰 λ²„νŠΌ **/
const BigButton = ({ children, ...props }) => {
return <ResetBtnWrapper {...props}>{children}</ResetBtnWrapper>;
};

const DifficultyBtnWrapper = styled.button`
Expand Down Expand Up @@ -67,27 +50,9 @@ const DifficultyBtnWrapper = styled.button`
`};
`;


/** λ‚œμ΄λ„ λ³€κ²½ λ²„νŠΌ **/
const DifficultyButton = (props) => {
const { difficulty, setDifficulty, currentDifficulty, reset } = props;

const changeGameDifficulty = () => {
setDifficulty(difficulty);
};

return (
<DifficultyBtnWrapper
onClick={() => {
changeGameDifficulty();
reset();
}}
difficulty={difficulty}
currentDifficulty={currentDifficulty}
>
{difficulty}
</DifficultyBtnWrapper>
);
const DifficultyButton = ({ children, ...props }) => {
return <DifficultyBtnWrapper {...props}>{children}</DifficultyBtnWrapper>;
};

export { ChangeThemeBtn, ResetButton, DifficultyButton };
export { BigButton, DifficultyButton };
Empty file.
1 change: 0 additions & 1 deletion Week3-0422/MatchCardsGame/src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
Expand Down
Loading

0 comments on commit 265186f

Please sign in to comment.