Skip to content

Commit 287084b

Browse files
refactor: move long locales const to the top and infer types (anuraghazra#4577)
Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
1 parent 0d365da commit 287084b

1 file changed

Lines changed: 32 additions & 25 deletions

File tree

src/cards/stats.js

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ const RANK_CARD_DEFAULT_WIDTH = 450;
1616
const RANK_ONLY_CARD_MIN_WIDTH = 290;
1717
const RANK_ONLY_CARD_DEFAULT_WIDTH = 290;
1818

19+
/**
20+
* Long locales that need more space for text. Keep sorted alphabetically.
21+
*
22+
* @type {(keyof typeof wakatimeCardLocales["wakatimecard.title"])[]}
23+
*/
24+
const LONG_LOCALES = [
25+
"az",
26+
"bg",
27+
"cs",
28+
"de",
29+
"es",
30+
"fil",
31+
"fr",
32+
"id",
33+
"ml",
34+
"my",
35+
"nl",
36+
"pl",
37+
"pt-br",
38+
"pt-pt",
39+
"ru",
40+
"sr",
41+
"sr-latn",
42+
"sw",
43+
"ta",
44+
"uk-ua",
45+
"uz",
46+
"zh-tw",
47+
];
48+
1949
/**
2050
* Create a stats card text item.
2151
*
@@ -374,31 +404,8 @@ const renderStatsCard = (stats, options = {}) => {
374404
id: "contribs",
375405
};
376406

377-
const longLocales = [
378-
"az",
379-
"bg",
380-
"cs",
381-
"de",
382-
"es",
383-
"fil",
384-
"fr",
385-
"id",
386-
"ml",
387-
"my",
388-
"nl",
389-
"pl",
390-
"pt-br",
391-
"pt-pt",
392-
"ru",
393-
"sr",
394-
"sr-latn",
395-
"sw",
396-
"ta",
397-
"uk-ua",
398-
"uz",
399-
"zh-tw",
400-
];
401-
const isLongLocale = locale ? longLocales.includes(locale) : false;
407+
// @ts-ignore
408+
const isLongLocale = locale ? LONG_LOCALES.includes(locale) : false;
402409

403410
// filter out hidden stats defined by user & create the text nodes
404411
const statItems = Object.keys(STATS)

0 commit comments

Comments
 (0)