fix: wakatime compact card bargraph rendering (#885)

* fix: wakatime compact card bargraph rendering at the right side

* Updated snapshots
This commit is contained in:
Haraldo Filho 2021-03-07 13:46:02 -03:00 committed by GitHub
parent 8e994304b3
commit 32976d8bd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 28 deletions

2
.gitignore vendored
View File

@ -6,3 +6,5 @@ package-lock.json
.vscode/ .vscode/
.idea/ .idea/
coverage coverage
vercel_token

View File

@ -73,10 +73,10 @@ const createTextNode = ({
return ` return `
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)"> <g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
<text class="stat bold" y="12.5">${label}:</text> <text class="stat bold" y="12.5">${label}:</text>
<text <text
class="stat" class="stat"
x="${hideProgress ? 170 : 350}" x="${hideProgress ? 170 : 350}"
y="12.5" y="12.5"
data-testid="${id}" data-testid="${id}"
>${value}</text> >${value}</text>
${cardProgress} ${cardProgress}
@ -158,17 +158,17 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
const compactProgressBar = languages const compactProgressBar = languages
.map((lang) => { .map((lang) => {
// const progress = (width * lang.percent) / 100; // const progress = (width * lang.percent) / 100;
const progress = ((width - 50) * lang.percent) / 100; const progress = ((width - 25) * lang.percent) / 100;
const languageColor = languageColors[lang.name] || "#858585"; const languageColor = languageColors[lang.name] || "#858585";
const output = ` const output = `
<rect <rect
mask="url(#rect-mask)" mask="url(#rect-mask)"
data-testid="lang-progress" data-testid="lang-progress"
x="${progressOffset}" x="${progressOffset}"
y="0" y="0"
width="${progress}" width="${progress}"
height="8" height="8"
fill="${languageColor}" fill="${languageColor}"
/> />
@ -230,7 +230,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
return card.render(` return card.render(`
<svg x="0" y="0" width="100%"> <svg x="0" y="0" width="100%">
${finalLayout} ${finalLayout}
</svg> </svg>
`); `);
}; };

View File

@ -100,10 +100,10 @@ exports[`Test Render Wakatime Card should render correctly 1`] = `
<g transform=\\"translate(0, 0)\\"> <g transform=\\"translate(0, 0)\\">
<g class=\\"stagger\\" style=\\"animation-delay: NaNms\\" transform=\\"translate(25, 0)\\"> <g class=\\"stagger\\" style=\\"animation-delay: NaNms\\" transform=\\"translate(25, 0)\\">
<text class=\\"stat bold\\" y=\\"12.5\\">Other:</text> <text class=\\"stat bold\\" y=\\"12.5\\">Other:</text>
<text <text
class=\\"stat\\" class=\\"stat\\"
x=\\"350\\" x=\\"350\\"
y=\\"12.5\\" y=\\"12.5\\"
data-testid=\\"Other\\" data-testid=\\"Other\\"
>19 mins</text> >19 mins</text>
@ -123,10 +123,10 @@ exports[`Test Render Wakatime Card should render correctly 1`] = `
</g><g transform=\\"translate(0, 25)\\"> </g><g transform=\\"translate(0, 25)\\">
<g class=\\"stagger\\" style=\\"animation-delay: NaNms\\" transform=\\"translate(25, 0)\\"> <g class=\\"stagger\\" style=\\"animation-delay: NaNms\\" transform=\\"translate(25, 0)\\">
<text class=\\"stat bold\\" y=\\"12.5\\">TypeScript:</text> <text class=\\"stat bold\\" y=\\"12.5\\">TypeScript:</text>
<text <text
class=\\"stat\\" class=\\"stat\\"
x=\\"350\\" x=\\"350\\"
y=\\"12.5\\" y=\\"12.5\\"
data-testid=\\"TypeScript\\" data-testid=\\"TypeScript\\"
>1 min</text> >1 min</text>
@ -144,7 +144,7 @@ exports[`Test Render Wakatime Card should render correctly 1`] = `
</g> </g>
</g> </g>
</svg> </svg>
</g> </g>
</svg> </svg>
@ -254,31 +254,31 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
</mask> </mask>
<rect <rect
mask=\\"url(#rect-mask)\\" mask=\\"url(#rect-mask)\\"
data-testid=\\"lang-progress\\" data-testid=\\"lang-progress\\"
x=\\"0\\" x=\\"0\\"
y=\\"0\\" y=\\"0\\"
width=\\"6.291999999999999\\" width=\\"6.6495\\"
height=\\"8\\" height=\\"8\\"
fill=\\"#858585\\" fill=\\"#858585\\"
/> />
<rect <rect
mask=\\"url(#rect-mask)\\" mask=\\"url(#rect-mask)\\"
data-testid=\\"lang-progress\\" data-testid=\\"lang-progress\\"
x=\\"6.291999999999999\\" x=\\"6.6495\\"
y=\\"0\\" y=\\"0\\"
width=\\"0.44\\" width=\\"0.465\\"
height=\\"8\\" height=\\"8\\"
fill=\\"#2b7489\\" fill=\\"#2b7489\\"
/> />
<rect <rect
mask=\\"url(#rect-mask)\\" mask=\\"url(#rect-mask)\\"
data-testid=\\"lang-progress\\" data-testid=\\"lang-progress\\"
x=\\"6.731999999999999\\" x=\\"7.1145\\"
y=\\"0\\" y=\\"0\\"
width=\\"0.30800000000000005\\" width=\\"0.32550000000000007\\"
height=\\"8\\" height=\\"8\\"
fill=\\"#cb171e\\" fill=\\"#cb171e\\"
/> />
@ -306,7 +306,7 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
</g> </g>
</svg> </svg>
</g> </g>
</svg> </svg>