Skip to content

fix(copy): change default copy icon #499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/copy/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { CSSProperties, ReactNode } from 'react';
import { CopyOutlined } from '@ant-design/icons';
import { message, Tooltip } from 'antd';
import classNames from 'classnames';
import useClippy from 'use-clippy';
Expand All @@ -16,9 +15,25 @@ export interface ICopyProps {
onCopy?: (text: string) => void;
}

// 后续迁移了 icon 库之后,可以直接从 icon 中引入
const CopyIcon = () => (
<span className="dtc-copy__default-icon">
<svg
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
fill="currentColor"
>
<path d="M704 96a96 96 0 0 1 96 96v16h32a96 96 0 0 1 96 96v512a96 96 0 0 1-96 96H320a96 96 0 0 1-96-96v-16h-32a96 96 0 0 1-95.936-92.4L96 704V192a96 96 0 0 1 96-96z m96 608a96 96 0 0 1-96 96H288v16a32 32 0 0 0 32 32h512a32 32 0 0 0 32-32V304a32 32 0 0 0-32-32h-32z m-96-544H192a32 32 0 0 0-32 32v512a32 32 0 0 0 32 32h512a32 32 0 0 0 32-32V192a32 32 0 0 0-32-32z m-256 64a32 32 0 0 1 32 32v160h160a32 32 0 1 1 0 64H480v160a32 32 0 1 1-64 0V480H256a32 32 0 1 1 0-64h160V256a32 32 0 0 1 32-32z"></path>
</svg>
</span>
);

const Copy: React.FC<ICopyProps> = (props) => {
const {
button = <CopyOutlined className="dtc-copy__default-icon" />,
button = <CopyIcon />,
text,
tooltip = '复制',
style,
Expand Down
4 changes: 2 additions & 2 deletions src/copy/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.dtc-copy {
display: inline-block;
cursor: pointer;
&__default-icon:hover {
color: #58ABF9;
&__default-icon {
color: #1D78FF;
}
}
Loading