From c6120bf8b4680b512ae5fcf431dc7f44863129e6 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 29 Jul 2022 00:52:58 +0200 Subject: [PATCH] * add padding for sticky-left languages * fix bar lenght by adding floor and ceil --- src/utils/locales.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/locales.ts b/src/utils/locales.ts index 1fd86fc..b960587 100644 --- a/src/utils/locales.ts +++ b/src/utils/locales.ts @@ -146,9 +146,9 @@ async (locales: Map>, default_lang: string) => { locales_size.forEach((size, lang) => { const percentage = (size / max_size) * 100; // Colored bar part - const blocks = ' '.repeat(percentage / bar_size); + const blocks = ' '.repeat(Math.floor(percentage / bar_size)); // Blank bar part - const blank = ' '.repeat((100 - percentage) / bar_size); + const blank = ' '.repeat(Math.ceil((100 - percentage) / bar_size)); const color = () => { switch (true) { case percentage <= 25: @@ -167,7 +167,8 @@ async (locales: Map>, default_lang: string) => { return ''; } }; + const padding = ' '.repeat(lang.length === 5 ? 1 : 4); - console.log(`${lang} | ${color()}${blocks}\x1b[0m${blank} | ${percentage.toPrecision(3)}%`); + console.log(`${padding}${lang} | ${color()}${blocks}\x1b[0m${blank} | ${percentage.toPrecision(3)}%`); }); };