46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
/**
|
|
* 统一的 EmptyState 组件
|
|
* 用于显示空状态
|
|
*/
|
|
import React from "react";
|
|
import type { LucideIcon } from "lucide-react";
|
|
import { Button } from "../ui/Button";
|
|
|
|
export interface EmptyStateProps {
|
|
icon?: LucideIcon;
|
|
title: string;
|
|
description?: string;
|
|
action?: {
|
|
label: string;
|
|
onClick: () => void;
|
|
icon?: LucideIcon;
|
|
};
|
|
}
|
|
|
|
export const EmptyState: React.FC<EmptyStateProps> = ({
|
|
icon: Icon,
|
|
title,
|
|
description,
|
|
action,
|
|
}) => {
|
|
return (
|
|
<div className="text-center py-16 bg-gray-800/30 border border-gray-700 border-dashed rounded-lg">
|
|
{Icon && <Icon className="w-16 h-16 mx-auto mb-4 text-gray-600" />}
|
|
<h3 className="text-lg font-semibold text-gray-400 mb-2">{title}</h3>
|
|
{description && (
|
|
<p className="text-sm text-gray-500 mb-6">{description}</p>
|
|
)}
|
|
{action && (
|
|
<Button
|
|
variant="primary"
|
|
icon={action.icon}
|
|
onClick={action.onClick}
|
|
>
|
|
{action.label}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|