import { Menu } from '@fluid-design/fluid-ui'; import { ArrowRightOnRectangleIcon, BellIcon, ChevronRightIcon, CogIcon, DocumentIcon, PencilIcon, TrashIcon, UserIcon, VideoCameraIcon, } from '@heroicons/react/24/outline'; import { PlusCircleIcon } from '@heroicons/react/24/solid'; import Image from 'next/image'; import { Fragment, useState } from 'react'; import clsxm from '@/lib/clsxm'; import { useToast } from '@/lib/useToast'; import { CodeFrameComponentWrap } from '../framework/CodeFrameComponentWrap'; /* .clickable { @apply border border-transparent hocus:border-gray-400/30 hocus:bg-gray-400/10 dark:hocus:border-gray-300/30 dark:hocus:bg-gray-500/10; } */ const avatarImage = 'https://images.unsplash.com/photo-1626544827763-d516dce335e2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=80&q=80'; const DefaultMenu = ({ className = '' }) => { const [present] = useToast(); const [isLoading, setIsLoading] = useState(false); const [isEditing, setIsEditing] = useState(false); const [isLoggedOut, setIsLoggedOut] = useState(false); const toggleStateWithTimeout = (setState: (state: boolean) => void) => { setState(true); setTimeout(() => { setState(false); }, 2300); }; const CustomIcon = () => (
); return ( present({ title: 'Profile', icon: UserIcon, }), }, { label: 'Notifications', role: 'info', iconStart: , badge: 4, iconEndPosition: 'between', onClick: () => { present({ title: 'Notifications', icon: BellIcon, }); }, }, { role: 'separator', }, { label: 'Logout', role: 'destructive', iconStart: ArrowRightOnRectangleIcon, isLoading, isLoaded: isLoggedOut, loadedOptions: { text: 'Signed out', }, disabled: isLoading, loadingOptions: { animation: 'spin-large', }, onClick: (e) => { e.preventDefault(); toggleStateWithTimeout(setIsLoading); setTimeout(() => { toggleStateWithTimeout(setIsLoggedOut); }, 2300); present({ title: 'Logout', }); }, }, ]} />
avatar

Custom Menu

{ e.preventDefault(); toggleStateWithTimeout(setIsEditing); }} > Edit Delete
present({ icon: VideoCameraIcon, }), }, { icon: DocumentIcon, onClick: () => present({ icon: DocumentIcon, }), }, ]} />
); }; const BasicExample = () => { const [present] = useToast(); return (
present({ title: 'Profile', icon: UserIcon, }), }, { role: 'separator', }, { label: 'Notifications', role: 'info', iconStart: BellIcon, onClick: () => present({ title: 'Notifications', icon: BellIcon, }), }, ]} />
); }; DefaultMenu.displayName = 'DefaultMenu'; BasicExample.displayName = 'BasicExample'; export const MenuExamples = Object.assign( {}, { Default: DefaultMenu, Basic: BasicExample } );