From 7ffda673af546c69f1b647f5804e64aa6a77509c Mon Sep 17 00:00:00 2001 From: chaerin <70943835+chaerin-dev@users.noreply.github.com> Date: Fri, 1 Jul 2022 22:47:11 +0900 Subject: [PATCH 1/4] =?UTF-8?q?refactor:=20=EC=88=AB=EC=9E=90=EA=B0=80=20?= =?UTF-8?q?=EC=95=84=EB=8B=8C=20=EC=8B=A4=EC=A0=9C=20=EC=98=B5=EC=85=98=20?= =?UTF-8?q?=EB=AA=85=EC=9C=BC=EB=A1=9C=20state=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Components/Tabs/ErrorReport.js | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Components/Tabs/ErrorReport.js b/src/Components/Tabs/ErrorReport.js index 10d9d9a..8cd882f 100644 --- a/src/Components/Tabs/ErrorReport.js +++ b/src/Components/Tabs/ErrorReport.js @@ -2,7 +2,7 @@ import { useState } from "react"; export default function ErrorReport() { const [submitted, setSubmitted] = useState(false); - const [errorCategory, setErrorCategory] = useState(-1); + const [errorCategory, setErrorCategory] = useState(""); const [questionName, setQuestionName] = useState(""); const [detailInput, setDetailInput] = useState(""); @@ -12,7 +12,7 @@ export default function ErrorReport() { + ) : (
@@ -28,21 +42,21 @@ export default function ErrorReport() { type="radio" id="error-wrongAnswer" name="errorCategory" - onClick={(e) => setErrorCategory(e.target.id)} + onClick={handleErrorCategoryClick} /> setErrorCategory(e.target.id)} + onClick={handleErrorCategoryClick} /> setErrorCategory(e.target.id)} + onClick={handleErrorCategoryClick} />
@@ -52,7 +66,7 @@ export default function ErrorReport() { setQuestionName(e.target.value)} + onInput={handleQuestionNameInput} defaultValue={questionName} /> @@ -70,15 +84,15 @@ export default function ErrorReport() {
diff --git a/src/Components/Tabs/SolutionReport.js b/src/Components/Tabs/SolutionReport.js index a26cdca..72f32dd 100644 --- a/src/Components/Tabs/SolutionReport.js +++ b/src/Components/Tabs/SolutionReport.js @@ -3,20 +3,30 @@ import { useState } from "react"; export default function SolutionReport() { const [submitted, setSubmitted] = useState(false); const [questionName, setQuestionName] = useState(""); - const [detailInput, setDetailInput] = useState(""); + const [detailContent, setDetailContent] = useState(""); + + function handleOtherSolutionBtnClick() { + setSubmitted(false); + setQuestionName(""); + setDetailContent(""); + } + + function handleQuestionNameInput(e) { + setQuestionName(e.target.value); + } + + function handleDetailContentInput(e) { + setDetailContent(e.target.value); + } + + function handleSubmitBtnClick() { + setSubmitted(true); + } return submitted ? (

제보해주셔서 감사합니다.

- +
) : (
@@ -25,7 +35,7 @@ export default function SolutionReport() { setQuestionName(e.target.value)} + onInput={handleQuestionNameInput} defaultValue={questionName} /> @@ -46,12 +56,12 @@ export default function SolutionReport() {
-
From 7c79f9ed21bfe0469fa9724ae604dd653bd82e04 Mon Sep 17 00:00:00 2001 From: chaerin <70943835+chaerin-dev@users.noreply.github.com> Date: Fri, 1 Jul 2022 23:08:27 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=EC=88=9C=EC=B0=A8=EC=A0=81=20?= =?UTF-8?q?=EB=A0=8C=EB=8D=94=EB=A7=81=EC=9D=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EB=85=BC=EB=A6=AC=EA=B5=AC=EB=AC=B8=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Components/Tabs/ErrorReport.js | 16 ++++++++-------- src/Components/Tabs/SolutionReport.js | 9 ++++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Components/Tabs/ErrorReport.js b/src/Components/Tabs/ErrorReport.js index 0d779fb..3e3612d 100644 --- a/src/Components/Tabs/ErrorReport.js +++ b/src/Components/Tabs/ErrorReport.js @@ -6,6 +6,11 @@ export default function ErrorReport() { const [questionName, setQuestionName] = useState(""); const [detailContent, setDetailContent] = useState(""); + const isQuestionNameUnvisible = errorCategory === "" || errorCategory === "error-notCopied"; + const isDetailContentUnvisible = + errorCategory === "" || (errorCategory === "error-wrongAnswer" && questionName === ""); + const isSubmitBtnDisabled = errorCategory === "error-other" && detailContent === ""; + function handleOtherErrorBtnClick() { setSubmitted(false); setErrorCategory(""); @@ -60,7 +65,7 @@ export default function ErrorReport() { />
- {errorCategory === "" || errorCategory === "error-notCopied" ? null : ( + {isQuestionNameUnvisible ? null : (
문제 이름:
)} - {errorCategory === "" || - (errorCategory === "error-wrongAnswer" && questionName === "") ? null : ( + {isDetailContentUnvisible ? null : ( <>
내용: @@ -89,11 +93,7 @@ export default function ErrorReport() { >
-
diff --git a/src/Components/Tabs/SolutionReport.js b/src/Components/Tabs/SolutionReport.js index 72f32dd..d2bea5b 100644 --- a/src/Components/Tabs/SolutionReport.js +++ b/src/Components/Tabs/SolutionReport.js @@ -5,6 +5,9 @@ export default function SolutionReport() { const [questionName, setQuestionName] = useState(""); const [detailContent, setDetailContent] = useState(""); + const isDetailContentUnvisible = questionName === ""; + const isSubmitBtnDisabled = detailContent === ""; + function handleOtherSolutionBtnClick() { setSubmitted(false); setQuestionName(""); @@ -31,7 +34,7 @@ export default function SolutionReport() { ) : (
- 문제 이름: + 문제 이름:
- {questionName === "" ? null : ( + {isDetailContentUnvisible ? null : ( <>
기여자 등록: @@ -61,7 +64,7 @@ export default function SolutionReport() { >
-
From da95249d4fe8d828d1050c48233f02da2ae21ef4 Mon Sep 17 00:00:00 2001 From: chaerin <70943835+chaerin-dev@users.noreply.github.com> Date: Sat, 2 Jul 2022 00:01:34 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20StyledComponent=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 6 +- src/Components/Contents.js | 21 +++-- src/Components/Tabs/ErrorReport.js | 82 ++++++++++++-------- src/Components/Tabs/Introduction.js | 9 +-- src/Components/Tabs/SolutionReport.js | 72 ++++++++++------- src/Components/Tabs/Style/StyledComponent.js | 27 +++++++ src/recoil/atom 2.js | 6 -- src/recoil/atom.js | 6 -- 8 files changed, 141 insertions(+), 88 deletions(-) create mode 100644 src/Components/Tabs/Style/StyledComponent.js delete mode 100644 src/recoil/atom 2.js delete mode 100644 src/recoil/atom.js diff --git a/src/App.js b/src/App.js index bc4d145..e80aafa 100644 --- a/src/App.js +++ b/src/App.js @@ -1,10 +1,14 @@ +import styled from "styled-components"; + import Contents from "./Components/Contents"; export default function App() { return ( <> -

🤖 프로그래머스 JS 정답 통과기

+ Codestin Search App ); } + +const Title = styled.h1``; diff --git a/src/Components/Contents.js b/src/Components/Contents.js index 4fe1bb1..ef40d11 100644 --- a/src/Components/Contents.js +++ b/src/Components/Contents.js @@ -1,4 +1,5 @@ import { BrowserRouter, Routes, Route, Link } from "react-router-dom"; +import styled from "styled-components"; import Introduction from "./Tabs/Introduction"; import ErrorReport from "./Tabs/ErrorReport"; @@ -7,17 +8,17 @@ import SolutionReport from "./Tabs/SolutionReport"; export default function TabNavigation() { return ( -
    -
  • + + 소개 -
  • -
  • + + 오류 제보 -
  • -
  • + + 정답 제보 -
  • -
+ + }> }> @@ -26,3 +27,7 @@ export default function TabNavigation() {
); } + +const TabList = styled.ul``; + +const TabItem = styled.li``; diff --git a/src/Components/Tabs/ErrorReport.js b/src/Components/Tabs/ErrorReport.js index 3e3612d..a9ebb43 100644 --- a/src/Components/Tabs/ErrorReport.js +++ b/src/Components/Tabs/ErrorReport.js @@ -1,4 +1,17 @@ import { useState } from "react"; +import { + TabWrapper, + BlockText, + Button, + StepByStepInputItem, + InlineText, + RadioInput, + Label, + TextInput, + DataList, + Option, + TextArea, +} from "./Style/StyledComponent"; export default function ErrorReport() { const [submitted, setSubmitted] = useState(false); @@ -35,70 +48,73 @@ export default function ErrorReport() { } return submitted ? ( -
-

제보해주셔서 감사합니다.

- -
+ + 제보해주셔서 감사합니다. + + ) : ( -
-
- 오류 유형: - + + 오류 유형: + - - 정답 통과가 안돼요 + - - 코드 복사가 안돼요 + - -
+ + + {isQuestionNameUnvisible ? null : ( -
- 문제 이름: - + 문제 이름: + - - -
+ + + )} + {isDetailContentUnvisible ? null : ( <> -
- 내용: - -
-
- -
+ + )} -
+ ); } diff --git a/src/Components/Tabs/Introduction.js b/src/Components/Tabs/Introduction.js index 9246900..17d1b77 100644 --- a/src/Components/Tabs/Introduction.js +++ b/src/Components/Tabs/Introduction.js @@ -1,8 +1,5 @@ +import { TabWrapper } from "./Style/StyledComponent"; + export default function Introduction() { - return ( -
-

IntroductionTab

- {/* IntroductionTab content will go here */} -
- ); + return {/* IntroductionTab content will go here */}; } diff --git a/src/Components/Tabs/SolutionReport.js b/src/Components/Tabs/SolutionReport.js index d2bea5b..5281a5a 100644 --- a/src/Components/Tabs/SolutionReport.js +++ b/src/Components/Tabs/SolutionReport.js @@ -1,4 +1,17 @@ import { useState } from "react"; +import styled from "styled-components"; + +import { + TabWrapper, + BlockText, + Button, + StepByStepInputItem, + InlineText, + TextInput, + DataList, + Option, + TextArea, +} from "./Style/StyledComponent"; export default function SolutionReport() { const [submitted, setSubmitted] = useState(false); @@ -27,49 +40,52 @@ export default function SolutionReport() { } return submitted ? ( -
-

제보해주셔서 감사합니다.

- -
+ + 제보해주셔서 감사합니다. + + ) : ( -
-
- 문제 이름: - + + 문제 이름: + - - -
+ + + {isDetailContentUnvisible ? null : ( <> -
- 기여자 등록: - -
-
- 내용: - -
-
- -
+ + )} -
+ ); } + +const GitHubLoginBtn = styled.button``; diff --git a/src/Components/Tabs/Style/StyledComponent.js b/src/Components/Tabs/Style/StyledComponent.js new file mode 100644 index 0000000..c2da699 --- /dev/null +++ b/src/Components/Tabs/Style/StyledComponent.js @@ -0,0 +1,27 @@ +// Tabs에서 공통적으로 사용되는 부분을 위해 폴더구조를 이렇게 만들었는데, 뭔가 어색하네요.. + +import styled from "styled-components"; + +export const TabWrapper = styled.div``; + +export const BlockText = styled.p``; + +export const Button = styled.button``; + +export const StepByStepInputItem = styled.div``; + +export const InlineText = styled.span``; + +export const RadioInput = styled.input``; + +export const Label = styled.label``; + +export const TextInput = styled.input``; + +export const DataList = styled.datalist``; + +export const Option = styled.option``; + +export const DetailContentWrapper = styled.div``; + +export const TextArea = styled.textarea``; diff --git a/src/recoil/atom 2.js b/src/recoil/atom 2.js deleted file mode 100644 index 9e958b5..0000000 --- a/src/recoil/atom 2.js +++ /dev/null @@ -1,6 +0,0 @@ -import { atom } from "recoil"; - -export const tabNoState = atom({ - key: "tabNoState", - default: 0, -}); diff --git a/src/recoil/atom.js b/src/recoil/atom.js deleted file mode 100644 index 9e958b5..0000000 --- a/src/recoil/atom.js +++ /dev/null @@ -1,6 +0,0 @@ -import { atom } from "recoil"; - -export const tabNoState = atom({ - key: "tabNoState", - default: 0, -});