пометки ввести свой ответ

This commit is contained in:
Nastya 2024-09-26 22:51:46 +03:00
parent b0d28dad6a
commit 584db3eec2
4 changed files with 201 additions and 79 deletions

@ -66,6 +66,7 @@ const OwnInput = ({ questionId, variant, largeCheck, ownPlaceholder }: OwnInputP
backgroundColor: theme.palette.primary.main, backgroundColor: theme.palette.primary.main,
}, },
scrollbarColor: theme.palette.primary.main, scrollbarColor: theme.palette.primary.main,
overflow: "auto",
}} }}
value={ownAnswer} value={ownAnswer}
onClick={(e: React.MouseEvent<HTMLTextAreaElement>) => e.stopPropagation()} onClick={(e: React.MouseEvent<HTMLTextAreaElement>) => e.stopPropagation()}
@ -171,6 +172,17 @@ export const EmojiVariant = ({
{variant.extendedText && <Typography fontSize="100px">{variant.extendedText}</Typography>} {variant.extendedText && <Typography fontSize="100px">{variant.extendedText}</Typography>}
</Box> </Box>
</Box> </Box>
{own && (
<Typography
sx={{
color: theme.palette.grey[800],
fontSize: "14px",
pl: "15px",
}}
>
Введите свой ответ
</Typography>
)}
<FormControlLabel <FormControlLabel
key={variant.id} key={variant.id}
sx={{ sx={{
@ -188,9 +200,7 @@ export const EmojiVariant = ({
wordBreak: "break-word", wordBreak: "break-word",
height: variant.answer.length <= 60 ? undefined : "60px", height: variant.answer.length <= 60 ? undefined : "60px",
overflow: "auto", overflow: "auto",
"&::-webkit-scrollbar": { "&::-webkit-scrollbar": { width: "4px" },
width: "4px",
},
"&::-webkit-scrollbar-thumb": { "&::-webkit-scrollbar-thumb": {
backgroundColor: theme.palette.primary.main, backgroundColor: theme.palette.primary.main,
}, },

@ -1,7 +1,7 @@
import { CheckboxIcon } from "@/assets/icons/Checkbox"; import { CheckboxIcon } from "@/assets/icons/Checkbox";
import type { QuestionVariant } from "@/model/questionTypes/shared"; import type { QuestionVariant } from "@/model/questionTypes/shared";
import { useQuizSettings } from "@contexts/QuizDataContext"; import { useQuizSettings } from "@contexts/QuizDataContext";
import { Box, Checkbox, FormControlLabel, Input, Radio, TextareaAutosize, useTheme } from "@mui/material"; import { Box, Checkbox, FormControlLabel, Input, Radio, TextareaAutosize, Typography, useTheme } from "@mui/material";
import { useQuizViewStore } from "@stores/quizView"; import { useQuizViewStore } from "@stores/quizView";
import RadioCheck from "@ui_kit/RadioCheck"; import RadioCheck from "@ui_kit/RadioCheck";
import RadioIcon from "@ui_kit/RadioIcon"; import RadioIcon from "@ui_kit/RadioIcon";
@ -120,6 +120,7 @@ export const ImageVariant = ({
return ( return (
<Box <Box
sx={{ sx={{
position: "relative",
cursor: "pointer", cursor: "pointer",
borderRadius: "12px", borderRadius: "12px",
border: `1px solid`, border: `1px solid`,
@ -151,6 +152,17 @@ export const ImageVariant = ({
)} )}
</Box> </Box>
</Box> </Box>
{own && (
<Typography
sx={{
color: theme.palette.grey[800],
fontSize: "14px",
pl: "15px",
}}
>
Введите свой ответ
</Typography>
)}
<FormControlLabel <FormControlLabel
key={variant.id} key={variant.id}
sx={{ sx={{

@ -9,6 +9,7 @@ import {
Radio, Radio,
TextFieldProps, TextFieldProps,
TextareaAutosize, TextareaAutosize,
Typography,
useTheme, useTheme,
} from "@mui/material"; } from "@mui/material";
import { useQuizViewStore } from "@stores/quizView"; import { useQuizViewStore } from "@stores/quizView";
@ -128,7 +129,9 @@ export const VariantItem = ({
<FormControlLabel <FormControlLabel
key={variant.id} key={variant.id}
sx={{ sx={{
position: "relative",
margin: "0", margin: "0",
mt: own ? "10px" : "0",
borderRadius: "12px", borderRadius: "12px",
color: theme.palette.text.primary, color: theme.palette.text.primary,
padding: "15px", padding: "15px",
@ -155,12 +158,8 @@ export const VariantItem = ({
height: variant.answer.length <= 60 ? undefined : "60px", height: variant.answer.length <= 60 ? undefined : "60px",
overflow: "auto", overflow: "auto",
lineHeight: "normal", lineHeight: "normal",
"&::-webkit-scrollbar": { "&::-webkit-scrollbar": { width: "4px" },
width: "4px", "&::-webkit-scrollbar-thumb": { backgroundColor: theme.palette.primary.main },
},
"&::-webkit-scrollbar-thumb": {
backgroundColor: theme.palette.primary.main,
},
scrollbarColor: theme.palette.primary.main, scrollbarColor: theme.palette.primary.main,
}, },
"& .MuiFormControlLabel-label.Mui-disabled": { "& .MuiFormControlLabel-label.Mui-disabled": {
@ -185,12 +184,24 @@ export const VariantItem = ({
} }
label={ label={
own ? ( own ? (
<OwnInput <>
questionId={questionId} <Typography
variant={variant} sx={{
largeCheck={questionLargeCheck} color: theme.palette.grey[800],
ownPlaceholder={ownPlaceholder} fontSize: "14px",
/> position: "absolute",
top: "-23px",
}}
>
Введите свой ответ
</Typography>
<OwnInput
questionId={questionId}
variant={variant}
largeCheck={questionLargeCheck}
ownPlaceholder={ownPlaceholder}
/>
</>
) : ( ) : (
variant.answer variant.answer
) )

@ -1,6 +1,16 @@
import type { QuestionVariant } from "@/model/questionTypes/shared"; import type { QuestionVariant } from "@/model/questionTypes/shared";
import { useQuizSettings } from "@contexts/QuizDataContext"; import { useQuizSettings } from "@contexts/QuizDataContext";
import { FormControlLabel, TextareaAutosize, Radio, useTheme, Box, Input } from "@mui/material"; import {
FormControlLabel,
TextareaAutosize,
Radio,
useTheme,
Box,
Input,
FormControl,
InputLabel,
Typography,
} from "@mui/material";
import { useQuizViewStore } from "@stores/quizView"; import { useQuizViewStore } from "@stores/quizView";
import RadioCheck from "@ui_kit/RadioCheck"; import RadioCheck from "@ui_kit/RadioCheck";
import RadioIcon from "@ui_kit/RadioIcon"; import RadioIcon from "@ui_kit/RadioIcon";
@ -54,6 +64,7 @@ const OwnInput = ({ questionId, variant, largeCheck, ownPlaceholder }: OwnInputP
}, },
scrollbarColor: theme.palette.primary.main, scrollbarColor: theme.palette.primary.main,
maxHeight: "44px", maxHeight: "44px",
overflow: "auto",
}} }}
value={ownAnswer} value={ownAnswer}
onClick={(e: React.MouseEvent<HTMLTextAreaElement>) => e.stopPropagation()} onClick={(e: React.MouseEvent<HTMLTextAreaElement>) => e.stopPropagation()}
@ -104,67 +115,145 @@ export const VarimgVariant = ({
} }
}; };
return ( if (variant?.isOwn) {
<FormControlLabel return (
key={variant.id} <Box>
disabled={isSending} <Typography
sx={{ sx={{
marginBottom: "15px", color: theme.palette.grey[800],
borderRadius: "12px", fontSize: "14px",
padding: "20px", pl: "15px",
color: theme.palette.text.primary, }}
backgroundColor: settings.cfg.design >
? quizThemes[settings.cfg.theme].isLight Введите свой ответ
? "#FFFFFF" </Typography>
: "rgba(255,255,255, 0.3)"
: quizThemes[settings.cfg.theme].isLight <FormControlLabel
? "white" key={variant.id}
: theme.palette.background.default, disabled={isSending}
border: `1px solid`, sx={{
borderColor: answer === variant.id ? theme.palette.primary.main : "#9A9AAF", marginBottom: "15px",
display: "flex", borderRadius: "12px",
margin: 0, padding: "20px",
justifyContent: "space-between", color: theme.palette.text.primary,
"&:hover": { borderColor: theme.palette.primary.main }, backgroundColor: settings.cfg.design
"& .MuiFormControlLabel-label": { ? quizThemes[settings.cfg.theme].isLight
wordBreak: "break-word", ? "#FFFFFF"
height: variant.answer.length <= 60 ? undefined : "60px", : "rgba(255,255,255, 0.3)"
overflow: "auto", : quizThemes[settings.cfg.theme].isLight
lineHeight: "normal", ? "white"
width: "100%", : theme.palette.background.default,
"&::-webkit-scrollbar": { border: `1px solid`,
width: "4px", borderColor: answer === variant.id ? theme.palette.primary.main : "#9A9AAF",
}, display: "flex",
"&::-webkit-scrollbar-thumb": { margin: 0,
backgroundColor: theme.palette.primary.main, justifyContent: "space-between",
}, "&:hover": { borderColor: theme.palette.primary.main },
scrollbarColor: theme.palette.primary.main, "& .MuiFormControlLabel-label": {
}, wordBreak: "break-word",
"& .MuiFormControlLabel-label.Mui-disabled": { height: variant.answer.length <= 60 ? undefined : "60px",
color: theme.palette.text.primary, overflow: "auto",
}, lineHeight: "normal",
}} width: "100%",
labelPlacement="start" "&::-webkit-scrollbar": {
value={index} width: "4px",
onClick={sendVariant} },
label={ "&::-webkit-scrollbar-thumb": {
variant?.isOwn ? ( backgroundColor: theme.palette.primary.main,
<OwnInput },
questionId={questionId} scrollbarColor: theme.palette.primary.main,
variant={variant} },
largeCheck={questionLargeCheck} "& .MuiFormControlLabel-label.Mui-disabled": {
ownPlaceholder={ownPlaceholder} color: theme.palette.text.primary,
/> },
) : ( }}
variant.answer labelPlacement="start"
) value={index}
} onClick={sendVariant}
control={ label={
<Radio variant?.isOwn ? (
checkedIcon={<RadioCheck color={theme.palette.primary.main} />} <OwnInput
icon={<RadioIcon />} questionId={questionId}
variant={variant}
largeCheck={questionLargeCheck}
ownPlaceholder={ownPlaceholder}
/>
) : (
variant.answer
)
}
control={
<Radio
checkedIcon={<RadioCheck color={theme.palette.primary.main} />}
icon={<RadioIcon />}
/>
}
/> />
} </Box>
/> );
); } else {
return (
<FormControlLabel
key={variant.id}
disabled={isSending}
sx={{
marginBottom: "15px",
borderRadius: "12px",
padding: "20px",
color: theme.palette.text.primary,
backgroundColor: settings.cfg.design
? quizThemes[settings.cfg.theme].isLight
? "#FFFFFF"
: "rgba(255,255,255, 0.3)"
: quizThemes[settings.cfg.theme].isLight
? "white"
: theme.palette.background.default,
border: `1px solid`,
borderColor: answer === variant.id ? theme.palette.primary.main : "#9A9AAF",
display: "flex",
margin: 0,
justifyContent: "space-between",
"&:hover": { borderColor: theme.palette.primary.main },
"& .MuiFormControlLabel-label": {
wordBreak: "break-word",
height: variant.answer.length <= 60 ? undefined : "60px",
overflow: "auto",
lineHeight: "normal",
width: "100%",
"&::-webkit-scrollbar": {
width: "4px",
},
"&::-webkit-scrollbar-thumb": {
backgroundColor: theme.palette.primary.main,
},
scrollbarColor: theme.palette.primary.main,
},
"& .MuiFormControlLabel-label.Mui-disabled": {
color: theme.palette.text.primary,
},
}}
labelPlacement="start"
value={index}
onClick={sendVariant}
label={
variant?.isOwn ? (
<OwnInput
questionId={questionId}
variant={variant}
largeCheck={questionLargeCheck}
ownPlaceholder={ownPlaceholder}
/>
) : (
variant.answer
)
}
control={
<Radio
checkedIcon={<RadioCheck color={theme.palette.primary.main} />}
icon={<RadioIcon />}
/>
}
/>
);
}
}; };