diff --git a/package-lock.json b/package-lock.json index cd5bb229..fc13b306 100755 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "notistack": "^3.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-image-file-resizer": "^0.4.8", "react-router-dom": "^6.6.2", "react-scripts": "5.0.1", "typescript": "^4.4.2", @@ -14677,6 +14678,11 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" }, + "node_modules/react-image-file-resizer": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/react-image-file-resizer/-/react-image-file-resizer-0.4.8.tgz", + "integrity": "sha512-Ue7CfKnSlsfJ//SKzxNMz8avDgDSpWQDOnTKOp/GNRFJv4dO9L5YGHNEnj40peWkXXAK2OK0eRIoXhOYpUzUTQ==" + }, "node_modules/react-is": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", @@ -27992,6 +27998,11 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" }, + "react-image-file-resizer": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/react-image-file-resizer/-/react-image-file-resizer-0.4.8.tgz", + "integrity": "sha512-Ue7CfKnSlsfJ//SKzxNMz8avDgDSpWQDOnTKOp/GNRFJv4dO9L5YGHNEnj40peWkXXAK2OK0eRIoXhOYpUzUTQ==" + }, "react-is": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", diff --git a/package.json b/package.json index 835ad773..eae5b528 100755 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "notistack": "^3.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-image-file-resizer": "^0.4.8", "react-router-dom": "^6.6.2", "react-scripts": "5.0.1", "typescript": "^4.4.2", diff --git a/src/pages/Questions/QuestionsPage.tsx b/src/pages/Questions/QuestionsPage.tsx index 67d5e338..4f5c8207 100755 --- a/src/pages/Questions/QuestionsPage.tsx +++ b/src/pages/Questions/QuestionsPage.tsx @@ -1,6 +1,6 @@ import React from "react"; import Stepper from "@ui_kit/Stepper"; -import { Box, Button, IconButton, Typography, Paper, useTheme } from "@mui/material"; +import {Box, Button, IconButton, Typography, Paper, useTheme, Link} from "@mui/material"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import CustomTextField from "@ui_kit/CustomTextField"; import OneIcon from "../../assets/icons/questionsPage/OneIcon"; @@ -19,6 +19,7 @@ import SliderOptions from "./SliderOptions/SliderOptions"; import UploadFile from "./UploadFile/UploadFile"; import PageOptions from "./PageOptions/PageOptions"; import RatingOptions from "./RatingOptions/RatingOptions"; +import SwitchQuestionsPage from "./SwitchQuestionsPage"; export default function QuestionsPage() { const [activeStep, setActiveStep] = React.useState(1); @@ -31,11 +32,25 @@ export default function QuestionsPage() { setActiveStep((prevActiveStep) => prevActiveStep - 1); }; + const [switchState, setSwitchState] = React.useState(''); + const SSHC = (data: string) => { + setSwitchState(data) + } + const theme = useTheme(); return ( <> - Заголовок квиза + + Заголовок квиза + Свернуть всё + + - - - - - - - - - - - - - - + + {switchState.length === 0 ? + + : + } + + {/**/} + {/* */} + {/**/} + diff --git a/src/pages/Questions/SwitchQuestionsPage.tsx b/src/pages/Questions/SwitchQuestionsPage.tsx new file mode 100644 index 00000000..503bfafa --- /dev/null +++ b/src/pages/Questions/SwitchQuestionsPage.tsx @@ -0,0 +1,68 @@ +import * as React from 'react'; + +import AnswerOptions from "./answerOptions/AnswerOptions"; +import OptionsPicture from "./OptionsPicture/OptionsPicture"; +import DataOptions from "./DataOptions/DataOptions"; +import SliderOptions from "./SliderOptions/SliderOptions"; +import OwnTextField from "./OwnTextField/OwnTextField"; +import PageOptions from "./PageOptions/PageOptions"; +import OptionsAndPicture from "./OptionsAndPicture/OptionsAndPicture"; +import RatingOptions from "./RatingOptions/RatingOptions"; +import Emoji from "./Emoji/Emoji"; +import DropDown from "./DropDown/DropDown"; +import UploadFile from "./UploadFile/UploadFile"; + +interface Props { + switchState: string, +} + +export default function SwitchQuestionsPage ({switchState = '' }: Props) { + switch (switchState) { + case 'answer': + return (); + break; + + case 'answerpict': + return (); + break; + + case 'answerandpict': + return (); + break; + + case 'emoji': + return (); + break; + + case 'textfield': + return (); + break; + + case 'dropdown': + return (); + break; + + case 'date': + return (); + break; + + case 'slider': + return (); + break; + + case 'uploader': + return (); + break; + + case 'page': + return (); + break; + + case 'rating': + return (); + break; + + default: + return (<>) + } +} \ No newline at end of file diff --git a/src/pages/Questions/TypeQuestions.tsx b/src/pages/Questions/TypeQuestions.tsx index 56290fe5..3c95ae72 100755 --- a/src/pages/Questions/TypeQuestions.tsx +++ b/src/pages/Questions/TypeQuestions.tsx @@ -13,20 +13,83 @@ import RatingIcon from "../../assets/icons/questionsPage/rating"; import {Box} from "@mui/material"; import React from "react"; -export default function TypeQuestions() { +interface Props { + switchState: string; + SSHC: (data: string) => void; +} + +export default function TypeQuestions({ SSHC, switchState }: Props) { + const buttonTypeQuestions: { icon: JSX.Element; title: string; value: string }[] = [ + { + icon: , + title: 'Варианты ответов', + value: 'answer', + }, + { + icon: , + title: 'Варианты с картинками', + value: 'answerpict', + }, + { + icon: , + title: 'Варианты и картинка', + value: 'answerandpict', + }, + { + icon: , + title: 'Эмоджи', + value: 'emoji', + }, + { + icon: , + title: 'Своё поле для ввода', + value: 'textfield', + }, + { + icon: , + title: 'Выпадающий список', + value: 'dropdown', + }, + { + icon: , + title: 'Дата', + value: 'date', + }, + { + icon: , + title: 'Ползунок', + value: 'slider', + }, + { + icon: , + title: 'Загрузка файла', + value: 'uploader', + }, + { + icon: , + title: 'Страница', + value: 'page', + }, + { + icon: , + title: 'Рейтинг', + value: 'rating', + }, + ]; return ( - } text={'Варианты ответов'}/> - } text={'Варианты с картинками'}/> - } text={'Варианты и картинка'}/> - } text={'Эможди'}/> - } text={'Своё поле для ввода'}/> - } text={'Выпадающий список'}/> - } text={'Дата'}/> - } text={'Ползунок'}/> - } text={'Загрузка файла'}/> - } text={'Страница'}/> - } text={'Рейтинг'}/> + + {buttonTypeQuestions.map(({ icon, title, value }) => ( + { + SSHC(value); + console.log(value) + }} + icon={icon} + text={title} + /> + ))} ) } diff --git a/src/pages/startPage/StartPage.tsx b/src/pages/startPage/StartPage.tsx index c997b6c7..f9159949 100755 --- a/src/pages/startPage/StartPage.tsx +++ b/src/pages/startPage/StartPage.tsx @@ -24,7 +24,7 @@ export default function StartPage() { const handleBack = () => { let result = listQuizes[params].step - 1 - updateQuizesList(params, {step: result ? result : 1}) + updateQuizesList(params, {step: result ? result : 0}) }; return ( diff --git a/src/pages/startPage/StartPageSettings.tsx b/src/pages/startPage/StartPageSettings.tsx index 5157fc4d..e326d41b 100755 --- a/src/pages/startPage/StartPageSettings.tsx +++ b/src/pages/startPage/StartPageSettings.tsx @@ -32,7 +32,7 @@ import ModalSizeImage from "./ModalSizeImage"; import DropZone from "./dropZone"; import Extra from "./extra"; import AlignCenterIcon from "@icons/AlignCenterIcon"; - +import DropFav from "./dropfavicon"; const designTypes = [ ["standard", (color: string) => , "Standard"], @@ -353,6 +353,7 @@ export default function StartPageSettings() { gap: "10px", }}> + 5 MB максимум + {/**/} {/*Правая сторона*/} ; + heightImg: string; + widthImg?: string +} + +export default ({text, sx, heightImg, widthImg}: Props) => { + const theme = useTheme(); + const callback = (newFileUri:any) => setData(URL.createObjectURL(newFileUri)); + const resizeImage = (imageFile:any) => { + try { + Resizer.imageFileResizer( + imageFile, + 150, + 150, + "JPEG", + 100, + 0, + callback, + ); + } catch (err) { + console.log(err); + }} + const handleImageResize = (imgInp:any) => resizeImage(imgInp.files); + const imgHC = (imgInp:any) => { + const [file] = imgInp.files + if (file.size < 5242880) { + setData(URL.createObjectURL(file)) + } else {enqueueSnackbar('Размер картинки слишком велик')} + handleImageResize(file) + console.log(file.height) + } + + + + + const [data, setData] = useState("") + const [ready, setReady] = useState(false); + + const dragenterHC = () => { + // console.log("onDragEnter") + setReady(true) + } + + const dragexitHC = () => { + // console.log("onDragExit") + setReady(false) + } + + const dropHC = (event: any) => { + event.preventDefault() + // console.log("onDrop") + setReady(false) + const file = event.dataTransfer.files[0] + console.log(event.dataTransfer.files[0]) + if (file.size < 5242880) { + setData(URL.createObjectURL(file)) + } else {enqueueSnackbar('Размер картинки слишком велик')} + // try { + // Resizer.imageFileResizer( + // file, + // 50, + // 50, + // "JPEG", + // 100, + // 0, + // callback, + // ); + // + // } catch (err) { + // console.log(err); + // } + // + } + + const dragOverHC = (event: any) => { + event.preventDefault() + // console.log("onDragOver") + } + + return ( + + imgHC(event.target)} hidden accept="image/*" multiple type="file" /> + + + {text} + + {data ? + + : + null + } + + + ) +} diff --git a/src/pages/startPage/switchStepPages.tsx b/src/pages/startPage/switchStepPages.tsx index fd15b7a9..66229c61 100755 --- a/src/pages/startPage/switchStepPages.tsx +++ b/src/pages/startPage/switchStepPages.tsx @@ -11,13 +11,13 @@ interface Props { export default function SwitchStepPages({activeStep = 1, handleNext }: Props) { switch (activeStep) { - case 1: + case 0: return (); break; - case 2: + case 1: return (); break - case 3: + case 2: return (); break; default: diff --git a/src/ui_kit/QuestionsMiniButton.tsx b/src/ui_kit/QuestionsMiniButton.tsx index e8eefff6..c3ef95a0 100755 --- a/src/ui_kit/QuestionsMiniButton.tsx +++ b/src/ui_kit/QuestionsMiniButton.tsx @@ -6,9 +6,10 @@ import { ReactNode } from "react"; interface QuestionsMiniButtonProps { icon: ReactNode; text: string; + onClick: () => void; } -export default function QuestionsMiniButton({ icon, text }: QuestionsMiniButtonProps) { +export default function QuestionsMiniButton({ icon, text, onClick }: QuestionsMiniButtonProps) { const theme = useTheme(); return ( @@ -24,6 +25,7 @@ export default function QuestionsMiniButton({ icon, text }: QuestionsMiniButtonP border: '1px solid #9A9AAF', borderRadius: '8px' }} + onClick={onClick} > {icon} Шаг {activeStep} из {steps} + lineHeight: '14.22px'}}> Шаг {activeStep + 1} из {steps} {desc} diff --git a/yarn.lock b/yarn.lock index 47764b3d..6d06bb97 100755 --- a/yarn.lock +++ b/yarn.lock @@ -7820,6 +7820,11 @@ "resolved" "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz" "version" "6.0.11" +"react-image-file-resizer@^0.4.8": + "integrity" "sha512-Ue7CfKnSlsfJ//SKzxNMz8avDgDSpWQDOnTKOp/GNRFJv4dO9L5YGHNEnj40peWkXXAK2OK0eRIoXhOYpUzUTQ==" + "resolved" "https://registry.npmjs.org/react-image-file-resizer/-/react-image-file-resizer-0.4.8.tgz" + "version" "0.4.8" + "react-is@^16.13.1": "integrity" "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" "resolved" "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz"