Skip to content

Commit f9527e1

Browse files
committed
style: unify Card component, remove featured variant, truncate tags to single line
1 parent d63f9bf commit f9527e1

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/components/Card.astro

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ interface Props {
77
tags?: string[];
88
href: string;
99
locale?: "zh" | "en";
10-
featured?: boolean;
1110
}
1211
13-
const { type, title, date, summary, tags = [], href, locale = "zh", featured = false } = Astro.props;
12+
const { type, title, date, summary, tags = [], href, locale = "zh" } = Astro.props;
1413
import { t } from "../i18n/utils.ts";
14+
1515
const badgeMap: Record<string, string> = {
1616
daily: t("badge.daily", locale),
1717
weekly: t("badge.weekly", locale),
@@ -24,27 +24,24 @@ const badgeColorMap = {
2424
};
2525
const badgeText = badgeMap[type];
2626
const badgeClass = badgeColorMap[type];
27-
const sizeClass = featured
28-
? "p-5 sm:p-7 border-2 border-accent/30"
29-
: "p-4 sm:p-6";
3027
---
3128

3229
<a href={href}
33-
class={`block bg-bg-card rounded-xl sm:rounded-2xl hover:bg-bg-hover hover:border-accent hover:-translate-y-0.5 transition-all duration-250 shadow-[0_8px_30px_rgba(99,102,241,0)] hover:shadow-[0_8px_30px_rgba(99,102,241,0.08)] no-underline animate-fade-in border border-border ${sizeClass}`}>
30+
class="block bg-bg-card rounded-xl sm:rounded-2xl p-4 sm:p-6 hover:bg-bg-hover hover:border-accent hover:-translate-y-0.5 transition-all duration-250 shadow-[0_8px_30px_rgba(99,102,241,0)] hover:shadow-[0_8px_30px_rgba(99,102,241,0.08)] no-underline animate-fade-in border border-border">
3431
<div class="flex items-center gap-2 sm:gap-3 mb-2 sm:mb-3">
3532
<span class={`text-xs font-semibold px-2.5 py-1 rounded-full ${badgeClass}`}>
3633
{badgeText}
3734
</span>
3835
<span class="text-text-muted text-xs sm:text-sm">{date}</span>
3936
</div>
40-
<h2 class={`font-semibold mb-1.5 sm:mb-2 ${featured ? "text-lg sm:text-xl" : "text-base sm:text-lg"} line-clamp-2`}>{title}</h2>
37+
<h2 class="text-base sm:text-lg font-semibold mb-1.5 sm:mb-2 line-clamp-2">{title}</h2>
4138
{summary && (
4239
<p class="text-text-dim text-xs sm:text-sm line-clamp-2">{summary}</p>
4340
)}
4441
{tags.length > 0 && (
45-
<div class="flex gap-1.5 sm:gap-2 mt-2.5 sm:mt-3.5 flex-wrap">
42+
<div class="flex gap-1.5 sm:gap-2 mt-2.5 sm:mt-3.5 overflow-hidden">
4643
{tags.map(tag => (
47-
<span class="text-[11px] sm:text-xs text-text-muted bg-white/[0.04] px-2 sm:px-2.5 py-1 rounded-full">{tag}</span>
44+
<span class="whitespace-nowrap flex-shrink-0 text-[11px] sm:text-xs text-text-muted bg-white/[0.04] px-2 sm:px-2.5 py-1 rounded-full">{tag}</span>
4845
))}
4946
</div>
5047
)}

src/pages/en/index.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ const recentTopics = topicsList.slice(1, 4).map((a) => ({
101101
<SectionHeader title={t("home.section_latest", "en")} href="/en/industry" />
102102
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4">
103103
{latestDaily && (
104-
<Card type={latestDaily.type} title={latestDaily.title} date={latestDaily.date} summary={latestDaily.summary} tags={latestDaily.tags} href={latestDaily.href} featured locale="en" />
104+
<Card type={latestDaily.type} title={latestDaily.title} date={latestDaily.date} summary={latestDaily.summary} tags={latestDaily.tags} href={latestDaily.href} locale="en" />
105105
)}
106106
{latestWeekly && (
107-
<Card type={latestWeekly.type} title={latestWeekly.title} date={latestWeekly.date} summary={latestWeekly.summary} tags={latestWeekly.tags} href={latestWeekly.href} featured locale="en" />
107+
<Card type={latestWeekly.type} title={latestWeekly.title} date={latestWeekly.date} summary={latestWeekly.summary} tags={latestWeekly.tags} href={latestWeekly.href} locale="en" />
108108
)}
109109
{latestTopic && (
110-
<Card type={latestTopic.type} title={latestTopic.title} date={latestTopic.date} summary={latestTopic.summary} tags={latestTopic.tags} href={latestTopic.href} featured locale="en" />
110+
<Card type={latestTopic.type} title={latestTopic.title} date={latestTopic.date} summary={latestTopic.summary} tags={latestTopic.tags} href={latestTopic.href} locale="en" />
111111
)}
112112
</div>
113113
</section>

src/pages/index.astro

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ const recentTopics = topicsList.slice(1, 4).map((a) => ({
107107
summary={latestDaily.summary}
108108
tags={latestDaily.tags}
109109
href={latestDaily.href}
110-
featured
111110
/>
112111
)}
113112
{latestWeekly && (
@@ -118,7 +117,6 @@ const recentTopics = topicsList.slice(1, 4).map((a) => ({
118117
summary={latestWeekly.summary}
119118
tags={latestWeekly.tags}
120119
href={latestWeekly.href}
121-
featured
122120
/>
123121
)}
124122
{latestTopic && (
@@ -129,7 +127,6 @@ const recentTopics = topicsList.slice(1, 4).map((a) => ({
129127
summary={latestTopic.summary}
130128
tags={latestTopic.tags}
131129
href={latestTopic.href}
132-
featured
133130
/>
134131
)}
135132
</div>

0 commit comments

Comments
 (0)