Files
NextEdu/src/shared/components/ui/empty-state.tsx
SpecialX 5ff7ab9e72 fix(teacher): 统一详情页返回路径与中英文文案 (P1-3+P2-1)
P1-3: empty-state 默认按钮 variant 改为 outline 并新增 variant prop;button.tsx 导出 ButtonProps;统一 5 个详情页返回路径为 ghost+ArrowLeft+文字标签;course-plan-detail raw a 改为 Link。P2-1: formatLongDate 默认 locale 改为 zh-CN,weekday 改为 short;返回按钮文案中文化;course-plan-detail 全量中文化;grades/analytics 标题中文化。验证:tsc 0 错误,lint 0 错误,架构图 004/005 已同步。
2026-06-22 13:52:26 +08:00

63 lines
1.8 KiB
TypeScript

import * as React from "react"
import Link from "next/link"
import { cn } from "@/shared/lib/utils"
import { Button } from "@/shared/components/ui/button"
import type { ButtonProps } from "@/shared/components/ui/button"
interface EmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {
title: string
description: string
icon?: React.ElementType
action?: {
label: string
onClick?: () => void
href?: string
/** 按钮样式,默认 "outline"(次级按钮)。首次引导场景可用 "default"(主按钮) */
variant?: ButtonProps["variant"]
}
}
export function EmptyState({
icon: Icon,
title,
description,
action,
className,
...props
}: EmptyStateProps) {
return (
<div
className={cn(
"flex h-[450px] shrink-0 items-center justify-center rounded-md border border-dashed",
className
)}
{...props}
>
<div className="mx-auto flex max-w-[420px] flex-col items-center justify-center text-center">
{Icon && (
<div className="flex h-20 w-20 items-center justify-center rounded-full bg-muted">
<Icon className="h-10 w-10 text-muted-foreground" />
</div>
)}
<h3 className="mt-4 text-lg font-semibold">{title}</h3>
{description && (
<p className="mb-4 mt-2 text-sm text-muted-foreground">
{description}
</p>
)}
{action && (
action.href ? (
<Button asChild variant={action.variant ?? "outline"}>
<Link href={action.href}>{action.label}</Link>
</Button>
) : (
<Button onClick={action.onClick} variant={action.variant ?? "outline"}>
{action.label}
</Button>
)
)}
</div>
</div>
)
}