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

Add format stats option #2155

Merged
merged 15 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
feat: added format_stats option (#2128)
  • Loading branch information
CaedenPH committed Oct 5, 2022
commit 53a578fcb8164a8400627951224c0a959d6d5036
2 changes: 2 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default async (req, res) => {
locale,
disable_animations,
border_radius,
format_stats,
rickstaa marked this conversation as resolved.
Show resolved Hide resolved
border_color,
} = req.query;
res.setHeader("Content-Type", "image/svg+xml");
Expand Down Expand Up @@ -84,6 +85,7 @@ export default async (req, res) => {
custom_title,
border_radius,
border_color,
format_stats: parseBoolean(format_stats),
locale: locale ? locale.toLowerCase() : null,
disable_animations: parseBoolean(disable_animations),
}),
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ You can provide multiple comma-separated values in the bg_color option to render
- `custom_title` - Sets a custom title for the card. Default: `<username> Github Stats`.
- `text_bold` - Use bold text _(boolean)_. Default: `true`.
- `disable_animations` - Disables all animations in the card _(boolean)_. Default: `false`.
- `format_stats` Formats stats with a `k` _(boolean)_. Default: `true`
rickstaa marked this conversation as resolved.
Show resolved Hide resolved

> Note on `hide_rank`:
> When hide_rank=`true`, the minimum card width is 270 px + the title length and padding.
Expand Down
6 changes: 5 additions & 1 deletion src/cards/stats-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ const createTextNode = ({
showIcons,
shiftValuePos,
bold,
format_stats,
}) => {
const kValue = kFormatter(value);
const kValue = format_stats ? kFormatter(value) : value;
console.log(kValue, format_stats);
rickstaa marked this conversation as resolved.
Show resolved Hide resolved
const staggerDelay = (index + 3) * 150;

const labelOffset = showIcons ? `x="25"` : "";
Expand Down Expand Up @@ -95,6 +97,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
custom_title,
border_radius,
border_color,
format_stats = true,
locale,
disable_animations = false,
} = options;
Expand Down Expand Up @@ -183,6 +186,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
shiftValuePos:
(!include_all_commits ? 50 : 35) + (isLongLocale ? 50 : 0),
bold: text_bold,
format_stats,
rickstaa marked this conversation as resolved.
Show resolved Hide resolved
}),
);

Expand Down
1 change: 1 addition & 0 deletions src/cards/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type StatCardOptions = CommonOptions & {
line_height: number | string;
custom_title: string;
disable_animations: boolean;
format_stats: boolean;
};

export type RepoCardOptions = CommonOptions & {
Expand Down