diff --git a/compass/components/Table/Index.tsx b/compass/components/Table/Index.tsx index 5a12c1b..0f9beb3 100644 --- a/compass/components/Table/Index.tsx +++ b/compass/components/Table/Index.tsx @@ -11,6 +11,7 @@ import { import { useState } from "react"; import { RowAction } from "./RowAction"; import { TableAction } from "./TableAction"; +import TagsInput from "../TagsInput/Index"; const usersExample = usersImport as unknown as User[]; @@ -34,7 +35,7 @@ export const Table = () => { cell: (info) => , }), columnHelper.accessor("role", { - cell: (info) => info.renderValue(), + cell: (info) => , }), columnHelper.accessor("email", { cell: (info) => info.renderValue(), diff --git a/compass/components/TagsInput/Index.tsx b/compass/components/TagsInput/Index.tsx new file mode 100644 index 0000000..69d5047 --- /dev/null +++ b/compass/components/TagsInput/Index.tsx @@ -0,0 +1,70 @@ +// In a file TagsInput.tsx + +import { useState } from 'react'; +import 'tailwindcss/tailwind.css'; +import {TagsArray} from './TagsArray'; // Assuming this is the correct path +import { TagDropdown } from './TagDropdown'; + +const TagsInput = () => { + const [inputValue, setInputValue] = useState(''); + const [cellSelected, setCellSelected] = useState(false); + const [tags, setTags] = useState(['Administrator']); + const [options, setOptions] = useState(["Administrators", "Employees", "Volunteers"]); + + const handleInputChange = (e: React.ChangeEvent) => { + setInputValue(e.target.value); + }; + + // Function to handle adding new tags when enter is pressed + const handleAddTag = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && inputValue) { + setTags([...tags, inputValue]); + setInputValue(''); + } + }; + + // Function to handle deleting tags + const handleDeleteTag = (tagToDelete: string) => { + setTags(tags.filter(tag => tag !== tagToDelete)); + }; + + const handleBlur = () => { + setCellSelected(false); + }; + + return ( +
setCellSelected(true)} + > + {!cellSelected ? ( + + ) : ( +
+
+
+ + +
+
+ Select an option or create one + +
+ +
+
+ )} +
+ ); +}; + +export default TagsInput; diff --git a/compass/components/TagsInput/Input.tsx b/compass/components/TagsInput/Input.tsx new file mode 100644 index 0000000..e69de29 diff --git a/compass/components/TagsInput/Tag.tsx b/compass/components/TagsInput/Tag.tsx new file mode 100644 index 0000000..3ad97f3 --- /dev/null +++ b/compass/components/TagsInput/Tag.tsx @@ -0,0 +1,9 @@ +import { XMarkIcon } from "@heroicons/react/24/solid" + +export const Tag = ({children, active = false}) => { + return ( + {children} + {active && } + + ) +} \ No newline at end of file diff --git a/compass/components/TagsInput/TagDropdown.tsx b/compass/components/TagsInput/TagDropdown.tsx new file mode 100644 index 0000000..91d8be5 --- /dev/null +++ b/compass/components/TagsInput/TagDropdown.tsx @@ -0,0 +1,15 @@ +import { EllipsisHorizontalIcon } from "@heroicons/react/24/solid" +import { Tag } from "./Tag" + +export const TagDropdown = ({tags}) => { + return ( +
+ + {tags.map((tag) => { + return
{tag}
+ })} + + +
+ ) +} \ No newline at end of file diff --git a/compass/components/TagsInput/TagsArray.tsx b/compass/components/TagsInput/TagsArray.tsx new file mode 100644 index 0000000..98769c7 --- /dev/null +++ b/compass/components/TagsInput/TagsArray.tsx @@ -0,0 +1,15 @@ +import { Tag } from "./Tag" + +export const TagsArray = ({ tags, active = false }) => { + return( +
+ { + tags.map((tag) => { + return ( + {tag} + ) + }) + } +
+ ) +} \ No newline at end of file