Skip to content

Commit 0a09c81

Browse files
authored
Merge pull request #2003 from oasisprotocol/kaja/mobile-verification-badge
Hide label of verification badge in a table for mobile screens
2 parents 3a94110 + 4df8d83 commit 0a09c81

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

.changelog/2003.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hide label of contract verification badge in a table for mobile screens

src/app/components/ContractVerificationIcon/index.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ export const verificationIconBoxHeight = 28
1414

1515
type ContractStatusProps = {
1616
verificationLevel?: 'full' | 'partial'
17+
hideLabel?: boolean
1718
}
18-
export const ContractStatus = ({ verificationLevel }: ContractStatusProps) => {
19+
export const ContractStatus = ({ verificationLevel, hideLabel }: ContractStatusProps) => {
1920
const { t } = useTranslation()
2021
const statusLabel =
2122
verificationLevel === 'full'
@@ -26,15 +27,18 @@ export const ContractStatus = ({ verificationLevel }: ContractStatusProps) => {
2627
const statusVariant =
2728
verificationLevel === 'full' ? 'success' : verificationLevel === 'partial' ? 'partialsuccess' : 'danger'
2829

29-
return <StatusBadge label={statusLabel} variant={statusVariant} />
30+
const label = hideLabel ? '' : statusLabel
31+
32+
return <StatusBadge label={label} variant={statusVariant} />
3033
}
3134

3235
export const VerificationIcon: FC<{
3336
address_eth: string
3437
scope: SearchScope
3538
verificationLevel?: 'full' | 'partial'
3639
noLink?: boolean
37-
}> = ({ address_eth, scope, verificationLevel, noLink = false }) => {
40+
hideLabel?: boolean
41+
}> = ({ address_eth, scope, verificationLevel, noLink = false, hideLabel }) => {
3842
const { t } = useTranslation()
3943
const [explainDelay, setExplainDelay] = useState(false)
4044
if (isLocalnet(scope.network)) {
@@ -49,16 +53,15 @@ export const VerificationIcon: FC<{
4953
}
5054
const Component = noLink ? Box : (Link as React.ElementType)
5155
const componentProps = noLink ? {} : sourcifyLinkProps
52-
5356
return (
5457
<>
5558
<Component {...componentProps}>
56-
<ContractStatus verificationLevel={verificationLevel} />
59+
<ContractStatus verificationLevel={verificationLevel} hideLabel={hideLabel} />
5760
</Component>
58-
&nbsp; &nbsp;
5961
{!noLink &&
6062
(verificationLevel ? (
6163
<Typography component="span" sx={{ fontSize: '12px', color: COLORS.brandExtraDark }}>
64+
&nbsp; &nbsp;
6265
<Trans
6366
t={t}
6467
i18nKey={'contract.verification.openInSourcify'}
@@ -70,6 +73,7 @@ export const VerificationIcon: FC<{
7073
</Typography>
7174
) : (
7275
<Typography component="span" sx={{ fontSize: '12px', color: COLORS.brandExtraDark }}>
76+
&nbsp; &nbsp;
7377
<Trans
7478
t={t}
7579
i18nKey={'contract.verification.verifyInSourcify'}

src/app/components/Tokens/TokenList.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import Typography from '@mui/material/Typography'
1818
import { COLORS } from '../../../styles/theme/colors'
1919
import { SxProps } from '@mui/material/styles'
2020
import { RoundedBalance } from '../RoundedBalance'
21+
import { useScreenSize } from 'app/hooks/useScreensize'
2122

2223
type TokensProps = {
2324
tokens?: EvmToken[]
@@ -59,12 +60,16 @@ export const TokenTypeTag: FC<{ tokenType: EvmTokenType | undefined; sx?: SxProp
5960
export const TokenList = (props: TokensProps) => {
6061
const { isLoading, tokens, pagination, limit } = props
6162
const { t } = useTranslation()
63+
const { isMobile } = useScreenSize()
6264
const tableColumns: TableColProps[] = [
6365
{ key: 'index', content: '' },
6466
{ key: 'name', content: t('common.name') },
6567
{ key: 'type', content: t('common.type') },
6668
{ key: 'contract', content: t('common.smartContract') },
67-
{ key: 'verification', content: t('contract.verification.title') },
69+
{
70+
key: 'verification',
71+
content: isMobile ? t('contract.verification.sourceShort') : t('contract.verification.source'),
72+
},
6873
{
6974
key: 'holders',
7075
content: t('tokens.holders'),
@@ -133,6 +138,7 @@ export const TokenList = (props: TokensProps) => {
133138
scope={token}
134139
verificationLevel={token.verification_level}
135140
noLink
141+
hideLabel={isMobile}
136142
/>
137143
</Box>
138144
),

src/app/components/common/StatusBadge.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,13 @@ const StyledBadge = styled(Box, {
5656
color: COLORS.brandExtraDark,
5757
borderRadius: 10,
5858
padding: 4,
59-
paddingLeft: 10,
60-
paddingRight: 5,
6159
}
6260
})
6361

6462
export const StatusBadge = ({ label, icon, variant = 'info' }: StatusBadgeProps) => {
6563
return (
6664
<StyledBadge bgColor={variantStyles[variant].bgColor}>
67-
{label}
65+
{label && <span style={{ paddingLeft: '5px' }}>{label}</span>}
6866
{icon || variantIcon[variant]}
6967
</StyledBadge>
7068
)

src/locales/en/translation.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@
188188
"isPartiallyVerified": "Partially Verified",
189189
"openInAbiPlayground": "Interact in <AbiPlaygroundLink>ABI Playground</AbiPlaygroundLink>",
190190
"openInSourcify": "Open in <SourcifyLink>Sourcify</SourcifyLink>",
191+
"source": "Source",
192+
"sourceShort": "Src",
191193
"verifyInSourcify": "Verify through <SourcifyLink>Sourcify</SourcifyLink>",
192194
"explainVerificationDelay": "If you have just verified a contract, it should take a few minutes to update here.",
193195
"proxyERC1167": "ERC-1167 proxy to"

0 commit comments

Comments
 (0)