Skip to content

Commit 20e5386

Browse files
authored
Merge pull request #2250 from oasisprotocol/kaja/uil-box-consensus
Update Boxes on Consensus related pages
2 parents e4a235b + a27e7cb commit 20e5386

File tree

11 files changed

+61
-147
lines changed

11 files changed

+61
-147
lines changed

.changelog/2250.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update Boxes on Consensus related pages.

src/app/components/ConsensusEvents/ConsensusEventsList.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { FC } from 'react'
22
import { useTranslation } from 'react-i18next'
3-
import Box from '@mui/material/Box'
43
import { ConsensusScope } from '../../../types/searchScope'
54
import { ConsensusEvent } from '../../../oasis-nexus/api'
65
import { TablePagination, TablePaginationProps } from '../Table/TablePagination'
@@ -55,9 +54,9 @@ export const ConsensusEventsList: FC<{
5554
</div>
5655
))}
5756
{pagination && (
58-
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
57+
<div className="flex justify-center">
5958
<TablePagination {...pagination} />
60-
</Box>
59+
</div>
6160
)}
6261
</>
6362
)

src/app/components/Snapshots/SnapshotCard.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import CardContent from '@mui/material/CardContent'
55
import CardActions from '@mui/material/CardActions'
66
import { styled } from '@mui/material/styles'
77

