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주차 과제 제출 #5

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2f35ae2
init: initial setting
Geun-Oh Apr 25, 2023
c1c3515
feat: asset 추가
Geun-Oh Apr 25, 2023
b5328a2
feat: 카드뒤집기 구현
Geun-Oh Apr 25, 2023
1bef0cf
feat: contextAPI 설정
Geun-Oh Apr 26, 2023
2ef8eb5
feat: 게임 성공까지 구현 완료
Geun-Oh Apr 27, 2023
45fda89
feat: 카드 두개 이상 열리지 않도록 구현
Geun-Oh Apr 27, 2023
7ccdc66
feat: 오픈된 카드 클릭 시 이벤트 막기
Geun-Oh Apr 27, 2023
1f0a2df
feat: 오픈된 카드 클릭 시 이벤트 막기
Geun-Oh Apr 27, 2023
f8d2ac3
feat: 랜덤 배열 전역상태화
Geun-Oh Apr 27, 2023
f15ac75
feat: 리셋 버튼 구현
Geun-Oh Apr 27, 2023
f1182a8
feat: 모달 조건부 렌더링 성공 및 스타일 설정
Geun-Oh Apr 27, 2023
35549df
style: styled-components 적용 완료
Geun-Oh Apr 27, 2023
03ce03a
chore: vite deploy test 1
Geun-Oh Apr 27, 2023
5a38f05
chore: vite config 이미지 빌드 수정
Geun-Oh Apr 27, 2023
c734470
Create static.yml
Geun-Oh Apr 27, 2023
d958239
Update static.yml
Geun-Oh Apr 27, 2023
4ab5e0f
chore: vite deploy test
Geun-Oh Apr 27, 2023
be2d080
Merge branch 'week3/assign1' of https://github.com/GO-SOPT-WEB/Hyeong…
Geun-Oh Apr 27, 2023
7a9c206
chore: static.yml 수정
Geun-Oh Apr 27, 2023
c6c11fc
chore: 불필요한 파일 제거
Geun-Oh Apr 27, 2023
c8c5f6d
Update static.yml
Geun-Oh Apr 27, 2023
ca017d7
Update static.yml
Geun-Oh Apr 27, 2023
7bf6dbc
chore: vite github acitons test
Geun-Oh Apr 27, 2023
9520a2b
chore: baseURL 수정
Geun-Oh Apr 27, 2023
ca3083d
style: 카드 쌍 맞출 시 애니메이션 추가
Geun-Oh Apr 27, 2023
2bb7851
chore: 잔디 테스트
Geun-Oh Apr 27, 2023
409ab2a
style: styled-component 설정 및 rotate 수정
Geun-Oh Apr 28, 2023
f10090a
refactor: 컴포넌트 전체 리팩토링...
Geun-Oh Apr 28, 2023
ff68a40
fix: 모달 문제 수정
Geun-Oh Apr 29, 2023
1bd428d
style: StyleHeader => StyledHeader 로 변경
Geun-Oh Apr 30, 2023
c5b8b7d
style: 모든 버튼에 hover 추가
Geun-Oh Apr 30, 2023
ba281f8
style: 메인 섹션 width 60% => 80% 변경
Geun-Oh Apr 30, 2023
bae0699
style: common button style 적용
Geun-Oh Apr 30, 2023
b1dbdc4
chore: ds_store modified
Geun-Oh Apr 30, 2023
431cee9
init: initialization
Geun-Oh May 28, 2023
47fc43a
refactor: page ~ template 까지의 파일들 ts로 마이그레이션 완료. 이후 진행 중...
Geun-Oh May 29, 2023
e603657
refactor: organism 파일 ts 마이그레이션 완료
Geun-Oh May 29, 2023
50ef42a
refactor: SuccessModal 컴포넌트 recoil 마이그레이션
Geun-Oh May 29, 2023
662c702
remove: 불필요한 ContextAPI 코드 제거
Geun-Oh May 29, 2023
254b97a
refactor: png 파일들 assets로 이동 및 png type declare
Geun-Oh May 29, 2023
97303ff
feat: modal portal용 div element 추가
Geun-Oh May 29, 2023
0477fba
fix: 불필요한 import 제거 및 타입 단언 추가
Geun-Oh May 29, 2023
7c486f8
refactor: modal 부모 요소 존재 여부 검증 로직 추가
Geun-Oh May 29, 2023
011a0c4
fix: assets import 수정
Geun-Oh May 29, 2023
c0af8d5
chore: backface-visibility 브라우저 최적화 실패
Geun-Oh Jun 4, 2023
d5e9a91
fix: 불필요한 변수 제거
Geun-Oh Jun 4, 2023
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
Binary file added .DS_Store
Binary file not shown.
54 changes: 54 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# GitHub Pages에 정적 콘텐츠를 배포하기 위한 간단한 워크플로우
name: Deploy static content to Pages

