import { FC } from 'react'; import { Button, Dropdown, Menu } from 'antd'; import { EllipsisOutlined, HeartOutlined, BellOutlined } from '@ant-design/icons'; import styles from './ActionButtonMenu.module.scss'; import { ExternalAction } from '../../../interfaces/external-action'; const NOTIFY_KEY = 'notify'; const FOLLOW_KEY = 'follow'; export type ActionButtonMenuProps = { actions: ExternalAction[]; showFollowItem?: boolean; showNotifyItem?: boolean; externalActionSelected: (action: ExternalAction) => void; notifyItemSelected: () => void; followItemSelected: () => void; }; export const ActionButtonMenu: FC = ({ actions, externalActionSelected, notifyItemSelected, followItemSelected, showFollowItem, showNotifyItem, }) => { const onMenuClick = a => { if (a.key === NOTIFY_KEY) { notifyItemSelected(); return; } if (a.key === FOLLOW_KEY) { followItemSelected(); return; } const action = actions.find(x => x.url === a.key); externalActionSelected(action); }; const items = actions.map(action => ({ key: action.url, label: ( {action.icon && {action.title}}{' '} {action.title} ), })); if (showFollowItem) { items.unshift({ key: FOLLOW_KEY, label: ( Follow this stream ), }); } if (showNotifyItem) { items.unshift({ key: NOTIFY_KEY, label: ( Notify when live ), }); } const menu = ; return (
); };