From 1cade539225c433cc8df2f211adca1c630680fa3 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 24 Mar 2022 20:18:44 -0400 Subject: [PATCH 1/2] add a preview button for MarkDown when edit mode + add markdown in challenge and schedule claim modals --- .../field-input/text-field-input.tsx | 66 ++++++++++++------- .../src/components/modals/challenge-modal.tsx | 1 + .../modals/schedule-claim-modal.tsx | 1 + 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/packages/react-app/src/components/field-input/text-field-input.tsx b/packages/react-app/src/components/field-input/text-field-input.tsx index 02a0a87e..1ec93083 100644 --- a/packages/react-app/src/components/field-input/text-field-input.tsx +++ b/packages/react-app/src/components/field-input/text-field-input.tsx @@ -1,6 +1,6 @@ -import { TextInput, Markdown } from '@1hive/1hive-ui'; +import { TextInput, Markdown, Button } from '@1hive/1hive-ui'; import { noop } from 'lodash-es'; -import React, { ReactNode } from 'react'; +import React, { ReactNode, useEffect, useState } from 'react'; import { CollapsableBlock } from 'src/collapsable-block'; import { GUpx } from 'src/utils/style.util'; import styled from 'styled-components'; @@ -21,6 +21,10 @@ const MaxLineStyled = styled.div` } `; +const BlockStyled = styled.div` + width: 100%; +`; + // #endregion type Props = { @@ -63,6 +67,16 @@ export default function TextFieldInput({ tooltipDetail, tooltip, }: Props) { + const [isEditState, setIsEdit] = useState(isEdit); + + const handlePreview = () => { + setIsEdit(!isEditState); + }; + + useEffect(() => { + setIsEdit(isEdit); + }, [isEdit]); + const readOnlyContent = ( <> {isMarkDown ? ( @@ -114,28 +128,34 @@ export default function TextFieldInput({ )} ); - const loadableContent = isEdit ? ( - + const loadableContent = isEditState ? ( + + + {isMarkDown && isEdit &&