Files
umed/web/components/NewsCard.vue
T
2026-07-09 14:35:32 +08:00

146 lines
2.6 KiB
Vue

<script setup lang="ts">
import type { ArticleItem, MediaPublicItem } from '~/data/news-content'
defineProps<{
item: ArticleItem | MediaPublicItem
reverse?: boolean
readOriginalLabel?: string
}>()
</script>
<template>
<article class="cstory" :class="{ 'cstory--reverse': reverse }">
<div class="cstory__grid">
<div class="cstory__media">
<img :src="item.thumbnail" :alt="item.thumbnailAlt" loading="lazy" />
</div>
<div class="cstory__content">
<a
:href="item.url"
target="_blank"
rel="noopener noreferrer"
class="cstory__title"
>
{{ item.title }}
</a>
<p class="cstory__summary">{{ item.summary }}</p>
<a
:href="item.url"
target="_blank"
rel="noopener noreferrer"
class="cstory__btn"
>
{{ readOriginalLabel ?? 'Read Original Article' }}
</a>
</div>
</div>
</article>
</template>
<style scoped>
.cstory {
padding: 40px 0;
border-bottom: 1px solid #d8dde3;
}
.cstory:last-child {
border-bottom: none;
}
.cstory__grid {
display: grid;
grid-template-columns: auto 1fr;
gap: 36px;
align-items: center;
}
.cstory--reverse .cstory__grid {
direction: rtl;
}
.cstory--reverse .cstory__grid > * {
direction: ltr;
}
.cstory__media img {
width: 220px;
height: 220px;
max-width: 100%;
object-fit: cover;
border-radius: 8px;
display: block;
box-shadow: 0 4px 16px rgba(15, 39, 64, 0.12);
}
.cstory__content {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
min-width: 0;
}
.cstory__title {
display: inline;
color: var(--blue);
font-size: clamp(18px, 2.2vw, 22px);
font-weight: 700;
line-height: 1.45;
text-decoration: underline;
text-underline-offset: 3px;
}
.cstory__title:hover {
color: #0077cc;
}
.cstory__summary {
margin: 14px 0 0;
color: #1e1e1e;
font-size: 15px;
line-height: 1.8;
text-align: justify;
}
.cstory__btn {
display: inline-block;
margin-top: 20px;
padding: 10px 24px;
border: none;
border-radius: 999px;
background: #48a4fc;
color: #fff;
font-family: Georgia, 'Times New Roman', serif;
font-size: 15px;
font-weight: 500;
text-decoration: none;
transition: background 0.18s ease;
}
.cstory__btn:hover {
background: #3a96f0;
}
@media (max-width: 900px) {
.cstory {
padding: 32px 0;
}
.cstory__grid {
grid-template-columns: 1fr;
gap: 20px;
align-items: start;
}
.cstory__media img {
width: min(100%, 280px);
height: min(100%, 280px);
}
.cstory--reverse .cstory__grid {
direction: ltr;
}
}
</style>