File size: 2,582 Bytes
4ccea17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
class FigmaImporter extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: 'open' });
  }

  connectedCallback() {
    this.shadowRoot.innerHTML = `
      <style>
        .importer-container {
          padding: 2rem;
          background: #f8fafc;
          border-radius: 0.5rem;
          box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        .dropzone {
          border: 2px dashed #cbd5e1;
          border-radius: 0.5rem;
          padding: 3rem;
          text-align: center;
          cursor: pointer;
          transition: all 0.2s;
        }
        .dropzone:hover {
          border-color: #6366f1;
        }
        .btn-primary {
          background: #6366f1;
          color: white;
          padding: 0.75rem 1.5rem;
          border-radius: 0.5rem;
          border: none;
          cursor: pointer;
          font-weight: 500;
          transition: all 0.2s;
        }
        .btn-primary:hover {
          background: #4f46e5;
        }
      </style>
      <div class="importer-container">
        <div class="dropzone" id="dropzone">
          <i data-feather="upload-cloud" class="w-12 h-12 mb-4 mx-auto text-gray-400"></i>
          <h3 class="text-lg font-medium text-gray-900 mb-2">Drop Figma file here</h3>
          <p class="text-gray-500 mb-4">or click to browse files</p>
          <button class="btn-primary">Import Design</button>
        </div>
      </div>
    `;
    this.setupDropzone();
  }

  setupDropzone() {
    const dropzone = this.shadowRoot.getElementById('dropzone');
    
    dropzone.addEventListener('click', () => {
      this.importFromFigma();
    });

    dropzone.addEventListener('dragover', (e) => {
      e.preventDefault();
      dropzone.style.borderColor = '#6366f1';
      dropzone.style.backgroundColor = '#eef2ff';
    });

    dropzone.addEventListener('dragleave', () => {
      dropzone.style.borderColor = '#cbd5e1';
      dropzone.style.backgroundColor = 'transparent';
    });

    dropzone.addEventListener('drop', (e) => {
      e.preventDefault();
      dropzone.style.borderColor = '#cbd5e1';
      dropzone.style.backgroundColor = 'transparent';
      
      const file = e.dataTransfer.files[0];
      if (file) {
        this.processFigmaFile(file);
      }
    });
  }

  importFromFigma() {
    // TODO: Implement Figma API integration
    console.log('Connecting to Figma API...');
  }

  processFigmaFile(file) {
    // TODO: Implement file processing
    console.log('Processing Figma file:', file.name);
  }
}

customElements.define('figma-importer', FigmaImporter);