@@ -15,6 +15,7 @@ import { formatBytes, formatReadableRows, roundToDynamicPrecision } from './util
15
15
import { getGoogleAnalyticsUserIdFromBrowserCookie } from '../../lib/google/google'
16
16
17
17
18
+
18
19
interface Props {
19
20
queryString : string
20
21
runnable : boolean
@@ -55,6 +56,21 @@ function CodeInterpreter({
55
56
}
56
57
} )
57
58
59
+ function useWindowWidth ( ) : number {
60
+ const [ width , setWidth ] = useState ( typeof window !== 'undefined' ? window . innerWidth : 0 )
61
+
62
+ useEffect ( ( ) => {
63
+ function handleResize ( ) {
64
+ setWidth ( window . innerWidth )
65
+ }
66
+
67
+ window . addEventListener ( 'resize' , handleResize )
68
+ return ( ) => window . removeEventListener ( 'resize' , handleResize )
69
+ } , [ ] )
70
+
71
+ return width
72
+ }
73
+
58
74
function generateId ( ) : string {
59
75
return short . generate ( ) . toUpperCase ( ) . slice ( 0 , 27 )
60
76
}
@@ -197,28 +213,29 @@ function CodeInterpreter({
197
213
)
198
214
199
215
return (
200
- < div className = { `flex items-end whitespace-pre-wrap ${ chart && 'w-[180px] h-[28px]' } ` } >
216
+ < div className = { `flex items-end whitespace-pre-wrap flex-nowrap ${ chart && 'w-[180px] h-[28px]' } ` } >
201
217
{ show_results }
202
218
{ chart && (
203
- < div className = '' >
204
- < RadioGroup
205
- orientation = 'vertical'
206
- value = { currentView } >
207
- < RadioGroup . Item
208
- label = 'Table'
209
- onClick = { ( ) : void => {
210
- setCurrentView ( DefaultView . Table )
211
- } }
212
- value = { DefaultView . Table }
213
- />
214
- < RadioGroup . Item
215
- label = 'Chart'
216
- onClick = { ( ) : void => {
217
- setCurrentView ( DefaultView . Chart )
218
- } }
219
- value = { DefaultView . Chart }
220
- />
221
- </ RadioGroup >
219
+ < div className = 'flex-nowrap' >
220
+ < RadioGroup
221
+ orientation = 'horizontal'
222
+ style = { { 'flexWrap' : 'nowrap' } }
223
+ value = { currentView } >
224
+ < RadioGroup . Item
225
+ label = 'Table'
226
+ onClick = { ( ) : void => {
227
+ setCurrentView ( DefaultView . Table )
228
+ } }
229
+ value = { DefaultView . Table }
230
+ />
231
+ < RadioGroup . Item
232
+ label = 'Chart'
233
+ onClick = { ( ) : void => {
234
+ setCurrentView ( DefaultView . Chart )
235
+ } }
236
+ value = { DefaultView . Chart }
237
+ />
238
+ </ RadioGroup >
222
239
</ div >
223
240
) }
224
241
@@ -227,16 +244,20 @@ function CodeInterpreter({
227
244
}
228
245
}
229
246
247
+ const windowWidth = useWindowWidth ( )
248
+
230
249
const runButton = ( ) => {
250
+
231
251
if ( runnable ) {
232
252
return (
233
253
< div className = 'flex justify-between' >
234
- < div className = 'flex items-center' >
254
+ < div className = 'flex items-center flex-nowrap ' >
235
255
< div className = 'flex items-center' > { hideTableResultButton ( ) } </ div >
236
256
< div className = 'flex items-end min-h-[28px]' >
237
257
{ show_statistics && results ?. response ?. statistics && (
238
- < div className = { `whitespace-pre-wrap text-[12px] mx-auto italic ${ chart ? 'ml-[8px]' : '' } ` } >
239
- { `Read ${ formatReadableRows ( results . response . statistics . rows_read ) } rows and ${ formatBytes ( results . response . statistics . bytes_read ) } in ${ roundToDynamicPrecision ( results . response . statistics . elapsed ) } secs` }
258
+ < div className = { `whitespace-pre-wrap text-[${ windowWidth > 600 ? '12' : '10' } px] mx-auto italic ${ chart ? 'ml-[8px]' : '' } ` } >
259
+ { windowWidth > 600 ? `Read ${ formatReadableRows ( results . response . statistics . rows_read ) } rows and ${ formatBytes ( results . response . statistics . bytes_read ) } in ${ roundToDynamicPrecision ( results . response . statistics . elapsed ) } secs` :
260
+ `Read ${ formatReadableRows ( results . response . statistics . rows_read ) } rows in ${ roundToDynamicPrecision ( results . response . statistics . elapsed ) } secs` }
240
261
</ div >
241
262
) }
242
263
</ div >
0 commit comments