Skip to content

Commit

Permalink
Merge pull request #443 from memosys/fix/markdown-expanded-view
Browse files Browse the repository at this point in the history
Markdown Editor & Preview respect outer container & responsive;
  • Loading branch information
dekanbro authored Nov 9, 2023
2 parents 4d83cce + 9cbe19d commit 5f26d56
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions libs/moloch-v3-fields/src/fields/MarkdownField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
DialogContent,
Field,
Label,
Card,
WrappedTextArea,
} from '@daohaus/ui';

import { useFormContext } from 'react-hook-form';
import { BiPencil } from 'react-icons/bi';
import { MdFullscreen, MdFullscreenExit, MdPreview } from 'react-icons/md';
Expand Down Expand Up @@ -38,8 +40,6 @@ const MarkDownContainer = styled.div`

const DialogMarkDownContainer = styled.div`
height: 50rem;
max-width: 100rem;
min-width: 50rem;
overflow-y: scroll;
padding: 10px;
margin-bottom: 5rem;
Expand All @@ -64,8 +64,12 @@ const LabelContainer = styled(Label)`

const DialogWrappedTextArea = styled(WrappedTextArea)`
height: 50rem;
max-width: 100rem;
min-width: 70rem;
overflow-y: scroll;
padding: 10px;
margin-bottom: 5rem;
border-radius: 5px;
font-size: 1.5rem;
font-family: inherit;
`;

const DialogButtonWrapper = styled.div`
Expand All @@ -75,6 +79,12 @@ const DialogButtonWrapper = styled.div`
margin-bottom: -2rem;
`;

const ContentWrapper = styled(Card)`
border: none;
min-width: 50vw;
max-width: 90vw;
`;

export const MarkdownField = (props: Buildable<Field>) => {
const { watch } = useFormContext();
const value = watch(props.id);
Expand Down Expand Up @@ -132,18 +142,20 @@ export const MarkdownField = (props: Buildable<Field>) => {
<MdPreview />
</Button>
</DialogButtonWrapper>
{edit ? (
<DialogWrappedTextArea {...props} />
) : (
<>
<LabelContainer>
<Label>Preview</Label>
</LabelContainer>
<DialogMarkDownContainer>
<ReactMarkdown>{value}</ReactMarkdown>
</DialogMarkDownContainer>
</>
)}
<ContentWrapper>
{edit ? (
<DialogWrappedTextArea {...props} />
) : (
<>
<LabelContainer>
<Label>Preview</Label>
</LabelContainer>
<DialogMarkDownContainer>
<ReactMarkdown>{value}</ReactMarkdown>
</DialogMarkDownContainer>
</>
)}
</ContentWrapper>
</DialogContent>
</Dialog>
</TabsContainer>
Expand Down

0 comments on commit 5f26d56

Please sign in to comment.