fix: total commit counts (#211)

* fix: wip fix total commit counts

* tests: added tests

* chore: remove console logs

* docs: added docs for include_all_commits

* chore: increased value offset x

* chore: added reference/links comments

* docs: updated docs
This commit is contained in:
Anurag Hazra
2020-07-31 13:37:39 +05:30
committed by GitHub
parent a4486d0327
commit 416f027fae
6 changed files with 117 additions and 11 deletions
+20 -3
View File
@@ -8,7 +8,15 @@ const { getStyles } = require("./getStyles");
const icons = require("./icons");
const Card = require("./Card");
const createTextNode = ({ icon, label, value, id, index, showIcons }) => {
const createTextNode = ({
icon,
label,
value,
id,
index,
showIcons,
shiftValuePos,
}) => {
const kValue = kFormatter(value);
const staggerDelay = (index + 3) * 150;
@@ -24,7 +32,12 @@ const createTextNode = ({ icon, label, value, id, index, showIcons }) => {
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
${iconSvg}
<text class="stat bold" ${labelOffset} y="12.5">${label}:</text>
<text class="stat" x="135" y="12.5" data-testid="${id}">${kValue}</text>
<text
class="stat"
x="${shiftValuePos ? 170 : 150}"
y="12.5"
data-testid="${id}"
>${kValue}</text>
</g>
`;
};
@@ -45,6 +58,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
hide_title = false,
hide_border = false,
hide_rank = false,
include_all_commits = false,
line_height = 25,
title_color,
icon_color,
@@ -74,7 +88,9 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
},
commits: {
icon: icons.commits,
label: "Total Commits",
label: `Total Commits${
include_all_commits ? "" : ` (${new Date().getFullYear()})`
}`,
value: totalCommits,
id: "commits",
},
@@ -107,6 +123,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
...STATS[key],
index,
showIcons: show_icons,
shiftValuePos: !include_all_commits,
})
);