From bad4442aa0daaf49c5c9df5f1e10cf62fa0b5aa3 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Wed, 23 Nov 2022 21:04:50 +0530 Subject: [PATCH] allow copy button customization --- src/components/CodeBlock/CopyButton.tsx | 32 ++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/components/CodeBlock/CopyButton.tsx b/src/components/CodeBlock/CopyButton.tsx index 18f88c752..bc8e09f60 100644 --- a/src/components/CodeBlock/CopyButton.tsx +++ b/src/components/CodeBlock/CopyButton.tsx @@ -1,11 +1,23 @@ import React, { useState } from 'react'; import constants from 'utils/strings/constants'; -import { CopyButtonWrapper } from './styledComponents'; import DoneIcon from '@mui/icons-material/Done'; import ContentCopyIcon from '@mui/icons-material/ContentCopy'; -import { Tooltip } from '@mui/material'; +import { + IconButton, + IconButtonProps, + SvgIconProps, + Tooltip, +} from '@mui/material'; -export default function CopyButton({ code }) { +export default function CopyButton({ + code, + color, + size, +}: { + code: string; + color?: IconButtonProps['color']; + size?: SvgIconProps['fontSize']; +}) { const [copied, setCopied] = useState(false); const copyToClipboardHelper = (text: string) => () => { @@ -14,14 +26,18 @@ export default function CopyButton({ code }) { setTimeout(() => setCopied(false), 1000); }; return ( - - + + {copied ? ( - + ) : ( - + )} - + ); }