@team-monolith/cds 1.38.3 → 1.38.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/patterns/Dropdown/Dropdown.js +18 -4
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/InputComponent.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/InputComponent.js +3 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/ProblemInputNode.d.ts +5 -2
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/ProblemInputNode.js +8 -5
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SegmentedInput.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/SegmentedInput.js +13 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/TextInput.d.ts +1 -0
- package/dist/patterns/LexicalEditor/nodes/ProblemInputNode/TextInput.js +20 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxComponent.d.ts +3 -0
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxComponent.js +38 -3
- package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxView.js +23 -85
- package/package.json +1 -1
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
13
|
/** @jsxImportSource @emotion/react */
|
|
3
14
|
import { forwardRef, useRef, useState } from "react";
|
|
@@ -7,7 +18,7 @@ import { DropdownMenu } from "./DropdownMenu";
|
|
|
7
18
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?type=design&node-id=203-95329&t=FwczLZ1IVvskUVbT-0)
|
|
8
19
|
*/
|
|
9
20
|
const Dropdown = forwardRef((props, ref) => {
|
|
10
|
-
const { className, component: Component = "div", disabled, color = "primary", size = "medium", bold, startIcon, endIcon = _jsx(ArrowDropDownFillIcon, {}), buttonCss, label, onClick, menuProps = {}, children, closeOnItemClick
|
|
21
|
+
const { className, component: Component = "div", disabled, color = "primary", size = "medium", bold, startIcon, endIcon = _jsx(ArrowDropDownFillIcon, {}), buttonCss, label, onClick, menuProps = {}, children, closeOnItemClick } = props, other = __rest(props, ["className", "component", "disabled", "color", "size", "bold", "startIcon", "endIcon", "buttonCss", "label", "onClick", "menuProps", "children", "closeOnItemClick"]);
|
|
11
22
|
const buttonProps = {
|
|
12
23
|
disabled,
|
|
13
24
|
color,
|
|
@@ -16,16 +27,19 @@ const Dropdown = forwardRef((props, ref) => {
|
|
|
16
27
|
endIcon,
|
|
17
28
|
};
|
|
18
29
|
const menuRef = useRef(null);
|
|
30
|
+
const isControlled = menuProps.open !== undefined;
|
|
19
31
|
const [open, setOpen] = useState(false);
|
|
20
32
|
const [itemState, setItemState] = useState(new Map());
|
|
21
33
|
const handleClick = (e) => {
|
|
22
34
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
23
|
-
|
|
35
|
+
if (!isControlled)
|
|
36
|
+
setOpen(true);
|
|
24
37
|
};
|
|
25
38
|
const handleClose = (e) => {
|
|
26
39
|
var _a;
|
|
27
40
|
e.stopPropagation();
|
|
28
|
-
|
|
41
|
+
if (!isControlled)
|
|
42
|
+
setOpen(false);
|
|
29
43
|
setItemState((prevState) => {
|
|
30
44
|
const newState = new Map(prevState);
|
|
31
45
|
newState.forEach((value, key) => {
|
|
@@ -38,6 +52,6 @@ const Dropdown = forwardRef((props, ref) => {
|
|
|
38
52
|
});
|
|
39
53
|
(_a = menuProps === null || menuProps === void 0 ? void 0 : menuProps.onClose) === null || _a === void 0 ? void 0 : _a.call(menuProps, e);
|
|
40
54
|
};
|
|
41
|
-
return (_jsxs(Component, Object.assign({ className: className, ref: ref }, { children: [_jsx(Button, Object.assign({ css: buttonCss, ref: menuRef }, buttonProps, { label: label, bold: bold, onClick: handleClick, fullWidth: true })), _jsx(DropdownMenu, Object.assign({}, menuProps, { open: open, onClose: handleClose, anchorEl: menuRef.current, closeOnItemClick: closeOnItemClick, itemState: itemState, setItemState: setItemState }, { children: children }))] })));
|
|
55
|
+
return (_jsxs(Component, Object.assign({ className: className }, other, { ref: ref }, { children: [_jsx(Button, Object.assign({ css: buttonCss, ref: menuRef }, buttonProps, { label: label, bold: bold, onClick: handleClick, fullWidth: true })), _jsx(DropdownMenu, Object.assign({}, menuProps, { open: isControlled ? menuProps.open : open, onClose: handleClose, anchorEl: menuRef.current, closeOnItemClick: closeOnItemClick, itemState: itemState, setItemState: setItemState }, { children: children }))] })));
|
|
42
56
|
});
|
|
43
57
|
export { Dropdown };
|
|
@@ -25,7 +25,7 @@ import { LexicalCustomConfigContext } from "../../LexicalCustomConfigContext";
|
|
|
25
25
|
import TextInput from "./TextInput";
|
|
26
26
|
import SegmentedInput from "./SegmentedInput";
|
|
27
27
|
export function InputComponent(props) {
|
|
28
|
-
const { answer } = props, settingFormProps = __rest(props, ["answer"]);
|
|
28
|
+
const { answer, isCorrect } = props, settingFormProps = __rest(props, ["answer", "isCorrect"]);
|
|
29
29
|
const { solutions, showCharacterNumber, placeholder, nodeKey } = settingFormProps;
|
|
30
30
|
const [editor] = useLexicalComposerContext();
|
|
31
31
|
const [settingOpen, setSettingOpen] = useState(false);
|
|
@@ -51,9 +51,9 @@ export function InputComponent(props) {
|
|
|
51
51
|
// 학생 view
|
|
52
52
|
if (!isEditable) {
|
|
53
53
|
if (showCharacterNumber) {
|
|
54
|
-
return (_jsx(SegmentedInput, { readOnly: lexicalCustomConfig.freezeProblemNode, answerFormat: answerFormat, placeholder: placeholder || "여기에 입력하세요.", value: answerInput, onChange: handleChange }));
|
|
54
|
+
return (_jsx(SegmentedInput, { readOnly: lexicalCustomConfig.freezeProblemNode, isCorrect: isCorrect, answerFormat: answerFormat, placeholder: placeholder || "여기에 입력하세요.", value: answerInput, onChange: handleChange }));
|
|
55
55
|
}
|
|
56
|
-
return (_jsx(TextInput, { readOnly: lexicalCustomConfig.freezeProblemNode, size: "small", color: "default", placeholder: placeholder || "여기에 입력하세요.", value: answerInput, onChange: (e) => {
|
|
56
|
+
return (_jsx(TextInput, { readOnly: lexicalCustomConfig.freezeProblemNode, isCorrect: isCorrect, size: "small", color: "default", placeholder: placeholder || "여기에 입력하세요.", value: answerInput, onChange: (e) => {
|
|
57
57
|
handleChange(e.target.value);
|
|
58
58
|
}, fullWidth: true }));
|
|
59
59
|
}
|
|
@@ -11,6 +11,8 @@ export interface ProblemInputPayload {
|
|
|
11
11
|
* (ex: "코들 입니다" => "** ***") */
|
|
12
12
|
solutions: Solution[];
|
|
13
13
|
answer: string;
|
|
14
|
+
/** FE에서만 사용하는 값. 문제의 정오답 여부를 주입하여 스타일을 변경합니다. */
|
|
15
|
+
isCorrect?: boolean;
|
|
14
16
|
key?: NodeKey;
|
|
15
17
|
}
|
|
16
18
|
export type SerializedProblemInputNode = Spread<ProblemInputPayload, SerializedLexicalNode>;
|
|
@@ -23,6 +25,7 @@ export declare class ProblemInputNode extends DecoratorNode<ReactNode> {
|
|
|
23
25
|
__showCharacterNumber: boolean;
|
|
24
26
|
__placeholder: string;
|
|
25
27
|
__answer: string;
|
|
28
|
+
__isCorrect?: boolean;
|
|
26
29
|
isInline(): boolean;
|
|
27
30
|
static getType(): string;
|
|
28
31
|
getSolutions(): Solution[];
|
|
@@ -34,12 +37,12 @@ export declare class ProblemInputNode extends DecoratorNode<ReactNode> {
|
|
|
34
37
|
setPlaceholder(placeholder: string): void;
|
|
35
38
|
setAnswer(answer: string): void;
|
|
36
39
|
static clone(node: ProblemInputNode): ProblemInputNode;
|
|
37
|
-
constructor(showCharacterNumber: boolean, placeholder: string, solutions: Solution[], answer: string, key?: NodeKey);
|
|
40
|
+
constructor(showCharacterNumber: boolean, placeholder: string, solutions: Solution[], answer: string, isCorrect?: boolean, key?: NodeKey);
|
|
38
41
|
createDOM(config: EditorConfig): HTMLElement;
|
|
39
42
|
updateDOM(): boolean;
|
|
40
43
|
static importJSON(serializedNode: SerializedProblemInputNode): ProblemInputNode;
|
|
41
44
|
exportJSON(): SerializedProblemInputNode;
|
|
42
45
|
decorate(): ReactNode;
|
|
43
46
|
}
|
|
44
|
-
export declare function $createProblemInputNode({ showCharacterNumber, placeholder, solutions, answer, key, }: ProblemInputPayload): ProblemInputNode;
|
|
47
|
+
export declare function $createProblemInputNode({ showCharacterNumber, placeholder, solutions, answer, isCorrect, key, }: ProblemInputPayload): ProblemInputNode;
|
|
45
48
|
export declare function $isProblemInputNode(node: LexicalNode | null | undefined): node is ProblemInputNode;
|
|
@@ -42,14 +42,15 @@ export class ProblemInputNode extends DecoratorNode {
|
|
|
42
42
|
self.__answer = answer;
|
|
43
43
|
}
|
|
44
44
|
static clone(node) {
|
|
45
|
-
return new ProblemInputNode(node.__showCharacterNumber, node.__placeholder, node.__solutions, node.__answer, node.__key);
|
|
45
|
+
return new ProblemInputNode(node.__showCharacterNumber, node.__placeholder, node.__solutions, node.__answer, node.__isCorrect, node.__key);
|
|
46
46
|
}
|
|
47
|
-
constructor(showCharacterNumber, placeholder, solutions, answer, key) {
|
|
47
|
+
constructor(showCharacterNumber, placeholder, solutions, answer, isCorrect, key) {
|
|
48
48
|
super(key);
|
|
49
49
|
this.__showCharacterNumber = showCharacterNumber;
|
|
50
50
|
this.__placeholder = placeholder;
|
|
51
51
|
this.__solutions = solutions;
|
|
52
52
|
this.__answer = answer;
|
|
53
|
+
this.__isCorrect = isCorrect;
|
|
53
54
|
}
|
|
54
55
|
createDOM(config) {
|
|
55
56
|
// Define the DOM element here
|
|
@@ -67,6 +68,7 @@ export class ProblemInputNode extends DecoratorNode {
|
|
|
67
68
|
showCharacterNumber: serializedNode.showCharacterNumber,
|
|
68
69
|
placeholder: serializedNode.placeholder,
|
|
69
70
|
answer: serializedNode.answer,
|
|
71
|
+
isCorrect: serializedNode.isCorrect,
|
|
70
72
|
});
|
|
71
73
|
return node;
|
|
72
74
|
}
|
|
@@ -77,15 +79,16 @@ export class ProblemInputNode extends DecoratorNode {
|
|
|
77
79
|
showCharacterNumber: this.__showCharacterNumber,
|
|
78
80
|
placeholder: this.__placeholder,
|
|
79
81
|
solutions: this.__solutions,
|
|
82
|
+
isCorrect: this.__isCorrect,
|
|
80
83
|
answer: this.__answer,
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
decorate() {
|
|
84
|
-
return (_jsx(InputComponent, { solutions: this.__solutions, showCharacterNumber: this.__showCharacterNumber, placeholder: this.__placeholder, answer: this.__answer, nodeKey: this.getKey() }));
|
|
87
|
+
return (_jsx(InputComponent, { solutions: this.__solutions, showCharacterNumber: this.__showCharacterNumber, placeholder: this.__placeholder, answer: this.__answer, isCorrect: this.__isCorrect, nodeKey: this.getKey() }));
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
|
-
export function $createProblemInputNode({ showCharacterNumber, placeholder, solutions, answer, key, }) {
|
|
88
|
-
return $applyNodeReplacement(new ProblemInputNode(showCharacterNumber, placeholder, solutions, answer, key));
|
|
90
|
+
export function $createProblemInputNode({ showCharacterNumber, placeholder, solutions, answer, isCorrect, key, }) {
|
|
91
|
+
return $applyNodeReplacement(new ProblemInputNode(showCharacterNumber, placeholder, solutions, answer, isCorrect, key));
|
|
89
92
|
}
|
|
90
93
|
export function $isProblemInputNode(node) {
|
|
91
94
|
return node instanceof ProblemInputNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
-
import { css } from "@emotion/react";
|
|
3
|
+
import { css, useTheme } from "@emotion/react";
|
|
4
4
|
import styled from "@emotion/styled";
|
|
5
5
|
import { InputBase } from "../../../../components/InputBase";
|
|
6
6
|
import { useRef, useState } from "react";
|
|
@@ -9,7 +9,8 @@ import { useRef, useState } from "react";
|
|
|
9
9
|
* 그리고 그 value는 split되어 segmented input에 표시됩니다.
|
|
10
10
|
*/
|
|
11
11
|
export default function SegmentedInput(props) {
|
|
12
|
-
const { readOnly, answerFormat, placeholder, value, onChange } = props;
|
|
12
|
+
const { readOnly, isCorrect, answerFormat, placeholder, value, onChange } = props;
|
|
13
|
+
const theme = useTheme();
|
|
13
14
|
// "** ***" => ["*", "*", " ", "*", "*", "*"]
|
|
14
15
|
const splitedFormat = answerFormat.split("");
|
|
15
16
|
// ["*", "*", " ", "*", "*", "*", " ", "*", "*"] => [2, 5]
|
|
@@ -58,7 +59,13 @@ export default function SegmentedInput(props) {
|
|
|
58
59
|
display: flex;
|
|
59
60
|
align-items: center;
|
|
60
61
|
gap: 4px;
|
|
61
|
-
` }, { children: despacedFormat.map((_format, i) => (_jsx(SquareInput, { leftSpaced: leftSpacedIndexs.includes(i), size: "small", color:
|
|
62
|
+
` }, { children: despacedFormat.map((_format, i) => (_jsx(SquareInput, { leftSpaced: leftSpacedIndexs.includes(i), size: "small", color: isCorrect === true
|
|
63
|
+
? "activeSuccess"
|
|
64
|
+
: isCorrect === false
|
|
65
|
+
? "activeDanger"
|
|
66
|
+
: focusedIndex === i
|
|
67
|
+
? "activePrimary"
|
|
68
|
+
: "default", inputProps: {
|
|
62
69
|
readOnly,
|
|
63
70
|
onFocus: () => {
|
|
64
71
|
var _a, _b;
|
|
@@ -68,6 +75,9 @@ export default function SegmentedInput(props) {
|
|
|
68
75
|
(_a = hiddenRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
69
76
|
(_b = hiddenRef.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(i, i);
|
|
70
77
|
},
|
|
78
|
+
color: isCorrect === false
|
|
79
|
+
? theme.color.foreground.danger
|
|
80
|
+
: undefined,
|
|
71
81
|
}, value: splitedValues[i] || "", onChange: () => { } }, i))) })), _jsx(InputMarker, {})] }), _jsx(Text, { children: placeholder })] }));
|
|
72
82
|
}
|
|
73
83
|
const Container = styled.div `
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InputProps } from "../../../../components/Input";
|
|
2
2
|
export type TextInputProps = InputProps & {
|
|
3
3
|
readOnly: boolean;
|
|
4
|
+
isCorrect?: boolean;
|
|
4
5
|
};
|
|
5
6
|
/** 읽기모드/편집모드가 가능한 input 컴포넌트 */
|
|
6
7
|
export default function TextInput(props: TextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,16 +12,33 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { useState } from "react";
|
|
14
14
|
import Input from "../../../../components/Input";
|
|
15
|
+
import { css as cssToClassName } from "@emotion/css";
|
|
16
|
+
import { useTheme } from "@emotion/react";
|
|
15
17
|
/** 읽기모드/편집모드가 가능한 input 컴포넌트 */
|
|
16
18
|
export default function TextInput(props) {
|
|
17
|
-
const { readOnly } = props,
|
|
19
|
+
const { readOnly, isCorrect } = props, inputOriginalProps = __rest(props, ["readOnly", "isCorrect"]);
|
|
18
20
|
const [focus, setFocus] = useState(false);
|
|
21
|
+
const theme = useTheme();
|
|
19
22
|
if (readOnly) {
|
|
20
|
-
return (_jsx(Input, Object.assign({},
|
|
23
|
+
return (_jsx(Input, Object.assign({}, inputOriginalProps, { color: isCorrect === true
|
|
24
|
+
? "activeSuccess"
|
|
25
|
+
: isCorrect === false
|
|
26
|
+
? "activeDanger"
|
|
27
|
+
: inputOriginalProps.color, inputProps: {
|
|
21
28
|
readOnly: true,
|
|
29
|
+
className: isCorrect === false
|
|
30
|
+
? cssToClassName `
|
|
31
|
+
color: ${theme.color.foreground.danger};
|
|
32
|
+
&::placeholder {
|
|
33
|
+
// inputComponent의 placeholder 스타일을 덮어쓰기 위해 부득이하게 !important 사용
|
|
34
|
+
// TODO: static classname을 사용하여 !important 제거
|
|
35
|
+
color: ${theme.color.foreground.dangerDisabled} !important;
|
|
36
|
+
}
|
|
37
|
+
`
|
|
38
|
+
: undefined,
|
|
22
39
|
} })));
|
|
23
40
|
}
|
|
24
|
-
return (_jsx(Input, Object.assign({},
|
|
41
|
+
return (_jsx(Input, Object.assign({}, inputOriginalProps, { color: focus ? "activePrimary" : inputOriginalProps.color, inputProps: {
|
|
25
42
|
onFocus: () => setFocus(true),
|
|
26
43
|
onBlur: () => setFocus(false),
|
|
27
44
|
} })));
|
package/dist/patterns/LexicalEditor/nodes/ProblemSelectNode/SelectBox/SelectBoxComponent.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ImageProps } from "../ProblemSelectNode";
|
|
3
|
+
export type SelectBoxType = "primary" | "success" | "danger";
|
|
3
4
|
/** 비지니스 로직과 무관한 SelectBox를 그리는 공통 컴포넌트입니다. */
|
|
4
5
|
export declare function SelectBoxComponent(props: {
|
|
5
6
|
className?: string;
|
|
6
7
|
indexClassName?: string;
|
|
7
8
|
contentClassName?: string;
|
|
9
|
+
/** SelectBox의 스타일 타입. 전달하지 않으면 기본 스타일이 적용됩니다. */
|
|
10
|
+
type?: SelectBoxType;
|
|
8
11
|
/** 문제 번호 박스 내부를 그립니다. */
|
|
9
12
|
index: React.ReactNode;
|
|
10
13
|
image?: ImageProps | null;
|
|
@@ -1,11 +1,46 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
-
import { css } from "@emotion/react";
|
|
3
|
+
import { css, useTheme } from "@emotion/react";
|
|
4
4
|
import styled from "@emotion/styled";
|
|
5
|
+
const TYPE_TO_CONTAINER_STYLE = (theme, type) => ({
|
|
6
|
+
primary: css `
|
|
7
|
+
background: ${theme.color.container.primaryContainer};
|
|
8
|
+
border: 1px solid ${theme.color.foreground.primary};
|
|
9
|
+
color: ${theme.color.container.primaryOnContainer};
|
|
10
|
+
`,
|
|
11
|
+
success: css `
|
|
12
|
+
background: ${theme.color.container.successContainer};
|
|
13
|
+
border: 1px solid ${theme.color.background.successActive};
|
|
14
|
+
color: ${theme.color.container.successOnContainer};
|
|
15
|
+
`,
|
|
16
|
+
danger: css `
|
|
17
|
+
background: ${theme.color.container.dangerContainer};
|
|
18
|
+
border: 1px solid ${theme.color.background.dangerActive};
|
|
19
|
+
color: ${theme.color.container.dangerOnContainer};
|
|
20
|
+
`,
|
|
21
|
+
})[type];
|
|
22
|
+
const TYPE_TO_INDEX_STYLE = (theme, type) => ({
|
|
23
|
+
primary: css `
|
|
24
|
+
background: ${theme.color.background.primary};
|
|
25
|
+
border: 1px solid ${theme.color.background.primary};
|
|
26
|
+
color: ${theme.color.foreground.neutralAlt};
|
|
27
|
+
`,
|
|
28
|
+
success: css `
|
|
29
|
+
background: ${theme.color.background.successActive};
|
|
30
|
+
border: 1px solid ${theme.color.background.successActive};
|
|
31
|
+
color: ${theme.color.foreground.neutralAlt};
|
|
32
|
+
`,
|
|
33
|
+
danger: css `
|
|
34
|
+
background: ${theme.color.background.dangerActive};
|
|
35
|
+
border: 1px solid ${theme.color.background.dangerActive};
|
|
36
|
+
color: ${theme.color.foreground.neutralAlt};
|
|
37
|
+
`,
|
|
38
|
+
})[type];
|
|
5
39
|
/** 비지니스 로직과 무관한 SelectBox를 그리는 공통 컴포넌트입니다. */
|
|
6
40
|
export function SelectBoxComponent(props) {
|
|
7
|
-
const { className, indexClassName, contentClassName, index, image, text, endIcon, onClick, } = props;
|
|
8
|
-
|
|
41
|
+
const { className, indexClassName, contentClassName, type, index, image, text, endIcon, onClick, } = props;
|
|
42
|
+
const theme = useTheme();
|
|
43
|
+
return (_jsxs(Container, Object.assign({ className: className, css: type ? TYPE_TO_CONTAINER_STYLE(theme, type) : undefined, onClick: onClick }, { children: [_jsx(Index, Object.assign({ className: indexClassName, css: type ? TYPE_TO_INDEX_STYLE(theme, type) : undefined }, { children: index })), _jsxs(Content, Object.assign({ className: contentClassName }, { children: [image && (_jsx("img", { src: image.src, alt: image.altText, css: css `
|
|
9
44
|
height: auto;
|
|
10
45
|
// 이미지로 인해 좌우로 스크롤이 생기는 것을 방지
|
|
11
46
|
max-width: 100%;
|
|
@@ -1,97 +1,35 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
-
import { css
|
|
4
|
-
import { css as cssToClassName } from "@emotion/css";
|
|
3
|
+
import { css } from "@emotion/react";
|
|
5
4
|
import { CheckboxCircleFillIcon, CheckFillIcon, CloseCircleFillIcon, } from "../../../../../icons";
|
|
6
5
|
import { SelectBoxComponent } from "./SelectBoxComponent";
|
|
7
6
|
import Tag from "../../../../../components/Tag";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
// 선택 박스
|
|
11
|
-
if (isAnswer === undefined) {
|
|
12
|
-
return css `
|
|
13
|
-
background: ${theme.color.container.primaryContainer};
|
|
14
|
-
border: 1px solid ${theme.color.foreground.primary};
|
|
15
|
-
color: ${theme.color.container.primaryOnContainer};
|
|
16
|
-
`;
|
|
17
|
-
}
|
|
18
|
-
// 정답 박스
|
|
19
|
-
if (isAnswer) {
|
|
20
|
-
return css `
|
|
21
|
-
background: ${theme.color.container.successContainer};
|
|
22
|
-
border: 1px solid ${theme.color.background.successActive};
|
|
23
|
-
color: ${theme.color.container.successOnContainer};
|
|
24
|
-
`;
|
|
25
|
-
}
|
|
26
|
-
// 오답 박스
|
|
27
|
-
return css `
|
|
28
|
-
background: ${theme.color.container.dangerContainer};
|
|
29
|
-
border: 1px solid ${theme.color.background.dangerActive};
|
|
30
|
-
color: ${theme.color.container.dangerOnContainer};
|
|
31
|
-
`;
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
};
|
|
35
|
-
const getIndexClassName = (theme, isSelected, isAnswer) => {
|
|
36
|
-
if (isSelected) {
|
|
37
|
-
// 선택 박스
|
|
38
|
-
if (isAnswer === undefined) {
|
|
39
|
-
return cssToClassName `
|
|
40
|
-
background: ${theme.color.background.primary};
|
|
41
|
-
border: 1px solid ${theme.color.background.primary};
|
|
42
|
-
color: ${theme.color.foreground.neutralAlt};
|
|
43
|
-
`;
|
|
44
|
-
}
|
|
45
|
-
// 정답 박스
|
|
46
|
-
if (isAnswer) {
|
|
47
|
-
return cssToClassName `
|
|
48
|
-
background: ${theme.color.background.successActive};
|
|
49
|
-
border: 1px solid ${theme.color.background.successActive};
|
|
50
|
-
color: ${theme.color.foreground.neutralAlt};
|
|
51
|
-
`;
|
|
52
|
-
}
|
|
53
|
-
// 오답 박스
|
|
54
|
-
return cssToClassName `
|
|
55
|
-
background: ${theme.color.background.dangerActive};
|
|
56
|
-
border: 1px solid ${theme.color.background.dangerActive};
|
|
57
|
-
color: ${theme.color.foreground.neutralAlt};
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
return undefined;
|
|
61
|
-
};
|
|
62
|
-
const getIndexComponent = (index, isSelected, isAnswer) => {
|
|
63
|
-
if (isSelected) {
|
|
64
|
-
// 선택 박스
|
|
65
|
-
if (isAnswer === undefined) {
|
|
66
|
-
return (_jsx(CheckFillIcon, { css: css `
|
|
67
|
-
width: 12px;
|
|
68
|
-
height: 12px;
|
|
69
|
-
` }));
|
|
70
|
-
}
|
|
71
|
-
// 정답 박스
|
|
72
|
-
if (isAnswer) {
|
|
73
|
-
return (_jsx(CheckboxCircleFillIcon, { css: css `
|
|
74
|
-
width: 12px;
|
|
75
|
-
height: 12px;
|
|
76
|
-
` }));
|
|
77
|
-
}
|
|
78
|
-
// 오답 박스
|
|
79
|
-
return (_jsx(CloseCircleFillIcon, { css: css `
|
|
7
|
+
const TYPE_TO_INDEX_ICON = (type) => ({
|
|
8
|
+
primary: (_jsx(CheckFillIcon, { css: css `
|
|
80
9
|
width: 12px;
|
|
81
10
|
height: 12px;
|
|
82
|
-
` }))
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
11
|
+
` })),
|
|
12
|
+
success: (_jsx(CheckboxCircleFillIcon, { css: css `
|
|
13
|
+
width: 12px;
|
|
14
|
+
height: 12px;
|
|
15
|
+
` })),
|
|
16
|
+
danger: (_jsx(CloseCircleFillIcon, { css: css `
|
|
17
|
+
width: 12px;
|
|
18
|
+
height: 12px;
|
|
19
|
+
` })),
|
|
20
|
+
})[type];
|
|
86
21
|
export function SelectBoxView(props) {
|
|
87
22
|
const { index, isSelected, isAnswer, image, text, onClick } = props;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
23
|
+
const selectBoxType = isSelected
|
|
24
|
+
? isAnswer === undefined
|
|
25
|
+
? "primary"
|
|
26
|
+
: isAnswer
|
|
27
|
+
? "success"
|
|
28
|
+
: "danger"
|
|
29
|
+
: undefined;
|
|
30
|
+
return (_jsx(SelectBoxComponent, { css: css `
|
|
31
|
+
width: 100%;
|
|
32
|
+
`, type: selectBoxType, index: selectBoxType ? TYPE_TO_INDEX_ICON(selectBoxType) : index, image: image, text: text,
|
|
95
33
|
// isAnswer가 존재하면 채점 후의 상태이므로 unclickable을 위해 onClick을 전달하지 않음
|
|
96
34
|
onClick: isAnswer === undefined ? onClick : undefined,
|
|
97
35
|
// 선택되지 않았으나 정답일 때 정답 태그를 표시
|