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

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 ? (
<>
<Typography
sx={{
color: theme.palette.grey[800],
fontSize: "14px",
position: "absolute",
top: "-23px",
}}
>
Введите свой ответ
</Typography>
<OwnInput <OwnInput
questionId={questionId} questionId={questionId}
variant={variant} variant={variant}
largeCheck={questionLargeCheck} largeCheck={questionLargeCheck}
ownPlaceholder={ownPlaceholder} 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,6 +115,83 @@ export const VarimgVariant = ({
} }
}; };
if (variant?.isOwn) {
return (
<Box>
<Typography
sx={{
color: theme.palette.grey[800],
fontSize: "14px",
pl: "15px",
}}
>
Введите свой ответ
</Typography>
<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 />}
/>
}
/>
</Box>
);
} else {
return ( return (
<FormControlLabel <FormControlLabel
key={variant.id} key={variant.id}
@ -167,4 +255,5 @@ export const VarimgVariant = ({
} }
/> />
); );
}
}; };