@@ -23,7 +23,7 @@ import {
23
23
import { groupBy , max } from "lodash" ;
24
24
import { CSSProperties , useEffect , useMemo , useState } from "react" ;
25
25
import ToggleGroupControl from "./ToggleGroupControl" ;
26
- import { useMeasure , useUnmount } from "react-use" ;
26
+ import { useMeasure , useMedia , useUnmount } from "react-use" ;
27
27
import { errorCodeMap , FilterEnum , TxnState } from "./consts" ;
28
28
import ToggleControl from "./ToggleControl" ;
29
29
import toggleControlStyles from "./toggleControl.module.css" ;
@@ -41,10 +41,8 @@ interface ChartControlsProps {
41
41
maxTs : number ;
42
42
}
43
43
44
- export default function ChartControls ( {
45
- transactions,
46
- maxTs,
47
- } : ChartControlsProps ) {
44
+ export default function ChartControls ( props : ChartControlsProps ) {
45
+ const { transactions, maxTs } = props ;
48
46
const setChartFilters = useSetAtom ( chartFiltersAtom ) ;
49
47
const setBarCount = useSetAtom ( barCountAtom ) ;
50
48
const setSelectedBank = useSetAtom ( selectedBankAtom ) ;
@@ -61,8 +59,12 @@ export default function ChartControls({
61
59
setTxnState ( TxnState . DEFAULT ) ;
62
60
} ) ;
63
61
62
+ if ( useMedia ( "(max-width: 500px)" ) ) {
63
+ return < MobileViewChartControls { ...props } /> ;
64
+ }
65
+
64
66
return (
65
- < Flex align = "center" gap = "2 " wrap = "wrap" >
67
+ < Flex gap = "2" align = "center " wrap = "wrap" >
66
68
< Separator orientation = "vertical" size = "2" />
67
69
< ErrorControl transactions = { transactions } maxTs = { maxTs } />
68
70
< Separator orientation = "vertical" size = "2" />
@@ -72,24 +74,33 @@ export default function ChartControls({
72
74
< Separator orientation = "vertical" size = "2" />
73
75
< SimpleControl transactions = { transactions } maxTs = { maxTs } />
74
76
< Separator orientation = "vertical" size = "2" />
75
- < FeeControl transactions = { transactions } />
76
- < TipsControl transactions = { transactions } />
77
- < IncomeControl transactions = { transactions } />
77
+ < ToggleSeriesControls transactions = { transactions } />
78
78
< Separator orientation = "vertical" size = "2" />
79
- < Flex gap = "2" >
80
- < Text className = { toggleControlStyles . label } > CU</ Text >
81
- < CuConsumedControl transactions = { transactions } />
82
- < CuRequestedControl transactions = { transactions } />
83
- </ Flex >
79
+ < CuControls transactions = { transactions } />
84
80
< Separator orientation = "vertical" size = "2" />
85
81
< ArrivalControl transactions = { transactions } />
86
82
</ Flex >
87
83
) ;
88
84
}
89
85
86
+ function MobileViewChartControls ( { transactions, maxTs } : ChartControlsProps ) {
87
+ return (
88
+ < Flex direction = "column" gap = "3" >
89
+ < ErrorControl transactions = { transactions } maxTs = { maxTs } />
90
+ < BundleControl transactions = { transactions } maxTs = { maxTs } isMobileView />
91
+ < LandedControl transactions = { transactions } maxTs = { maxTs } isMobileView />
92
+ < SimpleControl transactions = { transactions } maxTs = { maxTs } isMobileView />
93
+ < ToggleSeriesControls transactions = { transactions } />
94
+ < CuControls transactions = { transactions } />
95
+ < ArrivalControl transactions = { transactions } />
96
+ </ Flex >
97
+ ) ;
98
+ }
99
+
90
100
interface ToggleGroupControlProps {
91
101
transactions : SlotTransactions ;
92
102
maxTs : number ;
103
+ isMobileView ?: boolean ;
93
104
}
94
105
95
106
function ErrorControl ( { transactions, maxTs } : ToggleGroupControlProps ) {
@@ -98,7 +109,7 @@ function ErrorControl({ transactions, maxTs }: ToggleGroupControlProps) {
98
109
const [ value , setValue ] = useState < "All" | "Success" | "Errors" > ( "All" ) ;
99
110
100
111
return (
101
- < >
112
+ < Flex gap = "2" >
102
113
< ToggleGroupControl
103
114
options = { [ "All" , "Success" , "Errors" ] }
104
115
optionColors = { { Success : "#30A46C" , Errors : "#E5484D" } }
@@ -118,7 +129,7 @@ function ErrorControl({ transactions, maxTs }: ToggleGroupControlProps) {
118
129
transactions = { transactions }
119
130
isDisabled = { value === "Success" }
120
131
/>
121
- </ >
132
+ </ Flex >
122
133
) ;
123
134
}
124
135
@@ -197,7 +208,11 @@ function HighlightErrorControl({
197
208
) ;
198
209
}
199
210
200
- function BundleControl ( { transactions, maxTs } : ToggleGroupControlProps ) {
211
+ function BundleControl ( {
212
+ transactions,
213
+ maxTs,
214
+ isMobileView,
215
+ } : ToggleGroupControlProps ) {
201
216
const uplotAction = useSetAtom ( txnBarsUplotActionAtom ) ;
202
217
const filterBundle = useSetAtom ( filterBundleDataAtom ) ;
203
218
@@ -212,11 +227,16 @@ function BundleControl({ transactions, maxTs }: ToggleGroupControlProps) {
212
227
filterBundle ( u , transactions , bankIdx , maxTs , value ) ,
213
228
)
214
229
}
230
+ hasMinTextWidth = { isMobileView }
215
231
/>
216
232
) ;
217
233
}
218
234
219
- function LandedControl ( { transactions, maxTs } : ToggleGroupControlProps ) {
235
+ function LandedControl ( {
236
+ transactions,
237
+ maxTs,
238
+ isMobileView,
239
+ } : ToggleGroupControlProps ) {
220
240
const uplotAction = useSetAtom ( txnBarsUplotActionAtom ) ;
221
241
const filterLanded = useSetAtom ( filterLandedDataAtom ) ;
222
242
@@ -231,11 +251,16 @@ function LandedControl({ transactions, maxTs }: ToggleGroupControlProps) {
231
251
filterLanded ( u , transactions , bankIdx , maxTs , value ) ,
232
252
)
233
253
}
254
+ hasMinTextWidth = { isMobileView }
234
255
/>
235
256
) ;
236
257
}
237
258
238
- function SimpleControl ( { transactions, maxTs } : ToggleGroupControlProps ) {
259
+ function SimpleControl ( {
260
+ transactions,
261
+ maxTs,
262
+ isMobileView,
263
+ } : ToggleGroupControlProps ) {
239
264
const uplotAction = useSetAtom ( txnBarsUplotActionAtom ) ;
240
265
const filterSimple = useSetAtom ( filterSimpleDataAtom ) ;
241
266
@@ -250,6 +275,7 @@ function SimpleControl({ transactions, maxTs }: ToggleGroupControlProps) {
250
275
filterSimple ( u , transactions , bankIdx , maxTs , value ) ,
251
276
)
252
277
}
278
+ hasMinTextWidth = { isMobileView }
253
279
/>
254
280
) ;
255
281
}
@@ -258,6 +284,16 @@ interface WithTransactionsProps {
258
284
transactions : SlotTransactions ;
259
285
}
260
286
287
+ function ToggleSeriesControls ( { transactions } : WithTransactionsProps ) {
288
+ return (
289
+ < Flex gap = "2" >
290
+ < FeeControl transactions = { transactions } />
291
+ < TipsControl transactions = { transactions } />
292
+ < IncomeControl transactions = { transactions } />
293
+ </ Flex >
294
+ ) ;
295
+ }
296
+
261
297
function FeeControl ( { transactions } : WithTransactionsProps ) {
262
298
const [ isEnabled , setIsEnabled ] = useState ( false ) ;
263
299
const uplotAction = useSetAtom ( txnBarsUplotActionAtom ) ;
@@ -308,6 +344,16 @@ function TipsControl({ transactions }: WithTransactionsProps) {
308
344
) ;
309
345
}
310
346
347
+ function CuControls ( { transactions } : WithTransactionsProps ) {
348
+ return (
349
+ < Flex gap = "2" >
350
+ < Text className = { toggleControlStyles . label } > CU</ Text >
351
+ < CuConsumedControl transactions = { transactions } />
352
+ < CuRequestedControl transactions = { transactions } />
353
+ </ Flex >
354
+ ) ;
355
+ }
356
+
311
357
function CuConsumedControl ( { transactions } : WithTransactionsProps ) {
312
358
const [ isEnabled , setIsEnabled ] = useState ( false ) ;
313
359
const uplotAction = useSetAtom ( txnBarsUplotActionAtom ) ;
0 commit comments