Skip to content

Commit 03cbf12

Browse files
committed
feat: add support for custom initial tooltip in clipboard button
1 parent 0464882 commit 03cbf12

File tree

5 files changed

+14
-30
lines changed

5 files changed

+14
-30
lines changed

src/Assets/IconV2/ic-key.svg

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Common/ClipboardButton/ClipboardButton.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg'
3131
*/
3232
export const ClipboardButton = ({
3333
content,
34+
initialTippyText = 'Copy',
3435
copiedTippyText = 'Copied!',
3536
duration = 1000,
3637
copyToClipboardPromise,
@@ -94,19 +95,17 @@ export const ClipboardButton = ({
9495
const iconClassName = `icon-dim-${iconSize} dc__no-shrink`
9596

9697
return (
97-
<Tooltip content="Copy" alwaysShowTippyOnHover={!copied}>
98+
<Tooltip content={copied ? copiedTippyText : initialTippyText} alwaysShowTippyOnHover>
9899
{/* TODO: semantically buttons should not be nested; fix later */}
99100
<button
100101
type="button"
101102
className={`dc__outline-none-imp p-0 flex dc__transparent--unstyled dc__no-border ${rootClassName}`}
102103
aria-label={`Copy ${content}`}
103104
onClick={handleCopyContent}
104105
>
105-
<Tooltip content={copiedTippyText} alwaysShowTippyOnHover visible={copied}>
106-
<div className="flex">
107-
{copied ? <Check className={iconClassName} /> : <ICCopy className={iconClassName} />}
108-
</div>
109-
</Tooltip>
106+
<div className="flex">
107+
{copied ? <Check className={iconClassName} /> : <ICCopy className={iconClassName} />}
108+
</div>
110109
</button>
111110
</Tooltip>
112111
)

src/Common/ClipboardButton/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
export default interface ClipboardProps {
1818
content: string
19+
initialTippyText?: string
1920
copiedTippyText?: string
2021
duration?: number
2122
copyToClipboardPromise?: Promise<void>

src/Shared/Components/DevtronLicenseCard/DevtronLicenseCard.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,17 @@ export const DevtronLicenseCard = ({
101101
</div>
102102
<div className="flexbox-col dc__gap-2">
103103
<div className="flexbox dc__align-items-center dc__gap-6">
104-
<Icon name="ic-key" color="N900" size={16} />
105-
<div className="flex dc__gap-4 cn-7 fs-16 fw-5 lh-1-5 cn-9 font-ibm-plex-mono">
104+
<div className="flex dc__gap-2 cn-7 fs-16 fw-5 lh-1-5 cn-9 font-ibm-plex-mono">
106105
<span>&bull;&bull;&bull;&bull;</span>
107106
<span>{licenseSuffix || licenseKey?.slice(-8)}</span>
108107
</div>
109-
{licenseKey && <ClipboardButton content={licenseKey} onClick={onCopyButtonClick} />}
108+
{licenseKey && (
109+
<ClipboardButton
110+
initialTippyText="Copy license key"
111+
content={licenseKey}
112+
onClick={onCopyButtonClick}
113+
/>
114+
)}
110115
</div>
111116
<div className="flexbox dc__align-items-center dc__gap-4 flex-wrap fs-12">
112117
<span className="font-ibm-plex-mono cn-9">{expiryDate}</span>

src/Shared/Components/Icon/Icon.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import { ReactComponent as ICInfoFilled } from '@IconsV2/ic-info-filled.svg'
5858
import { ReactComponent as ICInfoOutline } from '@IconsV2/ic-info-outline.svg'
5959
import { ReactComponent as ICJobColor } from '@IconsV2/ic-job-color.svg'
6060
import { ReactComponent as ICK8sJob } from '@IconsV2/ic-k8s-job.svg'
61-
import { ReactComponent as ICKey } from '@IconsV2/ic-key.svg'
6261
import { ReactComponent as ICLdap } from '@IconsV2/ic-ldap.svg'
6362
import { ReactComponent as ICLivspace } from '@IconsV2/ic-livspace.svg'
6463
import { ReactComponent as ICLoginDevtronLogo } from '@IconsV2/ic-login-devtron-logo.svg'
@@ -153,7 +152,6 @@ export const iconMap = {
153152
'ic-info-outline': ICInfoOutline,
154153
'ic-job-color': ICJobColor,
155154
'ic-k8s-job': ICK8sJob,
156-
'ic-key': ICKey,
157155
'ic-ldap': ICLdap,
158156
'ic-livspace': ICLivspace,
159157
'ic-login-devtron-logo': ICLoginDevtronLogo,

0 commit comments

Comments
 (0)