on:
# 기본 브랜치에 대한 푸시 이벤트 발생 시 실행
push:
branches: ["week3/assign1"]

# Actions 탭에서 수동으로 워크플로우를 실행할 수 있도록 구성
workflow_dispatch:

# GITHUB_TOKEN의 권한을 설정하여 GitHub Pages에 배포할 수 있도록 함
permissions:
contents: read
pages: write
id-token: write

# 동시에 하나의 배포만 허용하도록 구성
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# 단순히 배포만 수행하기에 하나의 잡으로만 구성
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
defaults:
run:
working-directory: "week3/Assignment1"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# dist 디렉터리 업로드
path: "./dist"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
14 changes: 14 additions & 0 deletions week3-ts/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
env: { browser: true, es2020: true, node: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": "warn",
},
};
24 changes: 24 additions & 0 deletions week3-ts/.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?
14 changes: 14 additions & 0 deletions week3-ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="modal"></div>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions week3-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "week3-ts",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"recoil": "^0.7.7",
"styled-components": "^5.3.11"
},
"devDependencies": {
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@vitejs/plugin-react-swc": "^3.0.0",
"eslint": "^8.38.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"typescript": "^5.0.2",
"vite": "^4.3.2"
}
}
Binary file added week3-ts/public/assets/IMG_0454.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week3-ts/public/assets/IMG_0455.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week3-ts/public/assets/IMG_0456.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week3-ts/public/assets/IMG_0457.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week3-ts/public/assets/IMG_0459.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week3-ts/public/assets/IMG_0460.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week3-ts/public/assets/IMG_0461.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week3-ts/public/assets/IMG_0463.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week3-ts/public/assets/IMG_0464.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions week3-ts/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions week3-ts/src/@types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "*.png";
18 changes: 18 additions & 0 deletions week3-ts/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ThemeProvider } from "styled-components";
import theme from "./styles/theme";
import GlobalStyle from "./styles/globalStyle";
import { RecoilRoot } from "recoil";
import MainPage from "./pages/MainPage";

function App() {
return (
<ThemeProvider theme={theme}>
<GlobalStyle />
<RecoilRoot>
<MainPage />
</RecoilRoot>
</ThemeProvider>
);
}

export default App;
25 changes: 25 additions & 0 deletions week3-ts/src/components/GameSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import styled from 'styled-components';

import CardTemplate from './template/CardTemplate';
import DifficultyButtonTemplate from './template/DifficultyButtonTemplate';

const GameSection = () => {
return (
<StyledGameSection>
<DifficultyButtonTemplate />
<CardTemplate />
</StyledGameSection>
);
};

const StyledGameSection = styled.section`
width: 100vw;
height: auto;
min-height: calc(100vw - 200px);
background-color: ${({ theme }) => theme.Background};
display: flex;
flex-direction: column;
align-items: center;
`;

export default GameSection;
52 changes: 52 additions & 0 deletions week3-ts/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import "../styles/bright.css";

import { useEffect } from "react";
import { useRef } from "react";
import styled from "styled-components";

import { useRecoilValue } from "recoil";
import RootState from "../recoil/atom";

