Fix copy button
This commit is contained in:
parent
7558a61066
commit
e5e57387c4
3 changed files with 20 additions and 3 deletions
|
@ -15,6 +15,7 @@ const variantToClassName = {
|
||||||
toolbar: [styles.toolbarButton],
|
toolbar: [styles.toolbarButton],
|
||||||
icon: [styles.iconButton],
|
icon: [styles.iconButton],
|
||||||
copy: [styles.copyButton],
|
copy: [styles.copyButton],
|
||||||
|
iconCopy: [styles.iconCopyButton],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Button = forwardRef(
|
export const Button = forwardRef(
|
||||||
|
|
|
@ -16,7 +16,8 @@ limitations under the License.
|
||||||
|
|
||||||
.button,
|
.button,
|
||||||
.toolbarButton,
|
.toolbarButton,
|
||||||
.iconButton {
|
.iconButton,
|
||||||
|
.iconCopyButton {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
@ -154,3 +155,17 @@ limitations under the License.
|
||||||
.copyButton.on svg * {
|
.copyButton.on svg * {
|
||||||
stroke: white;
|
stroke: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.iconCopyButton svg * {
|
||||||
|
fill: var(--textColor3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconCopyButton:hover svg * {
|
||||||
|
fill: #0dbd8b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconCopyButton.on svg *,
|
||||||
|
.iconCopyButton.on:hover svg * {
|
||||||
|
fill: transparent;
|
||||||
|
stroke: #0dbd8b;
|
||||||
|
}
|
||||||
|
|
|
@ -4,14 +4,15 @@ import { ReactComponent as CheckIcon } from "../icons/Check.svg";
|
||||||
import { ReactComponent as CopyIcon } from "../icons/Copy.svg";
|
import { ReactComponent as CopyIcon } from "../icons/Copy.svg";
|
||||||
import { Button } from "./Button";
|
import { Button } from "./Button";
|
||||||
|
|
||||||
export function CopyButton({ value, children, variant, ...rest }) {
|
export function CopyButton({ value, children, onClassName, variant, ...rest }) {
|
||||||
const [isCopied, setCopied] = useClipboard(value, { successDuration: 3000 });
|
const [isCopied, setCopied] = useClipboard(value, { successDuration: 3000 });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
{...rest}
|
{...rest}
|
||||||
variant={variant || "copy"}
|
variant={variant === "icon" ? "iconCopy" : "copy"}
|
||||||
on={isCopied}
|
on={isCopied}
|
||||||
|
onClassName={onClassName}
|
||||||
onPress={setCopied}
|
onPress={setCopied}
|
||||||
iconStyle={isCopied ? "stroke" : "fill"}
|
iconStyle={isCopied ? "stroke" : "fill"}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Reference in a new issue