diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js index 4007008b38f8b..13f48ca1e5e17 100644 --- a/src/cards/top-languages-card.js +++ b/src/cards/top-languages-card.js @@ -12,7 +12,7 @@ import { } from "../common/utils.js"; import { langCardLocales } from "../translations.js"; - +const DEFAULT_CARD_WIDTH = 300; const MIN_CARD_WIDTH = 280; const DEFAULT_LANG_COLOR = "#858585"; const CARD_PADDING = 25; @@ -218,14 +218,14 @@ const createProgressTextNode = ({ width, color, name, progress, index }) => { ${name} ${progress}% ${createProgressNode({ - x: 0, - y: 25, - color, - width: progressWidth, - progress, - progressBarBackgroundColor: "#ddd", - delay: staggerDelay + 300, - })} + x: 0, + y: 25, + color, + width: progressWidth, + progress, + progressBarBackgroundColor: "#ddd", + delay: staggerDelay + 300, + })} `; }; @@ -382,22 +382,21 @@ const renderCompactLayout = (langs, width, totalLanguageSize, hideProgress) => { .join(""); return ` - ${ - !hideProgress - ? ` - - - - ${compactProgressBar} - ` - : "" - } + ${hideProgress + ? "" + : ` + + + + ${compactProgressBar} + ` + } ${createLanguageTextNode({ - langs, - totalSize: totalLanguageSize, - hideProgress, - })} + langs, + totalSize: totalLanguageSize, + hideProgress, + })} `; }; @@ -431,7 +430,7 @@ const renderDonutVerticalLayout = (langs, totalLanguageSize) => { circles.push(` - { ${createLanguageTextNode({ - langs, - totalSize: totalLanguageSize, - hideProgress: false, - })} + langs, + totalSize: totalLanguageSize, + hideProgress: false, + })} @@ -557,10 +556,10 @@ const renderPieLayout = (langs, totalLanguageSize) => { ${createLanguageTextNode({ - langs, - totalSize: totalLanguageSize, - hideProgress: false, - })} + langs, + totalSize: totalLanguageSize, + hideProgress: false, + })} @@ -629,11 +628,11 @@ const renderDonutLayout = (langs, width, totalLanguageSize) => { langs.length === 1 ? `` : langPaths - .map((section, index) => { - const staggerDelay = (index + 3) * 100; - const delay = staggerDelay + 300; + .map((section, index) => { + const staggerDelay = (index + 3) * 100; + const delay = staggerDelay + 300; - const output = ` + const output = ` { `; - return output; - }) - .join(""); + return output; + }) + .join(""); const donut = `${donutPaths}`; @@ -681,8 +680,7 @@ const renderDonutLayout = (langs, width, totalLanguageSize) => { */ const noLanguagesDataNode = ({ color, text, layout }) => { return ` - ${text} `; }; @@ -734,8 +732,6 @@ const renderTopLanguages = (topLangs, options = {}) => { layout, custom_title, locale, - card_width = DEFAULT_CARD_WIDTH, - card_height = calculateNormalLayoutHeight(topLangs.length), langs_count = getDefaultLanguagesCountByLayout({ layout, hide_progress }), border_radius, border_color, @@ -757,8 +753,8 @@ const renderTopLanguages = (topLangs, options = {}) => { ? isNaN(card_width) ? DEFAULT_CARD_WIDTH : card_width < MIN_CARD_WIDTH - ? MIN_CARD_WIDTH - : card_width + ? MIN_CARD_WIDTH + : card_width : DEFAULT_CARD_WIDTH; let height = calculateNormalLayoutHeight(langs.length); @@ -806,8 +802,8 @@ const renderTopLanguages = (topLangs, options = {}) => { const card = new Card({ customTitle: custom_title, defaultTitle: i18n.t("langcard.title"), - width: card_width, - height: card_height, + width, + height, border_radius, colors, });