11'use client' ;
22
3- import { DocumentDuplicateIcon } from '@heroicons/react/24/outline' ;
43import classNames from 'classnames' ;
54import { Fragment , isValidElement , useRef } from 'react' ;
6- import { CheckIcon } from '@heroicons/react/24/outline' ;
75
86import BaseButton from '#ui/Common/BaseButton' ;
97
108import type { LinkLike } from '#ui/types' ;
11- import type { FC , PropsWithChildren , ReactElement } from 'react' ;
9+ import type { FC , PropsWithChildren , ReactElement , ReactNode } from 'react' ;
1210
1311import styles from './index.module.css' ;
1412
@@ -70,8 +68,7 @@ type CodeBoxProps = {
7068 className ?: string ;
7169 onCopy : ( text : string ) => void ;
7270 as ?: LinkLike ;
73- buttonText : string ;
74- showCopyButton ?: boolean ;
71+ buttonContent : ReactNode ;
7572 copied ?: boolean ;
7673} ;
7774
@@ -80,10 +77,8 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
8077 language,
8178 className,
8279 onCopy,
83- buttonText ,
80+ buttonContent ,
8481 as = 'a' ,
85- showCopyButton = true ,
86- copied = false ,
8782} : PropsWithChildren < CodeBoxProps > ) => {
8883 const containerRef = useRef < HTMLPreElement > ( null ) ;
8984
@@ -106,21 +101,14 @@ const BaseCodeBox: FC<PropsWithChildren<CodeBoxProps>> = ({
106101 { language && (
107102 < div className = { styles . footer } >
108103 < span className = { styles . language } > { language } </ span >
109- { showCopyButton && (
110- < BaseButton
111- as = { as }
112- className = { styles . action }
113- kind = "neutral"
114- onClick = { handleCopy }
115- >
116- { copied ? (
117- < CheckIcon className = { styles . icon } />
118- ) : (
119- < DocumentDuplicateIcon className = { styles . icon } />
120- ) }
121- { buttonText }
122- </ BaseButton >
123- ) }
104+ < BaseButton
105+ as = { as }
106+ className = { styles . action }
107+ kind = "neutral"
108+ onClick = { handleCopy }
109+ >
110+ { buttonContent }
111+ </ BaseButton >
124112 </ div >
125113 ) }
126114 </ div >
0 commit comments