@@ -15,6 +15,10 @@ interface ConsoleBlockProps {
15
15
children : React . ReactNode ;
16
16
}
17
17
18
+ interface ConsoleBlockMultiProps {
19
+ children : React . ReactNode ;
20
+ }
21
+
18
22
const Box = ( {
19
23
width = '60px' ,
20
24
height = '17px' ,
@@ -29,7 +33,7 @@ const Box = ({
29
33
< div className = { className } style = { { width, height, ...customStyles } } > </ div >
30
34
) ;
31
35
32
- function ConsoleBlock ( { level = 'error' , children} : ConsoleBlockProps ) {
36
+ export function ConsoleBlock ( { level = 'error' , children} : ConsoleBlockProps ) {
33
37
let message : React . ReactNode | null ;
34
38
if ( typeof children === 'string' ) {
35
39
message = children ;
@@ -38,7 +42,7 @@ function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
38
42
}
39
43
40
44
return (
41
- < div className = "mb-4 text-secondary" translate = "no" dir = "ltr" >
45
+ < div className = "console-block mb-4 text-secondary" translate = "no" dir = "ltr" >
42
46
< div className = "flex w-full rounded-t-lg bg-gray-200 dark:bg-gray-80" >
43
47
< div className = "px-4 py-2 border-gray-300 dark:border-gray-90 border-r" >
44
48
< Box className = "bg-gray-300 dark:bg-gray-70" width = "15px" />
@@ -73,4 +77,73 @@ function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
73
77
) ;
74
78
}
75
79
76
- export default ConsoleBlock ;
80
+ export function ConsoleBlockMulti ( { children} : ConsoleBlockMultiProps ) {
81
+ return (
82
+ < div className = "console-block mb-4 text-secondary" translate = "no" dir = "ltr" >
83
+ < div className = "flex w-full rounded-t-lg bg-gray-200 dark:bg-gray-80" >
84
+ < div className = "px-4 py-2 border-gray-300 dark:border-gray-90 border-r" >
85
+ < Box className = "bg-gray-300 dark:bg-gray-70" width = "15px" />
86
+ </ div >
87
+ < div className = "flex text-sm px-4" >
88
+ < div className = "border-b-2 border-gray-300 dark:border-gray-90 text-tertiary dark:text-tertiary-dark" >
89
+ Console
90
+ </ div >
91
+ < div className = "px-4 py-2 flex" >
92
+ < Box className = "me-2 bg-gray-300 dark:bg-gray-70" />
93
+ < Box className = "me-2 hidden md:block bg-gray-300 dark:bg-gray-70" />
94
+ < Box className = "hidden md:block bg-gray-300 dark:bg-gray-70" />
95
+ </ div >
96
+ </ div >
97
+ </ div >
98
+ < div className = "grid grid-cols-1 divide-y divide-gray-300 dark:divide-gray-70 text-base" >
99
+ { children }
100
+ </ div >
101
+ </ div >
102
+ ) ;
103
+ }
104
+
105
+ export function ConsoleLogLine ( { children, level} : ConsoleBlockProps ) {
106
+ let message : React . ReactNode | null ;
107
+ if ( typeof children === 'string' ) {
108
+ message = children ;
109
+ } else if ( isValidElement ( children ) ) {
110
+ message = children . props . children ;
111
+ } else if ( Array . isArray ( children ) ) {
112
+ console . log ( 'array' , children ) ;
113
+ message = children . reduce ( ( result , child ) => {
114
+ if ( typeof child === 'string' ) {
115
+ console . log ( 'adding' , child ) ;
116
+ result += child ;
117
+ } else if ( isValidElement ( child ) ) {
118
+ // @ts -ignore
119
+ console . log ( 'adding' , child . props . children ) ;
120
+ // @ts -ignore
121
+ result += child . props . children ;
122
+ }
123
+ return result ;
124
+ } , '' ) ;
125
+ }
126
+
127
+ return (
128
+ < div
129
+ className = { cn (
130
+ 'ps-4 pe-2 pt-1 pb-2 grid grid-cols-[18px_auto] font-mono rounded-b-md' ,
131
+ {
132
+ 'bg-red-30 text-red-50 dark:text-red-30 bg-opacity-5' :
133
+ level === 'error' ,
134
+ 'bg-yellow-5 text-yellow-50' : level === 'warning' ,
135
+ 'bg-gray-5 text-secondary dark:text-secondary-dark' : level === 'info' ,
136
+ }
137
+ ) } >
138
+ { level === 'error' && (
139
+ < IconError className = "self-start mt-1.5 text-[.7rem] w-6" />
140
+ ) }
141
+ { level === 'warning' && (
142
+ < IconWarning className = "self-start mt-1 text-[.65rem] w-6" />
143
+ ) }
144
+ < div className = "px-2 pt-1 whitespace-break-spaces text-code leading-tight" >
145
+ { message }
146
+ </ div >
147
+ </ div >
148
+ ) ;
149
+ }
0 commit comments