Skip to content

Commit c202667

Browse files
committed
feat: add common copy button using Button component
1 parent fa1bedd commit c202667

File tree

6 files changed

+59
-13
lines changed

6 files changed

+59
-13
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { ReactComponent as ICClipboard } from '@Icons/ic-copy.svg'
2+
import { ReactComponent as ICCheck } from '@Icons/ic-check.svg'
3+
import { useState } from 'react'
4+
import { ComponentSizeType } from '@Shared/constants'
5+
import { copyToClipboard, showError } from '@Common/index'
6+
import { Button, ButtonProps, ButtonStyleType, ButtonVariantType } from '../Button'
7+
8+
interface CopyButtonProps {
9+
buttonConfig?: Partial<Pick<ButtonProps, 'style' | 'variant' | 'size' | 'text'>>
10+
copyContent: string
11+
}
12+
13+
const CopyButton = ({ buttonConfig, copyContent }: CopyButtonProps) => {
14+
const [clicked, setClicked] = useState<boolean>(false)
15+
16+
const handleCopy = async () => {
17+
try {
18+
await copyToClipboard(copyContent)
19+
setClicked(true)
20+
setTimeout(() => {
21+
setClicked(false)
22+
}, 1000)
23+
} catch (err) {
24+
showError(err)
25+
}
26+
}
27+
28+
return (
29+
<Button
30+
dataTestId="copy-button"
31+
text={buttonConfig?.text || 'Copy'}
32+
startIcon={clicked ? <ICCheck /> : <ICClipboard />}
33+
style={buttonConfig?.style ?? ButtonStyleType.default}
34+
variant={buttonConfig?.variant ?? ButtonVariantType.primary}
35+
size={buttonConfig?.size ?? ComponentSizeType.large}
36+
onClick={handleCopy}
37+
/>
38+
)
39+
}
40+
41+
export default CopyButton
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as CopyButton } from './CopyButton'

src/Shared/Components/DevtronLicenseCard/DevtronLicenseCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const DevtronLicenseCard = ({
9090
transformStyle: 'preserve-3d',
9191
transform: 'translateZ(0)',
9292
}}
93+
whileHover={{ scale: 1.05 }}
9394
>
9495
<div className="p-20 flexbox-col dc__content-space flex-grow-1">
9596
<div className="flexbox dc__content-space dc__gap-72">
@@ -98,9 +99,9 @@ export const DevtronLicenseCard = ({
9899
</span>
99100
<Icon name="ic-devtron" color="N900" size={24} />
100101
</div>
101-
<div className="flexbox-col dc__gap-4">
102+
<div className="flexbox-col dc__gap-2">
102103
<div className="flexbox dc__align-items-center dc__gap-6">
103-
<Icon name="ic-key" color={null} size={16} />
104+
<Icon name="ic-key" color="N900" size={16} />
104105
<div className="flex dc__gap-4 cn-7 fs-16 fw-5 lh-1-5 cn-9 font-ibm-plex-mono">
105106
<span>&bull;&bull;&bull;&bull;</span>
106107
<span>{licenseSuffix || licenseKey?.slice(-8)}</span>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.license-card {
22

33
.trial-license-badge {
4-
background-color: var(--bg-hover);
4+
background-color: var(--divider-secondary-translucent);
55
letter-spacing: 0.55px;
66
}
77
}

src/Shared/Components/LoginBanner/LoginBanner.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const AnimatedBackground = () => (
2727
r="2000"
2828
fill="#FD0000"
2929
animate={{ scale: [1, 0.9], y: [0, 50] }}
30-
transition={{ duration: 8, repeat: Infinity, repeatType: 'reverse' }}
30+
transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse' }}
3131
/>
3232
<motion.circle
3333
cx="418"
@@ -39,15 +39,15 @@ const AnimatedBackground = () => (
3939
x: [0, 1000],
4040
rotate: [0, 60],
4141
}}
42-
transition={{ duration: 8, repeat: Infinity, repeatType: 'reverse' }}
42+
transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse' }}
4343
/>
4444
<motion.circle
4545
cx="418"
4646
cy="2953"
4747
r="1525"
4848
fill="#A412DF"
4949
animate={{ scale: [0.8, 1], x: [0, 50], y: [-100, 200] }}
50-
transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse' }}
50+
transition={{ duration: 2, repeat: Infinity, repeatType: 'reverse' }}
5151
/>
5252
<motion.circle
5353
cx="418"
@@ -59,7 +59,7 @@ const AnimatedBackground = () => (
5959
x: [0, 1000],
6060
rotate: [0, 60],
6161
}}
62-
transition={{ duration: 8, repeat: Infinity, repeatType: 'reverse' }}
62+
transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse' }}
6363
/>
6464
<motion.ellipse
6565
cx="759.5"
@@ -68,7 +68,7 @@ const AnimatedBackground = () => (
6868
ry="975"
6969
fill="white"
7070
animate={{ scale: [0.8, 1], x: [0, 50], y: [-100, 200] }}
71-
transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse' }}
71+
transition={{ duration: 2, repeat: Infinity, repeatType: 'reverse' }}
7272
/>
7373
<motion.path
7474
d="M1449.92 730.265C1649.97 261.314 2460.84 884.083 2656.59 1131.43C2852.35 1378.78 3240.21 2146.55 2913.48 2307.57C2508.24 2507.29 2384.89 1871.7 2116.5 1567.52C1848.1 1263.34 1326.48 1019.64 1449.92 730.265Z"
@@ -79,7 +79,7 @@ const AnimatedBackground = () => (
7979
'M659.5 743.5C527.947 250.927 1702.5 356.5 2267 825.5C2831.5 1294.5 2825.95 1970.73 2476.5 2073.5C1657 2314.5 1824.89 1047.68 1556.5 743.5C1288.11 439.319 769 1153.5 659.5 743.5Z',
8080
],
8181
}}
82-
transition={{ duration: 8, repeat: Infinity, repeatType: 'reverse' }}
82+
transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse' }}
8383
/>
8484
<motion.circle
8585
cx="1479"
@@ -91,7 +91,7 @@ const AnimatedBackground = () => (
9191
x: [0, 1000],
9292
rotate: [0, 60],
9393
}}
94-
transition={{ duration: 8, repeat: Infinity, repeatType: 'reverse' }}
94+
transition={{ duration: 4, repeat: Infinity, repeatType: 'reverse' }}
9595
/>
9696
</svg>
9797
</motion.div>
@@ -115,9 +115,11 @@ const LoginBanner = () => {
115115

116116
return (
117117
<div className="flexbox-col br-12 border__primary dc__position-rel dc__overflow-hidden bg__primary">
118-
<div className="flexbox-col flex-grow-1 pt-32 pl-32 dc__content-space">
119-
<div className="flex h-36 w-130 dc__fill-available-space dc__zi-2">
120-
<Icon name="ic-devtron-header-logo" color="N900" />
118+
<div className="flexbox-col flex-grow-1 dc__content-space">
119+
<div className="pl-32 pt-32">
120+
<div className="flex h-36 w-130 dc__fill-available-space dc__zi-2">
121+
<Icon name="ic-devtron-header-logo" color="N900" />
122+
</div>
121123
</div>
122124
<AnimatedBackground />
123125
<img

src/Shared/Components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ export * from './FlagImage'
9292
export * from './DevtronLicenseCard'
9393
export * from './LoginBanner'
9494
export * from './Confetti'
95+
export * from './CopyButton'

0 commit comments

Comments
 (0)