2024-04-29 12:45:33 +00:00
|
|
|
import {Box} from "@mui/material";
|
2024-02-28 14:10:50 +00:00
|
|
|
|
2024-04-29 12:45:33 +00:00
|
|
|
import {useQuizData} from "@contexts/QuizDataContext";
|
2024-03-06 15:45:45 +00:00
|
|
|
|
2024-04-29 12:45:33 +00:00
|
|
|
import {notReachable} from "@utils/notReachable";
|
|
|
|
import {quizThemes} from "@utils/themes/Publication/themePublication";
|
2024-02-29 13:44:45 +00:00
|
|
|
|
2024-04-29 12:45:33 +00:00
|
|
|
import type {QuizStartpageType} from "@model/settingsData";
|
|
|
|
import {DESIGN_LIST} from "@/utils/designList";
|
2024-02-29 08:13:51 +00:00
|
|
|
|
2024-02-28 14:10:50 +00:00
|
|
|
type StartPageMobileProps = {
|
2024-05-10 13:38:01 +00:00
|
|
|
quizHeaderBlock: JSX.Element;
|
|
|
|
quizMainBlock: JSX.Element;
|
|
|
|
backgroundBlock: JSX.Element | null;
|
|
|
|
startpageType: QuizStartpageType;
|
2024-02-28 14:10:50 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 13:44:45 +00:00
|
|
|
type MobileLayoutProps = Omit<StartPageMobileProps, "startpageType">;
|
|
|
|
|
|
|
|
const StandartMobileLayout = ({
|
2024-05-10 13:38:01 +00:00
|
|
|
quizHeaderBlock,
|
|
|
|
quizMainBlock,
|
|
|
|
backgroundBlock,
|
|
|
|
}: MobileLayoutProps) => {
|
|
|
|
const {settings} = useQuizData();
|
2024-03-06 15:45:45 +00:00
|
|
|
|
2024-05-10 13:38:01 +00:00
|
|
|
return (
|
2024-03-06 15:45:45 +00:00
|
|
|
<Box
|
2024-05-10 13:38:01 +00:00
|
|
|
sx={{
|
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column",
|
|
|
|
flexGrow: 1,
|
|
|
|
justifyContent: "flex-end",
|
|
|
|
minHeight: "100%",
|
|
|
|
height: "100%",
|
|
|
|
"&::-webkit-scrollbar": {width: 0},
|
|
|
|
backgroundPosition: "center",
|
|
|
|
backgroundSize: "cover",
|
|
|
|
backgroundImage: settings.cfg.design
|
|
|
|
? `url(${DESIGN_LIST[settings.cfg.theme]})`
|
|
|
|
: null,
|
|
|
|
}}
|
2024-03-06 15:45:45 +00:00
|
|
|
>
|
2024-05-10 13:38:01 +00:00
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
width: "100%",
|
|
|
|
display: "flex",
|
|
|
|
flexGrow: 1,
|
|
|
|
flexDirection: "column",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
alignItems: "flex-start",
|
|
|
|
p: "20px",
|
|
|
|
height: "100%",
|
|
|
|
overflowY: "auto",
|
|
|
|
overflowX: "hidden",
|
|
|
|
background:
|
|
|
|
settings.cfg.design && !quizThemes[settings.cfg.theme].isLight
|
|
|
|
? "linear-gradient(90deg,#272626,transparent)"
|
|
|
|
: null,
|
|
|
|
"&::-webkit-scrollbar": {
|
|
|
|
width: "4px",
|
|
|
|
},
|
|
|
|
"&::-webkit-scrollbar-thumb": {
|
|
|
|
backgroundColor: "#b8babf",
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Box sx={{marginBottom: "13px"}}>
|
|
|
|
{quizHeaderBlock}
|
|
|
|
</Box>
|
|
|
|
{settings.cfg.startpage.background.desktop && (
|
|
|
|
<Box sx={{width: "100%", overflow: "hidden"}}>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
display: "flex",
|
|
|
|
justifyContent: "center",
|
|
|
|
"& > img": {
|
|
|
|
width: "100%",
|
|
|
|
borderRadius: "12px"
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{backgroundBlock}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
)}
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
height: "80%",
|
|
|
|
display: "flex",
|
|
|
|
flexGrow: 1,
|
|
|
|
flexDirection: "column",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
width: "100%",
|
|
|
|
marginTop: "30px"
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{quizMainBlock}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
2024-03-06 15:45:45 +00:00
|
|
|
</Box>
|
2024-05-10 13:38:01 +00:00
|
|
|
);
|
2024-03-06 15:45:45 +00:00
|
|
|
};
|
2024-02-29 13:44:45 +00:00
|
|
|
|
|
|
|
const ExpandedMobileLayout = ({
|
2024-05-10 13:38:01 +00:00
|
|
|
quizHeaderBlock,
|
|
|
|
quizMainBlock,
|
|
|
|
backgroundBlock,
|
|
|
|
}: MobileLayoutProps) => (
|
2024-02-29 13:44:45 +00:00
|
|
|
<Box
|
|
|
|
sx={{
|
2024-05-10 13:38:01 +00:00
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column-reverse",
|
|
|
|
flexGrow: 1,
|
|
|
|
justifyContent: "flex-end",
|
|
|
|
minHeight: "100%",
|
|
|
|
height: "100%",
|
|
|
|
"&::-webkit-scrollbar": {width: 0},
|
2024-02-28 14:10:50 +00:00
|
|
|
}}
|
2024-02-29 13:44:45 +00:00
|
|
|
>
|
2024-05-10 13:38:01 +00:00
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
zIndex: 3,
|
|
|
|
width: "100%",
|
|
|
|
display: "flex",
|
|
|
|
flexGrow: 1,
|
|
|
|
flexDirection: "column",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
alignItems: "flex-start",
|
|
|
|
height: "100%",
|
|
|
|
overflowY: "auto",
|
|
|
|
overflowX: "hidden",
|
|
|
|
"&::-webkit-scrollbar": {width: "4px"},
|
|
|
|
"&::-webkit-scrollbar-thumb": {backgroundColor: "#b8babf"},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
padding: "20px",
|
|
|
|
height: "80%",
|
|
|
|
display: "flex",
|
|
|
|
flexGrow: 1,
|
|
|
|
flexDirection: "column",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
width: "100%",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{quizHeaderBlock}
|
|
|
|
{quizMainBlock}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
zIndex: -1,
|
|
|
|
position: "absolute",
|
|
|
|
left: 0,
|
|
|
|
top: 0,
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
// minHeight: "100%",
|
|
|
|
overflow: "hidden",
|
|
|
|
"& > img": {
|
|
|
|
display: "block",
|
|
|
|
minHeight: "100%",
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{backgroundBlock}
|
|
|
|
</Box>
|
2024-02-29 13:44:45 +00:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
|
|
|
const CenteredMobileLayout = ({
|
2024-05-10 13:38:01 +00:00
|
|
|
quizHeaderBlock,
|
|
|
|
quizMainBlock,
|
|
|
|
backgroundBlock,
|
|
|
|
}: MobileLayoutProps) => {
|
2024-03-07 20:52:54 +00:00
|
|
|
const {settings} = useQuizData();
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
display: "flex",
|
|
|
|
flexDirection: "column-reverse",
|
|
|
|
flexGrow: 1,
|
|
|
|
justifyContent: "flex-end",
|
2024-04-02 17:21:31 +00:00
|
|
|
minHeight: "100%",
|
2024-03-07 20:52:54 +00:00
|
|
|
height: "100%",
|
|
|
|
backgroundPosition: "center",
|
|
|
|
backgroundSize: "cover",
|
2024-05-10 13:38:01 +00:00
|
|
|
backgroundImage: !settings.cfg.design ? null : settings.cfg.design && !quizThemes[settings.cfg.theme].isLight
|
|
|
|
? `linear-gradient(0deg, #272626, transparent), url(${DESIGN_LIST[settings.cfg.theme]})` : `url(${DESIGN_LIST[settings.cfg.theme]})`,
|
2024-03-07 20:52:54 +00:00
|
|
|
"&::-webkit-scrollbar": {width: 0},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
width: "100%",
|
|
|
|
display: "flex",
|
|
|
|
flexGrow: 1,
|
|
|
|
flexDirection: "column",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
alignItems: "flex-start",
|
2024-05-02 23:05:39 +00:00
|
|
|
padding: "20px",
|
2024-03-07 20:52:54 +00:00
|
|
|
height: "100%",
|
|
|
|
overflowY: "auto",
|
|
|
|
overflowX: "hidden",
|
|
|
|
"&::-webkit-scrollbar": {width: "4px"},
|
|
|
|
"&::-webkit-scrollbar-thumb": {backgroundColor: "#b8babf"},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{quizHeaderBlock}
|
|
|
|
{settings.cfg.startpage.background.desktop && (
|
|
|
|
<Box
|
2024-05-10 13:38:01 +00:00
|
|
|
sx={{
|
|
|
|
width: "100%",
|
|
|
|
overflow: "hidden",
|
|
|
|
"& > img": {width: "100%", borderRadius: "12px"},
|
|
|
|
}}
|
2024-03-07 20:52:54 +00:00
|
|
|
>
|
|
|
|
{backgroundBlock}
|
|
|
|
</Box>
|
|
|
|
)}
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
height: "80%",
|
|
|
|
display: "flex",
|
|
|
|
flexGrow: 1,
|
|
|
|
flexDirection: "column",
|
|
|
|
justifyContent: "space-between",
|
|
|
|
width: "100%",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{quizMainBlock}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
2024-02-29 13:44:45 +00:00
|
|
|
|
|
|
|
export const StartPageMobile = ({
|
2024-05-10 13:38:01 +00:00
|
|
|
quizHeaderBlock,
|
|
|
|
quizMainBlock,
|
|
|
|
backgroundBlock,
|
|
|
|
startpageType,
|
|
|
|
}: StartPageMobileProps) => {
|
|
|
|
switch (startpageType) {
|
|
|
|
case null:
|
|
|
|
case "standard": {
|
|
|
|
return (
|
|
|
|
<StandartMobileLayout
|
|
|
|
quizHeaderBlock={quizHeaderBlock}
|
|
|
|
quizMainBlock={quizMainBlock}
|
|
|
|
backgroundBlock={backgroundBlock}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2024-02-29 13:44:45 +00:00
|
|
|
|
2024-05-10 13:38:01 +00:00
|
|
|
case "expanded": {
|
|
|
|
return (
|
|
|
|
<ExpandedMobileLayout
|
|
|
|
quizHeaderBlock={quizHeaderBlock}
|
|
|
|
quizMainBlock={quizMainBlock}
|
|
|
|
backgroundBlock={backgroundBlock}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2024-02-29 13:44:45 +00:00
|
|
|
|
2024-05-10 13:38:01 +00:00
|
|
|
case "centered": {
|
|
|
|
return (
|
|
|
|
<CenteredMobileLayout
|
|
|
|
quizHeaderBlock={quizHeaderBlock}
|
|
|
|
quizMainBlock={quizMainBlock}
|
|
|
|
backgroundBlock={backgroundBlock}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2024-02-29 13:44:45 +00:00
|
|
|
|
2024-05-10 13:38:01 +00:00
|
|
|
default:
|
|
|
|
notReachable(startpageType);
|
|
|
|
}
|
2024-02-28 14:10:50 +00:00
|
|
|
};
|