diff --git a/package.json b/package.json index c544f8ab..50ce7a0f 100755 --- a/package.json +++ b/package.json @@ -110,6 +110,6 @@ "bracketSpacing": true, "arrowParens": "always", "jsxSingleQuote": false, - "singleAttributePerLine": false + "singleAttributePerLine": true } } diff --git a/src/assets/banner-widget-preview.png b/src/assets/banner-widget-preview.png index 7c00d7f1..7631e894 100644 Binary files a/src/assets/banner-widget-preview.png and b/src/assets/banner-widget-preview.png differ diff --git a/src/assets/fixed-button-widget-preview.png b/src/assets/fixed-button-widget-preview.png index b84a1aaa..af64082b 100644 Binary files a/src/assets/fixed-button-widget-preview.png and b/src/assets/fixed-button-widget-preview.png differ diff --git a/src/pages/InstallQuiz/QuizInstallationCard/QuizInstallationCard.tsx b/src/pages/InstallQuiz/QuizInstallationCard/QuizInstallationCard.tsx index 19367730..dc1ab3d1 100644 --- a/src/pages/InstallQuiz/QuizInstallationCard/QuizInstallationCard.tsx +++ b/src/pages/InstallQuiz/QuizInstallationCard/QuizInstallationCard.tsx @@ -1,16 +1,10 @@ import { WidgetType } from "@frontend/squzanswerer"; -import { - Box, - Button, - Typography, - useMediaQuery, - useTheme, -} from "@mui/material"; +import { Box, Button, Typography, useMediaQuery, useTheme } from "@mui/material"; import { useCurrentQuiz } from "@root/quizes/hooks"; import { useState } from "react"; import InstallationStepButton from "./InstallationStepButton"; import BannerWidgetSetup from "./WidgetSetupByType/BannerWidgetSetup/BannerWidgetSetup"; -import ButtonWidgetSetup from "./WidgetSetupByType/ButtonWidgetSetup"; +import ButtonWidgetSetup from "./WidgetSetupByType/ButtonWidgetSetup/ButtonWidgetSetup"; import ContainerWidgetSetup from "./WidgetSetupByType/ContainerWidgetSetup"; import PopupWidgetSetup from "./WidgetSetupByType/PopupWidgetSetup"; import SideWidgetSetup from "./WidgetSetupByType/SideWidgetSetup/SideWidgetSetup"; @@ -30,16 +24,15 @@ export default function QuizInstallationCard() { const theme = useTheme(); const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1065)); const quiz = useCurrentQuiz(); - const [widgetSetupSettings, setWidgetSetupSettings] = - useState({ step: 1, widgetType: "container" }); + const [widgetSetupSettings, setWidgetSetupSettings] = useState({ + step: 1, + widgetType: "container", + }); if (!quiz) return null; const nextButton = ( - ); @@ -187,34 +180,19 @@ export default function QuizInstallationCard() { ) : ( <> {widgetSetupSettings.widgetType === "container" && ( - + )} {widgetSetupSettings.widgetType === "button" && ( - + )} {widgetSetupSettings.widgetType === "banner" && ( - + )} {widgetSetupSettings.widgetType === "popup" && ( - + )} {widgetSetupSettings.widgetType === "side" && ( - + )} )} diff --git a/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetPreviewDesktop.tsx b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetPreviewDesktop.tsx new file mode 100644 index 00000000..2d38942a --- /dev/null +++ b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetPreviewDesktop.tsx @@ -0,0 +1,157 @@ +import TaskIcon from "@/ui_kit/TaskIcon"; +import CloseIcon from "@mui/icons-material/Close"; +import { Box, Typography } from "@mui/material"; +import RunningStripe from "@ui_kit/RunningStripe"; + +interface Props { + position: "topleft" | "topright" | "bottomleft" | "bottomright"; + bannerFullWidth: boolean; + pulsation: boolean; + rounded: boolean; + withShadow: boolean; + buttonFlash: boolean; + buttonBackgroundColor: string; + buttonTextColor: string; + appealText: string; + quizHeaderText: string; +} + +export default function BannerWidgetPreviewDesktop({ + bannerFullWidth, + buttonBackgroundColor, + buttonFlash, + buttonTextColor, + position, + pulsation, + rounded, + withShadow, + appealText, + quizHeaderText, +}: Props) { + return ( + + + + + + {appealText || "Пройти тест"} + + + {quizHeaderText || "Заголовок теста"} + + + {buttonFlash && } + + + + ); +} diff --git a/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetPreviewMobile.tsx b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetPreviewMobile.tsx new file mode 100644 index 00000000..47a26914 --- /dev/null +++ b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetPreviewMobile.tsx @@ -0,0 +1,128 @@ +import TaskIcon from "@/ui_kit/TaskIcon"; +import CloseIcon from "@mui/icons-material/Close"; +import { Box, Typography } from "@mui/material"; +import RunningStripe from "@ui_kit/RunningStripe"; + +interface Props { + position: "topleft" | "topright" | "bottomleft" | "bottomright"; + pulsation: boolean; + withShadow: boolean; + buttonFlash: boolean; + buttonBackgroundColor: string; + buttonTextColor: string; + appealText: string; + quizHeaderText: string; +} + +export default function BannerWidgetPreviewMobile({ + buttonBackgroundColor, + buttonFlash, + buttonTextColor, + position, + pulsation, + withShadow, + appealText, + quizHeaderText, +}: Props) { + return ( + + + + + + {appealText || "Пройти тест"} + + + {quizHeaderText || "Заголовок теста"} + + + {buttonFlash && } + + + + ); +} diff --git a/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetSetup.tsx b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetSetup.tsx index ca5dcad7..4cd14a40 100644 --- a/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetSetup.tsx +++ b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/BannerWidgetSetup/BannerWidgetSetup.tsx @@ -1,5 +1,4 @@ import { BannerWidgetParams } from "@frontend/squzanswerer"; -import CloseIcon from "@mui/icons-material/Close"; import { Box, Button, @@ -19,13 +18,13 @@ import CustomCheckbox from "@ui_kit/CustomCheckbox"; import PenaTextField from "@ui_kit/PenaTextField"; import RadioCheck from "@ui_kit/RadioCheck"; import RadioIcon from "@ui_kit/RadioIcon"; -import RunningStripe from "@ui_kit/RunningStripe"; import { ReactNode, useState } from "react"; -import fixedButtonWidgetPreview from "../../../../../assets/banner-widget-preview.png"; +import fixedBannerWidgetPreview from "../../../../../assets/banner-widget-preview.png"; import WidgetScript from "../../WidgetScript"; import { createBannerWidgetScriptText } from "../../createWidgetScriptText"; import { useWidgetUrl } from "../../useWidgetUrl"; -import BannerWidgetPreviewIcon from "./BannerWidgetPreviewIcon"; +import BannerWidgetPreviewDesktop from "./BannerWidgetPreviewDesktop"; +import BannerWidgetPreviewMobile from "./BannerWidgetPreviewMobile"; interface Props { step: 2 | 3; @@ -49,7 +48,7 @@ export default function BannerWidgetSetup({ step, nextButton }: Props) { const [autoShowQuiz, setAutoShowQuiz] = useState(false); const [autoShowQuizTime, setAutoShowQuizTime] = useState(10); const [openOnLeaveAttempt, setOpenOnLeaveAttempt] = useState(false); - const [position, setPosition] = useState("bottomleft"); + const [position, setPosition] = useState("topleft"); const [bannerFullWidth, setBannerFullWidth] = useState(false); const [autoShowWidgetTime, setAutoShowWidgetTime] = useState(10); const [appealText, setAppealText] = useState(""); @@ -114,129 +113,35 @@ export default function BannerWidgetSetup({ step, nextButton }: Props) { }} > - - - - - - {appealText || "Пройти тест"} - - - {quizHeaderText || "Заголовок теста"} - - - {buttonFlash && } - - - + + - Цвет кнопки + Цвет баннера setButtonBackgroundColor(color)} /> - Цвет текста кнопки + Цвет текста баннера setButtonTextColor(color)} /> + + + {buttonText || "Пройти тест"} + + {buttonFlash && } + + ); +} diff --git a/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup/ButtonWidgetPreviewMobile.tsx b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup/ButtonWidgetPreviewMobile.tsx new file mode 100644 index 00000000..e70eb7a6 --- /dev/null +++ b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup/ButtonWidgetPreviewMobile.tsx @@ -0,0 +1,47 @@ +import TaskIcon from "@/ui_kit/TaskIcon"; +import { Box } from "@mui/material"; + +interface Props { + fixedSide: "left" | "right"; + buttonBackgroundColor: string; + buttonTextColor: string; +} + +export default function ButtonWidgetPreviewMobile({ buttonBackgroundColor, fixedSide, buttonTextColor }: Props) { + return ( + + + + ); +} diff --git a/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup.tsx b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup/ButtonWidgetSetup.tsx similarity index 80% rename from src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup.tsx rename to src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup/ButtonWidgetSetup.tsx index dbf76127..86103443 100644 --- a/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup.tsx +++ b/src/pages/InstallQuiz/QuizInstallationCard/WidgetSetupByType/ButtonWidgetSetup/ButtonWidgetSetup.tsx @@ -21,11 +21,13 @@ import RadioIcon from "@ui_kit/RadioIcon"; import RunningStripe from "@ui_kit/RunningStripe"; import { nanoid } from "nanoid"; import { ReactNode, useState } from "react"; -import Dots from "../../../../assets/dots.png"; -import fixedButtonWidgetPreview from "../../../../assets/fixed-button-widget-preview.png"; -import WidgetScript from "../WidgetScript"; -import { createButtonWidgetScriptText } from "../createWidgetScriptText"; -import { useWidgetUrl } from "../useWidgetUrl"; +import Dots from "../../../../../assets/dots.png"; +import fixedButtonWidgetPreview from "../../../../../assets/fixed-button-widget-preview.png"; +import WidgetScript from "../../WidgetScript"; +import { createButtonWidgetScriptText } from "../../createWidgetScriptText"; +import { useWidgetUrl } from "../../useWidgetUrl"; +import ButtonWidgetPreviewDesktop from "./ButtonWidgetPreviewDesktop"; +import ButtonWidgetPreviewMobile from "./ButtonWidgetPreviewMobile"; interface Props { step: 2 | 3; @@ -180,14 +182,47 @@ export default function ButtonWidgetSetup({ step, nextButton }: Props) { pt: "40px", }} > - + > + + + + {!hideOnMobile && ( + + )} + + )} @@ -199,7 +234,10 @@ export default function ButtonWidgetSetup({ step, nextButton }: Props) { flex: "1 1 0", }} > - + 1. Задайте размеры окна квиза (опционально) - + 2. Конструктор кнопки Цвет кнопки - setButtonBackgroundColor(color)} /> + setButtonBackgroundColor(color)} + /> Цвет текста кнопки - setButtonTextColor(color)} /> + setButtonTextColor(color)} + /> setHideOnMobile(e.target.checked)} /> - setRounded(e.target.checked)} /> - setWithShadow(e.target.checked)} /> + setRounded(e.target.checked)} + /> + setWithShadow(e.target.checked)} + /> setFixedSide(e.target.checked ? "left" : null)} /> - {fixedSide && ( + } icon={} />} + control={ + } + icon={} + /> + } label="Слева" sx={{ color: theme.palette.grey2.main, @@ -294,7 +354,12 @@ export default function ButtonWidgetSetup({ step, nextButton }: Props) { /> } icon={} />} + control={ + } + icon={} + /> + } label="Справа" sx={{ color: theme.palette.grey2.main, @@ -302,7 +367,7 @@ export default function ButtonWidgetSetup({ step, nextButton }: Props) { /> - )} + Текст кнопки ; } -export default function BannerWidgetPreviewIcon({ sx = [] }: Props) { +export default function TaskIcon({ sx = [] }: Props) { return ( - +