diff --git a/src/pages/ViewPublicationPage/StartPageViewPublication.tsx b/src/pages/ViewPublicationPage/StartPageViewPublication.tsx index 610cd0d7..9feb7bf2 100644 --- a/src/pages/ViewPublicationPage/StartPageViewPublication.tsx +++ b/src/pages/ViewPublicationPage/StartPageViewPublication.tsx @@ -142,6 +142,9 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => { fontStyle: "normal", fontStretch: "normal", lineHeight: "1.2", + overflowWrap: "break-word", + width: "100%", + textAlign: quiz.config.startpageType === "centered" ? "center" : "-moz-initial", }} > {quiz.name} @@ -150,6 +153,9 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => { sx={{ fontSize: "16px", m: "16px 0", + overflowWrap: "break-word", + width: "100%", + textAlign: quiz.config.startpageType === "centered" ? "center" : "-moz-initial", }} > {quiz.config.startpage.description} @@ -172,7 +178,7 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => { - + {quiz.config.info.clickable ? ( isMobileDevice ? ( @@ -192,7 +198,9 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => { {quiz.config.info.phonenumber} )} - {quiz.config.info.law} + + {quiz.config.info.law} + {quizHeaderBlock} - {backgroundBlock && {backgroundBlock}} + {backgroundBlock && ( + + {backgroundBlock} + + )} {quizMainBlock} ); diff --git a/src/pages/startPage/StartPageSettings.tsx b/src/pages/startPage/StartPageSettings.tsx index f6fa0f0f..fa1cc2d4 100755 --- a/src/pages/startPage/StartPageSettings.tsx +++ b/src/pages/startPage/StartPageSettings.tsx @@ -9,16 +9,16 @@ import LayoutStandartIcon from "@icons/LayoutStandartIcon"; import MobilePhoneIcon from "@icons/MobilePhoneIcon"; import { QuizStartpageType } from "@model/quizSettings"; import { - Box, - Button, - Checkbox, - FormControl, - FormControlLabel, - MenuItem, - Select, - Typography, - useMediaQuery, - useTheme + Box, + Button, + Checkbox, + FormControl, + FormControlLabel, + MenuItem, + Select, + Typography, + useMediaQuery, + useTheme, } from "@mui/material"; import { incrementCurrentStep, updateQuiz, uploadQuizImage } from "@root/quizes/actions"; import { useCurrentQuiz } from "@root/quizes/hooks"; @@ -35,733 +35,736 @@ import SelectableIconButton from "./SelectableIconButton"; import { DropZone } from "./dropZone"; import Extra from "./extra"; - const designTypes = [ - [ - "standard", - (color: string) => , - "Standard", - ], - [ - "expanded", - (color: string) => , - "Expanded", - ], - [ - "centered", - (color: string) => , - "Centered", - ], + ["standard", (color: string) => , "Standard"], + ["expanded", (color: string) => , "Expanded"], + ["centered", (color: string) => , "Centered"], ] as const; // type DesignType = typeof designTypes[number][0]; - export default function StartPageSettings() { - const theme = useTheme(); - const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1500)); - const isTablet = useMediaQuery(theme.breakpoints.down(950)); - const quiz = useCurrentQuiz(); - const [formState, setFormState] = useState<"design" | "content">("design"); - const [mobileVersion, setMobileVersion] = useState(false); + const theme = useTheme(); + const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1500)); + const isTablet = useMediaQuery(theme.breakpoints.down(950)); + const quiz = useCurrentQuiz(); + const [formState, setFormState] = useState<"design" | "content">("design"); + const [mobileVersion, setMobileVersion] = useState(false); - if (!quiz) return null; + if (!quiz) return null; - const MobileVersionHC = (bool: boolean) => { - setMobileVersion(bool); - }; + const MobileVersionHC = (bool: boolean) => { + setMobileVersion(bool); + }; - const designType = quiz?.config?.startpageType; + const designType = quiz?.config?.startpageType; - const favIconDropZoneElement = ( - { - const resizedImage = await resizeFavIcon(file); - uploadQuizImage(quiz.id, resizedImage, (quiz, url) => { - quiz.config.startpage.favIcon = url; - }); - }} - onDeleteClick={() => { - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.favIcon = null; - }); - }} - /> - ); + const favIconDropZoneElement = ( + { + const resizedImage = await resizeFavIcon(file); + uploadQuizImage(quiz.id, resizedImage, (quiz, url) => { + quiz.config.startpage.favIcon = url; + }); + }} + onDeleteClick={() => { + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.favIcon = null; + }); + }} + /> + ); - return ( - <> + return ( + <> + + Стартовая страница + + {isSmallMonitor && ( + + - - - )} - + + + )} + + {(!isSmallMonitor || (isSmallMonitor && formState === "design")) && ( + + - {(!isSmallMonitor || (isSmallMonitor && formState === "design")) && ( - - - Дизайн - - - - - - Фон - - - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.background.type = "image"; - })} - > - Изображение - - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.background.type = "video"; - })} - > - Видео - - - - - - - Изображение - - { - uploadQuizImage(quiz.id, file, (quiz, url) => { - quiz.config.startpage.background.desktop = url; - quiz.config.startpage.background.originalDesktop = url; - }); - }} - onImageSaveClick={file => { - uploadQuizImage(quiz.id, file, (quiz, url) => { - quiz.config.startpage.background.desktop = url; - }); - }} - onDeleteClick={() => { - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.background.desktop = null; - }); - }} - /> - - - - - - - - - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.background.video = e.target.value; - })} - /> - - - - {designType !== "centered" && - <> - - Расположение элементов - - - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.position = "left"; - })} - isActive={quiz.config.startpage.position === "left"} - Icon={AlignLeftIcon} - /> - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.position = "center"; - })} - isActive={quiz.config.startpage.position === "center"} - Icon={AlignCenterIcon} - sx={{ display: designType === "standard" ? "none" : "flex" }} - /> - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.position = "right"; - })} - isActive={quiz.config.startpage.position === "right"} - Icon={AlignRightIcon} - /> - - - - } - {(isTablet || !isSmallMonitor) && ( - <> - - - Логотип - - { - uploadQuizImage(quiz.id, file, (quiz, url) => { - quiz.config.startpage.logo = url; - quiz.config.startpage.originalLogo = url; - }); - }} - onImageSaveClick={file => { - uploadQuizImage(quiz.id, file, (quiz, url) => { - quiz.config.startpage.logo = url; - }); - }} - onDeleteClick={() => { - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.logo = null; - }); - }} - /> - - - - Favicon - - {favIconDropZoneElement} - - )} - - )} - {/*Правая сторона*/} - - {!isTablet && isSmallMonitor && formState === "design" && ( - <> - - - Логотип - - { - uploadQuizImage(quiz.id, file, (quiz, url) => { - quiz.config.startpage.logo = url; - quiz.config.startpage.originalLogo = url; - }); - }} - onImageSaveClick={file => { - uploadQuizImage(quiz.id, file, (quiz, url) => { - quiz.config.startpage.logo = url; - }); - }} - onDeleteClick={() => { - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.logo = null; - }); - }} - /> - - - - Favicon - - {favIconDropZoneElement} - - )} - {(!isSmallMonitor || (isSmallMonitor && formState === "content")) && ( - <> - - Заголовок - - updateQuiz(quiz.id, quiz => { - quiz.name = e.target.value; - })} - /> - - Текст - - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.description = e.target.value; - })} - /> - - Текст кнопки - - updateQuiz(quiz.id, quiz => { - quiz.config.startpage.button = e.target.value; - })} - /> - - Телефон - - updateQuiz(quiz.id, quiz => { - quiz.config.info.phonenumber = e.target.value; - })} - /> - updateQuiz(quiz.id, quiz => { - quiz.config.info.clickable = e.target.checked; - })} - /> - - Название или слоган компании - - updateQuiz(quiz.id, quiz => { - quiz.config.info.orgname = e.target.value; - })} - /> - - Сайт - - updateQuiz(quiz.id, quiz => { - quiz.config.info.site = e.target.value; - })} - /> - - Юридическая информация - - updateQuiz(quiz.id, quiz => { - quiz.config.info.law = e.target.value; - })} - /> - - - )} - - - {isSmallMonitor && ( - - {formState === "content" && ( - - )} - {formState === "design" && ( - - )} - - )} - + + + + + Фон + + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.background.type = "image"; + }) + } + > + Изображение + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.background.type = "video"; + }) + } + > + Видео + - {createPortal(, document.body)} - - ); + + + + + Изображение + + { + uploadQuizImage(quiz.id, file, (quiz, url) => { + quiz.config.startpage.background.desktop = url; + quiz.config.startpage.background.originalDesktop = url; + }); + }} + onImageSaveClick={(file) => { + uploadQuizImage(quiz.id, file, (quiz, url) => { + quiz.config.startpage.background.desktop = url; + }); + }} + onDeleteClick={() => { + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.background.desktop = null; + }); + }} + /> + + + + + + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.background.video = e.target.value; + }) + } + /> + + + {designType !== "centered" && ( + <> + + Расположение элементов + + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.position = "left"; + }) + } + isActive={quiz.config.startpage.position === "left"} + Icon={AlignLeftIcon} + /> + + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.position = "center"; + }) + } + isActive={quiz.config.startpage.position === "center"} + Icon={AlignCenterIcon} + sx={{ display: designType === "standard" ? "none" : "flex" }} + /> + + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.position = "right"; + }) + } + isActive={quiz.config.startpage.position === "right"} + Icon={AlignRightIcon} + /> + + + )} + {(isTablet || !isSmallMonitor) && ( + <> + + + Логотип + + { + uploadQuizImage(quiz.id, file, (quiz, url) => { + quiz.config.startpage.logo = url; + quiz.config.startpage.originalLogo = url; + }); + }} + onImageSaveClick={(file) => { + uploadQuizImage(quiz.id, file, (quiz, url) => { + quiz.config.startpage.logo = url; + }); + }} + onDeleteClick={() => { + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.logo = null; + }); + }} + /> + + + + Favicon + + {favIconDropZoneElement} + + )} + + )} + {/*Правая сторона*/} + + {!isTablet && isSmallMonitor && formState === "design" && ( + <> + + + Логотип + + { + uploadQuizImage(quiz.id, file, (quiz, url) => { + quiz.config.startpage.logo = url; + quiz.config.startpage.originalLogo = url; + }); + }} + onImageSaveClick={(file) => { + uploadQuizImage(quiz.id, file, (quiz, url) => { + quiz.config.startpage.logo = url; + }); + }} + onDeleteClick={() => { + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.logo = null; + }); + }} + /> + + + + Favicon + + {favIconDropZoneElement} + + )} + {(!isSmallMonitor || (isSmallMonitor && formState === "content")) && ( + <> + + Заголовок + + + updateQuiz(quiz.id, (quiz) => { + quiz.name = e.target.value; + }) + } + maxLength={40} + /> + + Текст + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.description = e.target.value; + }) + } + maxLength={70} + /> + + Текст кнопки + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.startpage.button = e.target.value; + }) + } + maxLength={15} + /> + + Телефон + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.info.phonenumber = e.target.value; + }) + } + maxLength={20} + /> + + updateQuiz(quiz.id, (quiz) => { + quiz.config.info.clickable = e.target.checked; + }) + } + /> + + Название или слоган компании + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.info.orgname = e.target.value; + }) + } + maxLength={25} + /> + + Сайт + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.info.site = e.target.value; + }) + } + maxLength={25} + /> + + Юридическая информация + + + updateQuiz(quiz.id, (quiz) => { + quiz.config.info.law = e.target.value; + }) + } + maxLength={45} + /> + + + )} + + + {isSmallMonitor && ( + + {formState === "content" && ( + + )} + {formState === "design" && ( + + )} + + )} + + + Отключить стартовую страницу + + } + checkedIcon={ + + } + sx={{ + borderRadius: 0, + padding: 0, + }} + onChange={(e) => + updateQuiz(quiz.id, (quiz) => { + quiz.config.noStartPage = e.target.checked; + }) + } + checked={quiz.config.noStartPage} + /> + } + label="" + sx={{ + color: theme.palette.brightPurple.main, + margin: "0", + userSelect: "none", + justifyContent: "flex-end", + }} + /> + + + {createPortal(, document.body)} + + ); } function IconCheck() { - return ( - - ); + return ( + + ); } diff --git a/src/ui_kit/CustomTextField.tsx b/src/ui_kit/CustomTextField.tsx index b04df3b4..34dc98b8 100755 --- a/src/ui_kit/CustomTextField.tsx +++ b/src/ui_kit/CustomTextField.tsx @@ -1,7 +1,7 @@ -import { FormControl, TextField, useTheme, SxProps, Theme } from "@mui/material"; - +import React, { useState } from "react"; +import { Box, FormControl, TextField, Typography, useTheme } from "@mui/material"; import type { ChangeEvent, KeyboardEvent, FocusEvent } from "react"; -import type { InputProps } from "@mui/material"; +import type { InputProps, SxProps, Theme } from "@mui/material"; interface CustomTextFieldProps { placeholder: string; @@ -11,6 +11,7 @@ interface CustomTextFieldProps { onKeyDown?: (event: KeyboardEvent) => void; onBlur?: (event: FocusEvent) => void; text?: string; + maxLength?: number; sx?: SxProps; InputProps?: Partial; } @@ -18,28 +19,54 @@ interface CustomTextFieldProps { export default function CustomTextField({ placeholder, value, - text, - sx, - error, onChange, onKeyDown, onBlur, + text, + sx, + error, InputProps, + maxLength = 200, }: CustomTextFieldProps) { const theme = useTheme(); + const [inputValue, setInputValue] = useState(value || ""); + const [isInputActive, setIsInputActive] = useState(false); + + const handleInputChange = (event: React.ChangeEvent) => { + const inputValue = event.target.value; + setInputValue(inputValue); + + if (onChange) { + onChange(event); + } + }; + + const handleInputFocus = () => { + setIsInputActive(true); + }; + + const handleInputBlur = (event: React.FocusEvent) => { + setIsInputActive(false); + + if (onBlur) { + onBlur(event); + } + }; + return ( + {isInputActive && inputValue.length >= maxLength - 7 && ( + + {inputValue.length} + / + {maxLength} + + )} ); }