Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@

<div class="nft-select-list__token-info-name">
<h4>
{{
item.name.length > 40
? item.name.substring(0, 40) + '...'
: item.name
}}
{{ $filters.truncate(item.name, 25) }}
</h4>
<p>
{{
item.collectionName.length > 50
? item.collectionName.substring(0, 50) + '...'
: item.collectionName
}}
{{ $filters.truncate(item.collectionName, 50) }}
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@
</div>
<div class="send-nft-select__info">
<h5>
{{
item.name.length > 25
? item.name.substring(0, 25) + '...'
: item.name
}}
{{ $filters.truncate(item.name, 25) }}
</h5>
<p>
{{
item.collectionName.length > 50
? item.collectionName.substring(0, 50) + '...'
: item.collectionName
}}
{{ $filters.truncate(item.collectionName, 50) }}
</p>
</div>

Expand Down
2 changes: 2 additions & 0 deletions packages/extension/src/ui/action/types/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
replaceWithEllipsis,
formatFiatValue,
formatFloatingPointValue,
truncate
} from '../utils/filters';
declare global {
namespace $filters {
Expand All @@ -12,6 +13,7 @@ declare global {
replaceWithEllipsis,
formatFiatValue,
formatFloatingPointValue,
truncate
};
}
}
8 changes: 8 additions & 0 deletions packages/extension/src/ui/action/utils/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export const replaceWithEllipsis = (
value.substring(value.length - keepRight, value.length)
);
};


export const truncate = (value: string, length: number): string => {
if (!value) return '';
value = value.toString();
return value.length > length ? value.substring(0, length) + '...' : value;
}

export const formatDuration = (
duration: moment.Duration,
date: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<img :src="token.icon" @error="imageLoadError" />
</div>
<div class="assets-select-list__token-info-name">
<h4>{{ token.name }}</h4>
<h4>
{{ $filters.truncate(token.name, 25) }}
</h4>
<p>
{{ balance ? $filters.formatFloatingPointValue(balance).value : '~' }}
<span>{{ token.symbol }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@
fromBase(activity.value, activity.token.decimals),
).value
}}
<span>{{
activity.token.symbol.length > 40
? activity.token.symbol.substring(0, 40) + '...'
: activity.token.symbol
}}</span>
<span>{{ $filters.truncate(activity.token.symbol, 40) }}</span>
</h4>
<p>$ {{ $filters.formatFiatValue(getFiatValue).value }}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<img :src="token.logoURI" alt="" @error="imageLoadError" />
</div>
<div class="swap-token-select__info">
<h5>{{ token.name }}</h5>
<h5>
{{ $filters.truncate(token.name, 25) }}
</h5>
<p>
{{
tokenBalance
Expand Down
Loading