From 89e768e42938a9390a8634da3fe35a8073f0a013 Mon Sep 17 00:00:00 2001 From: Thea Nguyen Date: Sat, 18 May 2024 23:39:32 -0600 Subject: [PATCH] Created MemberTable.tsx + MemberTableTestRoute.tsx --- src/App.tsx | 190 +++++++++++++------------ src/components/MemberTable.tsx | 133 +++++++++++++++++ src/components/ProfilePictures.tsx | 55 +++---- src/routes/MemberTableTestRoute.tsx | 42 ++++++ src/routes/ProfilePictureTestRoute.tsx | 60 +++----- 5 files changed, 321 insertions(+), 159 deletions(-) create mode 100644 src/components/MemberTable.tsx create mode 100644 src/routes/MemberTableTestRoute.tsx diff --git a/src/App.tsx b/src/App.tsx index bcaf8ed..44a50c9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,120 +1,126 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom"; +//#region imports // routes - +import ModalTestRoute from "@/routes/ModalTestRoute"; import ButtonTestRoute from "@/routes/ButtonTestRoute"; import ProfilePictureTest from "./routes/ProfilePictureTestRoute"; import Test from "./routes/Test"; import SearchBarTest from "./routes/SearchBarTestRoute"; -import DropdownItem from "@/components/DropdownItem"; import SortDropdownListTestRoute from "@/routes/SortDropdownListTestRoute"; import NavigationTest from "@/routes/NavigationTest"; import TooltipTestRoute from "./routes/TooltipTestRoute"; import InputCodeTest from "@/routes/InputCodeTest"; import ToastTestRoute from "@/routes/ToastTestRoute"; import MediaUploadZoneTestRoute from "@/routes/MediaUploadZoneTestRoute"; - import IconOptionTest from "./routes/IconOptionTest"; +import { MemberTableTestRoute } from "./routes/MemberTableTestRoute"; +// components import ColorPickerTestRoute from "@/routes/ColorPickerTestRoute"; import InputFieldTestRoute from "./routes/InputFieldTestRoute"; import MemberHeaderTestRoute from "@/routes/MemberHeaderTestRoute"; import { MemberInformation } from "./components/MemberInformation"; -import ModalTestRoute from "@/routes/ModalTestRoute"; import { LoginModal } from "./components/LoginModal"; +import { MemberTable } from "./components/MemberTable"; +//#endregion const router = createBrowserRouter([ - { - path: "/test", - element: , - }, - { - path: "/SearchBarTestRoute", - element: , - }, - { - path: "/testButton", - element: , - }, - { - path: "/SortDropdownListTestRoute", - element: , - }, - { - path: "/nav-test", - element: , - }, - { - path: "/tooltip", - element: , - }, - { - path: "/input-code-test", - element: , - }, - { - path: "/upload-file-test", - element: , - }, - { - path: "/toast-test", - element: , - }, - { - path: "/icon-select", - element: , - }, - { - path: "/ProfilePic", - element: , - }, - { - path: "/color-picker-test", - element: , - }, - { - path: "/member-header-test", - element: , - }, - { - path: "/profile-test", - element: , - }, - { - path: "/member-information-test", - element: ( -
- -
- ), - }, - { - path: "/input-field-test", - element: , - }, - { - path: "/modal-test", - element: , - }, - { - path: "/login-modal-test", - element: ( -
- - -
- ), - }, + { + path: "/test", + element: , + }, + { + path: "/SearchBarTestRoute", + element: , + }, + { + path: "/testButton", + element: , + }, + { + path: "/SortDropdownListTestRoute", + element: , + }, + { + path: "/nav-test", + element: , + }, + { + path: "/tooltip", + element: , + }, + { + path: "/input-code-test", + element: , + }, + { + path: "/upload-file-test", + element: , + }, + { + path: "/toast-test", + element: , + }, + { + path: "/icon-select", + element: , + }, + { + path: "/ProfilePic", + element: , + }, + { + path: "/color-picker-test", + element: , + }, + { + path: "/member-header-test", + element: , + }, + { + path: "/profile-test", + element: , + }, + { + path: "/member-information-test", + element: ( +
+ +
+ ), + }, + { + path: "/input-field-test", + element: , + }, + { + path: "/modal-test", + element: , + }, + { + path: "/login-modal-test", + element: ( +
+ + +
+ ), + }, + { + path: "/member-table", + element: , + }, ]); function App() { - return ; + return ; } export default App; diff --git a/src/components/MemberTable.tsx b/src/components/MemberTable.tsx new file mode 100644 index 0000000..763f782 --- /dev/null +++ b/src/components/MemberTable.tsx @@ -0,0 +1,133 @@ +//#region imports +import { UserCircle, Folder, ArrowsClockwise } from "@phosphor-icons/react"; +import ProfilePictures from "./ProfilePictures"; +import * as Icon from "@phosphor-icons/react"; +//#endregion + +//#region interfaces +interface MemberTableProps { + data: { + profilePicture: { + type: "img" | "icon" | string; + src: string; + backgroundColor?: string; + }; + name: string; + storageUsed: string; + lastUpdated: string; + }[]; +} +//#endregion + +//#region helpers +function selectIcon(type: string) { + const iconStyling = + "w-full h-full rounded-full p-2 object-cover text-white"; + switch (type) { + case "PawPrint": + return ; + case "Tree": + return ; + case "Pizza": + return ; + case "Camera": + return ; + case "Atom": + return ; + case "Binoculars": + return ; + case "SoccerBall": + return ; + case "Coffee": + return ; + } +} +//#endregion + +/** + * Represents a table component that displays member data. + * @param data - An array of objects representing each member's data. + */ +export function MemberTable({ data }: MemberTableProps) { + const headers = [ + { icon: , label: "Name" }, + { icon: , label: "Storage Used" }, + { icon: , label: "Last Updated" }, + ]; + + function handleClick(row: any) { + alert(`Clicked ${row.name}`); + } + + return ( +
+ + {/* Headers */} + + + {headers.map((header, index) => ( + + ))} + + + + {/* Data */} + + {data.map((row, index) => ( + handleClick(row)} + > + + + + + ))} + +
+
+ + {header.icon} + + + {header.label} + +
+
+
+ + {row.profilePicture.type === "img" ? ( + profile + ) : ( + selectIcon( + row.profilePicture + .src as string, + ) + )} + + + {row.name} + +
+
+ {row.storageUsed} + + {row.lastUpdated} +
+
+ ); +} diff --git a/src/components/ProfilePictures.tsx b/src/components/ProfilePictures.tsx index 6c7a44a..09db4d8 100644 --- a/src/components/ProfilePictures.tsx +++ b/src/components/ProfilePictures.tsx @@ -1,32 +1,37 @@ -import * as Icon from "@phosphor-icons/react"; -import { ReactNode } from "react"; import { twMerge } from "tailwind-merge"; -interface Props { - children: ReactNode; - backgroundColor: - | "tulip" - | "gold" - | "lime" - | "jade" - | "water" - | "air" - | "lilac" - | "candy"; +//#region interfaces +interface ProfilePicturesProps { + children: React.ReactNode; + className?: string; + backgroundColor?: + | "tulip" + | "gold" + | "lime" + | "jade" + | "water" + | "air" + | "lilac" + | "candy" + | string; } +//#endregion -const ProfilePictures = (props: Props) => { - const backgroundColor = `bg-profile-${props.backgroundColor}`; - const className = twMerge( - backgroundColor, - "object-cover object-center flex overflow-hidden justify-center items-center rounded-full w-full h-full" - ); - - return ( -
-
{props.children}
-
- ); +const ProfilePictures = ({ + backgroundColor, + className, + children, +}: ProfilePicturesProps) => { + return ( +
+ {children} +
+ ); }; export default ProfilePictures; diff --git a/src/routes/MemberTableTestRoute.tsx b/src/routes/MemberTableTestRoute.tsx new file mode 100644 index 0000000..e18f6c9 --- /dev/null +++ b/src/routes/MemberTableTestRoute.tsx @@ -0,0 +1,42 @@ +import { MemberTable } from "@/components/MemberTable"; +import profilePic from "@/assets/images/face2.jpg"; +import * as Icon from "@phosphor-icons/react"; + +export function MemberTableTestRoute() { + const data = [ + { + profilePicture: { + type: "img", + src: profilePic, + }, + name: "John Doe", + storageUsed: "1.5GB", + lastUpdated: "12/20/2024", + }, + { + profilePicture: { + type: "icon", + src: "Tree", + backgroundColor: "lime", + }, + name: "Jane Doe", + storageUsed: "2.5GB", + lastUpdated: "12/11/2024", + }, + { + profilePicture: { + type: "icon", + src: "PawPrint", + backgroundColor: "water", + }, + name: "John Smith", + storageUsed: "3.5GB", + lastUpdated: "11/11/2024", + }, + ]; + return ( +
+ +
+ ); +} diff --git a/src/routes/ProfilePictureTestRoute.tsx b/src/routes/ProfilePictureTestRoute.tsx index 2a1a9c7..ce0e22f 100644 --- a/src/routes/ProfilePictureTestRoute.tsx +++ b/src/routes/ProfilePictureTestRoute.tsx @@ -1,52 +1,28 @@ import ProfilePictures from "@/components/ProfilePictures"; import profilePic from "@/assets/images/face2.jpg"; -import profilePic1 from "@/assets/images/face1.jpeg"; -import profilePic2 from "@/assets/images/face.jpeg"; import * as Icon from "@phosphor-icons/react"; function ProfilePictureTest() { - return ( -
-
- - Profile pic - -
+ return ( +
+
+ + profile + +
-
- - Profile pic - -
-
- - Profile pic - -
-
- - - -
-
- ); +
+ + + +
+
+ ); } export default ProfilePictureTest;