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(wakatime card): add disable animations query option #3496

Merged
merged 2 commits into from
Nov 23, 2023
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/wakatime.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default async (req, res) => {
api_domain,
border_radius,
border_color,
disable_animations,
} = req.query;

res.setHeader("Content-Type", "image/svg+xml");
Expand Down Expand Up @@ -83,6 +84,7 @@ export default async (req, res) => {
locale: locale ? locale.toLowerCase() : null,
layout,
langs_count,
disable_animations: parseBoolean(disable_animations),
}),
);
} catch (err) {
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ If we don't support your language, please consider contributing! You can find mo
* `layout` - Switches between two available layouts `default` & `compact`. Default `default`.
* `langs_count` - Limits the number of languages on the card, defaults to all reported languages *(number)*.
* `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`.
* `disable_animations` - Disables all animations in the card *(boolean)*. Default: `false`.

***

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 @@ -54,6 +54,7 @@ type WakaTimeOptions = CommonOptions & {
custom_title: string;
layout: "compact" | "normal";
langs_count: number;
disable_animations: boolean;
};

export type GistCardOptions = CommonOptions & {
Expand Down
5 changes: 5 additions & 0 deletions src/cards/wakatime-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
langs_count = languages.length,
border_radius,
border_color,
disable_animations,
} = options;

const shouldHideLangs = Array.isArray(hide) && hide.length > 0;
Expand Down Expand Up @@ -382,6 +383,10 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
},
});

if (disable_animations) {
card.disableAnimations();
}

card.setHideBorder(hide_border);
card.setHideTitle(hide_title);
card.setCSS(
Expand Down