Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[#5] React 프로젝트 생성 및 제보사이트 전체 레이아웃 구현 #6

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

Merged
merged 6 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
28,777 changes: 28,777 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "solution-bank-website",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"recoil": "^0.7.4",
"styled-components": "^5.3.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
13 changes: 13 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="'프로그래머스 JS 정답 통과기' 웹사이트입니다." />
<title>프로그래머스 JS 정답 통과기</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
12 changes: 12 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import TabNavigation from "./Components/TabNavigation/TabNavigation";
import ContentsSection from "./Components/ContentsSection/ContentsSection";

export default function App() {
return (
<>
<h1>🤖 프로그래머스 JS 정답 통과기</h1>
<TabNavigation />
<ContentsSection />
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function QuestionNameSection() {
return (
<div className="questionNameSection">
<span>문제 이름:</span>
<input list="questionName" name="question" />
<datalist id="questionName">
<option value="1번문제" />
<option value="2번문제" />
<option value="3번문제" />
</datalist>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function SubmitButton() {
return (
<div className="SubmitButton">
<button id="submitBtn">제출</button>
</div>
);
}
18 changes: 18 additions & 0 deletions src/Components/ContentsSection/ContentsSection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useRecoilValue } from "recoil";
import { tabNoState } from "../../recoil/atom";

import ErrorReportTab from "./ErrorReport/ErrorReportTab";
import IntroductionTab from "./Introduction/IntroductionTab";
import SolutionReportTab from "./SolutionReport/SolutionReportTab";

export default function ContentsSection() {
const tabNo = useRecoilValue(tabNoState);

const tabs = {
0: <IntroductionTab />,
1: <ErrorReportTab />,
2: <SolutionReportTab />,
};

return <div>{tabs[tabNo]}</div>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default function ErrorCategoryInput() {
function resetInput() {
Array.from(document.querySelectorAll("input, textarea")).forEach((input) => (input.value = ""));
}
return (
<div className="errorCategoryinput">
<span>오류 유형: </span>
<input type="radio" id="errorCategory0" name="errorCategory" onClick={resetInput} />
<label htmlFor="errorCategory0">정답 통과가 안돼요</label>

<input type="radio" id="errorCategory1" name="errorCategory" onClick={resetInput} />
<label htmlFor="errorCategory1">코드 복사가 안돼요</label>

<input type="radio" id="errorCategory2" name="errorCategory" onClick={resetInput} />
<label htmlFor="errorCategory2">기타</label>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function ErrorDetailInput() {
return (
<div className="ErrorDetailInput">
<span>내용: </span>
<textarea rows="20" cols="100"></textarea>
</div>
);
}
16 changes: 16 additions & 0 deletions src/Components/ContentsSection/ErrorReport/ErrorReportTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import ErrorCategoryInput from "./Components/ErrorCategoryInput";
import QuestionNameInput from "../CommonComponents/QuestionNameInput";
import ErrorDetailInput from "./Components/ErrorDetailInput";
import SubmitButton from "../CommonComponents/SubmitButton";

export default function ErrorReportTab() {
return (
<div className="ErrorReportTab">
<p>ErrorReportTab</p>
<ErrorCategoryInput />
<QuestionNameInput />
<ErrorDetailInput />
<SubmitButton />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function IntroductionTab() {
return (
<div className="IntroductionTab">
<p>IntroductionTab</p>
{/* IntroductionTab content will go here */}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function GitHubLogin() {
return (
<div className="gitHubLogin">
<span>기여자 등록: </span>
<button id="gitHubLoginBtn">GitHub 로그인</button>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function SolutionCodeInput() {
return (
<div className="SolutionCodeInput">
<span>정답 코드: </span>
<textarea rows="20" cols="100"></textarea>
</div>
);
}
16 changes: 16 additions & 0 deletions src/Components/ContentsSection/SolutionReport/SolutionReportTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import QuestionNameInput from "../CommonComponents/QuestionNameInput";
import GitHubLogin from "./Components/GitHubLogin";
import SolutionCodeInput from "./Components/SolutionCodeInput";
import SubmitButton from "../CommonComponents/SubmitButton";

export default function SolutionReportTab() {
return (
<div className="SolutionReportTab">
<p>SolutionReportTab</p>
<QuestionNameInput />
<GitHubLogin />
<SolutionCodeInput />
<SubmitButton />
</div>
);
}
27 changes: 27 additions & 0 deletions src/Components/TabNavigation/TabNavigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useSetRecoilState } from "recoil";
import { tabNoState } from "../../recoil/atom";

export default function TabNavigation() {
const setTabNo = useSetRecoilState(tabNoState);

function tabClicked(e) {
let targetId = e.target.id;
setTabNo(targetId[targetId.length - 1]);
}

return (
<div className="navigationTab">
<ul className="tabs">
<li id="tab0" onClick={tabClicked}>
소개
</li>
<li id="tab1" onClick={tabClicked}>
오류제보
</li>
<li id="tab2" onClick={tabClicked}>
정답제보
</li>
</ul>
</div>
);
}
13 changes: 13 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import { RecoilRoot } from "recoil";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<RecoilRoot>
<App />
</RecoilRoot>
</React.StrictMode>
);
6 changes: 6 additions & 0 deletions src/recoil/atom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { atom } from "recoil";

export const tabNoState = atom({
key: "tabNoState",
default: 0,
});