Skip to content

Commit 50e105f

Browse files
committed
Update Box element
1 parent 9b2dc2c commit 50e105f

File tree

11 files changed

+77
-203
lines changed

11 files changed

+77
-203
lines changed

src/app/components/AccountAvatar/__tests__/__snapshots__/AccountAvatar.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`AccountAvatar > 0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3 1`] = `
44
<div>
55
<div
6-
class="MuiBox-root css-u1jr60"
6+
style="height: 40px; width: 40px; display: inline-block;"
77
>
88
<div
99
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 40px; height: 40px; display: inline-block; background: rgb(24, 176, 242);"
@@ -47,7 +47,7 @@ exports[`AccountAvatar > 0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3 1`] = `
4747
exports[`AccountAvatar > 0xdAC17F958D2ee523a2206206994597C13D831ec7 1`] = `
4848
<div>
4949
<div
50-
class="MuiBox-root css-u1jr60"
50+
style="height: 40px; width: 40px; display: inline-block;"
5151
>
5252
<div
5353
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 40px; height: 40px; display: inline-block; background: rgb(200, 20, 77);"
@@ -91,7 +91,7 @@ exports[`AccountAvatar > 0xdAC17F958D2ee523a2206206994597C13D831ec7 1`] = `
9191
exports[`AccountAvatar > oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe 1`] = `
9292
<div>
9393
<div
94-
class="MuiBox-root css-u1jr60"
94+
style="height: 40px; width: 40px; display: inline-block;"
9595
>
9696
<div
9797
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 40px; height: 40px; display: inline-block; background: rgb(24, 107, 242);"
@@ -135,7 +135,7 @@ exports[`AccountAvatar > oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe 1`] = `
135135
exports[`AccountAvatar > oasis1qz0k5q8vjqvu4s4nwxyj406ylnflkc4vrcjghuwk 1`] = `
136136
<div>
137137
<div
138-
class="MuiBox-root css-u1jr60"
138+
style="height: 40px; width: 40px; display: inline-block;"
139139
>
140140
<div
141141
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 40px; height: 40px; display: inline-block; background: rgb(250, 129, 0);"
Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,8 @@
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'
52
import lightBackgroundEmptyState from './images/background-empty-state.svg'
63
import darkBackgroundEmptyState from './images/background-empty-state-dark.svg'
74
import CancelIcon from '@mui/icons-material/Cancel'
8-
import { COLORS } from '../../../styles/theme/colors'
9-
10-
const StyledBox = styled(Box)(({ theme }) => ({
11-
display: 'flex',
12-
alignItems: 'center',
13-
justifyContent: 'center',
14-
flexDirection: 'column',
15-
color: theme.palette.layout.main,
16-
backgroundImage: `url("${darkBackgroundEmptyState}")`,
17-
backgroundPosition: 'center',
18-
backgroundRepeat: 'no-repeat',
19-
backgroundSize: 'cover',
20-
borderRadius: 6,
21-
}))
22-
23-
const StyledBoxLight = styled(Box)(() => ({
24-
display: 'flex',
25-
alignItems: 'center',
26-
justifyContent: 'center',
27-
flexDirection: 'column',
28-
backgroundImage: `url("${lightBackgroundEmptyState}")`,
29-
color: COLORS.brandExtraDark,
30-
backgroundPosition: 'center',
31-
backgroundRepeat: 'no-repeat',
32-
backgroundSize: 'cover',
33-
height: '100%',
34-
}))
5+
import { cn } from '@oasisprotocol/ui-library/src/lib/utils'
356

367
type EmptyStateProps = {
378
description: ReactNode
@@ -42,21 +13,25 @@ type EmptyStateProps = {
4213

4314
export const EmptyState: FC<EmptyStateProps> = ({ description, title, light, minHeight = '360px' }) => {
4415
const content = (
45-
<Box sx={{ color: light ? 'inherit' : COLORS.white, textAlign: 'center' }}>
46-
<Typography component="span" sx={{ fontSize: '30px', fontWeight: 500, display: 'block' }}>
47-
{title}
48-
</Typography>
49-
<Typography component="span" sx={{ fontSize: '16px' }}>
50-
{description}
51-
</Typography>
52-
</Box>
16+
<div className={cn('text-center', light ? 'text-inherit' : 'text-white')}>
17+
<span className="block text-2xl font-medium">{title}</span>
18+
<span className="text-sm">{description}</span>
19+
</div>
5320
)
5421
return light ? (
55-
<StyledBoxLight sx={{ minHeight }}>
22+
<div
23+
className="flex flex-col items-center justify-center bg-no-repeat bg-cover bg-center h-full"
24+
style={{ backgroundImage: `url(${lightBackgroundEmptyState})`, minHeight }}
25+
>
5626
<CancelIcon color="error" fontSize="large" />
5727
{content}
58-
</StyledBoxLight>
28+
</div>
5929
) : (
60-
<StyledBox sx={{ minHeight }}>{content}</StyledBox>
30+
<div
31+
className="flex flex-col items-center justify-center bg-no-repeat bg-cover bg-center rounded-md text-white"
32+
style={{ backgroundImage: `url(${darkBackgroundEmptyState})`, minHeight }}
33+
>
34+
{content}
35+
</div>
6136
)
6237
}

src/app/components/ErrorDisplay/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { AppError, AppErrors, ErrorPayload } from '../../../types/errors'
66
import { TFunction } from 'i18next'
77
import { GoToFirstPageLink } from '../Table/GoToFirstPageLink'
88
import { ExploreOasisButton } from '../../pages/SearchResultsPage/ExploreOasisButton'
9-
import Box from '@mui/material/Box'
109
import { SearchSuggestionsLinksForNoResults } from '../Search/SearchSuggestionsLinksForNoResults'
1110
import { SearchScope } from '../../../types/searchScope'
1211
import { useScopeParam } from '../../hooks/useScopeParam'
@@ -78,20 +77,16 @@ const errorMap: Record<
7877
title: t('errors.notFoundProposal'),
7978
message: t('errors.validateURL'),
8079
}),
81-
[AppErrors.InvalidUrl]: (t, _, scope, theme) => ({
80+
[AppErrors.InvalidUrl]: (t, _, scope) => ({
8281
title: t('errors.invalidUrl'),
8382
message: (
84-
<Box
85-
sx={{
86-
a: { color: theme.palette.layout.contrastMain, textDecoration: 'underline' },
87-
}}
88-
>
83+
<div>
8984
<p>
9085
<SearchSuggestionsLinksForNoResults scope={scope} suggestSearch />
9186
</p>
9287
<p>{t('errors.alternativelyGoExplore')}</p>
9388
<ExploreOasisButton />
94-
</Box>
89+
</div>
9590
),
9691
}),
9792
[AppErrors.UnsupportedLayer]: t => ({

src/app/components/HighlightedText/index.tsx

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,13 @@
11
import * as React from 'react'
22
import { findTextMatches, NormalizerOptions, PositiveMatchInfo } from './text-matching'
33
import { FC, ReactNode } from 'react'
4-
import { SxProps } from '@mui/material/styles'
5-
import Box from '@mui/material/Box'
64
import { useHighlightPattern } from '../PatternHighlightingContext'
75

86
export interface HighlightOptions {
97
/**
108
* Options for identifying the matches
119
*/
1210
findOptions?: NormalizerOptions
13-
14-
/**
15-
* Which class to use for highlighting?
16-
*
17-
* Please don't supply both class and style together.
18-
*/
19-
className?: string
20-
21-
/**
22-
* Which styles to use for highlighting?
23-
*
24-
* Please don't supply both class and style together.
25-
*/
26-
sx?: SxProps
27-
}
28-
29-
const defaultHighlightStyle: SxProps = {
30-
background: '#FFFF5480',
31-
padding: '2px',
32-
margin: '-2px',
33-
}
34-
35-
const defaultHighlight: HighlightOptions = {
36-
sx: defaultHighlightStyle,
3711
}
3812

3913
export type HighlightPattern = string[]
@@ -65,13 +39,9 @@ interface HighlightedTextProps {
6539
/**
6640
* Display a text, with potential pattern matches highlighted with html MARKs
6741
*/
68-
export const HighlightedText: FC<HighlightedTextProps> = ({
69-
text,
70-
partsToHighlight,
71-
options = defaultHighlight,
72-
}) => {
42+
export const HighlightedText: FC<HighlightedTextProps> = ({ text, partsToHighlight, options = {} }) => {
7343
const pattern = useHighlightPattern()
74-
const { sx = defaultHighlightStyle, findOptions = {} } = options
44+
const { findOptions = {} } = options
7545

7646
// Have we been told what to highlight exactly? If not, look for the pattern
7747
const matches = partsToHighlight ?? findTextMatches(text, pattern, findOptions)
@@ -100,9 +70,9 @@ export const HighlightedText: FC<HighlightedTextProps> = ({
10070
pieces.push(text.substring(processedChars, match.startPos))
10171
const focus = text.substring(match.startPos, match.endPos)
10272
pieces.push(
103-
<Box key={processedMatches} component="mark" sx={sx}>
73+
<mark key={processedMatches} className="bg-yellow-200 px-0.5 -mx-0.5">
10474
{focus}
105-
</Box>,
75+
</mark>,
10676
)
10777
processedChars = match.endPos
10878
}
Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { FC, ReactNode, useEffect } from 'react'
22
import { useHoverHighlighting } from './index'
3-
import { COLORS } from '../../../styles/theme/colors'
4-
import Box from '@mui/material/Box'
53
import { useScreenSize } from '../../hooks/useScreensize'
4+
import { cn } from '@oasisprotocol/ui-library/src/lib/utils'
65

76
export const WithHoverHighlighting: FC<{ children: ReactNode; address: string }> = ({
87
children,
@@ -19,24 +18,16 @@ export const WithHoverHighlighting: FC<{ children: ReactNode; address: string }>
1918
// so we are on tablet (or mobile), just return the wrapped contnt directly.
2019
const isHighlighted = !isTablet && shouldHighlight(address)
2120
return (
22-
<Box
21+
<span
2322
onMouseEnter={() => selectAddress(address)}
2423
onMouseLeave={() => releaseAddress(address)}
25-
component="span"
26-
sx={{
27-
display: 'inline-flex',
28-
...(isHighlighted
29-
? {
30-
background: COLORS.warningLight,
31-
border: `1px dashed ${COLORS.warningColor}`,
32-
borderRadius: '6px',
33-
}
34-
: {
35-
border: `1px dashed transparent`,
36-
}),
37-
}}
24+
className={cn(
25+
'inline-flex',
26+
'border border-dashed rounded-md',
27+
isHighlighted ? 'bg-orange-50 border-orange-600' : 'border-transparent',
28+
)}
3829
>
3930
{children}
40-
</Box>
31+
</span>
4132
)
4233
}

src/app/components/ImagePreview/index.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 { Button } from '@mui/base/Button'
54
import { styled } from '@mui/material/styles'
65
import { ImagePreviewDialog } from '@oasisprotocol/ui-library/src/components/dialog'
@@ -42,11 +41,11 @@ export const ImagePreview: FC<ImagePreviewProps> = ({
4241

4342
return (
4443
<>
45-
<Box>
44+
<div>
4645
<StyledButton onClick={handlePreviewOpen}>
4746
<StyledThumbnail onError={onError} src={src} alt={label} maxThumbnailSize={maxThumbnailSize} />
4847
</StyledButton>
49-
</Box>
48+
</div>
5049
<ImagePreviewDialog open={previewOpen} onClose={handlePreviewClose} src={src} title={title} />
5150
</>
5251
)

src/app/components/JazzIcon/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { memo, useEffect, useRef } from 'react'
22
import jazzicon from '@metamask/jazzicon'
3-
import Box from '@mui/material/Box'
43

54
interface JazzIconProps {
65
diameter: number
@@ -18,5 +17,5 @@ export const JazzIcon = memo(({ diameter, seed }: JazzIconProps) => {
1817
}
1918
}, [diameter, ref, seed])
2019

21-
return <Box ref={ref} sx={{ height: diameter }} />
20+
return <div ref={ref} style={{ height: diameter, width: diameter, display: 'inline-block' }} />
2221
})

0 commit comments

Comments
 (0)