File tree Expand file tree Collapse file tree 2 files changed +15
-17
lines changed
apps/site/components/Common
packages/ui-components/src/Common/BaseCodeBox Expand file tree Collapse file tree 2 files changed +15
-17
lines changed Original file line number Diff line number Diff line change 11'use client' ;
22
3- import { CodeBracketIcon } from '@heroicons/react/24/outline' ;
43import 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' ;
74import { useTranslations } from 'next-intl' ;
85
96import Link from '#site/components/Link' ;
@@ -18,30 +15,24 @@ type CodeBoxProps = {
1815} ;
1916
2017const CodeBox : FC < PropsWithChildren < CodeBoxProps > > = props => {
21- const [ , copyToClipboard ] = useCopyToClipboard ( ) ;
22- const notify = useNotification ( ) ;
18+ const [ copied , copyToClipboard ] = useCopyToClipboard ( ) ;
2319 const t = useTranslations ( ) ;
2420
2521 const onCopy = ( text : string ) => {
2622 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- } ) ;
3723 } ;
3824
3925 return (
4026 < BaseCodeBox
4127 as = { Link }
4228 onCopy = { onCopy }
29+ copied = { copied }
4330 { ...props }
44- buttonText = { t ( 'components.common.codebox.copy' ) }
31+ buttonText = {
32+ copied
33+ ? t ( 'components.common.codebox.copied' )
34+ : t ( 'components.common.codebox.copy' )
35+ }
4536 />
4637 ) ;
4738} ;
Original file line number Diff line number Diff line change 33import { DocumentDuplicateIcon } from '@heroicons/react/24/outline' ;
44import classNames from 'classnames' ;
55import { Fragment , isValidElement , useRef } from 'react' ;
6+ import { CheckIcon } from '@heroicons/react/24/outline' ;
67
78import BaseButton from '#ui/Common/BaseButton' ;
89
@@ -71,6 +72,7 @@ type CodeBoxProps = {
7172 as ?: LinkLike ;
7273 buttonText : string ;
7374 showCopyButton ?: boolean ;
75+ copied ?: boolean ;
7476} ;
7577
7678const BaseCodeBox : FC < PropsWithChildren < CodeBoxProps > > = ( {
@@ -81,6 +83,7 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
8183 buttonText,
8284 as = 'a' ,
8385 showCopyButton = true ,
86+ copied = false ,
8487} : PropsWithChildren < CodeBoxProps > ) => {
8588 const containerRef = useRef < HTMLPreElement > ( null ) ;
8689
@@ -110,7 +113,11 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
110113 kind = "neutral"
111114 onClick = { handleCopy }
112115 >
113- < DocumentDuplicateIcon className = { styles . icon } />
116+ { copied ? (
117+ < CheckIcon className = { styles . icon } />
118+ ) : (
119+ < DocumentDuplicateIcon className = { styles . icon } />
120+ ) }
114121 { buttonText }
115122 </ BaseButton >
116123 ) }
You can’t perform that action at this time.
0 commit comments