From 9592062732093bcd478505cd854588c2c1a48abf Mon Sep 17 00:00:00 2001 From: Meliora Ho Date: Sun, 18 Feb 2024 03:14:15 +0000 Subject: [PATCH] Edited Input UI --- compass/app/page.tsx | 4 +-- compass/components/Input.tsx | 54 ++++++++++++++++++++++-------------- compass/utils/constants.tsx | 10 +++---- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/compass/app/page.tsx b/compass/app/page.tsx index 48493ae..756075c 100644 --- a/compass/app/page.tsx +++ b/compass/app/page.tsx @@ -16,10 +16,10 @@ export default function Page() {
- +
- +
diff --git a/compass/components/Input.tsx b/compass/components/Input.tsx index 618295b..5997296 100644 --- a/compass/components/Input.tsx +++ b/compass/components/Input.tsx @@ -1,29 +1,41 @@ -import React, { FunctionComponent, InputHTMLAttributes, ReactNode } from 'react'; +import { Icons } from '@/utils/constants'; +import React, { FunctionComponent, InputHTMLAttributes, ReactElement, ReactNode } from 'react'; type InputProps = InputHTMLAttributes & { - icon?: ReactNode; - title?: ReactNode; - type?:ReactNode; - placeholder?:ReactNode + iconKey?: keyof typeof Icons; // Use keyof typeof to ensure the key exists in Icons + title?: string; // Assuming title is always a string + type?: string; + placeholder?: string; }; -const Input: FunctionComponent = ({ icon, type, title, placeholder, ...rest }) => { +const Input: FunctionComponent = ({ iconKey, type, title, placeholder, ...rest }) => { + const IconComponent = iconKey ? Icons[iconKey] : null; + return ( -
- -
+
+ {title && ( +
+ +
+ )} +
+ {IconComponent && ( + + + + )} + +
+
); }; diff --git a/compass/utils/constants.tsx b/compass/utils/constants.tsx index ad0169d..d715bb7 100644 --- a/compass/utils/constants.tsx +++ b/compass/utils/constants.tsx @@ -47,8 +47,8 @@ export enum DATATYPE { SELECT } -export const COLLECTION_MAP: {[key in COLLECTION]: CollectionImpl} = { - [COLLECTION.RESOURCE]: new CollectionImpl('Resources', Icons.ResourceIcon), - [COLLECTION.SERVICE]: new CollectionImpl('Services', Icons.ServiceIcon), - [COLLECTION.USER]: new CollectionImpl('Users', Icons.UserIcon) -} \ No newline at end of file +// export const COLLECTION_MAP: {[key in COLLECTION]: CollectionImpl} = { +// [COLLECTION.RESOURCE]: new CollectionImpl('Resources', Icons.ResourceIcon), +// [COLLECTION.SERVICE]: new CollectionImpl('Services', Icons.ServiceIcon), +// [COLLECTION.USER]: new CollectionImpl('Users', Icons.UserIcon) +// } \ No newline at end of file