|
1 | 1 | <script lang="ts"> |
2 | 2 | import { _ } from 'svelte-i18n' |
3 | 3 | import { onMount } from 'svelte' |
4 | | - import Dropzone from 'dropzone' |
5 | | - import 'dropzone/dist/dropzone.css' |
| 4 | + import Dropzone from '@deltablot/dropzone' |
| 5 | + import '@deltablot/dropzone/dist/dropzone.css' |
6 | 6 | import BasketDrawing from '$lib/assets/images/basket_no_plane.svg' |
7 | | - import UploadedFileTemplate from '$lib/components/filesharing/inputs/UploadedFileTemplate.svelte' |
| 7 | + import closeIcon from '$lib/assets/images/google-icons/close.svg' |
8 | 8 | import Chip from '$lib/components/Chip.svelte' |
9 | 9 | import { EncryptionState } from '$lib/types/filesharing/attributes' |
10 | 10 |
|
|
37 | 37 | let remainingSize = $derived(MAX_UPLOAD_SIZE - totalSize) |
38 | 38 | let remainingSizeGB = $derived((remainingSize / (1024 * 1024 * 1024)).toFixed(2)) |
39 | 39 |
|
| 40 | + const previewTemplate = ` |
| 41 | + <div class="dz-preview dz-file-preview files"> |
| 42 | + <div> |
| 43 | + <div><p class="file-title" data-dz-name></p></div> |
| 44 | + </div> |
| 45 | + <div> |
| 46 | + <p data-dz-size></p> |
| 47 | + <button class="remove-button" data-dz-remove type="button"> |
| 48 | + <img class="invert" src="${closeIcon}" alt="remove button" /> |
| 49 | + </button> |
| 50 | + <div class="dz-error-message"><span data-dz-errormessage></span></div> |
| 51 | + </div> |
| 52 | + </div>` |
| 53 | +
|
40 | 54 | // handle all the Dropzone setup in onMount to ensure it only runs in the browser |
41 | 55 | onMount(() => { |
42 | | - // @ts-ignore, it's always set if UploadedFileTemplate is set because it's SSR'd |
43 | | - let previewTemplate = document.querySelector('#template-container').innerHTML |
44 | | -
|
45 | 56 | myDropzone = new Dropzone('#my-form', { |
46 | 57 | url: '#', // Dummy URL, can't be empty |
47 | 58 | autoProcessQueue: false, // Prevent automatic upload |
|
83 | 94 | class:dropzone-with-files={files.length > 0} |
84 | 95 | class:hidden={stage === EncryptionState.Done || stage === EncryptionState.Error} |
85 | 96 | > |
86 | | - <!-- so dropzone can get the template but its invisible --> |
87 | | - <div class="hidden" id="template-container"> |
88 | | - <UploadedFileTemplate /> |
89 | | - </div> |
90 | 97 | <div class="dz-message"> |
91 | 98 | <h1 class="file-tagline"> |
92 | 99 | {$_('filesharing.encryptPanel.fileBox.tagline')} |
|
343 | 350 | display: none !important; |
344 | 351 | } |
345 | 352 |
|
| 353 | + /* Override Dropzone's default .dz-preview styles */ |
| 354 | + .dz-previews :global(.dz-preview) { |
| 355 | + display: block; |
| 356 | + margin: 0; |
| 357 | + min-height: 0; |
| 358 | + position: relative; |
| 359 | + } |
| 360 | +
|
| 361 | + /* Preview template styles (injected by Dropzone, so must be :global) */ |
| 362 | + .dz-previews :global(.files) { |
| 363 | + display: flex; |
| 364 | + flex-direction: row; |
| 365 | + align-items: center; |
| 366 | + justify-content: space-between; |
| 367 | + gap: 0.5rem; |
| 368 | + width: 100%; |
| 369 | + margin-bottom: 0; |
| 370 | + padding: 8px 0; |
| 371 | + border-bottom: 2px solid var(--pg-input-normal-light); |
| 372 | + } |
| 373 | +
|
| 374 | + .dz-previews :global(.files > div:first-child) { |
| 375 | + display: flex; |
| 376 | + align-items: center; |
| 377 | + gap: 0.5rem; |
| 378 | + flex: 1; |
| 379 | + min-width: 0; |
| 380 | + } |
| 381 | +
|
| 382 | + .dz-previews :global(.files > div:first-child > div) { |
| 383 | + min-width: 0; |
| 384 | + flex: 1; |
| 385 | + } |
| 386 | +
|
| 387 | + .dz-previews :global(.files > div:last-child) { |
| 388 | + display: flex; |
| 389 | + align-items: center; |
| 390 | + gap: 0.5rem; |
| 391 | + flex-shrink: 0; |
| 392 | + } |
| 393 | +
|
| 394 | + .dz-previews :global(.file-title) { |
| 395 | + overflow: hidden; |
| 396 | + white-space: nowrap; |
| 397 | + font-family: var(--pg-font-family); |
| 398 | + font-weight: var(--pg-font-weight-regular); |
| 399 | + margin: 0; |
| 400 | + color: var(--pg-text); |
| 401 | + min-width: 0; |
| 402 | + font-size: var(--pg-font-size-sm); |
| 403 | + direction: rtl; |
| 404 | + text-align: left; |
| 405 | + text-overflow: ellipsis; |
| 406 | + } |
| 407 | +
|
| 408 | + .dz-previews :global(.files > div:last-child p) { |
| 409 | + font-family: var(--pg-font-family); |
| 410 | + font-weight: var(--pg-font-weight-regular); |
| 411 | + margin: 0; |
| 412 | + color: var(--pg-text-secondary); |
| 413 | + font-size: var(--pg-font-size-sm); |
| 414 | + } |
| 415 | +
|
| 416 | + .dz-previews :global(.remove-button) { |
| 417 | + cursor: pointer; |
| 418 | + height: 100%; |
| 419 | + padding: 4px 0 4px 4px; |
| 420 | + border-radius: var(--pg-border-radius-md); |
| 421 | + transition: all 0.2s ease; |
| 422 | + display: flex; |
| 423 | + align-items: center; |
| 424 | + justify-content: center; |
| 425 | + pointer-events: auto; |
| 426 | + } |
| 427 | +
|
| 428 | + .dz-previews :global(.remove-button:hover) { |
| 429 | + background-color: var(--pg-soft-background); |
| 430 | + } |
| 431 | +
|
| 432 | + .dz-previews :global(.remove-button *) { |
| 433 | + cursor: pointer; |
| 434 | + } |
| 435 | +
|
| 436 | + .dz-previews :global(.remove-button img) { |
| 437 | + width: 18px; |
| 438 | + height: 18px; |
| 439 | + } |
| 440 | +
|
| 441 | + .dz-previews :global(.dz-error-message) { |
| 442 | + display: none; |
| 443 | + } |
| 444 | +
|
| 445 | + .dz-previews :global(.dz-error .dz-error-message) { |
| 446 | + display: block; |
| 447 | + } |
| 448 | +
|
346 | 449 | .add-more-chip-container { |
347 | 450 | display: flex; |
348 | 451 | justify-content: center; |
|
0 commit comments