feat: new design

This commit is contained in:
IlyaDoronin 2024-02-27 18:29:26 +03:00
parent 02041e2f88
commit 112d13acd0
2 changed files with 542 additions and 460 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@ -1,4 +1,12 @@
import { Box, Button, ButtonBase, Link, Paper, Typography, useTheme } from "@mui/material"; import {
Box,
Button,
ButtonBase,
Link,
Paper,
Typography,
useTheme,
} from "@mui/material";
import { useUADevice } from "../../utils/hooks/useUADevice"; import { useUADevice } from "../../utils/hooks/useUADevice";
import { notReachable } from "../../utils/notReachable"; import { notReachable } from "../../utils/notReachable";
import YoutubeEmbedIframe from "./tools/YoutubeEmbedIframe"; import YoutubeEmbedIframe from "./tools/YoutubeEmbedIframe";
@ -10,6 +18,7 @@ import { quizThemes } from "@utils/themes/Publication/themePublication";
import { useRootContainerSize } from "../../contexts/RootContainerWidthContext"; import { useRootContainerSize } from "../../contexts/RootContainerWidthContext";
import { setCurrentQuizStep } from "@stores/quizView"; import { setCurrentQuizStep } from "@stores/quizView";
import PenaLogo from "@icons/PenaLogo.png";
export const StartPageViewPublication = () => { export const StartPageViewPublication = () => {
const theme = useTheme(); const theme = useTheme();
@ -30,7 +39,10 @@ export const StartPageViewPublication = () => {
src={settings.cfg.startpage.background.desktop} src={settings.cfg.startpage.background.desktop}
alt="" alt=""
style={{ style={{
width: (isMobile || settings.cfg.startpageType === "expanded") ? "100%" : undefined, width:
isMobile || settings.cfg.startpageType === "expanded"
? "100%"
: undefined,
height: "100%", height: "100%",
objectFit: "cover", objectFit: "cover",
overflow: "hidden", overflow: "hidden",
@ -42,15 +54,11 @@ export const StartPageViewPublication = () => {
<YoutubeEmbedIframe <YoutubeEmbedIframe
videoUrl={settings.cfg.startpage.background.video} videoUrl={settings.cfg.startpage.background.video}
containerSX={{ containerSX={{
width: width: settings.cfg.startpageType === "centered" ? "550px" : "100%",
settings.cfg.startpageType === "centered"
? "550px"
: "100%",
height: height:
settings.cfg.startpageType === "centered" settings.cfg.startpageType === "centered" ? "275px" : "100%",
? "275px" borderRadius:
: "100%", settings.cfg.startpageType === "centered" ? "10px" : "0",
borderRadius: settings.cfg.startpageType === "centered" ? "10px" : "0",
overflow: "hidden", overflow: "hidden",
"& iframe": { "& iframe": {
width: "100%", width: "100%",
@ -73,6 +81,7 @@ export const StartPageViewPublication = () => {
sx={{ sx={{
borderRadius: 0, borderRadius: 0,
height: "100%", height: "100%",
minHeight: "100vh",
width: "100%", width: "100%",
background: background:
settings.cfg.startpageType === "expanded" && !isMobile settings.cfg.startpageType === "expanded" && !isMobile
@ -93,43 +102,32 @@ export const StartPageViewPublication = () => {
sx={{ sx={{
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
gap: "20px", gap: "30px",
mb: "7px", mb: "7px",
}} }}
> >
{settings.cfg.startpage.logo && (
<img <img
src={settings.cfg.startpage.logo} src={settings.cfg.startpage.logo || PenaLogo}
style={{ style={{
height: "37px", height: "40px",
maxWidth: "43px", maxWidth: "110px",
objectFit: "cover", objectFit: "cover",
}} }}
alt="" alt=""
/> />
)}
<Typography <Typography
sx={{ sx={{
fontSize: "14px", fontSize: "14px",
color: settings.cfg.startpageType === "expanded" color:
&& !isMobile ? "white" : theme.palette.text.primary, settings.cfg.startpageType === "expanded" && !isMobile
wordBreak: "break-word" ? "white"
: theme.palette.text.primary,
wordBreak: "break-word",
}} }}
>{settings.cfg.info.orgname}</Typography> >
</Box> {settings.cfg.info.orgname}
<Link mb="16px" href={settings.cfg.info.site}>
<Typography
sx={{
fontSize: "16px",
color: theme.palette.primary.main,
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
maxWidth: isTablet ? "200px" : "300px"
}}>
{settings.cfg.info.site}
</Typography> </Typography>
</Link> </Box>
</Box> </Box>
} }
quizMainBlock={ quizMainBlock={
@ -160,8 +158,15 @@ export const StartPageViewPublication = () => {
lineHeight: "1.2", lineHeight: "1.2",
overflowWrap: "break-word", overflowWrap: "break-word",
width: "100%", width: "100%",
textAlign: settings.cfg.startpageType === "centered" || settings.cfg.startpage.position === "center" ? "center" : "-moz-initial", textAlign:
color: settings.cfg.startpageType === "expanded" && !isMobile ? "white" : theme.palette.text.primary settings.cfg.startpageType === "centered" ||
settings.cfg.startpage.position === "center"
? "center"
: "-moz-initial",
color:
settings.cfg.startpageType === "expanded" && !isMobile
? "white"
: theme.palette.text.primary,
}} }}
> >
{settings.name} {settings.name}
@ -169,26 +174,40 @@ export const StartPageViewPublication = () => {
<Typography <Typography
sx={{ sx={{
fontSize: "16px", fontSize: "16px",
m: "16px 0", margin: "16px 0 30px",
overflowWrap: "break-word", overflowWrap: "break-word",
width: "100%", width: "100%",
textAlign: settings.cfg.startpageType === "centered" || settings.cfg.startpage.position === "center" ? "center" : "-moz-initial", textAlign:
color: settings.cfg.startpageType === "expanded" && !isMobile ? "white" : theme.palette.text.primary settings.cfg.startpageType === "centered" ||
settings.cfg.startpage.position === "center"
? "center"
: "-moz-initial",
color:
settings.cfg.startpageType === "expanded" && !isMobile
? "white"
: theme.palette.text.primary,
}} }}
> >
{settings.cfg.startpage.description} {settings.cfg.startpage.description}
</Typography> </Typography>
<Box width={settings.cfg.startpageType === "standard" ? "100%" : "auto"}> <Box
width={
settings.cfg.startpageType === "standard" ? "100%" : "auto"
}
>
<Button <Button
variant="contained" variant="contained"
sx={{ sx={{
fontSize: "16px", fontSize: "18px",
padding: "10px 15px", padding: "10px 30px",
width: settings.cfg.startpageType === "standard" ? "100%" : "auto", width: "auto",
background: "#7E2AEA",
}} }}
onClick={() => setCurrentQuizStep("question")} onClick={() => setCurrentQuizStep("question")}
> >
{settings.cfg.startpage.button.trim() ? settings.cfg.startpage.button : "Пройти тест"} {settings.cfg.startpage.button.trim()
? settings.cfg.startpage.button
: "Пройти тест"}
</Button> </Button>
</Box> </Box>
</Box> </Box>
@ -197,45 +216,85 @@ export const StartPageViewPublication = () => {
sx={{ sx={{
mt: "46px", mt: "46px",
display: "flex", display: "flex",
alignItems: "center", gap: "20px",
alignItems: "flex-end",
justifyContent: "space-between", justifyContent: "space-between",
width: "100%", width: "100%",
flexDirection: "column" flexWrap: "wrap",
}} }}
> >
<Box sx={{ maxWidth: isTablet ? "240px" : "300px", marginBottom: "10px", }}> <Box
sx={{
maxWidth: isTablet ? "240px" : "300px",
marginBottom: "10px",
}}
>
{settings.cfg.info.site && (
<Link mb="16px" href={settings.cfg.info.site}>
<Typography
sx={{
fontSize: "16px",
color: "#7E2AEA",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
maxWidth: isTablet ? "200px" : "300px",
}}
>
{settings.cfg.info.site}
</Typography>
</Link>
)}
{settings.cfg.info.clickable ? ( {settings.cfg.info.clickable ? (
isMobileDevice ? ( isMobileDevice ? (
<Link href={`tel:${settings.cfg.info.phonenumber}`}> <Link href={`tel:${settings.cfg.info.phonenumber}`}>
<Typography sx={{ fontSize: "16px", color: theme.palette.primary.main }}> <Typography
sx={{
fontSize: "16px",
color: theme.palette.primary.main,
}}
>
{settings.cfg.info.phonenumber} {settings.cfg.info.phonenumber}
</Typography> </Typography>
</Link> </Link>
) : ( ) : (
<ButtonBase onClick={handleCopyNumber}> <ButtonBase onClick={handleCopyNumber}>
<Typography sx={{ fontSize: "16px", color: theme.palette.primary.main }}> <Typography
sx={{
fontSize: "16px",
color: theme.palette.primary.main,
}}
>
{settings.cfg.info.phonenumber} {settings.cfg.info.phonenumber}
</Typography> </Typography>
</ButtonBase> </ButtonBase>
) )
) : ( ) : (
<Typography sx={{ fontSize: "16px", color: theme.palette.primary.main }}> <Typography
sx={{
fontSize: "16px",
color: theme.palette.primary.main,
marginTop: "5px",
}}
>
{settings.cfg.info.phonenumber} {settings.cfg.info.phonenumber}
</Typography> </Typography>
)} )}
<Typography sx={{ <Typography
sx={{
width: "100%", width: "100%",
overflowWrap: "break-word", overflowWrap: "break-word",
fontSize: "12px", fontSize: "12px",
textAlign: "end",
maxHeight: "120px", maxHeight: "120px",
overflow: "auto", overflow: "auto",
marginTop: "5px",
"&::-webkit-scrollbar": { width: 0 }, "&::-webkit-scrollbar": { width: 0 },
color: color:
settings.cfg.startpageType === "expanded" && !isMobile settings.cfg.startpageType === "expanded" && !isMobile
? "white" ? "white"
: theme.palette.text.primary, : theme.palette.text.primary,
}}> }}
>
{settings.cfg.info.law} {settings.cfg.info.law}
</Typography> </Typography>
</Box> </Box>
@ -248,11 +307,32 @@ export const StartPageViewPublication = () => {
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
gap: "15px", gap: "15px",
textDecoration: "none" textDecoration: "none",
}}
>
<NameplateLogo
style={{
fontSize: "34px",
color:
settings.cfg.startpageType === "expanded" && !isMobile
? "#FFFFFF"
: quizThemes[settings.cfg.theme].isLight
? "#151515"
: "#FFFFFF",
}}
/>
<Typography
sx={{
fontSize: "20px",
color:
settings.cfg.startpageType === "expanded" && !isMobile
? "#F5F7FF"
: quizThemes[settings.cfg.theme].isLight
? "#4D4D4D"
: "#F5F7FF",
whiteSpace: "nowrap",
}} }}
> >
<NameplateLogo style={{ fontSize: "34px", color: settings.cfg.startpageType === "expanded" && !isMobile ? "#FFFFFF" : (quizThemes[settings.cfg.theme].isLight ? "#151515" : "#FFFFFF") }} />
<Typography sx={{ fontSize: "20px", color: settings.cfg.startpageType === "expanded" && !isMobile ? "#F5F7FF" : (quizThemes[settings.cfg.theme].isLight ? "#4D4D4D" : "#F5F7FF"), whiteSpace: "nowrap", }}>
Сделано на PenaQuiz Сделано на PenaQuiz
</Typography> </Typography>
</Box> </Box>
@ -267,7 +347,6 @@ export const StartPageViewPublication = () => {
); );
}; };
function QuizPreviewLayoutByType({ function QuizPreviewLayoutByType({
quizHeaderBlock, quizHeaderBlock,
quizMainBlock, quizMainBlock,
@ -291,6 +370,7 @@ function QuizPreviewLayoutByType({
flexDirection: "column-reverse", flexDirection: "column-reverse",
flexGrow: 1, flexGrow: 1,
justifyContent: "flex-end", justifyContent: "flex-end",
minHeight: "100vh",
height: "100%", height: "100%",
"&::-webkit-scrollbar": { width: 0 }, "&::-webkit-scrollbar": { width: 0 },
}} }}
@ -311,7 +391,7 @@ function QuizPreviewLayoutByType({
}, },
"&::-webkit-scrollbar-thumb": { "&::-webkit-scrollbar-thumb": {
backgroundColor: "#b8babf", backgroundColor: "#b8babf",
} },
}} }}
> >
{quizHeaderBlock} {quizHeaderBlock}
@ -321,7 +401,7 @@ function QuizPreviewLayoutByType({
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
justifyContent: "space-between", justifyContent: "space-between",
width: "100%" width: "100%",
}} }}
> >
{quizMainBlock} {quizMainBlock}
@ -351,12 +431,18 @@ function QuizPreviewLayoutByType({
id="pain" id="pain"
sx={{ sx={{
display: "flex", display: "flex",
flexDirection: alignType === "left" ? (isMobile ? "column-reverse" : "row") : "row-reverse", flexDirection:
alignType === "left"
? isMobile
? "column-reverse"
: "row"
: "row-reverse",
flexGrow: 1, flexGrow: 1,
justifyContent: isMobile ? "flex-end" : undefined, justifyContent: isMobile ? "flex-end" : undefined,
height: "100%", height: "100%",
minHeight: "100vh",
"&::-webkit-scrollbar": { width: 0 }, "&::-webkit-scrollbar": { width: 0 },
overflow: "auto" overflow: "auto",
}} }}
> >
<Box <Box
@ -367,7 +453,7 @@ function QuizPreviewLayoutByType({
justifyContent: "space-between", justifyContent: "space-between",
alignItems: "flex-start", alignItems: "flex-start",
p: "25px", p: "25px",
height: isMobile ? "80%" : undefined height: isMobile ? "80%" : undefined,
}} }}
> >
{quizHeaderBlock} {quizHeaderBlock}
@ -384,9 +470,7 @@ function QuizPreviewLayoutByType({
</Box> </Box>
</Box> </Box>
)} )}
</> </>
); );
} }
case "expanded": { case "expanded": {
@ -435,10 +519,8 @@ function QuizPreviewLayoutByType({
{backgroundBlock} {backgroundBlock}
</Box> </Box>
</Box> </Box>
) )}
}
</> </>
); );
} }
case "centered": { case "centered": {
@ -467,7 +549,7 @@ function QuizPreviewLayoutByType({
height: "275px", height: "275px",
// overflow: "hidden", // overflow: "hidden",
display: "flex", display: "flex",
justifyContent: "center" justifyContent: "center",
}} }}
> >
{backgroundBlock} {backgroundBlock}
@ -475,10 +557,8 @@ function QuizPreviewLayoutByType({
)} )}
{quizMainBlock} {quizMainBlock}
</Box> </Box>
) )}
}
</> </>
); );
} }
default: default:
@ -486,8 +566,10 @@ function QuizPreviewLayoutByType({
} }
} }
const startpageAlignTypeToJustifyContent: Record<
const startpageAlignTypeToJustifyContent: Record<QuizStartpageAlignType, "start" | "center" | "end"> = { QuizStartpageAlignType,
"start" | "center" | "end"
> = {
left: "start", left: "start",
center: "center", center: "center",
right: "end", right: "end",