单词列表改紧凑网格(一行2-3个),不再一行一个占空间

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jacobxu666
2026-08-05 21:41:26 +08:00
co-authored by Claude Opus 4.8
parent 566d80311a
commit b63ccdfa9e
+18 -13
View File
@@ -136,34 +136,39 @@ export function WordDayClient({
<span className="text-xs text-muted-foreground">已学 {learnedSet.size}/{items.length}</span> <span className="text-xs text-muted-foreground">已学 {learnedSet.size}/{items.length}</span>
</header> </header>
<div className="space-y-2"> <div className="grid grid-cols-2 gap-2 sm:grid-cols-3">
{items.map((it) => { {items.map((it) => {
const done = learnedSet.has(it.word); const done = learnedSet.has(it.word);
return ( return (
<div key={it.word} className="rounded-xl border border-slate-100 bg-white p-3 shadow-soft"> <div key={it.word} className="rounded-xl border border-slate-100 bg-white p-2.5 shadow-soft">
<div className="flex items-center gap-2"> <div className="flex items-center gap-1.5">
<button type="button" onClick={() => speak(it.word)} className="text-indigo-600" title="发音"> <button type="button" onClick={() => speak(it.word)} className="shrink-0 text-indigo-600" title="发音">
<Volume2 className="size-5" /> <Volume2 className="size-4" />
</button> </button>
<button type="button" onClick={() => openDetail(it.word)} className="text-left"> <button type="button" onClick={() => openDetail(it.word)} className="min-w-0 flex-1 truncate text-left text-sm font-bold text-slate-900">
<span className="text-base font-bold text-slate-900">{it.word}</span> {it.word}
</button> </button>
<span className="ml-1 flex-1 truncate text-sm text-muted-foreground">{it.meaning}</span>
<RecordBtn day={day} word={it.word} />
<button <button
type="button" type="button"
onClick={() => toggleLearn(it.word)} onClick={() => toggleLearn(it.word)}
className={cn( className={cn(
"flex size-8 shrink-0 items-center justify-center rounded-full border-2", "flex size-6 shrink-0 items-center justify-center rounded-full border-2",
done ? "border-transparent bg-gradient-to-br from-emerald-400 to-emerald-600 text-white" : "border-slate-300", done ? "border-transparent bg-gradient-to-br from-emerald-400 to-emerald-600 text-white" : "border-slate-300",
)} )}
title="学会" title="学会"
> >
{done && <Check className="size-4" strokeWidth={3} />} {done && <Check className="size-3.5" strokeWidth={3} />}
</button>
</div>
<p className="mt-1 truncate text-xs text-muted-foreground">{it.meaning}</p>
<div className="mt-1.5 flex items-center justify-between">
<RecordBtn day={day} word={it.word} />
<button type="button" onClick={() => openDetail(it.word)} className="text-xs text-indigo-600">
详情
</button> </button>
</div> </div>
{open === it.word && ( {open === it.word && (
<div className="mt-2 space-y-1 rounded-lg bg-slate-50 p-2 text-sm"> <div className="mt-2 space-y-1 rounded-lg bg-slate-50 p-2 text-xs">
<p className="text-slate-800"> <p className="text-slate-800">
<span className="font-medium text-indigo-600">释义:</span> <span className="font-medium text-indigo-600">释义:</span>
{it.meaning || "见例句"} {it.meaning || "见例句"}
@@ -174,7 +179,7 @@ export function WordDayClient({
</p> </p>
<p className="text-slate-700"> <p className="text-slate-700">
<span className="font-medium text-indigo-600">形近词:</span> <span className="font-medium text-indigo-600">形近词:</span>
{it.similar.map((s) => `${s.word}(${s.meaning})`).join("、") || "无"} {it.similar.map((s) => s.word).join("、") || "无"}
</p> </p>
</div> </div>
)} )}