feat: input answer title
This commit is contained in:
parent
f47b3260df
commit
879f206d8f
@ -1,3 +1,4 @@
|
|||||||
|
import { useState, useRef, useEffect } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
@ -40,9 +41,16 @@ const CONDITIONS = [
|
|||||||
export default function BranchingQuestions({
|
export default function BranchingQuestions({
|
||||||
totalIndex,
|
totalIndex,
|
||||||
}: BranchingQuestionsProps) {
|
}: BranchingQuestionsProps) {
|
||||||
|
const [title, setTitle] = useState<string>("Заголовок работа");
|
||||||
|
const [titleInputWidth, setTitleInputWidth] = useState<number>(0);
|
||||||
const quizId = Number(useParams().quizId);
|
const quizId = Number(useParams().quizId);
|
||||||
const { openedModalSettings, listQuestions } = questionStore();
|
const { openedModalSettings, listQuestions } = questionStore();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const titleRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setTitleInputWidth(titleRef.current?.offsetWidth || 0);
|
||||||
|
}, [title]);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
resetSomeField({ openedModalSettings: "" });
|
resetSomeField({ openedModalSettings: "" });
|
||||||
@ -80,7 +88,37 @@ export default function BranchingQuestions({
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography sx={{ color: "#9A9AAF" }}>()</Typography>
|
<Box sx={{ color: "#9A9AAF" }}>
|
||||||
|
<Typography component="span">(</Typography>
|
||||||
|
<Box sx={{ display: "inline" }}>
|
||||||
|
<Typography
|
||||||
|
ref={titleRef}
|
||||||
|
sx={{
|
||||||
|
position: "absolute",
|
||||||
|
opacity: 0,
|
||||||
|
zIndex: "-100",
|
||||||
|
whiteSpace: "pre",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={title}
|
||||||
|
onChange={({ target }) => setTitle(target.value)}
|
||||||
|
style={{
|
||||||
|
width: titleInputWidth,
|
||||||
|
outline: "none",
|
||||||
|
background: "transparent",
|
||||||
|
border: "none",
|
||||||
|
fontSize: "18px",
|
||||||
|
minWidth: "150px",
|
||||||
|
maxWidth: "500px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Typography component="span">)</Typography>
|
||||||
|
</Box>
|
||||||
<InfoIcon width={24} height={24} />
|
<InfoIcon width={24} height={24} />
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
|
Loading…
Reference in New Issue
Block a user