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 d518922 commit 532cab1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
12 changes: 9 additions & 3 deletions lib/client/vanilla/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ const Dialog: React.FC<DialogProps> = ({ open, setOpen }) => {
const [newTab, setNewTab] = useState(true)
const [type, setType] = useState('url')

const onChange = (e: string) => {
const onSelectType = (e: string) => {
setType(e.toLowerCase())
}

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

// TODO update dom element
}

return (
<DialogPrimitive.Root open={open} onOpenChange={setOpen}>
<DialogPrimitive.Portal>
Expand Down Expand Up @@ -66,7 +72,7 @@ const Dialog: React.FC<DialogProps> = ({ open, setOpen }) => {
values={options.map((o) => capitalize(o))}
open={openSelect}
setOpen={setOpenSelect}
onChange={onChange}
onChange={onSelectType}
/>

<div>
Expand Down Expand Up @@ -147,7 +153,7 @@ const Dialog: React.FC<DialogProps> = ({ open, setOpen }) => {
<div className="mt-4 flex justify-end">
<DialogPrimitive.Close
onClick={() => {
setOpen(false)
onSave()
}}
className={cx(
'inline-flex select-none justify-center rounded-md px-4 py-2 text-sm font-medium',
Expand Down
2 changes: 1 addition & 1 deletion lib/client/vanilla/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Dialog: React.FC<DialogProps> = ({ open, setOpen, selectedElement, standal
}

const onSave = async () => {
// TODO dom element
// TODO update dom element

setOpen(false)
}
Expand Down
8 changes: 7 additions & 1 deletion lib/client/vanilla/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const Dialog: React.FC<DialogProps> = ({ open, setOpen, selectedElement }) => {
const [link, setLink] = useState(selectedElement?.href ?? '')
const [newTab, setNewTab] = useState(true)

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

// TODO update dom element
}

return (
<DialogPrimitive.Root open={open} onOpenChange={setOpen}>
<DialogPrimitive.Portal>
Expand Down Expand Up @@ -59,7 +65,7 @@ const Dialog: React.FC<DialogProps> = ({ open, setOpen, selectedElement }) => {
<div className="mt-4 flex justify-end">
<DialogPrimitive.Close
onClick={() => {
setOpen(false)
onSave()
}}
className={cx(
'inline-flex select-none justify-center rounded-md px-4 py-2 text-sm font-medium',
Expand Down
8 changes: 7 additions & 1 deletion lib/client/vanilla/svg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ type DialogProps = {
const Dialog: React.FC<DialogProps> = ({ open, setOpen, selectedElement }) => {
const [path, setPath] = useState('')

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

// TODO update dom element
}

return (
<DialogPrimitive.Root open={open} onOpenChange={setOpen}>
<DialogPrimitive.Portal>
Expand Down Expand Up @@ -49,7 +55,7 @@ const Dialog: React.FC<DialogProps> = ({ open, setOpen, selectedElement }) => {
<div className="mt-4 flex justify-end">
<DialogPrimitive.Close
onClick={() => {
setOpen(false)
onSave()
}}
className={cx(
'inline-flex select-none justify-center rounded-md px-4 py-2 text-sm font-medium',
Expand Down

0 comments on commit 532cab1

Please sign in to comment.