Files
explore/lib/shortenString.ts
tom goriunovandGitHub 6112e475de Celo: support L2 epochs (#2784)
* epochs page

* epoch rewards distribution

* epoch election rewards

* address epoch rewards

* block epoch tag

* add some  tests

* adjust epoch details for L1 epochs

* support non-finalized epochs

* fixes after design review

* add truncation to block numbers on mobile

* update epochs table layout

* update timestamp hint

* fix bug with subheading of first epoch

* fixes of mobile view

* update screenshots
2025-06-30 17:44:10 +02:00

14 lines
332 B
TypeScript

export default function shortenString(string: string | null, charNumber: number | undefined = 8) {
if (!string) {
return '';
}
if (string.length <= charNumber) {
return string;
}
const tailLength = charNumber < 8 ? 2 : 4;
return string.slice(0, charNumber - tailLength) + '...' + string.slice(-tailLength);
}