Skip to content

Commit

Permalink
fix: wakatime compact card bargraph rendering (anuraghazra#885)
Browse files Browse the repository at this point in the history
* fix: wakatime compact card bargraph rendering at the right side

* Updated snapshots
  • Loading branch information
HaraldoFilho authored Mar 7, 2021
1 parent 8e99430 commit 32976d8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ package-lock.json
.vscode/
.idea/
coverage
vercel_token

18 changes: 9 additions & 9 deletions src/cards/wakatime-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ const createTextNode = ({
return `
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
<text class="stat bold" y="12.5">${label}:</text>
<text
class="stat"
x="${hideProgress ? 170 : 350}"
y="12.5"
<text
class="stat"
x="${hideProgress ? 170 : 350}"
y="12.5"
data-testid="${id}"
>${value}</text>
${cardProgress}
Expand Down Expand Up @@ -158,17 +158,17 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
const compactProgressBar = languages
.map((lang) => {
// 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 output = `
<rect
mask="url(#rect-mask)"
mask="url(#rect-mask)"
data-testid="lang-progress"
x="${progressOffset}"
x="${progressOffset}"
y="0"
width="${progress}"
width="${progress}"
height="8"
fill="${languageColor}"
/>
Expand Down Expand Up @@ -230,7 +230,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
return card.render(`
<svg x="0" y="0" width="100%">
${finalLayout}
</svg>
</svg>
`);
};

Expand Down
38 changes: 19 additions & 19 deletions tests/__snapshots__/renderWakatimeCard.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ exports[`Test Render Wakatime Card should render correctly 1`] = `
<g transform=\\"translate(0, 0)\\">
<g class=\\"stagger\\" style=\\"animation-delay: NaNms\\" transform=\\"translate(25, 0)\\">
<text class=\\"stat bold\\" y=\\"12.5\\">Other:</text>
<text
class=\\"stat\\"
x=\\"350\\"
y=\\"12.5\\"
<text
class=\\"stat\\"
x=\\"350\\"
y=\\"12.5\\"
data-testid=\\"Other\\"
>19 mins</text>
Expand All @@ -123,10 +123,10 @@ exports[`Test Render Wakatime Card should render correctly 1`] = `
</g><g transform=\\"translate(0, 25)\\">
<g class=\\"stagger\\" style=\\"animation-delay: NaNms\\" transform=\\"translate(25, 0)\\">
<text class=\\"stat bold\\" y=\\"12.5\\">TypeScript:</text>
<text
class=\\"stat\\"
x=\\"350\\"
y=\\"12.5\\"
<text
class=\\"stat\\"
x=\\"350\\"
y=\\"12.5\\"
data-testid=\\"TypeScript\\"
>1 min</text>
Expand All @@ -144,7 +144,7 @@ exports[`Test Render Wakatime Card should render correctly 1`] = `
</g>
</g>
</svg>
</svg>
</g>
</svg>
Expand Down Expand Up @@ -254,31 +254,31 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
</mask>
<rect
mask=\\"url(#rect-mask)\\"
mask=\\"url(#rect-mask)\\"
data-testid=\\"lang-progress\\"
x=\\"0\\"
x=\\"0\\"
y=\\"0\\"
width=\\"6.291999999999999\\"
width=\\"6.6495\\"
height=\\"8\\"
fill=\\"#858585\\"
/>
<rect
mask=\\"url(#rect-mask)\\"
mask=\\"url(#rect-mask)\\"
data-testid=\\"lang-progress\\"
x=\\"6.291999999999999\\"
x=\\"6.6495\\"
y=\\"0\\"
width=\\"0.44\\"
width=\\"0.465\\"
height=\\"8\\"
fill=\\"#2b7489\\"
/>
<rect
mask=\\"url(#rect-mask)\\"
mask=\\"url(#rect-mask)\\"
data-testid=\\"lang-progress\\"
x=\\"6.731999999999999\\"
x=\\"7.1145\\"
y=\\"0\\"
width=\\"0.30800000000000005\\"
width=\\"0.32550000000000007\\"
height=\\"8\\"
fill=\\"#cb171e\\"
/>
Expand Down Expand Up @@ -306,7 +306,7 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
</g>
</svg>
</svg>
</g>
</svg>
Expand Down

0 comments on commit 32976d8

Please sign in to comment.