Skip to content

Commit 829e1ab

Browse files
authored
Update repo-card.js
changes as per review
1 parent 81a24f5 commit 829e1ab

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/cards/repo-card.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,39 @@ const renderRepoCard = (repo, options = {}) => {
137137
gap: 25,
138138
}).join("");
139139

140-
// Calculate the card width and height based on the provided arguments or defaults
140+
// Calculate the card width and height based on the provided arguments or defaults;
141+
141142
const width = card_width || 400;
143+
const CARD_MIN_WIDTH = 287;
144+
const CARD_DEFAULT_WIDTH = 287;
145+
const RANK_CARD_MIN_WIDTH = 420;
146+
const RANK_CARD_DEFAULT_WIDTH = 450;
147+
const RANK_ONLY_CARD_MIN_WIDTH = 290;
148+
const RANK_ONLY_CARD_DEFAULT_WIDTH = 290;
149+
const minCardWidth =
150+
(hide_rank
151+
? clampValue(
152+
50 /* padding */ + calculateTextWidth() * 2,
153+
CARD_MIN_WIDTH,
154+
Infinity,
155+
)
156+
: statItems.length
157+
? RANK_CARD_MIN_WIDTH
158+
: RANK_ONLY_CARD_MIN_WIDTH) + iconWidth;
159+
const defaultCardWidth =
160+
(hide_rank
161+
? CARD_DEFAULT_WIDTH
162+
: statItems.length
163+
? RANK_CARD_DEFAULT_WIDTH
164+
: RANK_ONLY_CARD_DEFAULT_WIDTH) + iconWidth;
165+
let width = card_width
166+
? isNaN(card_width)
167+
? defaultCardWidth
168+
: card_width
169+
: defaultCardWidth;
170+
if (width < minCardWidth) {
171+
width = minCardWidth;
172+
}
142173

143174
const card = new Card({
144175
defaultTitle: header.length > 35 ? `${header.slice(0, 35)}...` : header,

0 commit comments

Comments
 (0)