FileItem.svelte 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <script lang="ts">
  2. import { createEventDispatcher, getContext } from 'svelte';
  3. const i18n = getContext('i18n');
  4. const dispatch = createEventDispatcher();
  5. export let className = 'w-72';
  6. export let url: string | null = null;
  7. export let dismissible = false;
  8. export let status = 'processed';
  9. export let name: string;
  10. export let type: string;
  11. </script>
  12. <div class="relative group">
  13. <button
  14. class="h-14 {className} flex items-center space-x-3 bg-white dark:bg-gray-800 rounded-xl border border-gray-100 dark:border-gray-800 text-left"
  15. type="button"
  16. on:click={async () => {
  17. if (url) {
  18. if (type === 'file') {
  19. window.open(`${url}/content`, '_blank').focus();
  20. } else {
  21. window.open(`${url}`, '_blank').focus();
  22. }
  23. }
  24. }}
  25. >
  26. <div class="p-4 py-[1.1rem] bg-red-400 text-white rounded-l-xl">
  27. {#if status === 'processed'}
  28. <svg
  29. xmlns="http://www.w3.org/2000/svg"
  30. viewBox="0 0 24 24"
  31. fill="currentColor"
  32. class=" size-5"
  33. >
  34. <path
  35. fill-rule="evenodd"
  36. d="M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z"
  37. clip-rule="evenodd"
  38. />
  39. <path
  40. d="M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"
  41. />
  42. </svg>
  43. {:else}
  44. <svg
  45. class=" size-5 translate-y-[0.5px]"
  46. fill="currentColor"
  47. viewBox="0 0 24 24"
  48. xmlns="http://www.w3.org/2000/svg"
  49. ><style>
  50. .spinner_qM83 {
  51. animation: spinner_8HQG 1.05s infinite;
  52. }
  53. .spinner_oXPr {
  54. animation-delay: 0.1s;
  55. }
  56. .spinner_ZTLf {
  57. animation-delay: 0.2s;
  58. }
  59. @keyframes spinner_8HQG {
  60. 0%,
  61. 57.14% {
  62. animation-timing-function: cubic-bezier(0.33, 0.66, 0.66, 1);
  63. transform: translate(0);
  64. }
  65. 28.57% {
  66. animation-timing-function: cubic-bezier(0.33, 0, 0.66, 0.33);
  67. transform: translateY(-6px);
  68. }
  69. 100% {
  70. transform: translate(0);
  71. }
  72. }
  73. </style><circle class="spinner_qM83" cx="4" cy="12" r="2.5" /><circle
  74. class="spinner_qM83 spinner_oXPr"
  75. cx="12"
  76. cy="12"
  77. r="2.5"
  78. /><circle class="spinner_qM83 spinner_ZTLf" cx="20" cy="12" r="2.5" /></svg
  79. >
  80. {/if}
  81. </div>
  82. <div class="flex flex-col justify-center -space-y-0.5 pl-1.5 pr-4 w-full">
  83. <div class=" dark:text-gray-100 text-sm font-medium line-clamp-1">
  84. {name}
  85. </div>
  86. <div class=" text-gray-500 text-xs">
  87. {#if type === 'file'}
  88. {$i18n.t('File')}
  89. {:else if type === 'doc'}
  90. {$i18n.t('Document')}
  91. {:else if type === 'collection'}
  92. {$i18n.t('Collection')}
  93. {:else}
  94. <span class=" capitalize">{type}</span>
  95. {/if}
  96. </div>
  97. </div>
  98. </button>
  99. {#if dismissible}
  100. <div class=" absolute -top-1 -right-1">
  101. <button
  102. class=" bg-gray-400 text-white border border-white rounded-full group-hover:visible invisible transition"
  103. type="button"
  104. on:click={() => {
  105. dispatch('dismiss');
  106. }}
  107. >
  108. <svg
  109. xmlns="http://www.w3.org/2000/svg"
  110. viewBox="0 0 20 20"
  111. fill="currentColor"
  112. class="w-4 h-4"
  113. >
  114. <path
  115. d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
  116. />
  117. </svg>
  118. </button>
  119. </div>
  120. {/if}
  121. </div>