File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/shared/container/components Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 11import { Icon } from '@/shared/icons' ;
22import { cn } from '@/shared/lib' ;
33import { cva , type VariantProps } from 'class-variance-authority' ;
4+ import type * as React from 'react' ;
5+ import { useState } from 'react' ;
46
57const addressCopyStyle = cva (
68 'flex items-center justify-start flex-shrink-0 rounded-full transition-all duration-200' ,
@@ -21,16 +23,31 @@ interface AddressCopyProps
2123 extends React . HTMLAttributes < HTMLDivElement > ,
2224 VariantProps < typeof addressCopyStyle > {
2325 label ?: string ;
26+ value ?: string ;
2427}
2528
2629const AddressCopy = ( {
2730 label = 'address copy' ,
31+ value = label ,
2832 variant = 'gray' ,
2933 className,
3034 ...props
3135} : AddressCopyProps ) => {
36+ const [ copied , setCopied ] = useState ( false ) ;
37+
38+ const handleCopy = async ( ) => {
39+ try {
40+ await navigator . clipboard . writeText ( value ) ;
41+ setCopied ( true ) ;
42+ setTimeout ( ( ) => setCopied ( false ) , 1500 ) ;
43+ } catch ( err ) {
44+ console . error ( '주소 복사 실패:' , err ) ;
45+ }
46+ } ;
47+
3248 return (
3349 < div
50+ onClick = { handleCopy }
3451 className = { cn (
3552 addressCopyStyle ( { variant } ) ,
3653 'w-[35.4rem] h-[4rem] px-[1.3rem] py-[1rem] gap-[0.4rem]' ,
You can’t perform that action at this time.
0 commit comments