Skip to content

Commit

Permalink
refactor: move display condition out of ViewOnlyCanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
Gum-Joe committed Jul 19, 2024
1 parent a531ff3 commit ee212d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const ViewOnlyCanvas: React.FC<ViewOnlyCanvasProps> = ({ initialData }) =
})
}, [excalidrawAPI, initialData])

return initialData && initialData?.length ? (
return (
<Card>
<Box
className="excalidraw-view-container excalidraw-box"
Expand All @@ -38,5 +38,5 @@ export const ViewOnlyCanvas: React.FC<ViewOnlyCanvasProps> = ({ initialData }) =
/>
</Box>
</Card>
) : null
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Pencil2Icon } from '@radix-ui/react-icons'
import { Button, Card, Dialog, Flex } from '@radix-ui/themes'
import { MathJax } from 'better-react-mathjax'
import { isEmpty } from 'lodash'
import { FC } from 'react'
import { useParams } from 'react-router-dom'

Expand All @@ -26,7 +27,9 @@ export const HandwritingTask: FC<HandwritingTaskProps> = ({
return (
<Dialog.Root>
<Dialog.Trigger>
<ViewOnlyCanvas initialData={answer?.excalidraw?.elements ?? []} />
{!isEmpty(answer?.excalidraw?.elements) && (
<ViewOnlyCanvas initialData={answer!.excalidraw.elements} />
)}
</Dialog.Trigger>
<Flex gap="3" align="center">
<Card className="latex-preview">
Expand Down

0 comments on commit ee212d2

Please sign in to comment.