Skip to content

Commit 1dd3873

Browse files
authored
Merge pull request #2285 from oasisprotocol/kaja/uil-box-various-5
Convert StyledBox elements
2 parents 4383977 + a42362b commit 1dd3873

File tree

23 files changed

+165
-496
lines changed

23 files changed

+165
-496
lines changed

.changelog/2285.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Convert StyledBox elements.
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
11
import { useTranslation } from 'react-i18next'
2-
import Box from '@mui/material/Box'
32
import Tooltip from '@mui/material/Tooltip'
4-
import { styled } from '@mui/material/styles'
53
import { FC } from 'react'
6-
import { COLORS } from 'styles/theme/colors'
7-
8-
const badgeSize = '27px'
9-
10-
export const StyledBox = styled(Box)(() => ({
11-
background: 'linear-gradient(88deg, #9747FF 1.71%, #3332CB 79.56%)',
12-
border: `2px solid ${COLORS.brandExtraDark}`,
13-
display: 'flex',
14-
justifyContent: 'center',
15-
alignItems: 'center',
16-
width: badgeSize,
17-
minWidth: badgeSize,
18-
height: badgeSize,
19-
borderRadius: badgeSize,
20-
color: COLORS.white,
21-
fontSize: '10px',
22-
fontWeight: 700,
23-
}))
244

