import { useState } from 'react'; import { MenuItem } from '@headlessui/react'; import { BookmarkFilledIcon, BookmarkIcon } from '@radix-ui/react-icons'; import type { FC } from 'react'; import { Spinner } from '~/components/svg'; import { cn } from '~/utils'; type MenuItemProps = { tag: string | React.ReactNode; selected: boolean; count?: number; handleSubmit: (tag?: string) => void; icon?: React.ReactNode; }; const BookmarkItem: FC = ({ tag, selected, handleSubmit, icon, ...rest }) => { const [isLoading, setIsLoading] = useState(false); const clickHandler = async () => { if (tag === 'New Bookmark') { handleSubmit(); return; } setIsLoading(true); handleSubmit(tag as string); setIsLoading(false); }; const breakWordStyle: React.CSSProperties = { wordBreak: 'break-word', overflowWrap: 'anywhere', }; const renderIcon = () => { if (icon != null) { return icon; } if (isLoading) { return ; } if (selected) { return ; } return ; }; return (
{renderIcon()}
{tag}
); }; export default BookmarkItem;