From 24593cd3f3e1058ed0e7a8f8b3eac8d4a7286ee7 Mon Sep 17 00:00:00 2001 From: ImAlpha Date: Sun, 14 Apr 2024 19:54:17 -0700 Subject: [PATCH] table created with modal for adding new items via dialog --- src/App.tsx | 87 +++++++++++++++--- src/components/Modal/ModalContent1.tsx | 9 ++ src/components/Modal/ModelContent2.tsx | 9 ++ src/components/ui/table.tsx | 117 +++++++++++++++++++++++++ 4 files changed, 209 insertions(+), 13 deletions(-) create mode 100644 src/components/Modal/ModalContent1.tsx create mode 100644 src/components/Modal/ModelContent2.tsx create mode 100644 src/components/ui/table.tsx diff --git a/src/App.tsx b/src/App.tsx index dd2eae4..010c022 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,29 +2,90 @@ import * as React from "react"; import "./App.css"; import { FaRegPlusSquare } from "react-icons/fa"; import { Button } from "./components/ui/button"; +import { + Table, + TableBody, + TableCaption, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import ModalContent1 from "./components/Modal/ModalContent1"; function App() { + const dialogRef = React.useRef(null); + const [dialogContent, setDialogContent] = + React.useState(null); + + function toggleDialog() { + if (!dialogRef.current) { + return; + } + dialogRef.current.hasAttribute("open") + ? dialogRef.current.close() + : dialogRef.current.showModal(); + } + return (

KEVO'S ATTIRE BACKEND

- {/* Add item */} + {/* Add item via dialog */}
-
- {/* Table headings */} -
- Item - Design Number - isActive -
-
-
    -
  • -
-
+ {/* Dialog content */} + { + if (e.currentTarget === e.target) { + toggleDialog(); + } + }} + className="p-12 bg-slate-400 rounded-xl border-black border-2 items-center" + > +
+ {dialogContent} + {/* close button */} + +
+
+ {/* Table */} + + All products within the database. + + + Invoice + Status + Method + Amount + + + + + INV001 + Paid + Credit Card + $250.00 + + +
); diff --git a/src/components/Modal/ModalContent1.tsx b/src/components/Modal/ModalContent1.tsx new file mode 100644 index 0000000..c880d52 --- /dev/null +++ b/src/components/Modal/ModalContent1.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const ModalContent1 = () => { + return ( +
ModalContent1
+ ) +} + +export default ModalContent1 \ No newline at end of file diff --git a/src/components/Modal/ModelContent2.tsx b/src/components/Modal/ModelContent2.tsx new file mode 100644 index 0000000..efe6c89 --- /dev/null +++ b/src/components/Modal/ModelContent2.tsx @@ -0,0 +1,9 @@ +import React from 'react' + +const ModelContent2 = () => { + return ( +
ModelContent2
+ ) +} + +export default ModelContent2 \ No newline at end of file diff --git a/src/components/ui/table.tsx b/src/components/ui/table.tsx new file mode 100644 index 0000000..cf07319 --- /dev/null +++ b/src/components/ui/table.tsx @@ -0,0 +1,117 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +const Table = React.forwardRef< + HTMLTableElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+ + +)) +Table.displayName = "Table" + +const TableHeader = React.forwardRef< + HTMLTableSectionElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableHeader.displayName = "TableHeader" + +const TableBody = React.forwardRef< + HTMLTableSectionElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableBody.displayName = "TableBody" + +const TableFooter = React.forwardRef< + HTMLTableSectionElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + tr]:last:border-b-0", + className + )} + {...props} + /> +)) +TableFooter.displayName = "TableFooter" + +const TableRow = React.forwardRef< + HTMLTableRowElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableRow.displayName = "TableRow" + +const TableHead = React.forwardRef< + HTMLTableCellElement, + React.ThHTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +TableHead.displayName = "TableHead" + +const TableCell = React.forwardRef< + HTMLTableCellElement, + React.TdHTMLAttributes +>(({ className, ...props }, ref) => ( + +)) +TableCell.displayName = "TableCell" + +const TableCaption = React.forwardRef< + HTMLTableCaptionElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +TableCaption.displayName = "TableCaption" + +export { + Table, + TableHeader, + TableBody, + TableFooter, + TableHead, + TableRow, + TableCell, + TableCaption, +}