-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(room-details): 컴포넌트 분리 (#23)
* refactor(room-details): indicator 리팩토링 * refactor: 컴포넌트 분리
- Loading branch information
Mincheol Kim
authored
Nov 29, 2020
1 parent
0e6a2ca
commit 3843d59
Showing
10 changed files
with
253 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { CSSProperties, ReactElement } from "react"; | ||
|
||
import { CheckItem } from "../models"; | ||
|
||
import CheckBox from "./CheckBox"; | ||
|
||
type MultipleChoiceViewProps = { | ||
checks: Array<CheckItem>; | ||
}; | ||
const 행_style = (): CSSProperties => ({ | ||
display: "grid", | ||
alignSelf: "flex-end", | ||
width: 174, | ||
gridTemplateColumns: "0.5fr 2fr 0.5fr 2fr", | ||
gap: "3px", | ||
}); | ||
export default function MultipleChoiceView({ | ||
checks, | ||
}: MultipleChoiceViewProps): ReactElement { | ||
return ( | ||
<div style={행_style()}> | ||
{checks?.map((check) => ( | ||
<CheckBox key={check.uid} uid={check.uid} label={check.contents} /> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { CSSProperties, ReactElement } from "react"; | ||
|
||
import { CheckQuestion } from "../models"; | ||
import { color } from "~/colors"; | ||
import SingleChoiceView from "./SingleChoiceView"; | ||
import MultipleChoiceView from "./MultipleChoiceView"; | ||
|
||
type Props = { | ||
question: CheckQuestion; | ||
}; | ||
const 행_style = (): CSSProperties => ({ | ||
display: "flex", | ||
alignItems: "flex-start", | ||
height: "auto", | ||
padding: "9px 0 9px 0", | ||
}); | ||
const 행_질문_style = (type: string): CSSProperties => ({ | ||
width: `${type === "MultipleChoice" ? "84px" : "auto"}`, | ||
fontSize: 12, | ||
alignSelf: "center", | ||
flexGrow: 1, | ||
}); | ||
|
||
const 밑줄_style = (): CSSProperties => ({ | ||
width: 264, | ||
height: 1, | ||
backgroundColor: color.grayscalef9, | ||
}); | ||
export default function QuestionItem({ question }: Props): ReactElement { | ||
return ( | ||
<div> | ||
<div style={행_style()}> | ||
<span style={행_질문_style(question.type_)}>{question.title}</span> | ||
{question.type_ === "MultipleChoice" ? ( | ||
<MultipleChoiceView checks={question.checks} /> | ||
) : ( | ||
<SingleChoiceView check={question.checks[0]} /> | ||
)} | ||
</div> | ||
<div style={밑줄_style()} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* Expansion 기능을 제공 | ||
* Header: Title, TriangleIcon | ||
* Contents: | ||
* SingleChoice: title, status, checks | ||
* MultipleChoice: title, status, checks | ||
*/ | ||
import React, { CSSProperties, ReactElement, useState } from "react"; | ||
|
||
import { CheckQuestion } from "../models"; | ||
import { ic_open } from "~/assets"; | ||
import { color } from "~/colors"; | ||
import QuestionItem from "./QuestionItem"; | ||
|
||
const 확장뷰_style = (): CSSProperties => ({ | ||
display: "flex", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
height: 39, | ||
fontSize: 16, | ||
fontWeight: "bold", | ||
fontStretch: "normal", | ||
fontStyle: "normal", | ||
lineHeight: 1.34, | ||
letterSpacing: "normal", | ||
color: color.grayscale29, | ||
cursor: "pointer", | ||
marginTop: 28, | ||
}); | ||
const 밑줄_style = (): CSSProperties => ({ | ||
height: 1, | ||
backgroundColor: color.primaryDullPurple, | ||
marginTop: 2, | ||
}); | ||
const 콘텐츠_style = (expand: boolean): CSSProperties => ({ | ||
display: `${expand ? "block" : "none"}`, | ||
}); | ||
type ItemProps = { | ||
label: string; | ||
questions: Array<CheckQuestion>; | ||
}; | ||
export default function QuestionPanel({ | ||
label, | ||
questions, | ||
}: ItemProps): ReactElement { | ||
const [expand, setExpand] = useState(false); | ||
return ( | ||
<> | ||
<QuestionPanelHeader label={label} expand={expand} click={setExpand} /> | ||
<div style={밑줄_style()} /> | ||
<div style={콘텐츠_style(expand)}> | ||
{questions.map((question) => ( | ||
<QuestionItem key={question.uid} question={question} /> | ||
))} | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
type HeaderProps = { | ||
label: string; | ||
expand: boolean; | ||
click: CallableFunction; | ||
}; | ||
const 아이콘_style = (expand: boolean): CSSProperties => ({ | ||
transition: "all ease 0.5s", | ||
transform: `rotate(${expand ? 180 : 360}deg)`, | ||
}); | ||
|
||
function QuestionPanelHeader({ | ||
label, | ||
expand, | ||
click, | ||
}: HeaderProps): ReactElement { | ||
return ( | ||
<div style={확장뷰_style()} onClick={() => click(!expand)}> | ||
<span>{label}</span> | ||
<img | ||
src={ic_open} | ||
alt="" | ||
width="24" | ||
height="24" | ||
style={아이콘_style(expand)} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { CSSProperties, ReactElement } from "react"; | ||
|
||
import { CheckItem } from "../models"; | ||
|
||
import CheckBox from "./CheckBox"; | ||
|
||
type Props = { | ||
check: CheckItem; | ||
}; | ||
const 행_style = (): CSSProperties => ({ | ||
display: "flex", | ||
justifyContent: "flex-end", | ||
flexGrow: 2, | ||
}); | ||
export default function SingleChoiceView({ check }: Props): ReactElement { | ||
return ( | ||
<div style={행_style()}> | ||
<CheckBox uid={check.uid} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
import ChecklistView from "./ChecklistView"; | ||
export { ChecklistView }; | ||
import QuestionItem from "./QuestionItem"; | ||
import SingleChoiceView from "./SingleChoiceView"; | ||
import MultipleChoiceView from "./MultipleChoiceView"; | ||
import QuestionPanel from "./QuestionPanel"; | ||
|
||
export { | ||
ChecklistView, | ||
QuestionItem, | ||
MultipleChoiceView, | ||
SingleChoiceView, | ||
QuestionPanel, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.