Files
AFFiNE-Mirror/packages/component/src/ui/menu/menu.tsx
T
2023-05-25 14:59:43 +08:00

42 lines
911 B
TypeScript

import type { TooltipProps } from '@mui/material';
import type { CSSProperties } from 'react';
import { Popper, type PopperProps } from '../popper';
import { StyledMenuWrapper } from './styles';
export type MenuProps = {
width?: CSSProperties['width'];
menuStyles?: CSSProperties;
} & PopperProps &
Omit<TooltipProps, 'title' | 'content' | 'placement'>;
export const Menu = (props: MenuProps) => {
const {
width,
menuStyles,
content,
placement = 'bottom-start',
children,
...popperProps
} = props;
return content ? (
<Popper
placement={placement}
{...popperProps}
showArrow={false}
content={
<StyledMenuWrapper
width={width}
placement={placement}
style={menuStyles}
>
{content}
</StyledMenuWrapper>
}
>
{children}
</Popper>
) : null;
};
export default Menu;