增加ActionIcon组件。
This commit is contained in:
25
src/components/ActionIcon.tsx
Normal file
25
src/components/ActionIcon.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Icon, IconProps } from '@iconify/react/dist/iconify.js';
|
||||
import cx from 'clsx';
|
||||
import { MouseEventHandler, useCallback } from 'react';
|
||||
import styles from './ActionIcon.module.css';
|
||||
|
||||
type ActionIconProps = {
|
||||
icon: IconProps['icon'];
|
||||
onClick?: MouseEventHandler<HTMLButtonElement>;
|
||||
extendClassName?: HTMLButtonElement['className'];
|
||||
};
|
||||
|
||||
export function ActionIcon({ icon, onClick, extendClassName }: ActionIconProps) {
|
||||
const handleClick = useCallback(
|
||||
(event: MouseEvent<HTMLButtonElement>) => {
|
||||
onClick?.(event);
|
||||
},
|
||||
[onClick],
|
||||
);
|
||||
|
||||
return (
|
||||
<button onClick={handleClick} className={cx(styles.action_icon, extendClassName)}>
|
||||
<Icon icon={icon} className={styles.icon} />
|
||||
</button>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user