import { useState } from '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) => Promise; icon?: React.ReactNode; highlightSelected?: boolean; }; const BookmarkItem: FC = ({ tag, selected, count, handleSubmit, icon, highlightSelected, ...rest }) => { const [isLoading, setIsLoading] = useState(false); const clickHandler = async () => { setIsLoading(true); await handleSubmit(tag as string); setIsLoading(false); }; const breakWordStyle: React.CSSProperties = { wordBreak: 'break-word', overflowWrap: 'anywhere', }; return (
{icon ? ( icon ) : isLoading ? ( ) : selected ? ( ) : ( )}
{tag}
{count !== undefined && (
)}
); }; export default BookmarkItem;