bigbuffet-rw/app/soapbox/components/ui/menu/menu.tsx

35 lines
921 B
TypeScript
Raw Normal View History

2022-03-21 11:09:01 -07:00
import {
Menu,
MenuButton,
MenuItem,
MenuItems,
MenuPopover,
MenuLink,
MenuPopoverProps,
} from '@reach/menu-button';
import { positionDefault, positionRight } from '@reach/popover';
import React from 'react';
import './menu.css';
interface IMenuList extends Omit<MenuPopoverProps, 'position'> {
/** Position of the dropdown menu. */
2022-03-21 11:09:01 -07:00
position?: 'left' | 'right'
}
/** Renders children as a dropdown menu. */
const MenuList: React.FC<IMenuList> = (props) => (
2022-03-21 11:09:01 -07:00
<MenuPopover position={props.position === 'left' ? positionDefault : positionRight}>
<MenuItems
onKeyDown={(event) => event.nativeEvent.stopImmediatePropagation()}
className='py-1 bg-white dark:bg-primary-900 rounded-lg shadow-menu'
2022-03-21 11:09:01 -07:00
{...props}
/>
</MenuPopover>
);
/** Divides menu items. */
2022-03-21 11:09:01 -07:00
const MenuDivider = () => <hr />;
export { Menu, MenuButton, MenuDivider, MenuItems, MenuItem, MenuList, MenuLink };