ownPlaceholder добавлен
This commit is contained in:
parent
22f8e80d16
commit
63bfe53e6c
1
CHANGELOG.md
Normal file
1
CHANGELOG.md
Normal file
@ -0,0 +1 @@
|
||||
1.0.0 Добавлены фичи "мультиответ", "перенос строки в своём ответе", "свой ответ", "плейсхолдер своего ответа"
|
@ -27,13 +27,21 @@ type AnswerItemProps = {
|
||||
additionalContent?: ReactNode;
|
||||
additionalMobile?: ReactNode;
|
||||
isOwn: boolean;
|
||||
ownPlaceholder: string;
|
||||
};
|
||||
|
||||
const AnswerItem = memo<AnswerItemProps>(
|
||||
({ index, variant, questionId, largeCheck = false, additionalContent, additionalMobile, disableKeyDown, isOwn }) => {
|
||||
({ index, variant, questionId, largeCheck = false, additionalContent, additionalMobile, disableKeyDown, isOwn, ownPlaceholder }) => {
|
||||
const theme = useTheme();
|
||||
const isTablet = useMediaQuery(theme.breakpoints.down(790));
|
||||
|
||||
const setOwnPlaceholder = (replText: string) => {
|
||||
updateQuestion(questionId, (question) => {
|
||||
question.content.ownPlaceholder = replText;
|
||||
console.log(question)
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Draggable
|
||||
draggableId={String(index)}
|
||||
@ -56,13 +64,16 @@ const AnswerItem = memo<AnswerItemProps>(
|
||||
}}
|
||||
>
|
||||
<TextField
|
||||
value={variant.answer}
|
||||
value={ isOwn ? ownPlaceholder : variant.answer}
|
||||
fullWidth
|
||||
focused={false}
|
||||
placeholder={isOwn ? "Добавьте текст-подсказку для ввода “своего ответа”" : "Добавьте ответ"}
|
||||
multiline={largeCheck}
|
||||
onChange={({ target }: ChangeEvent<HTMLInputElement>) => {
|
||||
if (target.value.length <= 1000) {
|
||||
isOwn ?
|
||||
setOwnPlaceholder(target.value || " ")
|
||||
:
|
||||
setQuestionVariantField(questionId, variant.id, "answer", target.value || " ");
|
||||
}
|
||||
}}
|
||||
|
@ -15,6 +15,7 @@ type Props = Omit<
|
||||
) => Promise<void>;
|
||||
openImageUploadModal: () => void;
|
||||
isOwn: boolean;
|
||||
ownPlaceholder: string;
|
||||
};
|
||||
|
||||
export default function ImageEditAnswerItem({
|
||||
@ -29,6 +30,7 @@ export default function ImageEditAnswerItem({
|
||||
openCropModal,
|
||||
openImageUploadModal,
|
||||
isOwn,
|
||||
ownPlaceholder,
|
||||
}: Props) {
|
||||
const addOrEditImageButton = useMemo(() => {
|
||||
return (
|
||||
@ -108,6 +110,7 @@ export default function ImageEditAnswerItem({
|
||||
additionalContent={addOrEditImageButton}
|
||||
additionalMobile={addOrEditImageButtonMobile}
|
||||
isOwn={isOwn}
|
||||
ownPlaceholder={ownPlaceholder}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ export default function Emoji({ question, openBranchingPage, setOpenBranchingPag
|
||||
setOpen={setOpen}
|
||||
setSelectedVariant={setSelectedVariant}
|
||||
isOwn={Boolean(variant?.isOwn)}
|
||||
ownPlaceholder={question.content.ownPlaceholder}
|
||||
/>
|
||||
))}
|
||||
/>
|
||||
|
@ -13,6 +13,7 @@ type Props = Omit<
|
||||
setSelectedVariant: React.Dispatch<React.SetStateAction<string | null>>;
|
||||
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
isOwn: boolean;
|
||||
ownPlaceholder: string;
|
||||
};
|
||||
|
||||
export default function EmojiAnswerItem({
|
||||
@ -25,16 +26,10 @@ export default function EmojiAnswerItem({
|
||||
setAnchorElement,
|
||||
setSelectedVariant,
|
||||
setOpen,
|
||||
isOwn
|
||||
isOwn,
|
||||
ownPlaceholder,
|
||||
}: Props) {
|
||||
|
||||
const setOwnPlaceholder = (replText: string) => {
|
||||
updateQuestion(questionId, (question) => {
|
||||
if (question.type !== "varimg") return;
|
||||
|
||||
question.content.ownPlaceholder = replText;
|
||||
});
|
||||
};
|
||||
|
||||
const addOrEditImageButton = useMemo(() => {
|
||||
return (
|
||||
@ -90,7 +85,7 @@ export default function EmojiAnswerItem({
|
||||
additionalContent={addOrEditImageButton}
|
||||
additionalMobile={addOrEditImageButtonMobile}
|
||||
isOwn={isOwn}
|
||||
changeOwnText={setOwnPlaceholder}
|
||||
ownPlaceholder={ownPlaceholder}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ export default function OptionsAndPicture({ question, setOpenBranchingPage }: Pr
|
||||
pictureUploding={pictureUploding}
|
||||
setSelectedVariantId={setSelectedVariantId}
|
||||
isOwn={Boolean(variant?.isOwn)}
|
||||
ownPlaceholder={question.content.ownPlaceholder}
|
||||
/>
|
||||
))}
|
||||
/>
|
||||
|
@ -85,6 +85,7 @@ export default function OptionsPicture({ question, openBranchingPage, setOpenBra
|
||||
pictureUploding={pictureUploding}
|
||||
setSelectedVariantId={setSelectedVariantId}
|
||||
isOwn={Boolean(variant?.isOwn)}
|
||||
ownPlaceholder={question.content.ownPlaceholder}
|
||||
/>
|
||||
))}
|
||||
/>
|
||||
|
@ -54,6 +54,7 @@ export default function AnswerOptions({ question, openBranchingPage, setOpenBran
|
||||
questionId={question.id}
|
||||
variant={variant}
|
||||
isOwn={Boolean(variant.isOwn)}
|
||||
ownPlaceholder={question.content.ownPlaceholder}
|
||||
/>
|
||||
))}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user