закончено с селектом, работа над дроп зоной на 39д
This commit is contained in:
parent
12e250d9a4
commit
09912cc884
@ -1,4 +1,4 @@
|
|||||||
import {Box, Button, FormControl, Link, MenuItem, Select, Typography, useTheme} from "@mui/material";
|
import {Box, Button, ButtonBase, FormControl, Link, MenuItem, Select, Typography, useTheme} from "@mui/material";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
||||||
import AlignLeftIcon from "../../assets/icons/AlignLeftIcon";
|
import AlignLeftIcon from "../../assets/icons/AlignLeftIcon";
|
||||||
@ -16,14 +16,15 @@ import UploadBox from "@ui_kit/UploadBox";
|
|||||||
import CustomTextField from "@ui_kit/CustomTextField";
|
import CustomTextField from "@ui_kit/CustomTextField";
|
||||||
import {quizStore} from "@root/quizes";
|
import {quizStore} from "@root/quizes";
|
||||||
import {useParams} from "react-router-dom";
|
import {useParams} from "react-router-dom";
|
||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
|
||||||
const designTypes = [
|
const designTypes = [
|
||||||
["Standard", (color: string) => <LayoutStandartIcon color={color} />],
|
["standard", (color: string) => <LayoutStandartIcon color={color} />, "Standard"],
|
||||||
["Expanded", (color: string) => <LayoutExpandedIcon color={color} />],
|
["expanded", (color: string) => <LayoutExpandedIcon color={color} />, "Expanded"],
|
||||||
["Centered", (color: string) => <LayoutCenteredIcon color={color} />]
|
["centered", (color: string) => <LayoutCenteredIcon color={color} />, "Centered"]
|
||||||
] as const;
|
] as const;
|
||||||
type DesignType = typeof designTypes[number][0];
|
// type DesignType = typeof designTypes[number][0];
|
||||||
|
|
||||||
type BackgroundType = "image" | "video";
|
type BackgroundType = "image" | "video";
|
||||||
type AlignType = "left" | "right";
|
type AlignType = "left" | "right";
|
||||||
@ -33,9 +34,30 @@ export default function StartPageSettings() {
|
|||||||
const params = Number(useParams().quizId);
|
const params = Number(useParams().quizId);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const designType = listQuizes[params].startpage
|
const designType = listQuizes[params].startpage
|
||||||
// const [designType, setDesignType] = useState<DesignType | "">(designTypes[0][0]);
|
|
||||||
const [backgroundType, setBackgroundType] = useState<BackgroundType>("image");
|
const [backgroundType, setBackgroundType] = useState<BackgroundType>("image");
|
||||||
const [alignType, setAlignType] = useState<AlignType>("left");
|
const [alignType, setAlignType] = useState<AlignType>("left");
|
||||||
|
//дропзона
|
||||||
|
const imgHC = (imgInp:any) => {
|
||||||
|
const [file] = imgInp.files
|
||||||
|
setImg(URL.createObjectURL(file))
|
||||||
|
}
|
||||||
|
const [img, setImg] = React.useState("");
|
||||||
|
|
||||||
|
const dropZone = React.useRef<any>(null);
|
||||||
|
const [ready, setReady] = React.useState(false);
|
||||||
|
|
||||||
|
const dragenterHC = () => {
|
||||||
|
setReady(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (dropZone.current) {
|
||||||
|
dropZone.current.addEventListener("dragenter", dragenterHC)
|
||||||
|
}
|
||||||
|
return () => {dropZone.current.removeEventListener("dragenter", dragenterHC)}
|
||||||
|
},)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -74,9 +96,7 @@ export default function StartPageSettings() {
|
|||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={designType}
|
value={designType}
|
||||||
displayEmpty
|
displayEmpty
|
||||||
onChange={(e, i) => console.log(e.target, e.target.value, i)}
|
onChange={e => updateQuizesList(params, {startpage: e.target.value})}
|
||||||
// onChange={e => setDesignType(e.target.value as DesignType)}
|
|
||||||
// onChange={updateQuizesList(params, {startpage: "standard"})}
|
|
||||||
sx={{
|
sx={{
|
||||||
height: "48px",
|
height: "48px",
|
||||||
borderRadius: "8px",
|
borderRadius: "8px",
|
||||||
@ -133,7 +153,7 @@ export default function StartPageSettings() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{type[1](type[0] === designType ? theme.palette.orange.main : theme.palette.grey2.main)}
|
{type[1](type[0] === designType ? theme.palette.orange.main : theme.palette.grey2.main)}
|
||||||
{type[0]}
|
{type[2]}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
</Select>
|
</Select>
|
||||||
@ -153,7 +173,38 @@ export default function StartPageSettings() {
|
|||||||
{backgroundType === "image" ?
|
{backgroundType === "image" ?
|
||||||
<>
|
<>
|
||||||
<Typography sx={{ fontWeight: 500, color: theme.palette.grey3.main, mt: "20px", mb: "14px" }}>Изображение</Typography>
|
<Typography sx={{ fontWeight: 500, color: theme.palette.grey3.main, mt: "20px", mb: "14px" }}>Изображение</Typography>
|
||||||
<UploadBox icon={<UploadIcon />} text="5 MB максимум" />
|
<ButtonBase component="label" sx={{justifyContent: 'flex-start'}} >
|
||||||
|
<input onChange={event => imgHC(event.target)} hidden accept="image/*" multiple type="file" />
|
||||||
|
<Box
|
||||||
|
ref={dropZone}
|
||||||
|
sx={{
|
||||||
|
width: "100%",
|
||||||
|
height: "120px",
|
||||||
|
position: "relative",
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
backgroundColor: theme.palette.background.default,
|
||||||
|
border: `1px solid ${ready? "red" : theme.palette.grey2.main}`,
|
||||||
|
borderRadius: "8px",
|
||||||
|
}}
|
||||||
|
|
||||||
|
>
|
||||||
|
<UploadIcon />
|
||||||
|
<Typography sx={{
|
||||||
|
position: "absolute",
|
||||||
|
right: "10px",
|
||||||
|
bottom: "10px",
|
||||||
|
color: theme.palette.orange.main,
|
||||||
|
fontSize: "16px",
|
||||||
|
lineHeight: "19px",
|
||||||
|
textDecoration: "underline",
|
||||||
|
}}>5 MB максимум</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/*<UploadBox icon={<UploadIcon />} text="5 MB максимум" ref={dropZone} sx={{border: `1px solid ${ready ? "red" : theme.palette.grey2.main}`}}/>*/}
|
||||||
|
</ButtonBase>
|
||||||
|
|
||||||
<Link sx={{
|
<Link sx={{
|
||||||
mt: "20px",
|
mt: "20px",
|
||||||
fontSize: "16px",
|
fontSize: "16px",
|
||||||
|
|||||||
@ -6,13 +6,16 @@ interface Props {
|
|||||||
sx?: SxProps<Theme>;
|
sx?: SxProps<Theme>;
|
||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
text?: string;
|
text?: string;
|
||||||
|
ref?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function UploadBox({ sx, icon, text }: Props) {
|
export default function UploadBox({ sx, icon, text, ref }: Props) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{
|
<Box
|
||||||
|
ref={ref}
|
||||||
|
sx={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "120px",
|
height: "120px",
|
||||||
position: "relative",
|
position: "relative",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user