import React, { Fragment } from 'react'; import { faAngleDown, faCheck, faPlus } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Listbox, Transition } from '@headlessui/react'; interface ListBoxProps { selected: string; onChange: (arg: string) => void; data: string[] | null; text?: string; buttonAction?: () => void; isFull?: boolean; } /** * This is the component that we use for drop down lists. * @param {object} obj * @param {string} obj.selected - the item that is currently selected * @param {function} obj.onChange - what happends if you select the item inside a list * @param {string[]} obj.data - all the options available * @param {string} obj.text - the text that shows us in front of the select option * @param {function} obj.buttonAction - if there is a button at the bottom of the list, this is the action that happens when you click the button * @returns */ const ListBox = ({ selected, onChange, data, text, buttonAction, isFull }: ListBoxProps): JSX.Element => { return (
{text} {' '} {selected}
{data && (
)}
{data && ( {data.map((person, personIdx) => ( `my-0.5 relative cursor-default select-none py-2 pl-10 pr-4 rounded-md capitalize ${ isSelected ? 'bg-white/10 text-gray-400 font-bold' : '' } ${ active && !isSelected ? 'bg-white/5 text-mineshaft-200 cursor-pointer' : 'text-gray-400' } ` } value={person} > {({ selected: isSelected }) => ( <> {person} {selected ? ( ) : null} )} ))} {buttonAction && ( )} )}
); }; export default ListBox;