From 98c87787db3d16548b616fa890bab131263d4a47 Mon Sep 17 00:00:00 2001 From: Nick Tchayka Date: Wed, 6 Sep 2023 15:19:23 +0100 Subject: Add modal --- src/components/Button.tsx | 9 ++++++-- src/components/Dialog.tsx | 15 +++++++------ src/components/Modal.tsx | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 src/components/Modal.tsx (limited to 'src/components') diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 8d2d6db..90d44f6 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -15,19 +15,23 @@ type ButtonType = { | "cyan" | ""; disabled?: boolean; + onClick?: () => void; + className?: string; }; const Button = ({ children, - rounded = "none", + onClick = () => {}, + rounded = "full", size = "md", color = "cyan", disabled, + className, }: ButtonType) => { return ( )} {actionButtonText && ( )} diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx new file mode 100644 index 0000000..55ad174 --- /dev/null +++ b/src/components/Modal.tsx @@ -0,0 +1,55 @@ +import React from "react"; +import Button from "./Button"; + +export interface ModalProps { + title: string | React.ReactNode; + children: React.ReactNode; + open: boolean; + okText?: string; + cancelText?: string; + onOk?: () => void; + onCancel?: () => void; +} + +export default function Modal({ + title, + children, + open, + okText = "OK", + cancelText, + onOk = () => {}, + onCancel = () => {}, +}: ModalProps) { + return ( + open && ( +
+
+
+
+

{title}

+
+ {children} +
+
+ {cancelText && ( + + )} + {okText && ( + + )} +
+
+
+
+
+ ) + ); +} -- cgit