From 01f726c3163402ce0f98bd18fef49374f5684490 Mon Sep 17 00:00:00 2001 From: Zohan Subhash Date: Tue, 17 Jan 2023 15:43:37 +0530 Subject: [PATCH] Update repo-card.js --- src/cards/repo-card.js | 46 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/cards/repo-card.js b/src/cards/repo-card.js index a306c1d5..1c86b8d2 100644 --- a/src/cards/repo-card.js +++ b/src/cards/repo-card.js @@ -87,16 +87,6 @@ const iconWithLabel = (icon, label, testid) => { * @returns {string} Repository card SVG object. */ const renderRepoCard = (repo, options = {}) => { - const { - name, - nameWithOwner, - description, - primaryLanguage, - isArchived, - isTemplate, - starCount, - forkCount, - } = repo; const { hide_border = false, title_color, @@ -109,6 +99,29 @@ const renderRepoCard = (repo, options = {}) => { border_color, locale, } = options; + + const i18n = new I18n({ + locale, + translations: repoCardLocales, + }); + + const { + name, + nameWithOwner, + description, + primaryLanguage, + isArchived, + isTemplate, + starCount, + forkCount, + highlight = isTemplate + ? // @ts-ignore + getBadgeSVG(i18n.t("repocard.template"), colors.textColor) + : isArchived + ? // @ts-ignore + getBadgeSVG(i18n.t("repocard.archived"), colors.textColor) + : "", + } = repo; const lineHeight = 10; const header = show_owner ? nameWithOwner : name; @@ -125,11 +138,6 @@ const renderRepoCard = (repo, options = {}) => { const height = (descriptionLines > 1 ? 120 : 110) + descriptionLines * lineHeight; - const i18n = new I18n({ - locale, - translations: repoCardLocales, - }); - // returns theme based colors with proper overrides and defaults const colors = getCardColors({ title_color, @@ -181,13 +189,7 @@ const renderRepoCard = (repo, options = {}) => { return card.render(` ${ - isTemplate - ? // @ts-ignore - getBadgeSVG(i18n.t("repocard.template"), colors.textColor) - : isArchived - ? // @ts-ignore - getBadgeSVG(i18n.t("repocard.archived"), colors.textColor) - : "" + highlight }