255
type AccountSizeBadgeProps = {
266
size: string
@@ -31,7 +11,9 @@ export const AccountSizeBadge: FC<AccountSizeBadgeProps> = ({ size }) => {
3111

3212
return (
3313
<Tooltip arrow placement="top" title={t('account.sizeTooltip', { size })}>
34-
<StyledBox>{size}</StyledBox>
14+
<div className="flex justify-center items-center w-9 h-9 rounded-full text-xs text-white font-semibold bg-primary">
15+
{size}
16+
</div>
3517
</Tooltip>
3618
)
3719
}

src/app/components/Balance/FiatMoneyAmount.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
import { styled } from '@mui/material/styles'
21
import WarningIcon from '@mui/icons-material/WarningAmber'
3-
import Box from '@mui/material/Box'
42
import { useTranslation } from 'react-i18next'
53
import { FC } from 'react'
64
import { CoinGeckoReferral } from '../CoinGeckoReferral'
75
import { FiatValueInfo } from './hooks'
86
import Tooltip from '@mui/material/Tooltip'
97
import { Skeleton } from '@oasisprotocol/ui-library/src/components/ui/skeleton'
108

11-
export const FiatMoneyAmountBox = styled(Box)(() => ({
12-
display: 'flex',
13-
alignItems: 'center',
14-
justifyContent: 'space-between',
15-
gap: 4,
16-
flex: 1,
17-
}))
18-
199
export const FiatMoneyWarning: FC<{ unknownTickers: string[] }> = ({ unknownTickers }) => {
2010
const { t } = useTranslation()
2111
return (
@@ -38,7 +28,7 @@ export const FiatMoneyAmount: FC<FiatValueInfo> = ({
3828
const { t } = useTranslation()
3929
const hasFailed = !!unknownTickers.length
4030
return (
41-
<FiatMoneyAmountBox>
31+
<div className="flex items-center justify-between gap-1 flex-1">
4232
<span>
4333
{!hasFailed ? (
4434
t('common.fiatValueInUSD', {
@@ -55,6 +45,6 @@ export const FiatMoneyAmount: FC<FiatValueInfo> = ({
5545
{loading && <Skeleton className="h-4" />}
5646
</span>
5747
{hasUsedCoinGecko && <CoinGeckoReferral />}
58-
</FiatMoneyAmountBox>
48+
</div>
5949
)
6050
}
Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,19 @@
11
import { FC, ReactNode } from 'react'
2-
import Box from '@mui/material/Box'
3-
import Typography from '@mui/material/Typography'
4-
import { styled } from '@mui/material/styles'
2+
import { Typography } from '@oasisprotocol/ui-library/src/components/typography'
53
import ReportProblemIcon from '@mui/icons-material/ReportProblem'
64
import { COLORS } from '../../../styles/theme/colors'
75

8-
const StyledBox = styled(Box)(({ theme }) => ({
9-
display: 'flex',
10-
flexDirection: 'column',
11-
justifyContent: 'center',
12-
alignItems: 'center',
13-
flex: 1,
14-
gap: theme.spacing(4),
15-
textAlign: 'center',
16-
[theme.breakpoints.down('sm')]: {
17-
padding: theme.spacing(5, 2, 6),
18-
},
19-
[theme.breakpoints.up('sm')]: {
20-
padding: theme.spacing(6, 4, 7),
21-
},
22-
}))
23-
246
type CardEmptyStateProps = {
257
label: string
268
action?: ReactNode
279
}
2810

2911
export const CardEmptyState: FC<CardEmptyStateProps> = ({ label, action }) => (
30-
<StyledBox>
12+
<div className="flex flex-col justify-center items-center flex-1 gap-3 text-center px-1 pt-8 pb-16 sm:px-4 sm:pt-16 sm:pb-32">
3113
<ReportProblemIcon sx={{ color: COLORS.warningColor, fontSize: '60px' }} />
32-
<Typography
33-
sx={{
34-
color: COLORS.grayDark,
35-
display: 'block',
36-
alignItems: 'center',
37-
verticalAlign: 'middle',
38-
}}
39-
>
14+
<Typography className="block align-middle text-gray-700">
4015
{label}
4116
{action}
4217
</Typography>
43-
</StyledBox>
18+
</div>
4419
)

src/app/components/Circle/index.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/app/components/CurrentFiatValue/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FC } from 'react'
22
import { useTranslation } from 'react-i18next'
3-
import { FiatMoneyAmountBox, FiatMoneyWarning } from '../Balance/FiatMoneyAmount'
3+
import { FiatMoneyWarning } from '../Balance/FiatMoneyAmount'
44
import Tooltip from '@mui/material/Tooltip'
55
import { CoinGeckoReferral } from '../CoinGeckoReferral'
66
import HelpIcon from '@mui/icons-material/Help'
@@ -21,7 +21,7 @@ export const CurrentFiatValue: FC<CurrentFiatValueProps> = ({
2121
}) => {
2222
const { t } = useTranslation()
2323
return price === undefined && !hasFailed ? null : (
24-
<FiatMoneyAmountBox>
24+
<div className="flex items-center justify-between gap-1 flex-1">
2525
<div className="inline-flex items-center">
2626
{hasFailed ? (
2727
<FiatMoneyWarning unknownTickers={[ticker]} />
@@ -43,6 +43,6 @@ export const CurrentFiatValue: FC<CurrentFiatValueProps> = ({
4343
)}
4444
</div>
4545
{hasUsedCoinGecko && <CoinGeckoReferral />}
46-
</FiatMoneyAmountBox>
46+
</div>
4747
)
4848
}

src/app/components/LayerPicker/LayerDetails.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Typography } from '@oasisprotocol/ui-library/src/components/typography'
66
import OpenInNewIcon from '@mui/icons-material/OpenInNew'
77
import { Link } from '@oasisprotocol/ui-library/src/components/link'
88
import { styled } from '@mui/material/styles'
9-
import { Circle } from '../Circle'
109
import { COLORS } from '../../../styles/theme/colors'
1110
import { Network, getNetworkNames } from '../../../types/network'
1211
import { Layer } from '../../../oasis-nexus/api'
@@ -227,17 +226,9 @@ export const LayerDetailsSection: FC<LayerDetailsSectionProps> = ({
227226
return (
228227
<div className="flex py-4 px-1 md:px-8" style={{ minHeight: contentMinHeight }}>
229228
<div className="pt-0.5 pr-4 text-primary">
230-
<Circle
231-
color={COLORS.white}
232-
size={5}
233-
sx={{
234-
borderColor: COLORS.brandDark,
235-
borderWidth: '2px',
236-
borderStyle: 'solid',
237-
}}
238-
>
229+
<div className="w-8 h-8 flex justify-center items-center text-inherit rounded-full border-2 border-solid border-primary">
239230
{icons[selectedScope.network]}
240-
</Circle>
231+
</div>
241232
</div>
242233
<div>
243234
<div className="flex items-center pb-2">

src/app/components/PageLayout/NetworkButton.tsx

Lines changed: 2 additions & 10 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 Button, { buttonClasses } from '@mui/material/Button'
54
import EditIcon from '@mui/icons-material/Edit'
65
import { styled } from '@mui/material/styles'
@@ -63,13 +62,6 @@ export const StyledNetworkButton = styled(Button)(({ theme }) => ({
6362
},
6463
}))
6564

66-
export const StyledBox = styled(Box)(({ theme }) => ({
67-
flex: 1,
68-
display: 'flex',
69-
alignItems: 'center',
70-
gap: theme.spacing(3),
71-
}))
72-
7365
type NetworkButtonProps = {
7466
isOutOfDate?: boolean
7567
layer: Layer
@@ -94,10 +86,10 @@ export const NetworkButton: FC<NetworkButtonProps> = ({ isOutOfDate, layer, netw
9486
endIcon={<EditIcon />}
9587
onClick={onClick}
9688
>
97-
<StyledBox>
89+
<div className="flex flex-1 items-center gap-2">
9890
{getNetworkButtonLabel(t, network, layer)}
9991
<LayerStatus isOutOfDate={isOutOfDate} />
100-
</StyledBox>
92+
</div>
10193
</StyledNetworkButton>
10294
)
10395
}

src/app/components/RuntimeEvents/EventError.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FC } from 'react'
22
import { useTranslation } from 'react-i18next'
33
import CancelIcon from '@mui/icons-material/Cancel'
44
import { RuntimeEvent } from '../../../oasis-nexus/api'
5-
import { StatusDetails, StyledBox } from '../StatusIcon'
5+
import { StatusDetails, StatusBadge } from '../StatusIcon'
66

77
// eslint-disable-next-line @typescript-eslint/no-unused-vars
88
import { RuntimeEventType } from '../../../oasis-nexus/api'
@@ -33,11 +33,11 @@ export const EventError: FC<EventErrorProps> = ({ event }) => {
3333
const errorMessage = `${t('errors.code')} ${error.code}, ${t('errors.module')}: ${error.module}`
3434
return (
3535
<>
36-
<StyledBox status="failure" withText>
36+
<StatusBadge status="failure" withText>
3737
{t('common.failed')}
3838
&nbsp;
3939
<CancelIcon color="error" fontSize="inherit" />
40-
</StyledBox>
40+
</StatusBadge>
4141
<StatusDetails error>{errorMessage}</StatusDetails>
4242
</>
4343
)
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
import { FC, ReactNode } from 'react'
2-
import Box from '@mui/material/Box'
32
import Button from '@mui/material/Button'
4-
import { styled } from '@mui/material/styles'
5-
import Typography from '@mui/material/Typography'
3+
import { Typography } from '@oasisprotocol/ui-library/src/components/typography'
64
import { SnapshotCard } from '../../components/Snapshots/SnapshotCard'
7-
import { COLORS } from '../../../styles/theme/colors'
85
import { isUrlSafe } from 'app/utils/url'
96

10-
const StyledBox = styled(Box)(({ theme }) => ({
11-
gap: theme.spacing(5),
12-
padding: '0',
13-
display: 'flex',
14-
flexDirection: 'column',
15-
alignItems: 'stretch',
16-
justifyContent: 'space-between',
17-
}))
18-
197
type SnapshotCardExternalLinkProps = {
208
description: string
219
label?: ReactNode
@@ -31,21 +19,16 @@ export const SnapshotCardExternalLink: FC<SnapshotCardExternalLinkProps> = ({
3119
}) => {
3220
return (
3321
<SnapshotCard title={title} withContentPadding={false}>
34-
<StyledBox>
35-
<Typography
36-
sx={{
37-
fontSize: '12px',
38-
color: COLORS.grayMedium,
39-
}}
40-
>
22+
<div className="flex flex-col items-stretch justify-between gap-4">
23+
<Typography textColor="muted" variant="xsmall">
4124
{description}
4225
</Typography>
4326
{url && isUrlSafe(url) && (
4427
<Button href={url} target="_blank" rel="noopener noreferrer" color="secondary" variant="outlined">
4528
{label}
4629
</Button>
4730
)}
48-
</StyledBox>
31+
</div>
4932
</SnapshotCard>
5033
)
5134
}

0 commit comments

Comments
 (0)