11'use client' ;
22
3- import { CodeBracketIcon } from '@heroicons/react/24/outline' ;
3+ import {
4+ DocumentDuplicateIcon ,
5+ CodeBracketIcon ,
6+ } from '@heroicons/react/24/outline' ;
47import BaseCodeBox from '@node-core/ui-components/Common/BaseCodeBox' ;
5- import styles from '@node-core/ui-components/Common/BaseCodeBox/index.module.css' ;
6- import { useNotification } from '@node-core/ui-components/Providers/NotificationProvider' ;
78import { useTranslations } from 'next-intl' ;
89
910import Link from '#site/components/Link' ;
@@ -14,34 +15,30 @@ import type { FC, PropsWithChildren } from 'react';
1415type CodeBoxProps = {
1516 language : string ;
1617 className ?: string ;
17- showCopyButton ?: boolean ;
1818} ;
1919
2020const CodeBox : FC < PropsWithChildren < CodeBoxProps > > = props => {
21- const [ , copyToClipboard ] = useCopyToClipboard ( ) ;
22- const notify = useNotification ( ) ;
21+ const [ copied , copyToClipboard ] = useCopyToClipboard ( ) ;
2322 const t = useTranslations ( ) ;
2423
25- const onCopy = ( text : string ) => {
26- copyToClipboard ( text ) ;
27-
28- notify ( {
29- duration : 800 ,
30- message : (
31- < div className = "flex items-center gap-3" >
32- < CodeBracketIcon className = { styles . icon } />
33- { t ( 'components.common.codebox.copied' ) }
34- </ div >
35- ) ,
36- } ) ;
37- } ;
38-
3924 return (
4025 < BaseCodeBox
4126 as = { Link }
42- onCopy = { onCopy }
27+ onCopy = { copyToClipboard }
28+ buttonContent = {
29+ copied ? (
30+ < >
31+ < DocumentDuplicateIcon className = "size-4" />
32+ { t ( 'components.common.codebox.copied' ) }
33+ </ >
34+ ) : (
35+ < >
36+ < CodeBracketIcon className = "size-4" />
37+ { t ( 'components.common.codebox.copy' ) }
38+ </ >
39+ )
40+ }
4341 { ...props }
44- buttonText = { t ( 'components.common.codebox.copy' ) }
4542 />
4643 ) ;
4744} ;
0 commit comments