diff --git a/api/index.ts b/api/index.ts index 2d0dec7..fc8bd8f 100644 --- a/api/index.ts +++ b/api/index.ts @@ -27,6 +27,7 @@ import { isValidHexColor, isValidGradient } from "../src/common/utils"; * @property {string|undefined} showItems - Items to show. * @property {boolean|string} hideStroke - Toggle for hiding strokes. * @property {boolean|string} hideBorder - Toggle for hiding borders. + * @property {boolean|string} Revert - Invert display order, stats to left and image to right. * @property {number|string} photoQuality - Photo image quality. * @property {number|string} photoResize - Photo image resize. */ @@ -48,6 +49,7 @@ type UiConfig = { showItems: string | undefined; hideStroke: boolean | string; hideBorder: boolean | string; + Revert: boolean | string; photoQuality: number | string; photoResize: number | string; }; @@ -87,6 +89,7 @@ async function readmeStats(req: any, res: any): Promise { showItems: escapeHTML(req.query.show), hideStroke: parseBoolean(escapeHTML(req.query.hide_stroke)) || false, hideBorder: parseBoolean(escapeHTML(req.query.hide_border)) || false, + Revert: parseBoolean(escapeHTML(req.query.revert)) || false, photoQuality: photoQuality, photoResize: photoResize, }; diff --git a/src/card.ts b/src/card.ts index ad1bbe4..b6cf5f5 100644 --- a/src/card.ts +++ b/src/card.ts @@ -37,6 +37,7 @@ async function card(data: GetData, uiConfig: UiConfig): Promise { const isRtlDirection = parseBoolean(selectLocale.rtlDirection); const isDisabledAnimations = parseBoolean(uiConfig.disabledAnimations || uiConfig.Format === "png"); + const isRevert = parseBoolean(uiConfig.Revert); let titleCard = defaultLocale.titleCard.split("{name}").join(data.name); if (uiConfig.Title && @@ -58,12 +59,13 @@ async function card(data: GetData, uiConfig: UiConfig): Promise { textXPosition: isRtlDirection ? 225 : 20, dataXPosition: isRtlDirection ? 25 : 220, iconXPosition: isRtlDirection ? 235 : -5, - imageXPosition: isDisabledAnimations ? 122 : 127, + imageXPosition: isDisabledAnimations ? (isRevert ? 412 : 122) : (isRevert ? 417 : 127), imageYPosition: isDisabledAnimations ? 70 : 65, - userXPosition: isDisabledAnimations ? 122 : 112, + userXPosition: isDisabledAnimations ? (isRevert ? 412 : 122) : (isRevert ? 402 : 112), userYPosition: isDisabledAnimations ? 140 : 130, - follXPosition: isDisabledAnimations ? 122 : 112, + follXPosition: isDisabledAnimations ? (isRevert ? 412 : 122) : (isRevert ? 402 : 112), follYPosition: isDisabledAnimations ? 161 : 151, + itemStatsXTransform: isRevert ? (isRtlDirection ? 10 : 0) : 230, }; const hideStroke = parseBoolean(uiConfig.hideStroke) ? `` : `stroke="#${uiConfig.strokeColor}" stroke-width="5"`; @@ -136,7 +138,7 @@ async function card(data: GetData, uiConfig: UiConfig): Promise { const cardItemsToShow = cardItems.filter(item => !item.hidden); const cardItemsSVG = cardItemsToShow.map((item, index) => ` - + ${item.icon} diff --git a/tests/card.test.ts b/tests/card.test.ts index e8da6a7..f9aa94e 100644 --- a/tests/card.test.ts +++ b/tests/card.test.ts @@ -40,6 +40,7 @@ describe("Test card function", () => { disabledAnimations: false, showItems: "reviews,issues_closed", hiddenItems: "forks,commits", + Revert: false, photoQuality: 15, photoResize: 150, };