const Header = () => {
const { correctCard, difficulty } = useRecoilValue(RootState);
const spanRef = useRef<HTMLSpanElement>(null);

useEffect(() => {
spanRef.current && spanRef.current.classList.add("bright");
setTimeout(() => {
spanRef.current && spanRef.current.classList.remove("bright");
}, 800);
}, [correctCard]);

return (
<StyledHeader>
<h1>⭐찌호를 맞춰주세요⭐</h1>
<span ref={spanRef}>
{correctCard.length} /{" "}
{difficulty === "Easy" ? 5 : difficulty === "Normal" ? 7 : 9}
</span>
</StyledHeader>
);
};

const StyledHeader = styled.header`
width: 100vw;
height: 200px;
background-color: #ebccb0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
h1 {
color: #815854;
font-size: 4rem;
margin-bottom: 1rem;
}
span {
color: #6b3a35;
font-size: 2rem;
font-weight: 700;
}
`;

export default Header;
19 changes: 19 additions & 0 deletions week3-ts/src/components/SuccessModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useRecoilValue } from "recoil";
import RootState from "../recoil/atom";
import Modal from "./organism/Modal";
import ModalRenderer from "./organism/ModalRenderer";

const SuccessModal = () => {
const { successModalOpen } = useRecoilValue(RootState);
return (
<>
{successModalOpen && (
<ModalRenderer>
<Modal />
</ModalRenderer>
)}
</>
);
};

export default SuccessModal;
56 changes: 56 additions & 0 deletions week3-ts/src/components/atom/ButtonView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import styled from "styled-components";

const StyledDifficulfyButton = styled.button`
${({ theme }) => theme.CommonButtonStyle}
height: 60px;
padding: 10px 20px;
font-size: 1.5rem;
border: none;
border-radius: 5px;
color: #6b2019;
background-color: #d37e75;
transition-duration: 0.3s;
`;

const StyledResetButton = styled.button`
${({ theme }) => theme.CommonButtonStyle}
top: 60px;
right: 40px;
height: 90px;
padding: 10px 20px;
font-size: 2rem;
color: #f1c4c0;
background-color: #6b2019;
position: fixed;
`;

const StyledSuccessModalButton = styled.button`
${({ theme }) => theme.CommonButtonStyle}
width: 80px;
padding: 10px;
margin-top: 10px;
border-radius: 10px;
background-color: ${({ theme }) => theme.SubBackground};
`;

const buttonTypes = {
DIFFICULTY: StyledDifficulfyButton,
RESET: StyledResetButton,
SUCCESSMODAL: StyledSuccessModalButton,
};

interface ButtonViewProps {
type: "DIFFICULTY" | "RESET" | "SUCCESSMODAL";
innerText: string;
onClick: (e: React.MouseEvent<HTMLElement>) => void;
}

const ButtonView = ({ type, innerText, onClick }: ButtonViewProps) => {
const ButtonType = buttonTypes[type];
return (
<ButtonType type="button" onClick={onClick} value={innerText}>
{innerText}
</ButtonType>
);
};
export default ButtonView;
53 changes: 53 additions & 0 deletions week3-ts/src/components/atom/CardView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import styled from "styled-components";

interface CardViewProps {
rotate: "rotateY(0deg)" | "rotateY(180deg)";
onClick: (e: React.MouseEvent<HTMLElement>) => void;
imgURL: string;
}

const CardView = ({ rotate, onClick, imgURL }: CardViewProps) => {
return (
<StyledCardArticle rotate={rotate} onClick={onClick}>
<div className="card_frontface">
<img src={imgURL} alt={`찌호이미지: ${imgURL}`} />
</div>
<div className="card_backface"></div>
</StyledCardArticle>
);
};

const StyledCardArticle = styled.article<{
rotate: "rotateY(0deg)" | "rotateY(180deg)";
}>`
position: relative;
transform: ${({ rotate }) => rotate};
transition-duration: 1s;
transform-style: preserve-3d;
.card_frontface {
width: 180px;
height: 250px;
border-radius: 20px;
background-color: white;
display: flex;
justify-content: center;
align-items: center;
img {
width: 150px;
backface-visibility: hidden;
}
}
.card_backface {
top: 0;
left: 0;
width: 180px;
height: 250px;
border-radius: 20px;
background-color: #a11818;
position: absolute;
transform: rotateY(180deg);
backface-visibility: hidden;
}
`;

export default CardView;
Loading