File size: 2,176 Bytes
194aaa5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { useEffect } from 'react';
import type { Source } from '../types';

interface SourceModalProps {
  source: Source;
  onClose: () => void;
}

export function SourceModal({ source, onClose }: SourceModalProps) {
  useEffect(() => {
    const handleKeyDown = (e: KeyboardEvent) => {
      if (e.key === 'Escape') onClose();
    };
    window.addEventListener('keydown', handleKeyDown);
    return () => window.removeEventListener('keydown', handleKeyDown);
  }, [onClose]);
  return (
    <div className="modal-backdrop" onClick={onClose}>

      <div className="modal-content" onClick={(e) => e.stopPropagation()}>

        <header className="modal-header">

          <div className="modal-title-container">

            <svg

              className="source-icon modal-icon"

              width="18"

              height="18"

              viewBox="0 0 24 24"

              fill="none"

              stroke="currentColor"

              strokeWidth="2"

            >

              <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>

              <polyline points="14 2 14 8 20 8"></polyline>

              <line x1="16" y1="13" x2="8" y2="13"></line>

              <line x1="16" y1="17" x2="8" y2="17"></line>

              <polyline points="10 9 9 9 8 9"></polyline>

            </svg>

            <h3>{source.filename}</h3>

            <span className="modal-badge">Chunk {source.chunk_index + 1}</span>

          </div>

          <button

            className="modal-close-btn"

            onClick={onClose}

            title="Close (Esc)"

          >

            <svg

              width="20"

              height="20"

              viewBox="0 0 24 24"

              fill="none"

              stroke="currentColor"

              strokeWidth="2"

            >

              <line x1="18" y1="6" x2="6" y2="18"></line>

              <line x1="6" y1="6" x2="18" y2="18"></line>

            </svg>

          </button>

        </header>

        <div className="modal-body">

          <pre className="source-snippet">{source.content}</pre>

        </div>

      </div>

    </div>
  );
}