Merge branch 'fixes' into dev

This commit is contained in:
Nastya 2024-01-04 21:38:54 +03:00
commit 69c975e1f4
3 changed files with 88 additions and 23 deletions

@ -84,6 +84,8 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => {
) : null ) : null
) : null; ) : null;
console.log(background)
return ( return (
<Paper <Paper
className="quiz-preview-draghandle" className="quiz-preview-draghandle"

@ -6,16 +6,24 @@ import ArrowLeft from "@icons/ArrowLeftSP";
import LayoutCenteredIcon from "@icons/LayoutCenteredIcon"; import LayoutCenteredIcon from "@icons/LayoutCenteredIcon";
import LayoutExpandedIcon from "@icons/LayoutExpandedIcon"; import LayoutExpandedIcon from "@icons/LayoutExpandedIcon";
import LayoutStandartIcon from "@icons/LayoutStandartIcon"; import LayoutStandartIcon from "@icons/LayoutStandartIcon";
import UploadIcon from "../../assets/icons/UploadIcon";
import MobilePhoneIcon from "@icons/MobilePhoneIcon"; import MobilePhoneIcon from "@icons/MobilePhoneIcon";
import { QuizStartpageType } from "@model/quizSettings"; import { QuizStartpageType } from "@model/quizSettings";
import InfoIcon from "@icons/InfoIcon";
import UploadBox from "@ui_kit/UploadBox";
import { import {
Box, Box,
Button, Button,
ButtonBase,
Checkbox, Checkbox,
FormControl, FormControl,
FormControlLabel, FormControlLabel,
MenuItem, MenuItem,
Select, Select,
Tooltip,
Typography, Typography,
useMediaQuery, useMediaQuery,
useTheme, useTheme,
@ -294,6 +302,7 @@ export default function StartPageSettings() {
</SelectableButton> </SelectableButton>
</Box> </Box>
{quiz.config.startpage.background.type === "image" &&
<Box <Box
sx={{ sx={{
display: display:
@ -348,27 +357,67 @@ export default function StartPageSettings() {
<ModalSizeImage /> <ModalSizeImage />
</Box> </Box>
<Box }
sx={{
display:
quiz.config.startpage.background.type === "image"
? "none"
: "flex",
flexDirection: "column",
mt: "20px",
}}
>
<CustomTextField
placeholder="URL видео"
value={quiz.config.startpage.background.video ?? ""}
onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.background.video = e.target.value;
})
}
/>
</Box>
{quiz.config.startpage.background.type === "video" && <>
<Box
sx={{
display: "flex",
alignItems: "center",
gap: "7px",
mt: "20px",
mb: "14px",
}}
>
<Typography
sx={{ fontWeight: 500, color: theme.palette.grey3.main }}
>
Добавить видео
</Typography>
<Tooltip title="Можно загрузить видео." placement="top">
<Box>
<InfoIcon />
</Box>
</Tooltip>
</Box>
<ButtonBase
component="label"
sx={{ justifyContent: "center",
height: "48px",
width: "48px",
display: "flex",
alignItems: "center",
my: "20px"
}}
>
<input
onChange={(event) => {
const file = event.target.files?.[0];
if (file) {
uploadQuizImage(quiz.id, file, (quiz, url) => {
quiz.config.startpage.background.video = url;
});
// setVideo(URL.createObjectURL(file));
}
}}
hidden
accept=".mp4"
multiple
type="file"
/>
<UploadBox
icon={<UploadIcon />}
sx={{
height: "48px",
width: "48px",
}}
/>
</ButtonBase>
{quiz.config.startpage.background.video ? <video src={quiz.config.startpage.background.video} width="400" controls /> : null}
</>}
{designType !== "centered" && ( {designType !== "centered" && (
<> <>
<Typography <Typography

@ -6,14 +6,16 @@ interface Props {
} }
export default function YoutubeEmbedIframe({ videoUrl, containerSX }: Props) { export default function YoutubeEmbedIframe({ videoUrl, containerSX }: Props) {
const extractYoutubeVideoId = const extractYoutubeVideoId =
/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/gi; /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/gi;
const videoId = extractYoutubeVideoId.exec(videoUrl)?.[1]; const videoId = extractYoutubeVideoId.exec(videoUrl)?.[1];
if (!videoId) return null; // if (!videoId) return null;
const embedUrl = `https://www.youtube.com/embed/${videoId}?controls=0&autoplay=1&modestbranding=0&showinfo=0&disablekb=1&mute=1&loop=1`; const embedUrl = `https://www.youtube.com/embed/${videoId}?controls=0&autoplay=1&modestbranding=0&showinfo=0&disablekb=1&mute=1&loop=1`;
// https://www.youtube.com/shorts/9VgqBPd6RPA // https://www.youtube.com/shorts/9VgqBPd6RPA
// https://www.youtube.com/watch?v=I2N8hTHhvGY // https://www.youtube.com/watch?v=I2N8hTHhvGY
console.log()
return ( return (
<Box <Box
sx={{ sx={{
@ -27,13 +29,25 @@ export default function YoutubeEmbedIframe({ videoUrl, containerSX }: Props) {
...containerSX, ...containerSX,
}} }}
> >
<iframe <Box
component="video"
sx={{
width: "100%",
height: "100%",
}}
autoPlay
muted
src={videoUrl}
/>
{/* <iframe
src={embedUrl} src={embedUrl}
title="YouTube video player" title="YouTube video player"
frameBorder="0" frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowFullScreen allowFullScreen
/> /> */}
</Box> </Box>
); );
} }