8-
export const StyledCard = styled(Card)(({ theme }) => ({
8+
export const StyledCard = styled(Card, {
9+
shouldForwardProp: prop => prop !== 'noBorder',
10+
})<{ noBorder?: boolean }>(({ theme, noBorder }) => ({
911
display: 'flex',
1012
flex: 1,
1113
flexDirection: 'column',
@@ -15,6 +17,8 @@ export const StyledCard = styled(Card)(({ theme }) => ({
1517
margin: 0,
1618
},
1719
height: 186,
20+
border: noBorder ? 0 : undefined,
21+
backgroundColor: '#FAFAFA',
1822
}))
1923

2024
const StyledCardContent = styled(CardContent, {
@@ -31,6 +35,7 @@ type SnapshotCardProps = PropsWithChildren & {
3135
title: ReactNode
3236
withContentPadding?: boolean
3337
alignWithCardsWithActions?: boolean
38+
noBorder?: boolean
3439
}
3540

3641
export const SnapshotCard: FC<SnapshotCardProps> = ({
@@ -40,20 +45,19 @@ export const SnapshotCard: FC<SnapshotCardProps> = ({
4045
label,
4146
withContentPadding = true,
4247
alignWithCardsWithActions = false,
48+
noBorder = false,
4349
}) => {
4450
return (
45-
<StyledCard>
46-
<Typography variant="h4" className="pl-4 pt-4">
51+
<StyledCard noBorder={noBorder}>
52+
<Typography variant="h4" className="pl-4 pt-4 text-sm">
4753
{title}
4854
</Typography>
4955
<StyledCardContent withContentPadding={withContentPadding}>{children}</StyledCardContent>
5056
{(badge || label || alignWithCardsWithActions) && (
5157
<CardActions sx={{ minHeight: 60 }}>
5258
<div className="flex justify-between items-center w-full px-4 pb-4">
5359
<div>{badge}</div>
54-
<Typography textColor="muted" className="flex-1">
55-
{label}
56-
</Typography>
60+
<div className="flex-1 text-muted-foreground">{label}</div>
5761
</div>
5862
</CardActions>
5963
)}

src/app/pages/ConsensusAccountDetailsPage/BalanceDistribution.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { FC } from 'react'
22
import { useTranslation } from 'react-i18next'
3-
import Box from '@mui/material/Box'
43
import Card from '@mui/material/Card'
54
import CardContent from '@mui/material/CardContent'
65
import { Skeleton } from '@oasisprotocol/ui-library/src/components/ui/skeleton'
@@ -74,7 +73,7 @@ const BalanceDistributionContent: FC<BalanceDistributionContentProps> = ({ accou
7473
value: totalValue,
7574
})}
7675
</Typography>
77-
<Box sx={{ height: isMobile ? '100px' : '250px' }}>
76+
<div className="h-[100px] md:h-[250px]">
7877
<PieChart
7978
compact={isMobile}
8079
data={data}
@@ -88,7 +87,7 @@ const BalanceDistributionContent: FC<BalanceDistributionContentProps> = ({ accou
8887
label: (label: string) => label,
8988
}}
9089
/>
91-
</Box>
90+
</div>
9291
</>
9392
)
9493
}

src/app/pages/ConsensusAccountDetailsPage/ConsensusAccountTransactionsCard.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { ConsensusAccountDetailsContext } from './hooks'
77
import { LinkableCardLayout } from 'app/components/LinkableCardLayout'
88
import { useScreenSize } from '../../hooks/useScreensize'
99
import { ConsensusTransactionMethodFilter } from '../../components/Transactions/ConsensusTransactionMethodFilter'
10-
import Box from '@mui/material/Box'
1110
import { transactionsContainerId } from '../../utils/tabAnchors'
1211

1312
export const ConsensusAccountTransactionsCard: FC<ConsensusAccountDetailsContext> = context => {
@@ -18,14 +17,9 @@ export const ConsensusAccountTransactionsCard: FC<ConsensusAccountDetailsContext
1817
<LinkableCardLayout
1918
containerId={transactionsContainerId}
2019
title={
21-
<Box
22-
sx={{
23-
display: 'flex',
24-
justifyContent: 'end',
25-
}}
26-
>
20+
<div className="flex justify-end">
2721
{!isMobile && <ConsensusTransactionMethodFilter value={txMethod} setValue={setTxMethod} />}
28-
</Box>
22+
</div>
2923
}
3024
>
3125
{isMobile && <ConsensusTransactionMethodFilter value={txMethod} setValue={setTxMethod} expand />}

src/app/pages/ConsensusBlockDetailPage/ConsensusBlockTransactionsCard.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
getConsensusTransactionMethodFilteringParam,
1515
ConsensusTxMethodFilterOption,
1616
} from '../../components/ConsensusTransactionMethod'
17-
import Box from '@mui/material/Box'
1817
import { transactionsContainerId } from '../../utils/tabAnchors'
1918

2019
const TransactionList: FC<{
@@ -66,14 +65,9 @@ export const ConsensusBlockTransactionsCard: FC<ConsensusBlockDetailsContext> =
6665
<LinkableCardLayout
6766
containerId={transactionsContainerId}
6867
title={
69-
<Box
70-
sx={{
71-
display: 'flex',
72-
justifyContent: 'end',
73-
}}
74-
>
68+
<div className="flex justify-end">
7569
{!isMobile && <ConsensusTransactionMethodFilter value={txMethod} setValue={setTxMethod} />}
76-
</Box>
70+
</div>
7771
}
7872
>
7973
{isMobile && <ConsensusTransactionMethodFilter value={txMethod} setValue={setTxMethod} expand />}

src/app/pages/ConsensusDashboardPage/RuntimePreview.tsx

Lines changed: 31 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { FC, ReactNode, useState } from 'react'
22
import { Link as RouterLink } from 'react-router-dom'
33
import { useTranslation } from 'react-i18next'
4-
import Box from '@mui/material/Box'
54
import { Button } from '@oasisprotocol/ui-library/src/components/ui/button'
6-
import Link from '@mui/material/Link'
7-
import Typography from '@mui/material/Typography'
5+
import { Link } from '@oasisprotocol/ui-library/src/components/link'
6+
import { Typography } from '@oasisprotocol/ui-library/src/components/typography'
87
import { styled } from '@mui/material/styles'
98
import FilterNoneIcon from '@mui/icons-material/FilterNone'
109
import RadioButtonUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked'
@@ -38,55 +37,6 @@ const StyledList = styled(InlineDescriptionList)(({ theme }) => ({
3837
},
3938
}))
4039

41-
const StyledBox = styled(Box)(() => ({
42-
border: `2px solid ${COLORS.brandDark}`,
43-
borderRadius: '12px',
44-
height: '180px',
45-
display: 'flex',
46-
flex: 1,
47-
justifyContent: 'center',
48-
alignItems: 'center',
49-
boxShadow: '0px 34px 24px -9px #324DAB1F',
50-
overflow: 'hidden',
51-
}))
52-
53-
const StyledTypography = styled(Typography)(() => ({
54-
fontSize: '18px',
55-
fontWeight: 700,
56-
color: COLORS.brandDark,
57-
flex: 1,
58-
minHeight: '44px',
59-
display: 'flex',
60-
alignItems: 'center',
61-
}))
62-
63-
const StyledDisabledRuntime = styled(Box)(({ theme }) => ({
64-
display: 'flex',
65-
gap: 3,
66-
paddingTop: theme.spacing(3),
67-
flexDirection: 'row',
68-
alignItems: 'center',
69-
[theme.breakpoints.between('md', 'xl')]: {
70-
flexDirection: 'column',
71-
alignItems: 'flex-start',
72-
},
73-
}))
74-
75-
const StyledEnabledRuntime = styled(Box)(({ theme }) => ({
76-
flex: 1,
77-
height: '100%',
78-
paddingTop: theme.spacing(3),
79-
paddingBottom: theme.spacing(3),
80-
[theme.breakpoints.down('lg')]: {
81-
paddingBottom: theme.spacing(5),
82-
borderBottom: `1px solid ${COLORS.grayMediumLight}`,
83-
},
84-
[theme.breakpoints.up('lg')]: {
85-
paddingRight: theme.spacing(4),
86-
borderRight: `1px solid ${COLORS.grayMediumLight}`,
87-
},
88-
}))
89-
9040
type RuntimeProps = {
9141
prominentItem?: boolean
9242
network: Network
@@ -134,12 +84,14 @@ export const DisabledRuntimePreview: FC<DisabledRuntimePreviewProps> = ({ runtim
13484
const runtimeLabel = layerLabels[runtime]
13585

13686
return (
137-
<StyledDisabledRuntime>
138-
<StyledTypography>{runtimeLabel}</StyledTypography>
139-
<Box>
87+
<div className="flex gap-2 flex-row items-center pt-2 lg:pt-0">
88+
<Typography className="text-base font-semibold text-primary flex items-center flex-1 min-h-[44px]">
89+
{runtimeLabel}
90+
</Typography>
91+
<div>
14092
<Badge variant="info">{t('paratimes.inactive')}</Badge>
141-
</Box>
142-
</StyledDisabledRuntime>
93+
</div>
94+
</div>
14395
)
14496
}
14597

@@ -161,28 +113,28 @@ const RuntimePreview: FC<RuntimePreviewProps> = ({ prominentItem, network, runti
161113
const dashboardLink = RouteUtils.getDashboardRoute({ network, layer: runtime })
162114
const runtimeStatus = status ? (status.outOfDate ? 'outdated' : 'stable') : 'inactive'
163115
return (
164-
<StyledEnabledRuntime>
165-
<Box sx={{ marginBottom: 4 }}>
166-
<StyledTypography>
116+
<div className="flex-1 h-full pb-6 border-b border-gray-200 lg:p-0 lg:pr-4 lg:border-b-0 lg:border-r">
117+
<div className="mb-4">
118+
<Typography className="text-base font-semibold text-primary flex items-center flex-1 min-h-[44px]">
167119
{status ? (
168120
<>
169-
<Link component={RouterLink} to={dashboardLink}>
170-
{runtimeLabel}
121+
<Link asChild>
122+
<RouterLink to={dashboardLink}>{runtimeLabel}</RouterLink>
171123
</Link>
172124
<RouterLinkCircle to={dashboardLink} />
173125
</>
174126
) : (
175127
<>{runtimeLabel}</>
176128
)}
177-
</StyledTypography>
178-
</Box>
129+
</Typography>
130+
</div>
179131
<StyledList>
180132
<dt>{t('common.status')}:</dt>
181133
<dd>
182-
<Box>
134+
<div>
183135
{runtimeStatus === 'stable' && <Badge variant="success">{t('common.online')}</Badge>}
184136
{runtimeStatus === 'outdated' && <Badge variant="error">{t('paratimes.outdated')}</Badge>}
185-
</Box>
137+
</div>
186138
</dd>
187139
<dt>{t('paratimes.blockNumber')}</dt>
188140
<dd>
@@ -201,7 +153,7 @@ const RuntimePreview: FC<RuntimePreviewProps> = ({ prominentItem, network, runti
201153
<dt>{t('paratimes.nodes')} </dt>
202154
<dd>{status?.activeNodes ? t('paratimes.activeNodes', { nodes: status?.activeNodes }) : '-'} </dd>
203155
</StyledList>
204-
<Box sx={{ display: 'flex', gap: 3 }}>
156+
<div className="flex gap-2">
205157
<ChartsContainer status={status}>
206158
{panel === 'transactions' && (
207159
<TransactionsChartCard
@@ -210,6 +162,7 @@ const RuntimePreview: FC<RuntimePreviewProps> = ({ prominentItem, network, runti
210162
network,
211163
}}
212164
chartDuration={ChartDuration.TODAY}
165+
noBorder
213166
/>
214167
)}
215168
{panel === 'accounts' && (
@@ -219,6 +172,7 @@ const RuntimePreview: FC<RuntimePreviewProps> = ({ prominentItem, network, runti
219172
network,
220173
}}
221174
chartDuration={ChartDuration.TODAY}
175+
noBorder
222176
/>
223177
)}
224178
</ChartsContainer>
@@ -230,12 +184,13 @@ const RuntimePreview: FC<RuntimePreviewProps> = ({ prominentItem, network, runti
230184
network,
231185
}}
232186
chartDuration={ChartDuration.TODAY}
187+
noBorder
233188
/>
234189
</ChartsContainer>
235190
)}
236-
</Box>
191+
</div>
237192
{!prominentItem && (
238-
<Box sx={{ display: 'flex', justifyContent: 'center', paddingTop: 3 }}>
193+
<div className="flex justify-center pt-2">
239194
{status && (
240195
<>
241196
<PanelButton
@@ -252,9 +207,9 @@ const RuntimePreview: FC<RuntimePreviewProps> = ({ prominentItem, network, runti
252207
/>
253208
</>
254209
)}
255-
</Box>
210+
</div>
256211
)}
257-
</StyledEnabledRuntime>
212+
</div>
258213
)
259214
}
260215

@@ -296,16 +251,16 @@ const ChartsContainer: FC<ChartsContainerProps> = ({ children, status }) => {
296251
const { t } = useTranslation()
297252

298253
return (
299-
<StyledBox>
300-
<Box gap={3} sx={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
301-
{status && <Box sx={{ width: '100%' }}>{children}</Box>}
254+
<div className="flex flex-1 items-center justify-center h-[180px] border-1 border-gray-200 rounded-md overflow-hidden">
255+
<div className="flex flex-1 flex-col items-center gap-2">
256+
{status && <div className="w-full">{children}</div>}
302257
{!status && (
303258
<>
304259
<FilterNoneIcon sx={{ color: COLORS.brandDark, fontSize: '33px' }} />
305260
{t('paratimes.noData')}
306261
</>
307262
)}
308-
</Box>
309-
</StyledBox>
263+
</div>
264+
</div>
310265
)
311266
}

0 commit comments

Comments
 (0)