Truncate addresses by 2 chars to compensate for color dot width
Some checks failed
check / check (push) Has been cancelled

Move truncateMiddle to helpers.js for reuse. Shorten displayed addresses
by 2 characters wherever a dot is shown: home view (40 char max), tx list
(maxAddr - 2), and address detail container (40ch width).
This commit is contained in:
2026-02-26 03:29:09 +07:00
parent 138468287c
commit 166bb46149
4 changed files with 13 additions and 10 deletions

View File

@@ -99,6 +99,13 @@ function balanceLinesForAddress(addr) {
return html;
}
function truncateMiddle(str, maxLen) {
if (str.length <= maxLen) return str;
if (maxLen < 5) return str.slice(0, maxLen);
const half = Math.floor((maxLen - 1) / 2);
return str.slice(0, half) + "\u2026" + str.slice(-(maxLen - 1 - half));
}
// 16 colors evenly spaced around the hue wheel (22.5° apart),
// all at HSL saturation 70%, lightness 50% for uniform vibrancy.
const ADDRESS_COLORS = [
@@ -139,4 +146,5 @@ module.exports = {
balanceLinesForAddress,
addressColor,
addressDotHtml,
truncateMiddle,
};