Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/components/Common/ArticleCard/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@
}

.image {
height: auto;
max-width: 300px;
display: block;
width: 100%;
height: 100%;
min-width: 0;
object-fit: cover;
}

.imageFrame {
display: block;
width: 300px;
aspect-ratio: 40 / 21;
flex-shrink: 0;
overflow: hidden;
background-color: rgba(156, 163, 175, 0.18);
}

.description {
Expand All @@ -41,9 +51,8 @@
}

@media (max-width: 1023px) and (min-width: 641px) {
.image {
height: auto;
max-width: 300px;
.imageFrame {
width: 300px;
}

.content {
Expand All @@ -52,9 +61,8 @@
}

@media (max-width: 1081px) and (min-width: 1023px) {
.image {
height: auto;
max-width: 250px;
.imageFrame {
width: 250px;
}

.content {
Expand All @@ -63,9 +71,8 @@
}

@media (max-width: 717px) and (min-width: 641px) {
.image {
height: auto;
max-width: 200px;
.imageFrame {
width: 200px;
}

.content {
Expand All @@ -78,10 +85,8 @@
display: block;
}

.image {
.imageFrame {
width: 100%;
max-width: 100%;
height: auto;
margin-bottom: 1rem;
}

Expand Down
21 changes: 10 additions & 11 deletions src/components/Common/Elements/WebpImage/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
}

.cardPicture {
max-width: 300px;
width: 300px;
aspect-ratio: 300 / 158;
flex-shrink: 0;
overflow: hidden;
background-color: rgba(156, 163, 175, 0.18);
}

.recentPicture {
Expand All @@ -17,9 +20,10 @@
.image {
display: block;
width: 100%;
height: auto;
height: 100%;
max-width: 300px;
min-width: 0;
object-fit: cover;
}

.recent {
Expand All @@ -39,48 +43,43 @@

@media (max-width: 1023px) and (min-width: 641px) {
.cardPicture {
max-width: 300px;
width: 300px;
}

.image {
height: auto;
max-width: 300px;
}
}

@media (max-width: 1081px) and (min-width: 1023px) {
.cardPicture {
max-width: 250px;
width: 250px;
}

.image {
height: auto;
max-width: 250px;
}
}

@media (max-width: 717px) and (min-width: 641px) {
.cardPicture {
max-width: 200px;
width: 200px;
}

.image {
height: auto;
max-width: 200px;
}
}

@media (max-width: 640px) {
.cardPicture {
width: 100%;
max-width: 100%;
margin-bottom: 1rem;
}

.image {
width: 100%;
max-width: 100%;
height: auto;
margin-bottom: 1rem;
}

.thumbnail {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('UnifiedArticleCard', () => {
expect(image).toHaveAttribute('src', 'https://example.com/zenn.png');
expect(image).toHaveAttribute('width', '1200');
expect(image).toHaveAttribute('height', '630');
expect(image?.parentElement?.tagName).toBe('SPAN');
});

it('renders the updated date only when it is a later day than publishedAt', () => {
Expand Down
23 changes: 12 additions & 11 deletions src/components/Common/UnifiedArticleCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ export default function UnifiedArticleCard({ article, priority = false }: Props)
<WebpImage article={article} card={true} priority={priority} />
)}
{article.source !== 'blog' && article.thumbnailUrl && (
<img
className={styles.image}
src={article.thumbnailUrl}
alt=""
width={1200}
height={630}
loading="lazy"
decoding="async"
fetchPriority={priority ? 'high' : undefined}
style={{ alignSelf: 'flex-start' }}
/>
<span className={styles.imageFrame}>
<img
className={styles.image}
src={article.thumbnailUrl}
alt=""
width={1200}
height={630}
loading={priority ? 'eager' : 'lazy'}
decoding="async"
fetchPriority={priority ? 'high' : undefined}
/>
</span>
)}
<div className={styles.content}>
{article.isSponsored && <SponsoredDisclosure compact />}
Expand Down
Loading