blob: a0d9656a64543c2b919808ca40b6925c965fc0f2 [file] [log] [blame]
Jiarenxiang38dcb052025-03-13 16:40:09 +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 });
31 return (
32 <li className={className}
33 onClick={() => {
34 if (onSelect) {
35 onSelect(theme, name);
36 }
37 }}>
38 <Tooltip title={name}>
39 {React.createElement(allIcons[name], { className: styles.anticon })}
40 </Tooltip>
41 {/* <span className={styles.anticonClass}>
42 <Badge dot={isNew}>{name}</Badge>
43 </span> */}
44 </li>
45 );
46};
47
48export default CopyableIcon;