Skip to content

Commit

Permalink
worked on dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
LiveDuo committed Nov 6, 2023
1 parent 79435ff commit 3fc1e3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/client/vanilla/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,11 @@ function Editor({ standaloneServer = false }) {
setOpen={setOpenLink}
selectedElement={selectedElement as unknown as HTMLAnchorElement}
/>
<SvgDialog open={openSvg} setOpen={setOpenSvg} selectedElement={selectedElement as unknown as SVGElement} />
<SvgDialog
open={openSvg}
setOpen={setOpenSvg}
selectedElement={selectedElement as unknown as SVGTextPathElement}
/>
<div className="flex justify-center bg-gray-200" style={{ overflowY: 'scroll' }}>
<div
id="editor"
Expand Down
10 changes: 7 additions & 3 deletions lib/client/vanilla/svg.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'

import * as DialogPrimitive from '@radix-ui/react-dialog'
import XMarkIcon from '@heroicons/react/24/outline/XMarkIcon'
Expand All @@ -9,16 +9,20 @@ import cx from 'classnames'
type DialogProps = {
open: boolean
setOpen: any
selectedElement: SVGElement
selectedElement: SVGTextPathElement
}

const Dialog: React.FC<DialogProps> = ({ open, setOpen, selectedElement }) => {
const [path, setPath] = useState('')

useEffect(() => {
setPath(selectedElement?.getAttribute('d') ?? '')
}, [open])

const onSave = () => {
setOpen(false)

// TODO update dom element
selectedElement.setAttribute('d', path)
}

return (
Expand Down

0 comments on commit 3fc1e3a

Please sign in to comment.