mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-13 16:16:46 +08:00
34 lines
945 B
TypeScript
34 lines
945 B
TypeScript
import type { HTMLAttributes, PropsWithChildren, ReactElement } from 'react';
|
|
import { forwardRef } from 'react';
|
|
|
|
import {
|
|
StyledContent,
|
|
StyledEndIconWrapper,
|
|
StyledMenuItem,
|
|
StyledStartIconWrapper,
|
|
} from './styles';
|
|
|
|
export type IconMenuProps = PropsWithChildren<{
|
|
icon?: ReactElement;
|
|
endIcon?: ReactElement;
|
|
iconSize?: [number, number];
|
|
disabled?: boolean;
|
|
active?: boolean;
|
|
disableHover?: boolean;
|
|
}> &
|
|
HTMLAttributes<HTMLButtonElement>;
|
|
|
|
export const MenuItem = forwardRef<HTMLButtonElement, IconMenuProps>(
|
|
({ endIcon, icon, children, ...props }, ref) => {
|
|
return (
|
|
<StyledMenuItem ref={ref} {...props}>
|
|
{icon && <StyledStartIconWrapper>{icon}</StyledStartIconWrapper>}
|
|
<StyledContent>{children}</StyledContent>
|
|
{endIcon && <StyledEndIconWrapper>{endIcon}</StyledEndIconWrapper>}
|
|
</StyledMenuItem>
|
|
);
|
|
}
|
|
);
|
|
MenuItem.displayName = 'MenuItem';
|
|
export default MenuItem;
|