blob: 371cba0c6dc144c64118a81ffe93102ca3ed2b71 [file] [log] [blame]
86133aaa3f5d2025-04-20 21:33:29 +08001import * as React from 'react';
2import { Tooltip } from 'antd';
3import classNames from 'classnames';
4import * as AntdIcons from '@ant-design/icons';
5import type { ThemeType } from './index';
6import styles from './style.less';
7
8const allIcons: {
9 [key: string]: any;
10} = AntdIcons;
11
12export interface CopyableIconProps {
13 name: string;
14 isNew: boolean;
15 theme: ThemeType;
16 justCopied: string | null;
17 onSelect: (type: string, text: string) => any;
18}
19
20const CopyableIcon: React.FC<CopyableIconProps> = ({
21 name,
22 justCopied,
23 onSelect,
24 theme,
25}) => {
26 const className = classNames({
27 copied: justCopied === name,
28 [theme]: !!theme,
29 });
30 return (
31 <li className={className}
32 onClick={() => {
33 if (onSelect) {
34 onSelect(theme, name);
35 }
36 }}>
37 <Tooltip title={name}>
38 {React.createElement(allIcons[name], { className: styles.anticon })}
39 </Tooltip>
40 {/* <span className={styles.anticonClass}>
41 <Badge dot={isNew}>{name}</Badge>
42 </span> */}
43 </li>
44 );
45};
46
47export default CopyableIcon;