File size: 5,117 Bytes
e2a9158
c9619ed
e2a9158
c9619ed
 
e2a9158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9619ed
e2a9158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9619ed
 
 
 
 
e2a9158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9619ed
 
 
 
 
e2a9158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9619ed
e2a9158
 
 
 
 
 
c9619ed
e2a9158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<script lang="ts">
  const { fileSelected } = $props();

  let xorbDragActive = $state(false);
  let shardDragActive = $state(false);
  let xorbFileInput: HTMLInputElement;
  let shardFileInput: HTMLInputElement;

  function handleDragOver(event: DragEvent, type: "xorb" | "shard") {
    event.preventDefault();
    if (type === "xorb") {
      xorbDragActive = true;
    } else {
      shardDragActive = true;
    }
  }

  function handleDragLeave(type: "xorb" | "shard") {
    if (type === "xorb") {
      xorbDragActive = false;
    } else {
      shardDragActive = false;
    }
  }

  function handleDrop(event: DragEvent, type: "xorb" | "shard") {
    event.preventDefault();
    if (type === "xorb") {
      xorbDragActive = false;
    } else {
      shardDragActive = false;
    }

    const files = event.dataTransfer?.files;
    if (files && files.length > 0) {
      handleFile(files[0], type);
    }
  }

  function handleFileInput(event: Event, type: "xorb" | "shard") {
    const input = event.target as HTMLInputElement;
    if (input.files && input.files.length > 0) {
      handleFile(input.files[0], type);
    }
  }

  function handleFile(file: File, type: "xorb" | "shard") {
    fileSelected({ file, type });
  }

  function openFileDialog(type: "xorb" | "shard") {
    if (type === "xorb") {
      xorbFileInput.click();
    } else {
      shardFileInput.click();
    }
  }
</script>

<div class="upload-container">
  <div class="upload-areas">
    <!-- XORB Upload Area -->
    <div class="upload-section">
      <h3>πŸ“¦ Upload XORB File</h3>
      <div
        class="upload-area xorb-area"
        class:drag-active={xorbDragActive}
        ondragover={(e) => handleDragOver(e, "xorb")}
        ondragleave={() => handleDragLeave("xorb")}
        ondrop={(e) => handleDrop(e, "xorb")}
        onclick={() => openFileDialog("xorb")}
        onkeydown={(e) => e.key === "Enter" && openFileDialog("xorb")}
        role="button"
        tabindex="0"
      >
        <div class="upload-content">
          <div class="upload-icon">πŸ“¦</div>
          <h4>Drop XORB file here</h4>
          <p>or click to browse</p>
          <span class="format-tag xorb-tag">XORB</span>
        </div>
      </div>
    </div>

    <!-- Shard Upload Area -->
    <div class="upload-section">
      <h3>πŸ—‚οΈ Upload Shard File</h3>
      <div
        class="upload-area shard-area"
        class:drag-active={shardDragActive}
        ondragover={(e) => handleDragOver(e, "shard")}
        ondragleave={() => handleDragLeave("shard")}
        ondrop={(e) => handleDrop(e, "shard")}
        onclick={() => openFileDialog("shard")}
        onkeydown={(e) => e.key === "Enter" && openFileDialog("shard")}
        role="button"
        tabindex="0"
      >
        <div class="upload-content">
          <div class="upload-icon">πŸ—‚οΈ</div>
          <h4>Drop Shard file here</h4>
          <p>or click to browse</p>
          <span class="format-tag shard-tag">SHARD</span>
        </div>
      </div>
    </div>
  </div>

  <input
    bind:this={xorbFileInput}
    type="file"
    onchange={(e) => handleFileInput(e, "xorb")}
    style="display: none;"
  />

  <input
    bind:this={shardFileInput}
    type="file"
    onchange={(e) => handleFileInput(e, "shard")}
    style="display: none;"
  />
</div>

<style>
  .upload-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
  }

  .upload-areas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
  }

  .upload-section {
    text-align: center;
  }

  .upload-section h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
  }

  .upload-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .xorb-area:hover {
    border-color: #28a745;
    background: #f0fff4;
  }

  .xorb-area.drag-active {
    border-color: #28a745;
    background: #e8f5e8;
    transform: scale(1.02);
  }

  .shard-area:hover {
    border-color: #007bff;
    background: #f0f8ff;
  }

  .shard-area.drag-active {
    border-color: #007bff;
    background: #e3f2fd;
    transform: scale(1.02);
  }

  .upload-content {
    pointer-events: none;
  }

  .upload-icon {
    font-size: 36px;
    margin-bottom: 12px;
  }

  .upload-area h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-weight: 600;
    font-size: 16px;
  }

  .upload-area p {
    margin: 0 0 16px 0;
    color: #666;
    font-size: 14px;
  }

  .format-tag {
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
  }

  .xorb-tag {
    background: #28a745;
  }

  .shard-tag {
    background: #007bff;
  }

  @media (max-width: 768px) {
    .upload-areas {
      grid-template-columns: 1fr;
      gap: 20px;
    }

    .upload-area {
      padding: 20px 15px;
      min-height: 150px;
    }

    .upload-icon {
      font-size: 28px;
    }
  }
</style>