Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(stats): add 'not_bold' option to stats card #1468

Merged
merged 2 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = async (req, res) => {
title_color,
icon_color,
text_color,
text_bold,
bg_color,
theme,
cache_seconds,
Expand Down Expand Up @@ -75,6 +76,7 @@ module.exports = async (req, res) => {
title_color,
icon_color,
text_color,
text_bold: parseBoolean(text_bold),
bg_color,
theme,
custom_title,
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ You can provide multiple comma-separated values in the bg_color option to render
- `line_height` - Sets the line-height between text _(number)_
- `exclude_repo` - Exclude stars from specified repositories _(Comma-separated values)_
- `custom_title` - Sets a custom title for the card
- `text_bold` - Use bold text _(boolean)_
- `disable_animations` - Disables all animations in the card _(boolean)_

#### Repo Card Exclusive Options:
Expand Down Expand Up @@ -453,3 +454,4 @@ Thanks! :heart:
Contributions are welcome! <3

Made with :heart: and JavaScript.

9 changes: 7 additions & 2 deletions src/cards/stats-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const createTextNode = ({
index,
showIcons,
shiftValuePos,
bold,
}) => {
const kValue = kFormatter(value);
const staggerDelay = (index + 3) * 150;
Expand All @@ -35,9 +36,11 @@ const createTextNode = ({
return `
<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 ${
bold ? " bold" : "not_bold"
}" ${labelOffset} y="12.5">${label}:</text>
<text
class="stat"
class="stat ${bold ? " bold" : "not_bold"}"
x="${(showIcons ? 140 : 120) + shiftValuePos}"
y="12.5"
data-testid="${id}"
Expand Down Expand Up @@ -73,6 +76,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
title_color,
icon_color,
text_color,
text_bold = true,
bg_color,
theme = "default",
custom_title,
Expand Down Expand Up @@ -165,6 +169,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
showIcons: show_icons,
shiftValuePos:
(!include_all_commits ? 50 : 35) + (isLongLocale ? 50 : 0),
bold: text_bold,
}),
);

Expand Down
1 change: 1 addition & 0 deletions src/getStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const getStyles = ({
animation: scaleInAnimation 0.3s ease-in-out forwards;
}

.not_bold { font-weight: 400 }
.bold { font-weight: 700 }
.icon {
fill: ${iconColor};
Expand Down
2 changes: 2 additions & 0 deletions tests/__snapshots__/renderWakatimeCard.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ exports[`Test Render Wakatime Card should render correctly 1`] = `
animation: scaleInAnimation 0.3s ease-in-out forwards;
}

.not_bold { font-weight: 400 }
.bold { font-weight: 700 }
.icon {
fill: #4c71f2;
Expand Down Expand Up @@ -202,6 +203,7 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
animation: scaleInAnimation 0.3s ease-in-out forwards;
}

.not_bold { font-weight: 400 }
.bold { font-weight: 700 }
.icon {
fill: #4c71f2;
Expand Down