Skip to content

Commit 0087bfd

Browse files
committed
fix: Enhance createLanguageTextNode to support dynamic line height for improved spacing
1 parent 8bdc975 commit 0087bfd

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/cards/wakatime.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,25 @@ const createCompactLangNode = ({ lang, x, y, display_format }) => {
8484
* @param {WakaTimeLang[]} args.langs The language objects.
8585
* @param {number} args.y The y position of the language node.
8686
* @param {"time" | "percent"} args.display_format The display format of the language node.
87+
* @param {number} args.lineHeight The line height for spacing.
8788
* @returns {string[]} The language text node items.
8889
*/
89-
const createLanguageTextNode = ({ langs, y, display_format }) => {
90+
const createLanguageTextNode = ({ langs, y, display_format, lineHeight = 25 }) => {
9091
const halfLength = Math.ceil(langs.length / 2);
9192

9293
return langs.map((lang, index) => {
9394
if (index < halfLength) {
9495
return createCompactLangNode({
9596
lang,
9697
x: 25,
97-
y: 12.5 * index + y,
98+
y: lineHeight * index + y,
9899
display_format,
99100
});
100101
} else {
101102
return createCompactLangNode({
102103
lang,
103104
x: 230,
104-
y: 12.5 * (index - halfLength) + y,
105+
y: lineHeight * (index - halfLength) + y,
105106
display_format,
106107
});
107108
}
@@ -297,7 +298,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
297298
// RENDER COMPACT LAYOUT
298299
if (layout === "compact") {
299300
width = width + 50;
300-
height = 90 + Math.round(filteredLanguages.length / 2) * 25;
301+
height = 90 + Math.round(filteredLanguages.length / 2) * lheight;
301302

302303
// progressOffset holds the previous language's width and used to offset the next language
303304
// so that we can stack them one after another, like this: [--][----][---]
@@ -336,6 +337,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
336337
y: 25,
337338
langs: filteredLanguages,
338339
display_format,
340+
lineHeight: lheight,
339341
}).join("")
340342
: noCodingActivityNode({
341343
// @ts-ignore

0 commit comments

Comments
 (0)