Skip to content

Commit c7609ce

Browse files
ritik48rickstaaqwerty541
authored andcommitted
feat: show wakatime stats in percentage (resolves anuraghazra#3016) (anuraghazra#3326)
* added option to display wakatime in percentage * updated exclusive options in wakatime * added percent sign * Update readme.md Co-authored-by: Rick Staa <rick.staa@outlook.com> * made the required changes * Update wakatime-card.js * Update wakatime-card.js --------- Co-authored-by: Rick Staa <rick.staa@outlook.com> Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
1 parent f27e9c0 commit c7609ce

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

api/wakatime.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default async (req, res) => {
3030
api_domain,
3131
border_radius,
3232
border_color,
33+
display_format,
3334
disable_animations,
3435
} = req.query;
3536

@@ -84,6 +85,7 @@ export default async (req, res) => {
8485
locale: locale ? locale.toLowerCase() : null,
8586
layout,
8687
langs_count,
88+
display_format,
8789
disable_animations: parseBoolean(disable_animations),
8890
}),
8991
);

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ If we don't support your language, please consider contributing! You can find mo
421421
* `layout` - Switches between two available layouts `default` & `compact`. Default `default`.
422422
* `langs_count` - Limits the number of languages on the card, defaults to all reported languages *(number)*.
423423
* `api_domain` - Sets a custom API domain for the card, e.g. to use services like [Hakatime](https://github.com/mujx/hakatime) or [Wakapi](https://github.com/muety/wakapi) *(string)*. Default `Waka API`.
424+
* `display_format` - Sets the WakaTime stats display format. Choose `time` to display time-based stats or `percent` to show percentages. Default: `time`.
424425
* `disable_animations` - Disables all animations in the card *(boolean)*. Default: `false`.
425426

426427
***

src/cards/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type WakaTimeOptions = CommonOptions & {
5454
custom_title: string;
5555
layout: "compact" | "normal";
5656
langs_count: number;
57+
display_format: "time" | "percent";
5758
disable_animations: boolean;
5859
};
5960

src/cards/wakatime-card.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
218218
langs_count = languages.length,
219219
border_radius,
220220
border_color,
221+
display_format = "time",
221222
disable_animations,
222223
} = options;
223224

@@ -331,7 +332,10 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
331332
return createTextNode({
332333
id: language.name,
333334
label: language.name,
334-
value: language.text,
335+
value:
336+
display_format === "percent"
337+
? `${language.percent.toFixed(2).toString()} %`
338+
: language.text,
335339
index,
336340
percent: language.percent,
337341
// @ts-ignore

0 commit comments

Comments
 (0)