Skip to content

Commit

Permalink
Merge pull request #315 from pshenmic/feat/display-new-aliases-format
Browse files Browse the repository at this point in the history
Update alias display for new format
  • Loading branch information
alexeyandreevsky authored Nov 17, 2024
2 parents dae2d34 + 3a0ab96 commit eba7304
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
12 changes: 6 additions & 6 deletions packages/frontend/src/app/home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ function Home () {
.map((identitiy, i) => ({
columns: [
{
value: identitiy?.aliases?.[0] || identitiy.identifier,
value: identitiy?.aliases?.[0]?.alias || identitiy.identifier,
avatar: true,
avatarSource: identitiy.identifier,
mono: true,
dim: !identitiy?.aliases?.[0],
dim: !identitiy?.aliases?.[0]?.alias,
ellipsis: true,
format: identitiy?.aliases?.[0] ? 'alias' : 'identifier'
format: identitiy?.aliases?.[0]?.alias ? 'alias' : 'identifier'
},
{
value: identitiy.totalTxs,
Expand Down Expand Up @@ -230,13 +230,13 @@ function Home () {
.map((identitiy, i) => ({
columns: [
{
value: identitiy?.aliases?.[0] || identitiy.identifier,
value: identitiy?.aliases?.[0]?.alias || identitiy.identifier,
avatar: true,
avatarSource: identitiy.identifier,
mono: true,
dim: !identitiy?.aliases?.[0],
dim: !identitiy?.aliases?.[0]?.alias,
ellipsis: true,
format: identitiy?.aliases?.[0] ? 'alias' : 'identifier'
format: identitiy?.aliases?.[0]?.alias ? 'alias' : 'identifier'
},
{
value: identitiy.balance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function Identity ({ identifier }) {
<LoadingLine loading={identity.loading}>
<div className={'IdentityInfo__AliasesContainer'}>
{identity?.data.aliases.map((alias, i) => (
<Alias key={i}>{alias}</Alias>
<Alias alias={alias.alias} key={i}/>
))}
</div>
</LoadingLine>
Expand Down
13 changes: 8 additions & 5 deletions packages/frontend/src/components/data/Alias.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import './Alias.scss'

export default function Alias ({ children, ellipsis = true, className }) {
const dashIndex = children.lastIndexOf('.dash')
export default function Alias ({ alias, children, ellipsis = true, className }) {
alias = alias || children
if (typeof alias !== 'string') return <></>

const dashIndex = alias?.lastIndexOf('.dash')

return (
<div className={`Alias ${ellipsis ? 'Alias--Ellipsis' : ''} ${className || ''}`}>
<span className={'Alias__Name'}>
{dashIndex !== -1
? children.slice(0, dashIndex)
: children
? alias?.slice(0, dashIndex)
: alias
}
</span>

{dashIndex !== -1 &&
<span className={'Alias__Domain'}>
{children.slice(dashIndex)}
{alias?.slice(dashIndex)}
</span>
}
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/identities/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function IdentityCard ({ identity, rate, loading = false }) {
<ImageGenerator username={identity.identifier} lightness={50} saturation={50} width={42} height={42} />
</div>
<div className={'IdentityCard__Alias'}>{identity?.aliases?.length
? <Alias>{identity.aliases[0]}</Alias>
? <Alias alias={identity?.aliases[0]?.alias}/>
: <Identifier styles={['highlight-both']}>{identity.identifier}</Identifier>}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function IdentitiesListItem ({ identity }) {
<ImageGenerator className={'IdentitiesListItem__Avatar'} username={identifier} lightness={50} saturation={50} width={28} height={28}/>

{aliases?.length
? <Alias className={'IdentitiesListItem__Alias'}>{aliases[0]}</Alias>
? <Alias className={'IdentitiesListItem__Alias'} alias={aliases[0]?.alias}/>
: <Identifier
className={'IdentitiesListItem__Identifier'}
copyButton={true}
Expand Down

0 comments on commit eba7304

Please sign in to comment.