quiz is fullscreen when viewport width is small
This commit is contained in:
parent
ffc8b5e9cb
commit
b421e6eed3
@ -1,5 +1,5 @@
|
||||
import lightTheme from "@/utils/themes/light";
|
||||
import { Button, ThemeProvider } from "@mui/material";
|
||||
import { Button, ThemeProvider, useMediaQuery } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import QuizDialog from "../QuizDialog";
|
||||
@ -15,6 +15,7 @@ interface Props {
|
||||
|
||||
export default function QuizSideButton({ quizId, position, buttonBackgroundColor }: Props) {
|
||||
const [isQuizShown, setIsQuizShown] = useState<boolean>(false);
|
||||
const isMobile = useMediaQuery("(max-width: 600px)");
|
||||
|
||||
return createPortal(
|
||||
<ThemeProvider theme={lightTheme}>
|
||||
@ -24,15 +25,26 @@ export default function QuizSideButton({ quizId, position, buttonBackgroundColor
|
||||
onClose={() => setIsQuizShown(false)}
|
||||
hideBackdrop
|
||||
disableScrollLock
|
||||
paperSx={{
|
||||
position: "absolute",
|
||||
bottom: PADDING,
|
||||
right: position === "right" ? PADDING : undefined,
|
||||
left: position === "left" ? PADDING : undefined,
|
||||
height: `calc(min(calc(100% - ${PADDING * 2}px), 800px))`,
|
||||
width: `calc(min(calc(100% - ${PADDING * 2}px), 600px))`,
|
||||
m: 0,
|
||||
}}
|
||||
paperSx={[
|
||||
{
|
||||
m: 0,
|
||||
},
|
||||
!isMobile && {
|
||||
position: "absolute",
|
||||
bottom: PADDING,
|
||||
right: position === "right" ? PADDING : undefined,
|
||||
left: position === "left" ? PADDING : undefined,
|
||||
height: `calc(min(calc(100% - ${PADDING * 2}px), 800px))`,
|
||||
width: `calc(min(calc(100% - ${PADDING * 2}px), 600px))`,
|
||||
},
|
||||
isMobile && {
|
||||
position: "relative",
|
||||
height: "100%",
|
||||
maxHeight: "100%",
|
||||
width: "100%",
|
||||
borderRadius: 0,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Button
|
||||
className="pena-quiz-widget-button"
|
||||
|
Loading…
Reference in New Issue
Block a user