diff --git a/web/src/App.scss b/web/src/App.scss
index a5eca31..0fc5701 100644
--- a/web/src/App.scss
+++ b/web/src/App.scss
@@ -22,12 +22,12 @@ textarea {
}
}
-button {
+button, .btn {
position: relative;
@apply cursor-pointer disabled:cursor-default;
@apply bg-brand hover:bg-brand-4 disabled:bg-brand-3 text-white rounded-md border-0 transition-colors;
- @apply flex items-center justify-center gap-1 px-4 py-2;
+ @apply flex items-center justify-center gap-1 px-4 py-2 leading-none;
&.btn-gray {
@apply bg-coolGray-5 hover:bg-coolGray-4 disabled:bg-coolGray-3;
diff --git a/web/src/components/ContentInput.tsx b/web/src/components/ContentInput.tsx
index 52470b3..7636528 100644
--- a/web/src/components/ContentInput.tsx
+++ b/web/src/components/ContentInput.tsx
@@ -157,15 +157,15 @@ export const ContentInput = memo(() => {
Add file
+
+ Clear
+
+
{files.map((file) => )}
-
-
- Clear
-
{!!isDragOver && (
@@ -194,7 +194,7 @@ function AttachedFileItem({ file, removeFile }: { file: FileStoreItem; removeFil
return () => URL.revokeObjectURL(url);
}, [file]);
- return
+ return
{file.thumbnail ? (
) : (
diff --git a/web/src/components/PopoverConfirm.tsx b/web/src/components/PopoverConfirm.tsx
new file mode 100644
index 0000000..e2369f2
--- /dev/null
+++ b/web/src/components/PopoverConfirm.tsx
@@ -0,0 +1,33 @@
+import { memo, useEffect, useRef, useState } from "react";
+
+export const PopoverConfirm = memo(({ children, onConfirm }: { children: React.ReactNode, onConfirm: () => void }) => {
+ const [visible, setVisible] = useState(false);
+ const confirmBtnRef = useRef
(null);
+
+ useEffect(() => {
+ const el = visible && confirmBtnRef.current;
+ if (!el) return;
+
+ const onBlur = () => {
+ setVisible(false);
+ }
+ el.addEventListener('blur', onBlur);
+ el.focus();
+
+ return () => el.removeEventListener('blur', onBlur);
+ }, [visible])
+
+ return (
+
+
setVisible(true)}>{children}
+
+ {
+ visible && (
+
setVisible(false)}>No
+
Yes
+
+
)
+ }
+
+ )
+})
\ No newline at end of file
diff --git a/web/src/components/UploadRecords.tsx b/web/src/components/UploadRecords.tsx
index 7130ab1..49fcce1 100644
--- a/web/src/components/UploadRecords.tsx
+++ b/web/src/components/UploadRecords.tsx
@@ -5,6 +5,7 @@ import relativeTime from 'dayjs/plugin/relativeTime';
import type { UploadRecord } from '../../../src/database';
import { fetchAPI } from '../store/auth';
+import { PopoverConfirm } from './PopoverConfirm';
dayjs.extend(relativeTime);
@@ -100,11 +101,15 @@ const UploadRecordItem = memo((props: { record: UploadRecord }) => {
)
}
- (e.preventDefault(), deleteRecord(props.record.id))} href='#' role='button'>
-
- Delete
-
-
+
deleteRecord(props.record.id)}>
+ e.preventDefault()} href='#' role='button'>
+
+ Delete
+
+
+
return (
@@ -176,7 +181,6 @@ function copyToClipboard(text: string) {
}
function deleteRecord(id: number) {
- if (!confirm('Are you sure you want to delete this record?')) return;
fetchAPI('/api/delete', {
method: 'POST',
headers: {