aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/ui
diff options
context:
space:
mode:
authorkamtschatka <sschatka@gmail.com>2024-05-19 13:13:54 +0200
committerGitHub <noreply@github.com>2024-05-19 12:13:54 +0100
commitd1ad84be48bb3b6914c0d478d13f92861889c466 (patch)
tree2f3f4f748b85b101d8f5b56473cf2d36944b1a1d /apps/web/components/ui
parentcb62db781235fbc4b1fe92a3f8b26dadb5181963 (diff)
downloadkarakeep-d1ad84be48bb3b6914c0d478d13f92861889c466.tar.zst
feature(web): Allow adding multiple URLs at once #158 (#167)
Added a reusable dialog opening a dialog that allows you to decide if you want to import multiple URLs at once if you provide only that Co-authored-by: kamtschatka <simon.schatka@gmx.at>
Diffstat (limited to 'apps/web/components/ui')
-rw-r--r--apps/web/components/ui/multiple-choice-dialog.tsx55
1 files changed, 55 insertions, 0 deletions
diff --git a/apps/web/components/ui/multiple-choice-dialog.tsx b/apps/web/components/ui/multiple-choice-dialog.tsx
new file mode 100644
index 00000000..b6f2a5c3
--- /dev/null
+++ b/apps/web/components/ui/multiple-choice-dialog.tsx
@@ -0,0 +1,55 @@
+import { useState } from "react";
+import {
+ Dialog,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/components/ui/dialog";
+
+export default function MultipleChoiceDialog({
+ open: userIsOpen,
+ setOpen: userSetOpen,
+ onOpenChange,
+ title,
+ description,
+ actionButtons,
+ children,
+}: {
+ open?: boolean;
+ setOpen?: (v: boolean) => void;
+ onOpenChange?: (open: boolean) => void;
+ title: React.ReactNode;
+ description: React.ReactNode;
+ actionButtons: ((
+ setDialogOpen: (open: boolean) => void,
+ ) => React.ReactNode)[];
+ children?: React.ReactNode;
+}) {
+ const [customIsOpen, setCustomIsOpen] = useState(false);
+ const [isDialogOpen, setDialogOpen] = [
+ userIsOpen ?? customIsOpen,
+ userSetOpen ?? setCustomIsOpen,
+ ];
+ return (
+ <Dialog
+ open={isDialogOpen}
+ onOpenChange={(isOpen) => {
+ onOpenChange?.(isOpen);
+ setDialogOpen(isOpen);
+ }}
+ >
+ {children && <DialogTrigger asChild>{children}</DialogTrigger>}
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>{title}</DialogTitle>
+ </DialogHeader>
+ {description}
+ <DialogFooter className="sm:justify-end">
+ {actionButtons.map((actionButton) => actionButton(setDialogOpen))}
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}