HistoryDrawer.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React from 'react';
  2. import { createPortal } from 'react-dom';
  3. import { KnowledgeGroup } from '../types';
  4. import { SearchHistoryList } from './SearchHistoryList';
  5. import { X, History } from 'lucide-react';
  6. import { useLanguage } from '../contexts/LanguageContext';
  7. interface HistoryDrawerProps {
  8. isOpen: boolean;
  9. onClose: () => void;
  10. groups: KnowledgeGroup[];
  11. onSelectHistory: (historyId: string) => void;
  12. }
  13. export const HistoryDrawer: React.FC<HistoryDrawerProps> = ({
  14. isOpen,
  15. onClose,
  16. groups,
  17. onSelectHistory
  18. }) => {
  19. const { t } = useLanguage();
  20. if (!isOpen) return null;
  21. return createPortal(
  22. <div className="fixed inset-0 z-50 overflow-hidden">
  23. <div className="absolute inset-0 bg-black/30 backdrop-blur-sm transition-opacity" onClick={onClose} />
  24. <div className="absolute inset-y-0 right-0 max-w-md w-full flex">
  25. <div className="flex-1 flex flex-col bg-white shadow-xl animate-in slide-in-from-right duration-300">
  26. <div className="flex items-center justify-between px-4 py-3 border-b border-gray-200">
  27. <h2 className="text-lg font-medium text-gray-900 flex items-center gap-2">
  28. <History size={20} />
  29. {t('historyTitle')}
  30. </h2>
  31. <button
  32. onClick={onClose}
  33. className="text-gray-400 hover:text-gray-500 focus:outline-none"
  34. >
  35. <X size={24} />
  36. </button>
  37. </div>
  38. <div className="flex-1 overflow-y-auto p-4">
  39. <SearchHistoryList
  40. groups={groups}
  41. onSelectHistory={onSelectHistory}
  42. />
  43. </div>
  44. </div>
  45. </div>
  46. </div>,
  47. document.body
  48. );
  49. };