Skip to content

Commit 34d6423

Browse files
committed
fix: fixes rank circle padding problem
This commit fixes a padding problem that was introduced in f9c0e0b. In the new code, the padding around the rank circle will be 50 when the stats card is bigger than 450. When it is smaller than 450 the left and right padding will shrink equally.
1 parent f642627 commit 34d6423

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/cards/stats-card.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,30 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
220220

221221
if (disable_animations) card.disableAnimations();
222222

223+
/**
224+
* Calculates the right rank circle translation values such that the rank circle
225+
* keeps respecting the padding.
226+
*
227+
* width > 450: The default left padding of 50 px will be used.
228+
* width < 450: The left and right padding will shrink equally.
229+
*
230+
* @returns {number} - Rank circle translation value.
231+
*/
232+
const calculateRankXTranslation = () => {
233+
if (width < 450) {
234+
return width - 95 + (45 * (450 - 340)) / 110;
235+
} else {
236+
return width - 95;
237+
}
238+
};
239+
223240
// Conditionally rendered elements
224241
const rankCircle = hide_rank
225242
? ""
226243
: `<g data-testid="rank-circle"
227-
transform="translate(${width - 50}, ${height / 2 - 50})">
244+
transform="translate(${calculateRankXTranslation()}, ${
245+
height / 2 - 50
246+
})">
228247
<circle class="rank-circle-rim" cx="-10" cy="8" r="40" />
229248
<circle class="rank-circle" cx="-10" cy="8" r="40" />
230249
<g class="rank-text">

0 commit comments

Comments
 (0)