Skip to content

Commit 19f663d

Browse files
committed
Relace MUI Progress with Oasis UI Library component
1 parent 0ae7b1f commit 19f663d

File tree

4 files changed

+24
-65
lines changed

4 files changed

+24
-65
lines changed

.changelog/2235.internal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Relace MUI Progress with Oasis UI Library component

src/app/components/Blocks/RuntimeBlocks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useTranslation } from 'react-i18next'
22
import { RuntimeBlock } from '../../../oasis-nexus/api'
3-
import { VerticalProgressBar } from '../../components/ProgressBar'
43
import { Table, TableCellAlign, TableColProps } from '../../components/Table'
54
import { paraTimesConfig } from '../../../config'
65
import { TablePaginationProps } from '../Table/TablePagination'
@@ -10,6 +9,7 @@ import { FC } from 'react'
109
import { BlocksTableType } from './index'
1110
import { TableHeaderAge } from '../TableHeaderAge'
1211
import { TableCellAge } from '../TableCellAge'
12+
import { Progress } from '@oasisprotocol/ui-library/src/components/progress'
1313

1414
export type TableRuntimeBlock = RuntimeBlock & {
1515
markAsNew?: boolean
@@ -77,7 +77,7 @@ export const RuntimeBlocks: FC<RuntimeBlocksProps> = ({
7777
...(type === BlocksTableType.Desktop
7878
? [
7979
{
80-
content: <VerticalProgressBar value={(100 * block.gas_used) / blockGasLimit} />,
80+
content: <Progress className="w-6" value={(100 * block.gas_used) / blockGasLimit} />,
8181
key: 'fill',
8282
},
8383
]

src/app/components/ProgressBar/index.tsx

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,6 @@
11
import { FC, ReactNode } from 'react'
2-
import Box from '@mui/material/Box'
3-
import LinearProgress, { linearProgressClasses } from '@mui/material/LinearProgress'
4-
import { styled } from '@mui/material/styles'
5-
import { COLORS } from 'styles/theme/colors'
62
import { Progress } from '@oasisprotocol/ui-library/src/components/progress'
73

8-
type VerticalProgressBarProps = {
9-
value: number
10-
height?: number
11-
width?: number
12-
barWithBorder?: boolean
13-
barBackgroundColor?: string
14-
}
15-
16-
const barSize = 36
17-
18-
export const VerticalProgressBar: FC<VerticalProgressBarProps> = ({
19-
value,
20-
height = barSize,
21-
width = barSize,
22-
barWithBorder = true,
23-
barBackgroundColor,
24-
}) => {
25-
return (
26-
<Box sx={{ height: width, width: height, transform: 'rotate(-90deg)' }}>
27-
<StyledLinearProgress
28-
sx={{ height: width, width: height }}
29-
barWithBorder={barWithBorder}
30-
barBackgroundColor={barBackgroundColor}
31-
variant="determinate"
32-
value={value}
33-
/>
34-
</Box>
35-
)
36-
}
37-
const StyledLinearProgress = styled(LinearProgress, {
38-
shouldForwardProp: prop => prop !== 'barWithBorder' && prop !== 'barBackgroundColor',
39-
})<{ barWithBorder?: boolean; barBackgroundColor?: string }>(({ barWithBorder, barBackgroundColor }) => ({
40-
[`&.${linearProgressClasses.determinate} > .${linearProgressClasses.bar1Determinate}`]: {
41-
backgroundColor: COLORS.brandDark,
42-
},
43-
...(!barWithBorder && { border: '0' }),
44-
...(barBackgroundColor && { backgroundColor: barBackgroundColor }),
45-
}))
46-
474
type CustomProgressProps = {
485
value?: number
496
max?: number

src/app/pages/ValidatorDetailsPage/VotingPowerCard.tsx

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { FC } from 'react'
22
import { useTranslation } from 'react-i18next'
3-
import Typography from '@mui/material/Typography'
3+
import { Typography } from '@oasisprotocol/ui-library/src/components/typography'
44
import { Validator, ValidatorAggStats } from '../../../oasis-nexus/api'
55
import { SnapshotTextCard } from '../../components/Snapshots/SnapshotCard'
6-
import { COLORS } from 'styles/theme/colors'
7-
import { VerticalProgressBar } from 'app/components/ProgressBar'
6+
import { CustomProgress } from 'app/components/ProgressBar'
87
import { PercentageValue } from '../../components/PercentageValue'
98

109
type VotingPowerCardProps = {
@@ -20,31 +19,33 @@ export const VotingPowerCard: FC<VotingPowerCardProps> = ({ validator, stats })
2019
title={t('validator.votingPower')}
2120
label={
2221
typeof validator?.voting_power === 'number' && (
23-
<Typography sx={{ fontSize: 18, color: COLORS.grayMedium }}>
24-
({validator?.voting_power.toLocaleString()})
25-
</Typography>
22+
<Typography>({validator?.voting_power.toLocaleString()})</Typography>
2623
)
2724
}
2825
withContentPadding={false}
2926
>
3027
{typeof validator?.voting_power === 'number' && stats?.total_voting_power && (
31-
<div className="flex justify-between">
32-
<div className="flex flex-col">
33-
<Typography sx={{ fontSize: 12, color: COLORS.grayMedium, textAlign: 'left', paddingBottom: 3 }}>
34-
{t('validator.votingPowerOverall')}
35-
</Typography>
36-
<PercentageValue value={validator.voting_power} total={stats.total_voting_power} />
37-
</div>
28+
<>
29+
<Typography className="font-normal text-xs text-muted-foreground text-left pb-2">
30+
{t('validator.votingPowerOverall')}
31+
</Typography>
3832
<div className="pt-4">
39-
<VerticalProgressBar
40-
height={80}
41-
width={50}
42-
value={(100 * validator.voting_power) / stats.total_voting_power}
43-
barWithBorder={false}
44-
barBackgroundColor={COLORS.grayMediumLight}
33+
<CustomProgress
34+
value={validator.voting_power}
35+
max={stats.total_voting_power}
36+
label={
37+
<span className="font-bold">
38+
<PercentageValue
39+
adaptMaximumFractionDigits
40+
value={validator.voting_power}
41+
total={stats.total_voting_power}
42+
maximumFractionDigits={2}
43+
/>
44+
</span>
45+
}
4546
/>
4647
</div>
47-
</div>
48+
</>
4849
)}
4950
</SnapshotTextCard>
5051
)

0 commit comments

Comments
 (0)