diff --git a/api/index.js b/api/index.js index 23feea7..9b96882 100644 --- a/api/index.js +++ b/api/index.js @@ -30,6 +30,7 @@ module.exports = async (req, res) => { cache_seconds, custom_title, locale, + disable_animations, } = req.query; let stats; @@ -74,6 +75,7 @@ module.exports = async (req, res) => { theme, custom_title, locale: locale ? locale.toLowerCase() : null, + disable_animations: parseBoolean(disable_animations), }), ); } catch (err) { diff --git a/readme.md b/readme.md index 974ec92..5205b5f 100644 --- a/readme.md +++ b/readme.md @@ -163,6 +163,7 @@ You can provide multiple comma-separated values in bg_color option to render a g - `count_private` - Count private commits _(boolean)_ - `line_height` - Sets the line-height between text _(number)_ - `custom_title` - Sets a custom title for the card +- `disable_animations` - Disables all animations in the card _(boolean)_ #### Repo Card Exclusive Options: diff --git a/src/cards/stats-card.js b/src/cards/stats-card.js index 9ee4b24..189709e 100644 --- a/src/cards/stats-card.js +++ b/src/cards/stats-card.js @@ -64,6 +64,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => { theme = "default", custom_title, locale, + disable_animations = false, } = options; const lheight = parseInt(line_height, 10); @@ -77,7 +78,9 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => { theme, }); - const apostrophe = ["x", "s"].includes(name.slice(-1).toLocaleLowerCase()) ? "" : "s"; + const apostrophe = ["x", "s"].includes(name.slice(-1).toLocaleLowerCase()) + ? "" + : "s"; const i18n = new I18n({ locale, translations: statCardLocales({ name, apostrophe }), @@ -190,6 +193,8 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => { card.setHideTitle(hide_title); card.setCSS(cssStyles); + if (disable_animations) card.disableAnimations(); + return card.render(` ${rankCircle} diff --git a/src/common/Card.js b/src/common/Card.js index 4144551..9afeb5f 100644 --- a/src/common/Card.js +++ b/src/common/Card.js @@ -128,10 +128,11 @@ class Card { } ${this.css} + ${process.env.NODE_ENV === "test" ? "" : getAnimations()} ${ - process.env.NODE_ENV === "test" || !this.animations - ? "" - : getAnimations() + this.animations === false + ? `* { animation-duration: 0s !important; animation-delay: 0s !important; }` + : "" } diff --git a/tests/__snapshots__/renderWakatimeCard.test.js.snap b/tests/__snapshots__/renderWakatimeCard.test.js.snap index 706fcd9..a89efa4 100644 --- a/tests/__snapshots__/renderWakatimeCard.test.js.snap +++ b/tests/__snapshots__/renderWakatimeCard.test.js.snap @@ -58,6 +58,7 @@ exports[`Test Render Wakatime Card should render correctly 1`] = ` + undefined @@ -208,6 +209,7 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1 + undefined