From 5b21df276d03d0b5a2472256af494ea31286088e Mon Sep 17 00:00:00 2001 From: IlyaDoronin Date: Thu, 19 Oct 2023 13:55:37 +0300 Subject: [PATCH] feat: StartPageSettings mobile styles --- src/pages/startPage/StartPageSettings.tsx | 1093 ++++++++++++--------- 1 file changed, 609 insertions(+), 484 deletions(-) diff --git a/src/pages/startPage/StartPageSettings.tsx b/src/pages/startPage/StartPageSettings.tsx index cfa1b465..b5e9095f 100755 --- a/src/pages/startPage/StartPageSettings.tsx +++ b/src/pages/startPage/StartPageSettings.tsx @@ -9,6 +9,7 @@ import { Select, Tooltip, Typography, + useMediaQuery, useTheme, } from "@mui/material"; import { ChangeEvent, useState } from "react"; @@ -59,15 +60,17 @@ type BackgroundType = "image" | "video"; type AlignType = "left" | "right" | "center"; export default function StartPageSettings() { + const [alignType, setAlignType] = useState("left"); + const [formState, setFormState] = useState<"design" | "content">("design"); const { listQuizes, updateQuizesList, removeQuiz, createBlank } = quizStore(); const params = Number(useParams().quizId); const theme = useTheme(); const designType = listQuizes[params].startpage; - const StartPageClone = listQuizes[params]; const [backgroundType, setBackgroundType] = useState( listQuizes[params].config.startpage.background.type ); - const [alignType, setAlignType] = useState("left"); + const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1500)); + const isTablet = useMediaQuery(theme.breakpoints.down(950)); const handleNext = () => { updateQuizesList(params, { step: listQuizes[params].step + 1 }); @@ -132,17 +135,54 @@ export default function StartPageSettings() { return ( <> - + Стартовая страница + {isSmallMonitor && ( + + + + + )} - - - Дизайн - - - + updateQuizesList(params, { startpage: e.target.value }) + } + sx={{ + height: "48px", + borderRadius: "8px", + "& .MuiOutlinedInput-notchedOutline": { + border: `1px solid ${theme.palette.brightPurple.main} !important`, }, - }, - MenuListProps: { - sx: { - py: 0, - display: "flex", - flexDirection: "column", - gap: "8px", - "& .Mui-selected": { - backgroundColor: theme.palette.background.default, - color: theme.palette.brightPurple.main, + }} + MenuProps={{ + PaperProps: { + sx: { + mt: "8px", + p: "4px", + borderRadius: "8px", + border: "1px solid #EEE4FC", + boxShadow: "0px 8px 24px rgba(210, 208, 225, 0.4)", }, }, - }, - }} - inputProps={{ - sx: { - color: theme.palette.brightPurple.main, - display: "flex", - alignItems: "center", - px: "9px", - gap: "20px", - }, - }} - IconComponent={(props) => } - > - {designTypes.map((type) => ( - - {type[1]( - type[0] === designType - ? theme.palette.orange.main - : theme.palette.grey2.main - )} - {type[2]} - - ))} - - - - Фон - - - { - setBackgroundType("image"); - let SPageClone = listQuizes[params].config; - SPageClone.startpage.background.type = "image"; - updateQuizesList(params, { config: SPageClone }); + }, + }} + IconComponent={(props) => } + > + {designTypes.map((type) => ( + + {type[1]( + type[0] === designType + ? theme.palette.orange.main + : theme.palette.grey2.main + )} + {type[2]} + + ))} + + + - Изображение - - { - setBackgroundType("video"); - let SPageClone = listQuizes[params].config; - SPageClone.startpage.background.type = "video"; - updateQuizesList(params, { config: SPageClone }); - }} - > - Видео - - - - + Фон + + { + setBackgroundType("image"); + let SPageClone = listQuizes[params].config; + SPageClone.startpage.background.type = "image"; + updateQuizesList(params, { config: SPageClone }); + }} + > + Изображение + + { + setBackgroundType("video"); + let SPageClone = listQuizes[params].config; + SPageClone.startpage.background.type = "video"; + updateQuizesList(params, { config: SPageClone }); + }} + > + Видео + + + + + + + Изображение + + + + + + + + } + checkedIcon={} + /> + } + label="мобильная версия" + sx={{ + color: theme.palette.brightPurple.main, + textDecorationLine: "underline", + textDecorationColor: theme.palette.brightPurple.main, + ml: "-9px", + userSelect: "none", + }} + onClick={() => { + MobileVersionHC(!mobileVersion); + }} + /> + {mobileVersion ? ( + + + Изображение для мобильной версии + + + + ) : ( + <> + )} + + + + + + + Добавить видео + + + + + + + + + videoHC(event.target)} + hidden + accept=".mp4" + multiple + type="file" + /> + } + sx={{ + height: "48px", + width: "48px", + marginBottom: "20px", + }} + /> + + {video ? + + + Расположение элементов + + + { + setAlignType("left"); + let SPageClone = listQuizes[params].config; + SPageClone.startpage.position = "ltr"; + updateQuizesList(params, { config: SPageClone }); + }} + isActive={alignType === "left"} + Icon={AlignLeftIcon} + /> + { + setAlignType("center"); + let SPageClone = listQuizes[params].config; + SPageClone.startpage.position = "cnt"; + updateQuizesList(params, { config: SPageClone }); + }} + isActive={alignType === "center"} + Icon={AlignCenterIcon} + sx={{ display: designType === "centered" ? "flex" : "none" }} + /> + { + setAlignType("right"); + let SPageClone = listQuizes[params].config; + SPageClone.startpage.position = "rtl"; + updateQuizesList(params, { config: SPageClone }); + }} + isActive={alignType === "right"} + Icon={AlignRightIcon} + /> + + + {(isTablet || !isSmallMonitor) && ( + <> + + + Логотип + + + + + + Favicon + + + + + + 5 MB максимум + + + + )} + + )} + {/*Правая сторона*/} + + {!isTablet && isSmallMonitor && formState === "design" && ( + <> + + + Логотип + + + + - Изображение + Favicon - - - - - - - } - checkedIcon={} - /> - } - label="мобильная версия" + { - MobileVersionHC(!mobileVersion); - }} - /> - {mobileVersion ? ( - - - Изображение для мобильной версии - - - - ) : ( - <> - )} - - - - - - - Добавить видео - - - - - - - - - videoHC(event.target)} - hidden - accept=".mp4" - multiple - type="file" - /> - } + + + + 5 MB максимум + + + + )} + {(!isSmallMonitor || (isSmallMonitor && formState === "content")) && ( + <> + + Заголовок + + + updateQuizesList(params, { name: e.target.value }) + } + /> + + Текст + + + + Текст кнопки + + + + Телефон + + + { + let SPageClone = listQuizes[params].config; + SPageClone.info.clickable = e.target.checked; + updateQuizesList(params, { config: SPageClone }); }} /> - - {video ?