11import React , { ReactNode , useState } from "react" ;
2+ import {
3+ FaChevronDown ,
4+ FaChevronUp ,
5+ FaCheckCircle ,
6+ FaExclamationCircle ,
7+ FaTimesCircle ,
8+ } from "react-icons/fa" ; // Ícones
29
310interface CollapsibleTextProps {
411 title : string ;
@@ -7,6 +14,18 @@ interface CollapsibleTextProps {
714 children ?: ReactNode ;
815}
916
17+ const getStatusIcon = ( status ?: string ) => {
18+ switch ( status ) {
19+ case "success" :
20+ return < FaCheckCircle color = "green" /> ;
21+ case "running" :
22+ return < FaExclamationCircle color = "orange" /> ;
23+ case "failed" :
24+ return < FaTimesCircle color = "red" /> ;
25+ default :
26+ return null ;
27+ }
28+ } ;
1029const CollapsibleText : React . FC < CollapsibleTextProps > = ( {
1130 title,
1231 log,
@@ -16,20 +35,69 @@ const CollapsibleText: React.FC<CollapsibleTextProps> = ({
1635 const [ isOpen , setIsOpen ] = useState ( false ) ;
1736
1837 return (
19- < div style = { { backgroundColor : "#999999" , padding : 12 , margin : 12 } } >
20- { ( log || children || status ) && (
21- < button onClick = { ( ) => setIsOpen ( ! isOpen ) } >
22- { isOpen ? "Hide" : "Show" } { title }
38+ < div
39+ style = { {
40+ backgroundColor : "#f6f8fa" ,
41+ padding : 16 ,
42+ margin : 12 ,
43+ borderRadius : 6 ,
44+ border : "1px solid #d1d5da" ,
45+ } }
46+ >
47+ < div
48+ style = { {
49+ display : "flex" ,
50+ alignItems : "center" ,
51+ justifyContent : "space-between" ,
52+ } }
53+ >
54+ < div style = { { display : "flex" , alignItems : "center" } } >
55+ { getStatusIcon ( status ) }
56+ < span style = { { marginLeft : 8 , fontWeight : 600 } } > { title } </ span >
57+ </ div >
58+ < button
59+ onClick = { ( ) => setIsOpen ( ! isOpen ) }
60+ style = { {
61+ background : "none" ,
62+ border : "none" ,
63+ cursor : "pointer" ,
64+ color : "#0366d6" ,
65+ display : "flex" ,
66+ alignItems : "center" ,
67+ fontSize : 14 ,
68+ } }
69+ >
70+ { isOpen ? "Hide logs" : "Show logs" } { " " }
71+ { isOpen ? < FaChevronUp /> : < FaChevronDown /> }
2372 </ button >
24- ) }
73+ </ div >
74+
2575 { isOpen && ( log || children || status ) && (
26- < >
27- { /* {children} <div dangerouslySetInnerHTML={{ __html: log.replace(/\n/g, "<br />") }} /> */ }
28- { children } < div > { log } </ div >
29- </ >
76+ < div
77+ style = { {
78+ padding : "12px 0" ,
79+ borderTop : "1px solid #e1e4e8" ,
80+ marginTop : 12 ,
81+ } }
82+ >
83+ { children }
84+ { log && (
85+ < pre
86+ style = { {
87+ whiteSpace : "pre-wrap" ,
88+ background : "#f6f8fa" ,
89+ padding : 12 ,
90+ borderRadius : 6 ,
91+ } }
92+ >
93+ { log }
94+ </ pre >
95+ ) }
96+ </ div >
97+ ) }
98+ { status && (
99+ < h4 style = { { color : "#586069" , marginTop : 12 } } > Status: { status } </ h4 >
30100 ) }
31- { status && < h4 > Status: { status } </ h4 > }
32- { /*TODO: change icon based on status... */ }
33101 </ div >
34102 ) ;
35103} ;
0 commit comments