File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ describe("CopyText", () => {
5757 expect ( screen . getByText ( "Copied!" ) ) . toBeInTheDocument ( ) ;
5858 } ) ;
5959
60+ it ( "should apply textClassName to the text element" , ( ) => {
61+ render ( < CopyText text = "Hello" textClassName = "custom-text" /> ) ;
62+ expect ( screen . getByText ( "Hello" ) ) . toHaveClass ( "custom-text" ) ;
63+ } ) ;
64+
6065 describe ( "behavior" , ( ) => {
6166 it ( "should copy the text when the button is clicked" , async ( ) => {
6267 render ( < CopyText text = "Let's copy text" /> ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ type CopyTextProps = {
1212 copied ?: boolean ;
1313 onClick ?: ( ) => void ;
1414 text : string ;
15+ textClassName ?: string ;
1516} ;
1617
1718const CopyText = ( {
@@ -23,6 +24,7 @@ const CopyText = ({
2324 showIcon = true ,
2425 copiedButtonLabel = "Copied" ,
2526 copyButtonLabel = "Copy" ,
27+ textClassName,
2628} : CopyTextProps ) => {
2729 const copyText = async ( ) => {
2830 await navigator . clipboard . writeText ( text ) ;
@@ -31,7 +33,7 @@ const CopyText = ({
3133
3234 return (
3335 < span className = { cx ( styles . wrapper , className ) } >
34- { text }
36+ < span className = { textClassName } > { text } </ span >
3537 < button className = { cx ( styles . button , buttonClassName ) } onClick = { copyText } >
3638 { copied ? (
3739 < >
You can’t perform that action at this time.
0 commit comments