frontAnswerer/lib/components/ViewPublicationPage/StartPageViewPublication/index.tsx

378 lines
12 KiB
TypeScript
Raw Normal View History

2024-02-28 14:10:50 +00:00
import {
Box,
Button,
ButtonBase,
Link,
Paper,
Typography,
useTheme,
} from "@mui/material";
import { QuizPreviewLayoutByType } from "./QuizPreviewLayoutByType";
2024-02-28 14:10:50 +00:00
import YoutubeEmbedIframe from "../tools/YoutubeEmbedIframe";
import { useQuizData } from "@contexts/QuizDataContext";
import { useRootContainerSize } from "@contexts/RootContainerWidthContext";
2024-02-28 14:10:50 +00:00
import { setCurrentQuizStep } from "@stores/quizView";
import { useUADevice } from "@utils/hooks/useUADevice";
import { quizThemes } from "@utils/themes/Publication/themePublication";
2024-03-01 14:08:09 +00:00
import { DESIGN_LIST } from "../Question";
import { NameplateLogo } from "@icons/NameplateLogo";
2024-02-28 14:10:50 +00:00
export const StartPageViewPublication = () => {
const theme = useTheme();
const { settings, show_badge, quizId } = useQuizData();
2024-02-28 14:10:50 +00:00
const { isMobileDevice } = useUADevice();
const isMobile = useRootContainerSize() < 700;
const isTablet = useRootContainerSize() < 800;
const handleCopyNumber = () => {
navigator.clipboard.writeText(settings.cfg.info.phonenumber);
};
const background =
settings.cfg.startpage.background.type === "image" ? (
2024-03-05 11:53:30 +00:00
<img
src={
settings.cfg.startpage.background.desktop ||
DESIGN_LIST[settings.cfg.theme] ||
""
}
alt=""
style={{
display: "block",
width:
isMobile || settings.cfg.startpageType === "expanded"
? "100%"
: undefined,
height: "100%",
minWidth: "100%",
2024-04-02 17:21:31 +00:00
maxHeight: "100%",
2024-03-05 11:53:30 +00:00
objectFit: "cover",
overflow: "hidden",
}}
/>
2024-02-28 14:10:50 +00:00
) : settings.cfg.startpage.background.type === "video" ? (
settings.cfg.startpage.background.video ? (
<YoutubeEmbedIframe
videoUrl={settings.cfg.startpage.background.video}
containerSX={{
width: settings.cfg.startpageType === "centered" ? "550px" : "100%",
height:
settings.cfg.startpageType === "centered" ? "275px" : "100%",
borderRadius:
settings.cfg.startpageType === "centered" ? "10px" : "0",
overflow: "hidden",
"& iframe": {
width: "100%",
height: "100%",
transform:
settings.cfg.startpageType === "centered"
? ""
: settings.cfg.startpageType === "expanded"
? "scale(1.5)"
: "scale(2.4)",
},
}}
/>
) : null
) : null;
return (
<Paper
className="settings-preview-draghandle"
sx={{
borderRadius: 0,
2024-04-02 17:03:19 +00:00
height: "100%",
2024-02-28 14:10:50 +00:00
width: "100%",
background:
settings.cfg.startpageType === "expanded"
? settings.cfg.startpage.position === "left"
? "linear-gradient(90deg,#272626,transparent)"
: settings.cfg.startpage.position === "center"
? "linear-gradient(180deg,transparent,#272626)"
: "linear-gradient(270deg,#272626,transparent)"
: theme.palette.background.default,
color: settings.cfg.startpageType === "expanded" ? "white" : "black",
}}
>
<QuizPreviewLayoutByType
quizHeaderBlock={
2024-02-29 13:44:45 +00:00
<Box
sx={{
margin:
settings.cfg.startpageType === "centered" ? "0 auto" : null,
padding: settings.cfg.startpageType === "standard" ? "" : "16px",
}}
>
2024-02-28 14:10:50 +00:00
<Box
sx={{
display: "flex",
alignItems: "center",
flexWrap: "wrap",
gap: "30px",
mb: "7px",
}}
>
2024-03-20 02:09:44 +00:00
{settings.cfg.startpage.logo &&
2024-02-28 14:10:50 +00:00
<img
src={settings.cfg.startpage.logo}
2024-02-28 14:10:50 +00:00
style={{
height: "40px",
maxWidth: "110px",
objectFit: "cover",
}}
alt=""
/>
2024-03-20 02:09:44 +00:00
}
2024-02-28 14:10:50 +00:00
<Typography
sx={{
fontSize: "14px",
color:
2024-02-29 13:44:45 +00:00
settings.cfg.startpageType === "expanded"
2024-02-28 14:10:50 +00:00
? "white"
: theme.palette.text.primary,
wordBreak: "break-word",
}}
>
{settings.cfg.info.orgname}
</Typography>
</Box>
</Box>
}
quizMainBlock={
<>
<Box
sx={{
display: "flex",
flexDirection: "column",
justifyContent: "center",
2024-02-29 13:44:45 +00:00
flexGrow: settings.cfg.startpageType === "centered" ? 0 : 1,
2024-02-28 14:10:50 +00:00
alignItems:
settings.cfg.startpageType === "centered"
? "center"
: settings.cfg.startpageType === "expanded"
? settings.cfg.startpage.position === "center"
? "center"
: "start"
: "start",
marginTop: "28px",
width: "100%",
}}
>
<Typography
sx={{
fontWeight: "bold",
fontSize: "26px",
fontStyle: "normal",
fontStretch: "normal",
lineHeight: "1.2",
overflowWrap: "break-word",
width: "100%",
textAlign:
settings.cfg.startpageType === "centered" ||
settings.cfg.startpage.position === "center"
? "center"
: "-moz-initial",
color:
2024-02-29 13:44:45 +00:00
settings.cfg.startpageType === "expanded"
2024-02-28 14:10:50 +00:00
? "white"
: theme.palette.text.primary,
}}
>
{settings.name}
</Typography>
<Typography
sx={{
fontSize: "16px",
margin: "16px 0 30px",
overflowWrap: "break-word",
width: "100%",
textAlign:
settings.cfg.startpageType === "centered" ||
settings.cfg.startpage.position === "center"
? "center"
: "-moz-initial",
color:
2024-02-29 13:44:45 +00:00
settings.cfg.startpageType === "expanded"
2024-02-28 14:10:50 +00:00
? "white"
: theme.palette.text.primary,
}}
>
{settings.cfg.startpage.description}
</Typography>
<Box
width={
settings.cfg.startpageType === "standard" ? "100%" : "auto"
}
>
<Button
variant="contained"
sx={{
fontSize: "18px",
padding: "10px 30px",
width: "auto",
2024-03-04 16:40:53 +00:00
background: theme.palette.primary.main,
2024-02-28 14:10:50 +00:00
}}
onClick={() => setCurrentQuizStep("question")}
>
{settings.cfg.startpage.button.trim()
? settings.cfg.startpage.button
: "Пройти тест"}
</Button>
</Box>
</Box>
<Box
sx={{
mt: "46px",
display: "flex",
2024-02-29 13:44:45 +00:00
flexGrow:
settings.cfg.startpageType === "centered"
? isMobile
? 0
: 1
: 0,
2024-02-28 14:10:50 +00:00
gap: "20px",
alignItems: "flex-end",
justifyContent: "space-between",
width: "100%",
flexWrap: "wrap",
}}
>
2024-02-29 13:44:45 +00:00
<Box sx={{ maxWidth: "300px" }}>
2024-02-28 14:10:50 +00:00
{settings.cfg.info.site && (
<Link mb="16px" href={settings.cfg.info.site}>
<Typography
sx={{
fontSize: "16px",
2024-03-04 16:40:53 +00:00
color: theme.palette.primary.main,
2024-02-28 14:10:50 +00:00
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
maxWidth: isTablet ? "200px" : "300px",
}}
>
{settings.cfg.info.site}
</Typography>
</Link>
)}
{settings.cfg.info.clickable ? (
isMobileDevice ? (
<Link href={`tel:${settings.cfg.info.phonenumber}`}>
2024-03-04 16:40:53 +00:00
<Typography
sx={{
fontSize: "16px",
2024-03-05 14:29:52 +00:00
color:
settings.cfg.startpageType === "expanded"
? "#FFFFFF"
: theme.palette.text.primary,
2024-03-04 16:40:53 +00:00
}}
>
2024-02-28 14:10:50 +00:00
{settings.cfg.info.phonenumber}
</Typography>
</Link>
) : (
<ButtonBase onClick={handleCopyNumber}>
2024-03-04 16:40:53 +00:00
<Typography
sx={{
fontSize: "16px",
2024-03-05 14:29:52 +00:00
color:
settings.cfg.startpageType === "expanded"
? "#FFFFFF"
: theme.palette.text.primary,
2024-03-04 16:40:53 +00:00
}}
>
2024-02-28 14:10:50 +00:00
{settings.cfg.info.phonenumber}
</Typography>
</ButtonBase>
)
) : (
2024-03-04 16:40:53 +00:00
<Typography
sx={{
fontSize: "16px",
marginTop: "5px",
2024-03-05 14:29:52 +00:00
color:
settings.cfg.startpageType === "expanded"
? "#FFFFFF"
: theme.palette.text.primary,
2024-03-04 16:40:53 +00:00
}}
>
2024-02-28 14:10:50 +00:00
{settings.cfg.info.phonenumber}
</Typography>
)}
<Typography
sx={{
width: "100%",
overflowWrap: "break-word",
fontSize: "12px",
maxHeight: "120px",
overflow: "auto",
marginTop: "5px",
"&::-webkit-scrollbar": { width: 0 },
color:
2024-02-29 13:44:45 +00:00
settings.cfg.startpageType === "expanded"
2024-02-28 14:10:50 +00:00
? "white"
: theme.palette.text.primary,
}}
>
{settings.cfg.info.law}
</Typography>
</Box>
2024-03-07 13:20:02 +00:00
{show_badge && (
<Box
component={Link}
target={"_blank"}
href={
`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`
}
2024-02-28 14:10:50 +00:00
sx={{
2024-03-07 13:20:02 +00:00
display: "flex",
alignItems: "center",
gap: "15px",
textDecoration: "none",
2024-02-28 14:10:50 +00:00
}}
>
2024-03-07 13:20:02 +00:00
<NameplateLogo
style={{
fontSize: "23px",
2024-03-07 13:20:02 +00:00
color:
settings.cfg.startpageType === "expanded"
? "#FFFFFF"
: quizThemes[settings.cfg.theme].isLight
? "#151515"
: "#FFFFFF",
}}
/>
<Typography
sx={{
fontSize: "14px",
2024-03-07 13:20:02 +00:00
color:
settings.cfg.startpageType === "expanded"
? "#F5F7FF"
: quizThemes[settings.cfg.theme].isLight
? "#4D4D4D"
: "#F5F7FF",
whiteSpace: "nowrap",
}}
>
Сделано на PenaQuiz
</Typography>
</Box>
)}
2024-02-28 14:10:50 +00:00
</Box>
</>
}
backgroundBlock={background}
startpageType={settings.cfg.startpageType}
alignType={settings.cfg.startpage.position}
/>
</Paper>
);
};