Skip to content

Commit 8257c78

Browse files
authored
Merge pull request #9 from AndyWang505/feature/ux-enhancements
fix: adjust cover width and image dimensions in CardItem component fo…
2 parents 45897e0 + 222e597 commit 8257c78

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/components/CardItem.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function getReadingTime(wordCount: number): number {
5353
const wordCount = content ? getWordCount(content) : getWordCount(description);
5454
const readingTime = getReadingTime(wordCount);
5555
const hasCover = heroImage !== undefined && heroImage !== null && heroImage !== "";
56-
const coverWidth = "28%";
56+
const coverWidth = "30%";
5757
---
5858

5959
<div class="w-full rounded-xl overflow-hidden relative mb-4 bg-white
@@ -77,7 +77,7 @@ const coverWidth = "28%";
7777
</a>
7878
}
7979

80-
<div class={`px-4 py-4 md:pl-9 md:pr-2 md:pt-7 md:pb-6 relative ${hasCover ? 'md:w-[calc(100%_-_var(--coverWidth)_-_12px)]' : 'md:w-[calc(100%_-_52px_-_12px)]'}`}>
80+
<div class={`px-4 py-4 md:pl-9 md:pr-2 md:pt-7 md:pb-6 relative ${hasCover ? `md:w-[calc(100%_-_${coverWidth}_-_12px)]` : 'md:w-[calc(100%_-_52px_-_12px)]'}`}>
8181
<a href={`/post/${slug}/`}
8282
class="group w-full block font-bold mb-2 md:mb-3 text-lg md:text-3xl
8383
text-zinc-900 dark:text-zinc-100
@@ -175,7 +175,7 @@ const coverWidth = "28%";
175175
<!-- Desktop images -->
176176
{hasCover &&
177177
<a href={`/post/${slug}/`}
178-
class="group hidden md:block md:w-[var(--coverWidth)] relative md:absolute md:top-3 md:bottom-3 md:right-3 rounded-xl overflow-hidden active:scale-95 transition-transform ease-out">
178+
class={`group hidden md:block md:w-[${coverWidth}] relative md:absolute md:top-3 md:bottom-3 md:right-3 rounded-xl overflow-hidden active:scale-95 transition-transform ease-out`}>
179179
<div class="absolute pointer-events-none z-10 w-full h-full group-hover:bg-black/30 group-active:bg-black/50 transition-colors duration-300 ease-out"></div>
180180
<div class="absolute pointer-events-none z-20 w-full h-full flex items-center justify-center">
181181
<svg class="opacity-0 group-hover:opacity-100 scale-50 group-hover:scale-100 text-white text-5xl transition-all" width="60" height="60" viewBox="0 0 24 24" fill="currentColor">
@@ -185,8 +185,8 @@ const coverWidth = "28%";
185185
<Image
186186
src={heroImage}
187187
alt={title}
188-
width={300}
189-
height={200}
188+
width={240}
189+
height={180}
190190
loading="lazy"
191191
format="webp"
192192
quality={80}

0 commit comments

Comments
 (0)