предпросмотр и публикация слайдер и рейтинг
This commit is contained in:
parent
6482598841
commit
cdf6b813ac
36
src/assets/icons/CloseBold.tsx
Normal file
36
src/assets/icons/CloseBold.tsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { useTheme } from "@mui/material";
|
||||||
|
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
width?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CloseBold({ width }: Props) {
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<svg width="35" height="33" viewBox="0 0 35 33" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g id="Close">
|
||||||
|
<g id="Rectangle 57" opacity="0.3" filter="url(#filter0_d_4080_12482)">
|
||||||
|
<rect x="6" y="4" width="24" height="24" rx="12" fill="#9A9AAF"/>
|
||||||
|
</g>
|
||||||
|
<g id="Group 331">
|
||||||
|
<path id="Vector 586" d="M22.8516 10.9517L12.9521 20.8512" stroke="#FDFDFF" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
<path id="Vector 587" d="M22.8516 20.8462L12.9521 10.9467" stroke="#FDFDFF" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<filter id="filter0_d_4080_12482" x="0" y="0" width="36" height="36" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||||
|
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||||
|
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||||
|
<feMorphology radius="1" operator="dilate" in="SourceAlpha" result="effect1_dropShadow_4080_12482"/>
|
||||||
|
<feOffset dy="2"/>
|
||||||
|
<feGaussianBlur stdDeviation="2.5"/>
|
||||||
|
<feComposite in2="hardAlpha" operator="out"/>
|
||||||
|
<feColorMatrix type="matrix" values="0 0 0 0 0.416562 0 0 0 0 0.452406 0 0 0 0 0.775 0 0 0 0.18 0"/>
|
||||||
|
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4080_12482"/>
|
||||||
|
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_4080_12482" result="shape"/>
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
)}
|
||||||
@ -12,7 +12,7 @@ export default function StarIconMini({ color, width = 30, sx }: Props) {
|
|||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
height: "30px",
|
height: "50px",
|
||||||
width: width + "px",
|
width: width + "px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
@ -20,7 +20,7 @@ export default function StarIconMini({ color, width = 30, sx }: Props) {
|
|||||||
...sx,
|
...sx,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svg width="28" height="27" viewBox="0 0 28 27" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width={width} height={width} viewBox="0 0 28 27" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path
|
<path
|
||||||
d="M14.551 21.8375L20.851 25.8375C21.6635 26.35 22.6635 25.5875 22.426 24.65L20.601 17.475C20.5516 17.2762 20.5595 17.0674 20.6236 16.8728C20.6877 16.6781 20.8056 16.5056 20.9635 16.375L26.6135 11.6625C27.351 11.05 26.976 9.81253 26.0135 9.75003L18.6385 9.27503C18.4372 9.26332 18.2438 9.19325 18.0817 9.07338C17.9197 8.95351 17.7961 8.78902 17.726 8.60003L14.976 1.67503C14.9032 1.47491 14.7706 1.30204 14.5961 1.17988C14.4217 1.05772 14.2139 0.992188 14.001 0.992188C13.788 0.992188 13.5802 1.05772 13.4058 1.17988C13.2314 1.30204 13.0988 1.47491 13.026 1.67503L10.276 8.60003C10.2059 8.78902 10.0823 8.95351 9.92021 9.07338C9.75816 9.19325 9.5647 9.26332 9.36347 9.27503L1.98847 9.75003C1.02597 9.81253 0.650971 11.05 1.38847 11.6625L7.03847 16.375C7.19639 16.5056 7.3142 16.6781 7.37834 16.8728C7.44247 17.0674 7.45032 17.2762 7.40097 17.475L5.71347 24.125C5.42597 25.25 6.62597 26.1625 7.58847 25.55L13.451 21.8375C13.6154 21.733 13.8062 21.6775 14.001 21.6775C14.1958 21.6775 14.3866 21.733 14.551 21.8375Z"
|
d="M14.551 21.8375L20.851 25.8375C21.6635 26.35 22.6635 25.5875 22.426 24.65L20.601 17.475C20.5516 17.2762 20.5595 17.0674 20.6236 16.8728C20.6877 16.6781 20.8056 16.5056 20.9635 16.375L26.6135 11.6625C27.351 11.05 26.976 9.81253 26.0135 9.75003L18.6385 9.27503C18.4372 9.26332 18.2438 9.19325 18.0817 9.07338C17.9197 8.95351 17.7961 8.78902 17.726 8.60003L14.976 1.67503C14.9032 1.47491 14.7706 1.30204 14.5961 1.17988C14.4217 1.05772 14.2139 0.992188 14.001 0.992188C13.788 0.992188 13.5802 1.05772 13.4058 1.17988C13.2314 1.30204 13.0988 1.47491 13.026 1.67503L10.276 8.60003C10.2059 8.78902 10.0823 8.95351 9.92021 9.07338C9.75816 9.19325 9.5647 9.26332 9.36347 9.27503L1.98847 9.75003C1.02597 9.81253 0.650971 11.05 1.38847 11.6625L7.03847 16.375C7.19639 16.5056 7.3142 16.6781 7.37834 16.8728C7.44247 17.0674 7.45032 17.2762 7.40097 17.475L5.71347 24.125C5.42597 25.25 6.62597 26.1625 7.58847 25.55L13.451 21.8375C13.6154 21.733 13.8062 21.6775 14.001 21.6775C14.1958 21.6775 14.3866 21.733 14.551 21.8375Z"
|
||||||
fill={color}
|
fill={color}
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
import { Box, Typography, ButtonBase } from "@mui/material";
|
import {Box, Typography, ButtonBase, useTheme, IconButton} from "@mui/material";
|
||||||
|
|
||||||
import UploadBox from "@ui_kit/UploadBox";
|
|
||||||
|
|
||||||
import { useQuizViewStore, updateAnswer } from "@root/quizView";
|
import { useQuizViewStore, updateAnswer } from "@root/quizView";
|
||||||
import { UPLOAD_FILE_TYPES_MAP } from "@ui_kit/QuizPreview/QuizPreviewQuestionTypes/File";
|
import { UPLOAD_FILE_TYPES_MAP } from "@ui_kit/QuizPreview/QuizPreviewQuestionTypes/File";
|
||||||
|
|
||||||
import UploadIcon from "@icons/UploadIcon";
|
import UploadIcon from "@icons/UploadIcon";
|
||||||
|
import X from "@icons/CloseBold";
|
||||||
import type { ChangeEvent } from "react";
|
import type { ChangeEvent } from "react";
|
||||||
import type { QuizQuestionFile } from "../../../model/questionTypes/file";
|
import type { QuizQuestionFile } from "../../../model/questionTypes/file";
|
||||||
|
import {DragEvent} from "react";
|
||||||
|
|
||||||
type FileProps = {
|
type FileProps = {
|
||||||
currentQuestion: QuizQuestionFile;
|
currentQuestion: QuizQuestionFile;
|
||||||
@ -17,7 +15,7 @@ type FileProps = {
|
|||||||
export const File = ({ currentQuestion }: FileProps) => {
|
export const File = ({ currentQuestion }: FileProps) => {
|
||||||
const { answers } = useQuizViewStore();
|
const { answers } = useQuizViewStore();
|
||||||
const { answer } = answers.find(({ questionId }) => questionId === currentQuestion.content.id) ?? {};
|
const { answer } = answers.find(({ questionId }) => questionId === currentQuestion.content.id) ?? {};
|
||||||
|
const theme = useTheme();
|
||||||
const uploadFile = ({ target }: ChangeEvent<HTMLInputElement>) => {
|
const uploadFile = ({ target }: ChangeEvent<HTMLInputElement>) => {
|
||||||
const file = target.files?.[0];
|
const file = target.files?.[0];
|
||||||
|
|
||||||
@ -35,8 +33,34 @@ export const File = ({ currentQuestion }: FileProps) => {
|
|||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
marginTop: "20px",
|
marginTop: "20px",
|
||||||
|
maxWidth: answer?.split("|")[0] ? "640px" : "550px"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{answer?.split("|")[0] && (
|
||||||
|
<Box sx={{display: "flex", alignItems: "center", gap: "15px"}}>
|
||||||
|
<Typography>Вы загрузили:</Typography>
|
||||||
|
<Box sx={{padding: "5px 5px 5px 16px", backgroundColor: theme.palette.brightPurple.main,
|
||||||
|
borderRadius: "8px",
|
||||||
|
color: "#FFFFFF",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: "15px"
|
||||||
|
}}>
|
||||||
|
<Typography>
|
||||||
|
{answer?.split("|")[0]}
|
||||||
|
</Typography>
|
||||||
|
<IconButton
|
||||||
|
sx={{p: 0}}
|
||||||
|
onClick={() => {updateAnswer(currentQuestion.content.id, "");}}
|
||||||
|
>
|
||||||
|
<X/>
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
)}
|
||||||
|
{!answer?.split("|")[0] && (
|
||||||
<ButtonBase component="label" sx={{ justifyContent: "flex-start" }}>
|
<ButtonBase component="label" sx={{ justifyContent: "flex-start" }}>
|
||||||
<input
|
<input
|
||||||
onChange={uploadFile}
|
onChange={uploadFile}
|
||||||
@ -45,12 +69,41 @@ export const File = ({ currentQuestion }: FileProps) => {
|
|||||||
multiple
|
multiple
|
||||||
type="file"
|
type="file"
|
||||||
/>
|
/>
|
||||||
<UploadBox icon={<UploadIcon />} text="5 MB максимум" />
|
<Box
|
||||||
</ButtonBase>
|
onDragOver={(event: DragEvent<HTMLDivElement>) => event.preventDefault()}
|
||||||
{answer?.split("|")[0] && (
|
sx={{
|
||||||
<Typography sx={{ marginTop: "15px" }}>
|
width: "100%",
|
||||||
{answer?.split("|")[0]}
|
height: "120px",
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
|
padding: "33px 44px 33px 55px",
|
||||||
|
backgroundColor: theme.palette.background.default,
|
||||||
|
border: `1px solid ${theme.palette.grey2.main}`,
|
||||||
|
borderRadius: "8px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<UploadIcon />
|
||||||
|
<Box>
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.grey2.main,
|
||||||
|
fontWeight: 500
|
||||||
|
}}
|
||||||
|
>Добавить видео</Typography>
|
||||||
|
<Typography
|
||||||
|
sx={{
|
||||||
|
color: theme.palette.grey2.main,
|
||||||
|
fontSize: "16px",
|
||||||
|
lineHeight: "19px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Принимает .mp4 и .mov формат — максимум 100мб
|
||||||
</Typography>
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
</Box>
|
||||||
|
</ButtonBase>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import CustomTextField from "@ui_kit/CustomTextField";
|
|||||||
import { useQuizViewStore, updateAnswer } from "@root/quizView";
|
import { useQuizViewStore, updateAnswer } from "@root/quizView";
|
||||||
|
|
||||||
import type { QuizQuestionNumber } from "../../../model/questionTypes/number";
|
import type { QuizQuestionNumber } from "../../../model/questionTypes/number";
|
||||||
|
import {CustomSlider} from "@ui_kit/CustomSlider";
|
||||||
|
|
||||||
type NumberProps = {
|
type NumberProps = {
|
||||||
currentQuestion: QuizQuestionNumber;
|
currentQuestion: QuizQuestionNumber;
|
||||||
@ -74,10 +75,11 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
|||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
marginTop: "20px",
|
marginTop: "20px",
|
||||||
|
gap: "30px"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Slider
|
<CustomSlider
|
||||||
value={
|
value={
|
||||||
currentQuestion.content.chooseRange
|
currentQuestion.content.chooseRange
|
||||||
? answer?.split("—").length || 0 > 1
|
? answer?.split("—").length || 0 > 1
|
||||||
@ -88,36 +90,6 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
|||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
step={currentQuestion.content.step || 1}
|
step={currentQuestion.content.step || 1}
|
||||||
sx={{
|
|
||||||
color: theme.palette.brightPurple.main,
|
|
||||||
padding: "0",
|
|
||||||
marginTop: "75px",
|
|
||||||
"& .MuiSlider-valueLabel":{
|
|
||||||
background: theme.palette.brightPurple.main,
|
|
||||||
borderRadius: "8px",
|
|
||||||
width: "60px",
|
|
||||||
height: "36px"
|
|
||||||
},
|
|
||||||
"& .MuiSlider-valueLabel::before": {
|
|
||||||
width: "6px",
|
|
||||||
height: "2px",
|
|
||||||
transform: "translate(-50%, 50%) rotate(90deg)",
|
|
||||||
bottom: "-5px"
|
|
||||||
},
|
|
||||||
"& .MuiSlider-rail": {
|
|
||||||
backgroundColor: "#F2F3F7",
|
|
||||||
border: `1px solid #9A9AAF`,
|
|
||||||
height: "12px"
|
|
||||||
},
|
|
||||||
"& .MuiSlider-thumb": {
|
|
||||||
border: "3px #f2f3f7 solid",
|
|
||||||
height: "23px",
|
|
||||||
width: "23px"
|
|
||||||
},
|
|
||||||
"& .MuiSlider-track": {
|
|
||||||
height: "12px"
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onChange={(_, value) => {
|
onChange={(_, value) => {
|
||||||
const range = String(value).replace(",", "—");
|
const range = String(value).replace(",", "—");
|
||||||
updateAnswer(currentQuestion.content.id, range);
|
updateAnswer(currentQuestion.content.id, range);
|
||||||
@ -158,6 +130,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
|||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
gap: "15px",
|
gap: "15px",
|
||||||
|
alignItems: "center",
|
||||||
"& .MuiFormControl-root": { width: "auto" },
|
"& .MuiFormControl-root": { width: "auto" },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -180,9 +153,9 @@ export const Number = ({ currentQuestion }: NumberProps) => {
|
|||||||
"& .MuiInputBase-input": { textAlign: "center" },
|
"& .MuiInputBase-input": { textAlign: "center" },
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Typography>
|
||||||
до
|
до
|
||||||
|
</Typography>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
value={maxRange}
|
value={maxRange}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ export const Rating = ({ currentQuestion }: RatingProps) => {
|
|||||||
onChange={(_, value) =>
|
onChange={(_, value) =>
|
||||||
updateAnswer(currentQuestion.content.id, String(value))
|
updateAnswer(currentQuestion.content.id, String(value))
|
||||||
}
|
}
|
||||||
sx={{ height: "50px" }}
|
sx={{ height: "50px", gap: "15px" }}
|
||||||
max={currentQuestion.content.steps}
|
max={currentQuestion.content.steps}
|
||||||
icon={
|
icon={
|
||||||
<StarIconMini
|
<StarIconMini
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Slider } from "@mui/material";
|
import {Slider, useTheme} from "@mui/material";
|
||||||
|
|
||||||
type CustomSliderProps = {
|
type CustomSliderProps = {
|
||||||
defaultValue?: number;
|
defaultValue?: number;
|
||||||
@ -6,7 +6,8 @@ type CustomSliderProps = {
|
|||||||
min?: number;
|
min?: number;
|
||||||
max?: number;
|
max?: number;
|
||||||
step?: number;
|
step?: number;
|
||||||
onChange?: (value: number | number[]) => void;
|
onChange?: (_: Event, value: number | number[]) => void;
|
||||||
|
onChangeCommitted?: (_: React.SyntheticEvent | Event, value: number | number[]) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CustomSlider = ({
|
export const CustomSlider = ({
|
||||||
@ -16,13 +17,15 @@ export const CustomSlider = ({
|
|||||||
max = 100,
|
max = 100,
|
||||||
step,
|
step,
|
||||||
onChange,
|
onChange,
|
||||||
|
onChangeCommitted
|
||||||
}: CustomSliderProps) => {
|
}: CustomSliderProps) => {
|
||||||
const handleChange = ({ type }: Event, newValue: number | number[]) => {
|
// const handleChange = ({ type }: Event, newValue: number | number[]) => {
|
||||||
// Для корректной работы слайдера в FireFox
|
// // Для корректной работы слайдера в FireFox
|
||||||
if (type !== "change") {
|
// if (type !== "change") {
|
||||||
onChange?.(newValue);
|
// onChange?.(e, newValue);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Slider
|
<Slider
|
||||||
@ -31,31 +34,40 @@ export const CustomSlider = ({
|
|||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
step={step}
|
step={step}
|
||||||
onChange={handleChange}
|
onChange={onChange}
|
||||||
valueLabelDisplay="auto"
|
valueLabelDisplay="on"
|
||||||
|
onChangeCommitted={onChangeCommitted}
|
||||||
|
onMouseDown={(e) => e.stopPropagation()}
|
||||||
data-cy="slider"
|
data-cy="slider"
|
||||||
sx={{
|
sx={{
|
||||||
color: "#7E2AEA",
|
color: theme.palette.brightPurple.main,
|
||||||
height: "12px",
|
padding: "0",
|
||||||
"& .MuiSlider-track": {
|
marginTop: "75px",
|
||||||
border: "none",
|
"& .MuiSlider-valueLabel":{
|
||||||
|
background: theme.palette.brightPurple.main,
|
||||||
|
borderRadius: "8px",
|
||||||
|
width: "60px",
|
||||||
|
height: "36px"
|
||||||
|
},
|
||||||
|
"& .MuiSlider-valueLabel::before": {
|
||||||
|
width: "6px",
|
||||||
|
height: "2px",
|
||||||
|
transform: "translate(-50%, 50%) rotate(90deg)",
|
||||||
|
bottom: "-5px"
|
||||||
},
|
},
|
||||||
"& .MuiSlider-rail": {
|
"& .MuiSlider-rail": {
|
||||||
backgroundColor: "#F2F3F7",
|
backgroundColor: "#F2F3F7",
|
||||||
border: `1px solid #9A9AAF`,
|
border: `1px solid #9A9AAF`,
|
||||||
|
height: "12px"
|
||||||
},
|
},
|
||||||
"& .MuiSlider-thumb": {
|
"& .MuiSlider-thumb": {
|
||||||
height: 32,
|
border: "3px #f2f3f7 solid",
|
||||||
width: 32,
|
height: "23px",
|
||||||
border: `6px solid "#7E2AEA`,
|
width: "23px"
|
||||||
backgroundColor: "white",
|
|
||||||
boxShadow: `0px 0px 0px 3px white,
|
|
||||||
0px 4px 4px 3px #C3C8DD`,
|
|
||||||
"&:focus, &:hover, &.Mui-active, &.Mui-focusVisible": {
|
|
||||||
boxShadow: `0px 0px 0px 3px white,
|
|
||||||
0px 4px 4px 3px #C3C8DD`,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
"& .MuiSlider-track": {
|
||||||
|
height: "12px"
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -40,10 +40,13 @@ export default function Number({ question }: Props) {
|
|||||||
>
|
>
|
||||||
<CustomSlider
|
<CustomSlider
|
||||||
value={sliderValues}
|
value={sliderValues}
|
||||||
onChange={(value) => setSliderValues(value)}
|
onChange={(e, value) => {
|
||||||
|
setSliderValues(value);
|
||||||
|
}}
|
||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
defaultValue={start}
|
defaultValue={start}
|
||||||
|
valueLabelDisplay={"on"}
|
||||||
step={question.content.step}
|
step={question.content.step}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user