Skip to content

Commit 6466efa

Browse files
committed
Fix logo width.
1 parent 8d9118c commit 6466efa

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/components/SocialMediaSponsorCard.astro

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,22 @@ const {
1414
const logo = sponsorLogos[sponsor.id];
1515
// Assuming logo.width and logo.height are known
1616
const targetWidth = 400;
17-
const aspectRatio = logo.width / logo.height;
18-
const targetHeight = targetWidth / aspectRatio;
17+
const originalWidth = logo.width;
18+
const originalHeight = logo.height;
19+
const aspectRatio = originalWidth / originalHeight;
20+
21+
let width = targetWidth;
22+
let height = width / aspectRatio;
23+
1924
const maxHeight = 220;
20-
const realHeight = targetHeight < maxHeight? targetHeight : maxHeight;
25+
if (height > maxHeight) {
26+
height = maxHeight;
27+
width = height * aspectRatio; // adjust width to maintain aspect ratio
28+
}
29+
30+
const x = 650 - width / 2;
31+
const y = 650 - height / 2;
2132
22-
const x = 650 - targetWidth/ 2;
23-
const y = 650 - realHeight / 2;
2433
---
2534
<svg width="900" height="900" class="h-full w-full -z-10">
2635
<image href="/social/bg.png" width="900" height="900" />
@@ -50,11 +59,11 @@ const y = 650 - realHeight / 2;
5059
href={logo.src}
5160
x={x}
5261
y={y}
53-
width={targetWidth}
54-
height={realHeight}
55-
style={{
56-
padding: logo_padding ? logo_padding : undefined,
57-
}}
62+
width={width}
63+
height={height}
64+
style={{
65+
padding: logo_padding ? logo_padding : undefined,
66+
}}
5867
clip-path="url(#curvedCornerClip)"
5968
preserveAspectRatio="xMidYMid meet"
6069
/>

0 commit comments

Comments
 (0)