Skip to content

Commit 9855f06

Browse files
authored
Merge pull request #799 from Conflux-Chain/s40
feat: optimize address name tag in AddresssContainer
2 parents af7e768 + 59a7f8b commit 9855f06

File tree

4 files changed

+51
-19
lines changed

4 files changed

+51
-19
lines changed

src/app/components/AddressContainer/index.tsx

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ const defaultPCSuffixAddressSize =
5353
const defaultPCSuffixPosAddressSize = 10;
5454
const defaultMobileSuffixAddressSize = 4;
5555

56-
const getAddressLabelInfo = (label, alias) => {
56+
const getAddressLabelInfo = label => {
5757
if (label) {
5858
return {
59-
label: `${label}${alias ? ` (${alias})` : ''}`,
59+
label,
6060
icon: (
6161
<IconWrapper>
6262
<Text
@@ -74,7 +74,7 @@ const getAddressLabelInfo = (label, alias) => {
7474
};
7575
}
7676
return {
77-
label: alias,
77+
label: '',
7878
icon: null,
7979
};
8080
};
@@ -94,10 +94,11 @@ const RenderAddress = ({
9494
prefix = null,
9595
suffix = null,
9696
type = 'pow',
97+
addressLabel = '',
9798
}: any) => {
9899
const aftercontent =
99100
type === 'pow'
100-
? cfxAddress && !isFull && !alias
101+
? cfxAddress && !isFull && !addressLabel && !alias
101102
? cfxAddress.substr(-suffixSize)
102103
: ''
103104
: '';
@@ -129,7 +130,7 @@ const RenderAddress = ({
129130
alias={alias}
130131
aftercontent={aftercontent}
131132
>
132-
<span>{content || alias || cfxAddress}</span>
133+
<span>{content || addressLabel || alias || cfxAddress}</span>
133134
</LinkWrapper>
134135
);
135136
}
@@ -141,15 +142,42 @@ const RenderAddress = ({
141142
alias={alias}
142143
aftercontent={aftercontent}
143144
>
144-
<span>{content || alias || cfxAddress}</span>
145+
<span>{content || addressLabel || alias || cfxAddress}</span>
145146
</PlainWrapper>
146147
);
147148
}
148149

149150
return (
150151
<AddressWrapper>
151152
{prefix}
152-
<Text span hoverValue={hoverValue || cfxAddress}>
153+
<Text
154+
span
155+
hoverValue={
156+
<>
157+
{addressLabel ? (
158+
<>
159+
<span>
160+
<Translation>
161+
{t => t(translations.profile.address.myNameTag)}
162+
</Translation>
163+
</span>
164+
{addressLabel}
165+
</>
166+
) : null}
167+
<div>{hoverValue || cfxAddress}</div>
168+
{addressLabel && alias ? (
169+
<>
170+
<span>
171+
<Translation>
172+
{t => t(translations.profile.address.publicNameTag)}
173+
</Translation>
174+
</span>
175+
{alias}
176+
</>
177+
) : null}
178+
</>
179+
}
180+
>
153181
{text}
154182
</Text>
155183
{suffix}
@@ -199,7 +227,6 @@ export const AddressContainer = withTranslation()(
199227
globalData[LOCALSTORAGE_KEYS_MAP.addressLabel][
200228
formatAddress(contractCreated)
201229
],
202-
alias || txtContractCreation,
203230
);
204231

205232
addressLabel = label;
@@ -208,7 +235,8 @@ export const AddressContainer = withTranslation()(
208235

209236
return RenderAddress({
210237
cfxAddress: '',
211-
alias: addressLabel,
238+
alias: alias || txtContractCreation,
239+
addressLabel,
212240
hoverValue: formatAddress(contractCreated),
213241
hrefAddress: formatAddress(contractCreated),
214242
link,
@@ -311,7 +339,6 @@ export const AddressContainer = withTranslation()(
311339
globalData[LOCALSTORAGE_KEYS_MAP.addressLabel][
312340
formatAddress(cfxAddress)
313341
],
314-
alias,
315342
);
316343

317344
addressLabel = label;
@@ -328,7 +355,8 @@ export const AddressContainer = withTranslation()(
328355
);
329356
return RenderAddress({
330357
cfxAddress,
331-
alias: addressLabel,
358+
alias,
359+
addressLabel,
332360
link,
333361
isFull,
334362
maxWidth,
@@ -362,7 +390,8 @@ export const AddressContainer = withTranslation()(
362390
if (isMe) {
363391
return RenderAddress({
364392
cfxAddress,
365-
alias: addressLabel,
393+
alias,
394+
addressLabel,
366395
link,
367396
isFull,
368397
maxWidth,
@@ -385,7 +414,8 @@ export const AddressContainer = withTranslation()(
385414

386415
return RenderAddress({
387416
cfxAddress,
388-
alias: addressLabel,
417+
alias,
418+
addressLabel,
389419
link,
390420
isFull,
391421
maxWidth,
@@ -539,7 +569,7 @@ const addressStyle = (props: any) => `
539569
display: inline-flex !important;
540570
flex-wrap: nowrap;
541571
max-width: ${
542-
props.maxwidth || (props.alias ? 180 : defaultPCMaxWidth)
572+
props.maxwidth || (props.alias ? 160 : defaultPCMaxWidth)
543573
}px !important;
544574
outline: none;
545575
@@ -552,7 +582,7 @@ const addressStyle = (props: any) => `
552582
553583
${media.m} {
554584
max-width: ${
555-
props.maxwidth || (props.alias ? 160 : defaultMobileMaxWidth)
585+
props.maxwidth || (props.alias ? 140 : defaultMobileMaxWidth)
556586
}px !important;
557587
}
558588

src/app/containers/Transaction/EventLogs/Address.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import React from 'react';
22
import { Link } from 'app/components/Link/Loadable';
33
import { formatAddress } from 'utils';
44
import { ContractDetail } from 'app/components/TxnComponents/ContractDetail';
5-
import { AddressLabel } from 'app/components/TxnComponents/AddressLabel';
65

76
export const Address = ({ address, contract }) => {
87
return (
98
<>
109
<Link href={`/address/${address}`}>{formatAddress(address)}</Link>
1110
<ContractDetail info={contract} />
12-
<AddressLabel address={formatAddress(address)} />
1311
</>
1412
);
1513
};

src/locales/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
"label": "Please input name tags",
3535
"duplicated": "Duplicated address, already in the name tags list",
3636
"duplicatedNameTag": "Duplicated name tag, already in the name tags list"
37-
}
37+
},
38+
"publicNameTag": "Public Tag: ",
39+
"myNameTag": "My Name Tag: "
3840
}
3941
},
4042
"metadata": {

src/locales/zh_cn/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
"label": "请输入标签",
3535
"duplicated": "重复的地址,已经存在于记录中",
3636
"duplicatedNameTag": "重复的标签,已经存在于记录中"
37-
}
37+
},
38+
"publicNameTag": "公共标签:",
39+
"myNameTag": "我的标签:"
3840
}
3941
},
4042
"metadata": {

0 commit comments

Comments
 (0)