Empty.tsx 1.09 KB
import type { ReactNode } from 'react';

export interface EmptyProps {
  title?: ReactNode;
  description?: ReactNode;
  /** 紧凑模式:用于面板内部,去掉大留白 */
  compact?: boolean;
  action?: ReactNode;
}

/** 空态:统一的"没有数据"表达,避免各面板各写一句提示文案 */
export function Empty({ title = '暂无数据', description, compact, action }: EmptyProps) {
  return (
    <div className={compact ? 'hm-empty hm-empty--compact' : 'hm-empty'}>
      <svg width="44" height="44" viewBox="0 0 48 48" aria-hidden className="hm-empty__icon">
        <rect x="6" y="10" width="36" height="28" rx="5" fill="none" stroke="currentColor" strokeWidth="1.8" />
        <path d="M6 26 L17 20 L26 27 L33 22 L42 27" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinejoin="round" />
        <circle cx="33" cy="27" r="3.4" fill="currentColor" />
      </svg>
      <div className="hm-empty__title">{title}</div>
      {description && <div className="hm-empty__desc">{description}</div>}
      {action && <div className="hm-empty__action">{action}</div>}
    </div>
  );
}