HistoryDrawer.tsx 1.9 KB

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