@@ -14,12 +14,14 @@ interface CopyTextProps {
1414 children : string ;
1515 className ?: string ;
1616 showButton ?: boolean ;
17+ alwaysShowButton ?: boolean ;
1718}
1819
1920export const CopyText = ( {
2021 children,
2122 className,
2223 showButton = true ,
24+ alwaysShowButton = false ,
2325} : CopyTextProps ) => {
2426 const [ isCopied , setIsCopied ] = useState ( false ) ;
2527 const [ isFlashing , setIsFlashing ] = useState ( false ) ;
@@ -81,12 +83,17 @@ export const CopyText = ({
8183 variant = "ghost"
8284 size = "icon"
8385 className = { cn (
84- "h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100" ,
85- isCopied && "opacity-100" ,
86+ "h-6 w-6 shrink-0 transition-opacity duration-200" ,
87+ alwaysShowButton || isCopied
88+ ? "opacity-100"
89+ : "opacity-0 group-hover:opacity-100" ,
8690 ) }
8791 onClick = { handleButtonClick }
8892 >
89- < CopyIcon isCopied = { isCopied } isHovered = { isHovered } />
93+ < CopyIcon
94+ isCopied = { isCopied }
95+ alwaysShow = { alwaysShowButton || isHovered }
96+ />
9097 </ Button >
9198 ) }
9299 </ InlineStack >
@@ -96,10 +103,10 @@ export const CopyText = ({
96103
97104interface CopyIconProps {
98105 isCopied : boolean ;
99- isHovered : boolean ;
106+ alwaysShow : boolean ;
100107}
101108
102- const CopyIcon = ( { isCopied, isHovered } : CopyIconProps ) => (
109+ const CopyIcon = ( { isCopied, alwaysShow } : CopyIconProps ) => (
103110 < span className = "relative h-3.5 w-3.5" >
104111 < Icon
105112 name = "Check"
@@ -114,7 +121,7 @@ const CopyIcon = ({ isCopied, isHovered }: CopyIconProps) => (
114121 size = "sm"
115122 className = { cn (
116123 "absolute inset-0 text-muted-foreground transition-all duration-200" ,
117- isHovered && ! isCopied
124+ alwaysShow && ! isCopied
118125 ? "rotate-0 scale-100 opacity-100"
119126 : "rotate-90 scale-0 opacity-0" ,
120127 ) }
0 commit comments