import React from 'react'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { useLazyTranslation } from '@/utils/useLazyTranslation'; import { cn } from '@/lib/utils'; // 1. 引入标准的 shadcn 工具函数 export interface DiffNavigatorProps extends React.HTMLAttributes { total: number; /** 0-based index */ currentIndex: number; onPrev: () => void; onNext: () => void; } export default function DiffNavigator({ total, currentIndex, onPrev, onNext, className, ...props }: DiffNavigatorProps) { const { t } = useLazyTranslation('jsonDiff'); // 计算当前的边界禁用状态守卫 const isFirst = currentIndex <= 0; const isLast = currentIndex >= total - 1; // 2. 空状态面板:对齐 shadcn 规范的中性低调卡片 if (total === 0) { return (
{t('jsonDiff:noDiffs')}
); } return (
{/* 上一处差异按钮 */} {/* 计数看板:强制等宽防止数字长短不一时产生宽度挤压跳动 */} {currentIndex + 1} /{' '} {total} {/* 下一处差异按钮 */}
); }