From 5494d08954715f149e96b924f98059ad0c49630e Mon Sep 17 00:00:00 2001 From: Alexandr Date: Fri, 15 Sep 2023 13:54:13 +0300 Subject: [PATCH] refactor: resolve vscode type errors in wakatime card render and remove redundant css --- src/cards/wakatime-card.js | 32 ++++++++- .../renderWakatimeCard.test.js.snap | 68 ------------------- 2 files changed, 30 insertions(+), 70 deletions(-) diff --git a/src/cards/wakatime-card.js b/src/cards/wakatime-card.js index 187af7ed..5dbee549 100644 --- a/src/cards/wakatime-card.js +++ b/src/cards/wakatime-card.js @@ -8,7 +8,6 @@ import { getCardColors, lowercaseTrim, } from "../common/utils.js"; -import { getStyles } from "../getStyles.js"; import { wakatimeCardLocales } from "../translations.js"; /** Import language colors. @@ -158,6 +157,36 @@ const recalculatePercentages = (languages) => { }); }; +/** + * Retrieves CSS styles for a card. + * + * @param {Object} colors The colors to use for the card. + * @param {string} colors.titleColor The title color. + * @param {string} colors.textColor The text color. + * @returns {string} Card CSS styles. + */ +const getStyles = ({ + // eslint-disable-next-line no-unused-vars + titleColor, + textColor, +}) => { + return ` + .stat { + font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: ${textColor}; + } + @supports(-moz-appearance: auto) { + /* Selector detects Firefox */ + .stat { font-size:12px; } + } + .stagger { + opacity: 0; + animation: fadeInAnimation 0.3s ease-in-out forwards; + } + .not_bold { font-weight: 400 } + .bold { font-weight: 700 } + `; +}; + /** * @typedef {import('../fetchers/types').WakaTimeData} WakaTimeData * @typedef {import('./types').WakaTimeOptions} WakaTimeOptions @@ -235,7 +264,6 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => { const cssStyles = getStyles({ titleColor, textColor, - iconColor, }); let finalLayout = ""; diff --git a/tests/__snapshots__/renderWakatimeCard.test.js.snap b/tests/__snapshots__/renderWakatimeCard.test.js.snap index 2050be02..69bd8ce3 100644 --- a/tests/__snapshots__/renderWakatimeCard.test.js.snap +++ b/tests/__snapshots__/renderWakatimeCard.test.js.snap @@ -38,42 +38,8 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1 opacity: 0; animation: fadeInAnimation 0.3s ease-in-out forwards; } - .rank-text { - font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58; - animation: scaleInAnimation 0.3s ease-in-out forwards; - } - .rank-percentile-header { - font-size: 14px; - } - .rank-percentile-text { - font-size: 16px; - } - .not_bold { font-weight: 400 } .bold { font-weight: 700 } - .icon { - fill: #4c71f2; - display: none; - } - - .rank-circle-rim { - stroke: undefined; - fill: none; - stroke-width: 6; - opacity: 0.2; - } - .rank-circle { - stroke: undefined; - stroke-dasharray: 250; - fill: none; - stroke-width: 6; - stroke-linecap: round; - opacity: 0.8; - transform-origin: -10px 8px; - transform: rotate(-90deg); - animation: rankAnimation 1s forwards ease-in-out; - } - @keyframes slideInAnimation { from { @@ -224,42 +190,8 @@ exports[`Test Render Wakatime Card should render correctly with compact layout w opacity: 0; animation: fadeInAnimation 0.3s ease-in-out forwards; } - .rank-text { - font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58; - animation: scaleInAnimation 0.3s ease-in-out forwards; - } - .rank-percentile-header { - font-size: 14px; - } - .rank-percentile-text { - font-size: 16px; - } - .not_bold { font-weight: 400 } .bold { font-weight: 700 } - .icon { - fill: #4c71f2; - display: none; - } - - .rank-circle-rim { - stroke: undefined; - fill: none; - stroke-width: 6; - opacity: 0.2; - } - .rank-circle { - stroke: undefined; - stroke-dasharray: 250; - fill: none; - stroke-width: 6; - stroke-linecap: round; - opacity: 0.8; - transform-origin: -10px 8px; - transform: rotate(-90deg); - animation: rankAnimation 1s forwards ease-in-out; - } - @keyframes slideInAnimation { from {