From 4a63057336eb3d01a497a003732f7247f888236c Mon Sep 17 00:00:00 2001 From: plate Date: Sat, 2 Nov 2024 04:05:59 +0000 Subject: [PATCH] add a copy button in the view source modal --- web/src/icons/copy.svg | 1 + web/src/ui/timeline/menu/ViewSourceModal.tsx | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 web/src/icons/copy.svg diff --git a/web/src/icons/copy.svg b/web/src/icons/copy.svg new file mode 100644 index 0000000..c8abe8e --- /dev/null +++ b/web/src/icons/copy.svg @@ -0,0 +1 @@ + diff --git a/web/src/ui/timeline/menu/ViewSourceModal.tsx b/web/src/ui/timeline/menu/ViewSourceModal.tsx index 630929a..fa1840d 100644 --- a/web/src/ui/timeline/menu/ViewSourceModal.tsx +++ b/web/src/ui/timeline/menu/ViewSourceModal.tsx @@ -15,13 +15,22 @@ // along with this program. If not, see . import { MemDBEvent } from "@/api/types" import JSONView from "../../util/JSONView.tsx" +import CopyIcon from "@/icons/copy.svg?react" interface ViewSourceModalProps { evt: MemDBEvent } +// TODO: change the copy button's text on copy, without having typescript scream at me. +// will i need to make a component for the copy button and change its state? hmm +const copyButtonOnClick = (evt: MemDBEvent) => { + navigator.clipboard.writeText(JSON.stringify(evt, null, 4)) +} + +// TODO check with tulir that he in fact uses material design icons. i got the copy icon from google's site const ViewSourceModal = ({ evt }: ViewSourceModalProps) => { return
+
}