| 15 | * 让 Result 跨满整行能保证 outline-cli、表格、commit 列表完整展示。 |
| 16 | */ |
| 17 | export function StepCard({ step }: { step: StepData }) { |
| 18 | const t = useT(); |
| 19 | return ( |
| 20 | <section |
| 21 | id={`step-${step.id}`} |
| 22 | className="scroll-mt-20 border rounded-xl bg-card overflow-hidden" |
| 23 | > |
| 24 | {/* Header */} |
| 25 | <header className="px-5 py-4 border-b bg-muted/30 flex items-baseline gap-3"> |
| 26 | <span className="shrink-0 inline-flex items-center justify-center h-8 w-8 rounded-full bg-foreground text-background font-mono text-sm"> |
| 27 | {step.id} |
| 28 | </span> |
| 29 | <h2 className="text-lg font-semibold leading-tight">{t(step.titleKey)}</h2> |
| 30 | </header> |
| 31 | |
| 32 | {/* 上半部分:Why + What 并排(md+)/ 堆叠(sm) */} |
| 33 | <div className="grid grid-cols-1 md:grid-cols-2 border-b"> |
| 34 | {/* Why */} |
| 35 | <div className="p-5 bg-blue-50/30 dark:bg-blue-950/10 border-b md:border-b-0 md:border-r"> |
| 36 | <div className="flex items-center gap-2 mb-3 text-blue-700 dark:text-blue-300"> |
| 37 | <Lightbulb className="h-4 w-4" /> |
| 38 | <span className="text-xs uppercase tracking-wide font-medium"> |
| 39 | {t("learn.col.why")} |
| 40 | </span> |
| 41 | </div> |
| 42 | <p className="text-sm leading-relaxed text-foreground/90"> |
| 43 | {t(step.whyKey)} |
| 44 | </p> |
| 45 | {step.concepts && step.concepts.length > 0 && ( |
| 46 | <div className="mt-4 flex flex-wrap gap-2"> |
| 47 | {step.concepts.map((c, i) => ( |
| 48 | <ConceptHint key={i} termKey={c.termKey} bodyKey={c.bodyKey} /> |
| 49 | ))} |
| 50 | </div> |
| 51 | )} |
| 52 | </div> |
| 53 | |
| 54 | {/* What */} |
| 55 | <div className="p-5 bg-zinc-50/50 dark:bg-zinc-950/30"> |
| 56 | <div className="flex items-center gap-2 mb-3 text-zinc-700 dark:text-zinc-300"> |
| 57 | <Settings2 className="h-4 w-4" /> |
| 58 | <span className="text-xs uppercase tracking-wide font-medium"> |
| 59 | {t("learn.col.what")} |
| 60 | </span> |
| 61 | </div> |
| 62 | {step.whatCommand ? ( |
| 63 | <pre className="rounded-md bg-zinc-950 text-zinc-100 dark:bg-zinc-900 p-3 overflow-x-auto text-xs leading-relaxed font-mono"> |
| 64 | <code>{step.whatCommand}</code> |
| 65 | </pre> |
| 66 | ) : ( |
| 67 | <div className="rounded-md border border-dashed bg-card/50 p-3 text-xs text-muted-foreground italic"> |
| 68 | {step.whatNoteKey ? t(step.whatNoteKey) : "—"} |
| 69 | </div> |
| 70 | )} |
| 71 | {step.whatCommand && step.whatNoteKey && ( |
| 72 | <p className="mt-2 text-xs text-muted-foreground leading-relaxed"> |
| 73 | {t(step.whatNoteKey)} |
| 74 | </p> |