11import { ReactNode } from 'react'
2- import Box from '@mui/material/Box'
32import Tooltip from '@mui/material/Tooltip'
4- import { styled } from '@mui/material/styles'
5- import { COLORS } from '../../../styles/theme/colors'
3+ import { cn } from '@oasisprotocol/ui-library/src/lib/utils'
64
7- const StyledSquare = styled ( Box , {
8- shouldForwardProp : prop => prop !== 'success' ,
9- } ) ( ( { success } : { success ?: boolean } ) => {
10- return {
11- display : 'flex' ,
12- width : '24px' ,
13- height : '24px' ,
14- borderRadius : '3px' ,
15- backgroundColor : success ? COLORS . eucalyptus : COLORS . errorIndicatorBackground ,
16- }
17- } )
5+ const Square = ( { success, size = 32 } : { success ?: boolean ; size ?: number } ) => {
6+ const borderRadius = size <= 8 ? 2 : 6
7+
8+ return (
9+ < div
10+ className = { cn ( success ? 'bg-success' : 'bg-destructive' ) }
11+ style = { {
12+ width : `${ size } px` ,
13+ height : `${ size } px` ,
14+ borderRadius : `${ borderRadius } px` ,
15+ } }
16+ />
17+ )
18+ }
1819
1920type BlockStatsProps < T > = {
2021 data : T [ ]
@@ -39,25 +40,25 @@ export const BlockStats = <T extends { [key: string]: any }>({
3940
4041 return (
4142 < >
42- < Box sx = { { display : ' flex' , flexWrap : ' wrap' } } gap = { 2 } >
43+ < div className = " flex flex- wrap gap-2" >
4344 { data . map ( item => {
4445 const title = tooltipFormatter ? tooltipFormatter ( item [ dataKey ] . toString ( ) ) : item [ dataKey ]
4546 return (
4647 < Tooltip key = { item [ dataKey ] } title = { title } placement = "top" >
47- < StyledSquare success = { item [ statusKey ] } />
48+ < Square success = { item [ statusKey ] } />
4849 </ Tooltip >
4950 )
5051 } ) }
51- </ Box >
52+ </ div >
5253 { legendLabels && (
53- < Box pt = { 5 } sx = { { display : ' flex' } } >
54- < Box gap = { 3 } mr = { 4 } sx = { { display : 'flex' } } >
55- < StyledSquare success /> { legendLabels . success }
56- </ Box >
57- < Box gap = { 3 } sx = { { display : ' flex' } } >
58- < StyledSquare /> { legendLabels . fail }
59- </ Box >
60- </ Box >
54+ < div className = "pt-8 flex" >
55+ < div className = "flex gap-2 mr-4 items-center" >
56+ < Square success size = { 8 } /> { legendLabels . success }
57+ </ div >
58+ < div className = " flex gap-2 items-center" >
59+ < Square size = { 8 } /> { legendLabels . fail }
60+ </ div >
61+ </ div >
6162 ) }
6263 </ >
6364 )
0 commit comments