mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
site: fix icon copy text
This commit is contained in:
parent
23c4e222c9
commit
cbf9a6a694
@ -70,3 +70,10 @@ ul.anticons-list {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.copied-code {
|
||||
font-size: 12px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 2px;
|
||||
padding: 2px 4px 2px;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { message } from 'antd';
|
||||
import { ThemeType } from '../../../../components/icon';
|
||||
import CopyableIcon from './CopyableIcon';
|
||||
import { injectIntl, InjectedIntlProps } from 'react-intl';
|
||||
@ -20,7 +21,8 @@ class Category extends React.Component<CategoryProps, CategoryState> {
|
||||
justCopied: null,
|
||||
};
|
||||
|
||||
onCopied = (type: string) => {
|
||||
onCopied = (type: string, text: string) => {
|
||||
message.success(<span><code className="copied-code">{text}</code> copied 🎉</span>);
|
||||
this.setState({ justCopied: type }, () => {
|
||||
setTimeout(() => {
|
||||
this.setState({ justCopied: null });
|
||||
|
@ -10,7 +10,7 @@ export interface CopyableIconProps {
|
||||
theme: ThemeType;
|
||||
isNew: boolean;
|
||||
justCopied: string | null;
|
||||
onCopied: (type: string) => any;
|
||||
onCopied: (type: string, text: string) => any;
|
||||
}
|
||||
|
||||
const CopyableIcon: React.SFC<CopyableIconProps> = ({
|
||||
@ -18,8 +18,8 @@ const CopyableIcon: React.SFC<CopyableIconProps> = ({
|
||||
}) => {
|
||||
return (
|
||||
<CopyToClipboard
|
||||
text={theme === 'outlined' ? <Icon type="${type}" /> : `<Icon type="${type}" theme="${theme}" />`}
|
||||
onCopy={() => onCopied(type)}
|
||||
text={theme === 'outlined' ? `<Icon type="${type}" />` : `<Icon type="${type}" theme="${theme}" />`}
|
||||
onCopy={(text: string) => onCopied(type, text)}
|
||||
>
|
||||
<li className={justCopied === type ? 'copied' : ''}>
|
||||
<Icon type={type} theme={theme}/>
|
||||
|
Loading…
Reference in New Issue
Block a user