DiffNavigation.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import type { FileDiff } from "@opencode-ai/sdk/client"
  2. interface DiffNavigationProps {
  3. diffs: FileDiff[]
  4. selectedFile: number
  5. onSelectFile: (index: number) => void
  6. }
  7. export function DiffNavigation({ diffs, selectedFile, onSelectFile }: DiffNavigationProps) {
  8. if (diffs.length <= 1) {
  9. return null
  10. }
  11. return (
  12. <div className="flex items-center gap-1 px-4 py-2 border-b border-gray-200 dark:border-gray-800 overflow-x-auto bg-gray-50 dark:bg-gray-950">
  13. {diffs.map((diff, index) => (
  14. <button
  15. key={index}
  16. onClick={() => onSelectFile(index)}
  17. className={`px-3 py-1.5 text-xs font-medium rounded whitespace-nowrap transition-colors ${
  18. selectedFile === index
  19. ? "bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 shadow-sm"
  20. : "text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-900"
  21. }`}
  22. title={diff.file}
  23. data-tip={diff.file}
  24. >
  25. {diff.file.split("/").pop() || diff.file}
  26. </button>
  27. ))}
  28. </div>
  29. )
  30. }