diff --git a/lib/client/vanilla/button.tsx b/lib/client/vanilla/button.tsx new file mode 100644 index 00000000..0ef30612 --- /dev/null +++ b/lib/client/vanilla/button.tsx @@ -0,0 +1,173 @@ +import React, { useState } from 'react' + +import * as DialogPrimitive from '@radix-ui/react-dialog' + +import Select from './select' + +import XMarkIcon from '@heroicons/react/24/outline/XMarkIcon' +import ChevronDownIcon from '@heroicons/react/24/outline/ChevronDownIcon' + +// @ts-ignore +import cx from 'classnames' + +const capitalize = (text: string) => text[0].toUpperCase() + text.substring(1, text.length) + +const options = ['url', 'email', 'submit'] +const methods = ['GET', 'POST'] + +interface DialogProps { + open: boolean + setOpen: (open: boolean) => void +} + +const Dialog: React.FC = ({ open, setOpen }) => { + const [openSelect, setOpenSelect] = useState(false) + + const [url, setUrl] = useState('') + const [email, setEmail] = useState('') + const [submitUrl, setSubmitUrl] = useState('') + const [submitMethod, setSubmitMethod] = useState('GET') + const [submitAsync, setSubmitAsync] = useState(true) + const [methodSelect, setMethodSelect] = useState(true) + const [newTab, setNewTab] = useState(true) + const [type, setType] = useState('url') + + const onChange = (e: string) => { + setType(e.toLowerCase()) + } + + return ( + + + + + + Update Button + + + +
+
+
setOpenSelect(true)} + > + {capitalize(type)} +
+ setUrl(e.target.value)} + /> +
+

Open in new tab

+ setNewTab(e.target.checked)} + className="ml-4 w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 focus:ring-2" + /> +
+
+ )} + {/* Email */} + {type === 'email' && ( +
+ setEmail(e.target.value)} + /> +
+ )} + {/* Submit */} + {type === 'submit' && ( +
+
+ setSubmitUrl(e.target.value)} + /> +
setMethodSelect(true)} + > + {submitMethod} +
+ setSubmitAsync(e.target.checked)} + className="ml-4 w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 focus:ring-2" + /> +
+
+ )} +
+ + +
+ +
+ { + setOpen(false) + }} + className={cx( + 'inline-flex select-none justify-center rounded-md px-4 py-2 text-sm font-medium', + 'bg-blue-600 text-white hover:bg-blue-700 border border-transparent', + )} + > + Save + +
+ + setOpen(false)} + className={cx('absolute top-3.5 right-3.5 inline-flex items-center justify-center rounded-full p-1')} + > + + +
+
+
+
+ ) +} + +export default Dialog diff --git a/lib/client/vanilla/editor.tsx b/lib/client/vanilla/editor.tsx index 4c52fe7c..cd39dd71 100644 --- a/lib/client/vanilla/editor.tsx +++ b/lib/client/vanilla/editor.tsx @@ -16,6 +16,9 @@ import PencilIcon from '@heroicons/react/24/outline/PencilIcon' import Select from './select' import ImageDialog from './image' +import ButtonDialog from './button' +import LinkDialog from './link' +import SvgDialog from './svg' const standaloneServerPort = 12785 @@ -386,6 +389,9 @@ function Editor({ standaloneServer = false }) { )} + {}} /> + {}} /> + {}} />
void +} + +const Dialog: React.FC = ({ open, setOpen }) => { + const [link, setLink] = useState('') + const [newTab, setNewTab] = useState(true) + + return ( + + + + + + Update Link + + +
+
+
+
+ setLink(e.target.value)} + /> +
+

Open in new tab

+ setNewTab(e.target.checked)} + className="ml-4 w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 focus:ring-2" + /> +
+
+
+
+
+ +
+ { + setOpen(false) + }} + className={cx( + 'inline-flex select-none justify-center rounded-md px-4 py-2 text-sm font-medium', + 'bg-blue-600 text-white hover:bg-blue-700 border border-transparent', + )} + > + Save + +
+ + setOpen(false)} + className={cx('absolute top-3.5 right-3.5 inline-flex items-center justify-center rounded-full p-1')} + > + + +
+
+
+
+ ) +} + +export default Dialog diff --git a/lib/client/vanilla/svg.tsx b/lib/client/vanilla/svg.tsx new file mode 100644 index 00000000..64b49e86 --- /dev/null +++ b/lib/client/vanilla/svg.tsx @@ -0,0 +1,72 @@ +import React, { useState } from 'react' + +import * as DialogPrimitive from '@radix-ui/react-dialog' +import XMarkIcon from '@heroicons/react/24/outline/XMarkIcon' + +// @ts-ignore +import cx from 'classnames' + +type DialogProps = { open: boolean; setOpen: any } + +const Dialog: React.FC = ({ open, setOpen }) => { + const [path, setPath] = useState('') + + return ( + + + + + + Update SVG Path + + +
+
+
+
+ setPath(e.target.value)} + /> +
+
+
+
+ +
+ { + setOpen(false) + }} + className={cx( + 'inline-flex select-none justify-center rounded-md px-4 py-2 text-sm font-medium', + 'bg-blue-600 text-white hover:bg-blue-700 border border-transparent', + )} + > + Save + +
+ + setOpen(false)} + className={cx('absolute top-3.5 right-3.5 inline-flex items-center justify-center rounded-full p-1')} + > + + +
+
+
+
+ ) +} + +export default Dialog