mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 16:46:22 +08:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { ArrowDownSmallIcon } from '@blocksuite/icons/rc';
|
|
import type { ButtonHTMLAttributes, MouseEventHandler } from 'react';
|
|
import { forwardRef } from 'react';
|
|
|
|
import * as styles from './styles.css';
|
|
|
|
type DropdownButtonProps = {
|
|
size?: 'small' | 'default';
|
|
onClickDropDown?: MouseEventHandler<HTMLElement>;
|
|
} & ButtonHTMLAttributes<HTMLButtonElement>;
|
|
|
|
export const DropdownButton = forwardRef<
|
|
HTMLButtonElement,
|
|
DropdownButtonProps
|
|
>(({ onClickDropDown, children, size = 'default', ...props }, ref) => {
|
|
const handleClickDropDown: MouseEventHandler<HTMLElement> = e => {
|
|
e.stopPropagation();
|
|
onClickDropDown?.(e);
|
|
};
|
|
return (
|
|
<button
|
|
ref={ref}
|
|
data-size={size}
|
|
className={styles.dropdownBtn}
|
|
{...props}
|
|
>
|
|
<span>{children}</span>
|
|
<span className={styles.divider} />
|
|
<span className={styles.dropdownWrapper} onClick={handleClickDropDown}>
|
|
<ArrowDownSmallIcon
|
|
className={styles.dropdownIcon}
|
|
width={16}
|
|
height={16}
|
|
/>
|
|
</span>
|
|
</button>
|
|
);
|
|
});
|
|
DropdownButton.displayName = 'DropdownButton';
|