@widgetic/file-browser 0.5.34 → 0.5.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +1 -0
  2. package/dist/components/FolderTree.svelte +46 -97
  3. package/dist/components/FolderTree.svelte.d.ts +7 -7
  4. package/dist/components/core/Dropzone.svelte +127 -0
  5. package/dist/components/core/Dropzone.svelte.d.ts +15 -0
  6. package/dist/components/core/FileBrowser.css +11 -79
  7. package/dist/components/core/FileBrowser.svelte +278 -150
  8. package/dist/components/core/FileBrowser.svelte.d.ts +0 -1
  9. package/dist/components/core/FileUploader.svelte +204 -418
  10. package/dist/components/core/FileUploader.svelte.d.ts +1 -0
  11. package/dist/components/core/Header.svelte +49 -58
  12. package/dist/components/core/Header.svelte.d.ts +1 -0
  13. package/dist/components/core/RecentFiles.svelte +135 -562
  14. package/dist/components/core/RecentFiles.svelte.d.ts +2 -4
  15. package/dist/components/core/UploadPanel.svelte +169 -0
  16. package/dist/components/core/UploadPanel.svelte.d.ts +40 -0
  17. package/dist/components/core/UploadRow.svelte +90 -0
  18. package/dist/components/core/UploadRow.svelte.d.ts +21 -0
  19. package/dist/components/core/UploadStatus.svelte +34 -128
  20. package/dist/components/core/UploadStatus.svelte.d.ts +0 -1
  21. package/dist/components/core/UploadStatusList.svelte +61 -77
  22. package/dist/components/items/FileItem.svelte +190 -532
  23. package/dist/components/items/FileItem.svelte.d.ts +1 -1
  24. package/dist/components/items/FolderItem.svelte +46 -36
  25. package/dist/components/items/FolderItem.svelte.d.ts +1 -1
  26. package/dist/components/modals/MoveDialog.svelte +142 -281
  27. package/dist/components/modals/NewFolderButton.svelte +13 -14
  28. package/dist/components/modals/SearchModal.svelte +112 -264
  29. package/dist/components/modals/SearchModal.svelte.d.ts +0 -1
  30. package/dist/components/modals/SelectedFilesModal.svelte +91 -167
  31. package/dist/components/previews/AudioPlayer.svelte +75 -58
  32. package/dist/components/previews/ErrorPreview.svelte +9 -6
  33. package/dist/components/previews/FilePreview.svelte +182 -53
  34. package/dist/components/previews/FontPreview.svelte +37 -54
  35. package/dist/components/previews/ImagePreview.svelte +9 -2
  36. package/dist/components/previews/ImagePreview.svelte.d.ts +1 -0
  37. package/dist/components/previews/PreviewHeaderBar.svelte +70 -0
  38. package/dist/components/previews/PreviewHeaderBar.svelte.d.ts +32 -0
  39. package/dist/components/previews/TextPreview.svelte +32 -40
  40. package/dist/components/previews/VideoPlayer.svelte +124 -149
  41. package/dist/components/previews/WaveformVisualizer.svelte +42 -222
  42. package/dist/components/previews/WaveformVisualizer.svelte.d.ts +1 -1
  43. package/dist/components/ui/ControlToolbar.svelte +113 -288
  44. package/dist/components/ui/ControlToolbar.svelte.d.ts +2 -3
  45. package/dist/components/ui/DragSelect.svelte +41 -248
  46. package/dist/components/ui/DropdownMenu.svelte +56 -55
  47. package/dist/components/ui/DropdownMenu.svelte.d.ts +1 -1
  48. package/dist/components/ui/FileIcon.svelte +168 -51
  49. package/dist/components/ui/FileIcon.svelte.d.ts +13 -20
  50. package/dist/components/ui/FileMetadata.svelte +20 -9
  51. package/dist/components/ui/LoadingSkeleton.svelte +5 -20
  52. package/dist/components/ui/SearchResults.svelte +50 -26
  53. package/dist/components/ui/SearchResults.svelte.d.ts +4 -0
  54. package/dist/components/ui/SelectedBadge.svelte +25 -0
  55. package/dist/components/ui/SelectedBadge.svelte.d.ts +9 -0
  56. package/dist/components/ui/TileSkeleton.svelte +15 -0
  57. package/dist/components/ui/TileSkeleton.svelte.d.ts +18 -0
  58. package/dist/components/ui/VirtualList.svelte +3 -0
  59. package/dist/components/ui/index.d.ts +1 -0
  60. package/dist/components/ui/index.js +1 -0
  61. package/dist/i18n/messages.d.ts +40 -27
  62. package/dist/i18n/messages.js +41 -28
  63. package/dist/stores/fileStore.d.ts +2 -2
  64. package/dist/stores/navigationStore.d.ts +1 -1
  65. package/dist/stores/persistentSelectStore.d.ts +1 -1
  66. package/dist/utils/gridLayout.d.ts +2 -0
  67. package/dist/utils/gridLayout.js +10 -0
  68. package/package.json +3 -4
@@ -4,18 +4,17 @@
4
4
  const dispatch = createEventDispatcher();
5
5
 
6
6
  // Design system imports
7
- import { Button, toast, BaseModal, WScrollArea, EmptyState } from '@widgetic/design-system/components';
8
- import { IconCornerUpRight, IconCircleMinus, IconTrash } from '@widgetic/design-system/icons';
7
+ import { Button, toast, BaseModal, WScrollArea, EmptyState, IconButton } from '@widgetic/design-system/components';
8
+ import { IconCornerUpRight, IconCircleMinus } from '@widgetic/design-system/icons';
9
9
 
10
10
  // Local utils imports
11
11
  import type { FileSystemItem } from '../../types';
12
12
 
13
13
  // Local components imports
14
- import { FileItem } from '../items';
14
+ import { FileIcon } from '../ui';
15
15
 
16
16
  // Local stores imports
17
17
  import { fileStore, currentFolder } from '../../stores/fileStore';
18
- import { missingFiles } from '../../stores/missingFilesStore';
19
18
  import { persistentSelectStore, validSelections } from '../../stores/persistentSelectStore';
20
19
 
21
20
  // Local utils imports
@@ -24,7 +23,6 @@
24
23
  import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
25
24
 
26
25
  const { t } = useI18n();
27
- // The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
28
26
  const textDirection = useTextDirection();
29
27
  $: nameDirection = dirForUserText($textDirection);
30
28
 
@@ -35,14 +33,9 @@
35
33
  /** The words of the button that sends the files on. Left out, the File Browser's own ("Add to Editor", or the page's language's). */
36
34
  export let addToEditorLabel: string | undefined = undefined;
37
35
  export let target: string = 'selected-files-modal'; // target for Portal
38
-
39
- // Consts
40
- const scrolledAreaMaxHeight = 420;
41
36
 
42
- // Local vars
43
- let buttonsContainerHeight = 0;
37
+ const listScrollHeightPx = 348;
44
38
 
45
- // Get selected files from persistentSelectStore
46
39
  $: selectedFiles = $validSelections(currentFilter, allFiles);
47
40
  $: currentPath = $currentFolder;
48
41
  $: allowedTypes = getAllowedFileTypes(currentFilter);
@@ -57,21 +50,18 @@
57
50
  }
58
51
 
59
52
  function handleSend() {
60
- // Get the selected files with their paths
61
- const selectedFilesWithPaths = selectedFiles.map(file => {
53
+ const selectedFilesWithPaths = selectedFiles.map((file) => {
62
54
  const idPath = findItemPath($fileStore.root, file);
63
55
  return {
64
56
  id: file.id,
65
- path: idPath ? idPath.slice(1) : [] // Remove root ID from path
57
+ path: idPath ? idPath.slice(1) : []
66
58
  };
67
59
  });
68
60
 
69
- // Show sonar toast instead of alert
70
61
  toast.success($t('toast.filesAdded'), {
71
62
  description: $t('toast.filesAddedDetail', { count: selectedFiles.length })
72
63
  });
73
64
 
74
- // Clear selections and close modal
75
65
  persistentSelectStore.clearSelections(currentFilter);
76
66
  dispatch('send');
77
67
  open = false;
@@ -90,19 +80,12 @@
90
80
  }
91
81
 
92
82
  function removeFile(fileId: string) {
93
- // Update the persistent store instead of the fileStore
94
83
  persistentSelectStore.toggleSelection(
95
- selectedFiles.find(f => f.id === fileId)!,
84
+ selectedFiles.find((f) => f.id === fileId)!,
96
85
  currentFilter
97
86
  );
98
87
  }
99
88
 
100
- /**
101
- * Finds the path of IDs to a file in the file system
102
- * @param root Root folder to start search from
103
- * @param target Target file to find
104
- * @returns Array of folder IDs or null if not found
105
- */
106
89
  function findItemPath(root: FileSystemItem, target: FileSystemItem): string[] | null {
107
90
  if (root.id === target.id) {
108
91
  return [root.id];
@@ -120,28 +103,17 @@
120
103
  return null;
121
104
  }
122
105
 
123
- /**
124
- * Navigates to the folder containing the file and opens preview
125
- * @param file File to navigate to
126
- */
127
106
  function jumpToFolder(file: FileSystemItem) {
128
107
  const idPath = findItemPath($fileStore.root, file);
129
108
  if (idPath) {
130
- // Remove root ID and file ID from the path
131
- const folderPath = idPath[0] === $fileStore.root.id
132
- ? idPath.slice(1, -1) // Remove root ID and file ID
133
- : idPath.slice(0, -1); // Just remove file ID
134
-
135
- // console.log('Found ID path:', idPath);
136
- // console.log('Folder path to navigate to:', folderPath);
137
-
138
- // Close the modal first
109
+ const folderPath =
110
+ idPath[0] === $fileStore.root.id ? idPath.slice(1, -1) : idPath.slice(0, -1);
111
+
139
112
  dispatch('close');
140
-
141
- // Navigate to folder and preview file
142
- dispatch('navigate', {
113
+
114
+ dispatch('navigate', {
143
115
  path: folderPath,
144
- preview: file // Add the file to preview
116
+ preview: file
145
117
  });
146
118
  } else {
147
119
  console.error('Could not find path for file:', file);
@@ -149,14 +121,14 @@
149
121
  }
150
122
  </script>
151
123
 
152
- <BaseModal
124
+ <BaseModal
153
125
  bind:open
154
- title={$t('selectedFiles.title')}
126
+ title={$t('selectedFiles.title')}
155
127
  closeLabel={$t('dialog.close')}
156
128
  on:close={handleClose}
129
+ class="selected-files-modal"
157
130
  width="566px"
158
131
  height="496px"
159
- titlePadding="small"
160
132
  {target}
161
133
  showScroll={false}
162
134
  modalType="selectedFiles"
@@ -164,137 +136,89 @@
164
136
  on:restore={(event) => {
165
137
  if (event.detail) {
166
138
  currentFilter = event.detail.currentFilter;
167
- // No need to restore selectedFiles as they are managed by the persistentSelectStore
168
139
  }
169
140
  }}
170
141
  >
171
- <div class="selected-files-modal-root-container w-full max-h-[800px] min-h-[200px] flex flex-col gap-2 px-4">
172
-
173
- {#if selectedFiles.length === 0}
174
- <div style="height: {scrolledAreaMaxHeight}px; min-height: 70px;" class="overflow-hidden flex flex-col items-center justify-center">
175
- <EmptyState class="!relative" message={$t('selectedFiles.empty')} />
142
+ <div class="flex min-h-0 w-full flex-col gap-4">
143
+ {#if selectedFiles.length === 0}
144
+ <div
145
+ class="flex flex-col items-center justify-center overflow-hidden"
146
+ style="height: {listScrollHeightPx}px; min-height: 70px;"
147
+ >
148
+ <EmptyState message={$t('selectedFiles.empty')} />
176
149
  </div>
177
- {:else}
178
- <!-- Selected Files Container -->
179
- <WScrollArea class="selected-files-container flex-grow" style="height: {scrolledAreaMaxHeight}px;" scrollOutside={true} type="always">
180
- <div class="file-items-container pe-4">
181
- {#each selectedFiles as file (file.id)}
182
- <div class="selected-file-item relative overflow-hidden rounded-large transition-colors duration-200 hover:bg-[hsl(var(--grey2))]">
183
- <div
184
- class="selected-file-item-row flex items-center justify-between min-h-[70px] cursor-pointer pe-2 focus-visible:ring-0 focus-visible:ring-offset-0"
185
- onclick={() => jumpToFolder(file)}
186
- onkeydown={(e) => e.key === 'Enter' && jumpToFolder(file)}
187
- role="button"
188
- tabindex="0"
189
- >
190
- <div class="flex items-center gap-4 min-w-0 px-2">
191
- <div class="w-[62px] h-[54px] shrink-0 flex items-center justify-center thumbnail-container">
192
- <FileItem
193
- item={file}
194
- selected={false}
195
- allowSelecting={false}
196
- thumbnailOnly={true}
197
- />
198
- </div>
199
- <span dir={nameDirection} class="body-medium truncate {file.isMissing ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{file.name}</span>
200
- </div>
201
-
202
- <div class="selected-file-item-actions flex shrink-0 items-center gap-3 ps-2">
203
- <IconCornerUpRight
204
- class="h-6 w-6 shrink-0 text-[hsl(var(--grey7))] rtl:-scale-x-100"
150
+ {:else}
151
+ <!-- A fixed 348px window onto the list (Figma Selected Files Dialog). shrink-0, not flex-1: in a column that is as
152
+ tall as its content, flex-1 would give the height away. -->
153
+ <WScrollArea
154
+ class="shrink-0"
155
+ style="height: {listScrollHeightPx}px;"
156
+ scrollbarWidth={12}
157
+ type="always"
158
+ >
159
+ <ul class="flex flex-col" role="list">
160
+ {#each selectedFiles as file (file.id)}
161
+ <li
162
+ class="group flex h-12 items-center gap-3 rounded-xl py-2 ps-2 pe-2 transition-colors duration-fast hover:bg-accent"
163
+ >
164
+ <FileIcon
165
+ file={file}
166
+ kind={file.isMissing ? 'missing' : undefined}
167
+ size="sm"
168
+ class="shrink-0"
205
169
  />
206
-
207
- <button
208
- type="button"
209
- class="selected-file-remove-btn inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full hover:bg-[hsl(var(--grey3))] transition-all duration-300"
210
- onclick={(e) => {
211
- e.stopPropagation();
212
- removeFile(file.id);
213
- }}
170
+ <span
171
+ dir={nameDirection}
172
+ class="min-w-0 flex-1 truncate text-body-medium {file.isMissing
173
+ ? 'text-destructive'
174
+ : 'text-foreground'}"
214
175
  >
215
- <IconCircleMinus class="w-6 h-6 text-[hsl(var(--grey7))] hover:text-[hsl(var(--error))]" />
216
- </button>
217
- </div>
218
- </div>
219
- </div>
220
- {/each}
221
- </div>
222
- </WScrollArea>
223
-
224
- {/if}
225
-
226
- <!-- Buttons Container -->
227
- <div class="buttons-container flex items-center justify-between" bind:clientHeight={buttonsContainerHeight}>
228
-
229
- <!-- Results Count -->
230
- <div class="results-count text-[hsl(var(--grey5))] subtext">
231
- {#if selectedFiles.length > 0}
176
+ {file.name}
177
+ </span>
178
+ <div class="flex shrink-0 items-center gap-0">
179
+ <IconButton
180
+ variant="ghost"
181
+ label={$t('searchModal.jumpToFolder')}
182
+ class="size-8"
183
+ onclick={() => jumpToFolder(file)}
184
+ >
185
+ <IconCornerUpRight class="size-4 stroke-[1.333] rtl:rotate-180" />
186
+ </IconButton>
187
+ <IconButton
188
+ variant="ghost"
189
+ label={$t('selectedFiles.remove')}
190
+ class="size-8"
191
+ onclick={() => removeFile(file.id)}
192
+ >
193
+ <IconCircleMinus class="size-4 stroke-[1.333]" />
194
+ </IconButton>
195
+ </div>
196
+ </li>
197
+ {/each}
198
+ </ul>
199
+ </WScrollArea>
200
+ {/if}
201
+
202
+ <div class="flex shrink-0 items-center gap-2">
203
+ <p class="min-w-0 flex-1 truncate text-caption text-muted-foreground">
232
204
  {$t('selectedFiles.count', { count: selectedFiles.length })}
233
- {/if}
234
- </div>
235
-
236
- <div class="actions-buttons-container flex items-center gap-4">
237
- <!-- Cancel Button -->
238
- <Button
239
- type="button"
240
- class="modal-btn-secondary !h-[34px]"
241
- onclick={handleClose}
242
- >
243
- <span>{$t('action.cancel')}</span>
244
- </Button>
245
-
246
- <!-- Add to Editor Button -->
247
- {#if showAddToEditor}
248
- <Button
249
- type="submit"
250
- class="modal-btn-primary !h-[34px]"
251
- onclick={sendToEditor}
252
- disabled={selectedFiles.length === 0}
253
- >
254
- <span>{confirmAddLabel}</span>
205
+ </p>
206
+ <div class="flex shrink-0 items-center gap-2">
207
+ <Button type="button" variant="outline" class="h-9" onclick={handleClose}>
208
+ {$t('action.cancel')}
255
209
  </Button>
256
- {/if}
210
+ {#if showAddToEditor}
211
+ <Button
212
+ type="button"
213
+ variant="default"
214
+ class="h-9"
215
+ onclick={sendToEditor}
216
+ disabled={selectedFiles.length === 0}
217
+ >
218
+ {confirmAddLabel}
219
+ </Button>
220
+ {/if}
221
+ </div>
257
222
  </div>
258
223
  </div>
259
- </div>
260
224
  </BaseModal>
261
-
262
- <style>
263
- /* Ensure smooth transitions */
264
- .selected-file-item {
265
- transition: all 150ms ease;
266
- }
267
-
268
- /* File item hover effect */
269
- .selected-file-item:hover {
270
- background-color: hsl(var(--grey2));
271
- }
272
-
273
- /* Thumbnail container styling */
274
- .thumbnail-container {
275
- position: relative;
276
- }
277
-
278
- /* Make the FileItem have no pointer events so clicks pass through to the parent */
279
- .thumbnail-container :global(*) {
280
- pointer-events: none;
281
- }
282
-
283
- /* Match the exact animation from FileItem.svelte */
284
- .thumbnail-container :global(.thumbnail-button) {
285
- transform: scale(1);
286
- transform-origin: top left;
287
- will-change: transform;
288
- backface-visibility: hidden;
289
- -webkit-font-smoothing: antialiased;
290
- transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1),
291
- opacity 150ms cubic-bezier(0.4, 0, 0.2, 1),
292
- border-radius 150ms cubic-bezier(0.4, 0, 0.2, 1);
293
- }
294
-
295
- /* Apply the same hover animation as in FileItem.svelte */
296
- .selected-file-item:hover .thumbnail-container :global(.thumbnail-button) {
297
- transform: scale(0.81) translate(6px, 6px);
298
- opacity: 0.8;
299
- }
300
- </style>
@@ -1,12 +1,7 @@
1
1
  <script lang="ts">
2
- // Svelte imports
3
2
  import { onMount } from 'svelte';
4
-
5
- // Design system imports
6
- import { Button } from '@widgetic/design-system/components';
3
+ import { IconButton } from '@widgetic/design-system/components';
7
4
  import { IconPlayerPlayFilled, IconPlayerPauseFilled } from '@widgetic/design-system/icons';
8
-
9
- // Local components imports
10
5
  import ErrorPreview from './ErrorPreview.svelte';
11
6
  import WaveformVisualizer from './WaveformVisualizer.svelte';
12
7
  import { useI18n } from '../../i18n';
@@ -20,31 +15,36 @@
20
15
  let isPlaying = false;
21
16
  let hasError = false;
22
17
  let isLoading = true;
18
+ let currentTime = 0;
19
+ let duration = 0;
23
20
 
24
- onMount(() => {
25
- if (mediaElement && autoplay) {
26
- mediaElement.play().catch(error => {
27
- // console.log('Autoplay prevented:', error);
28
- });
29
- }
30
- setTimeout(() => {
31
- isLoading = false;
32
- }, 100);
33
- });
21
+ function formatTime(seconds: number): string {
22
+ if (!Number.isFinite(seconds) || seconds < 0) return '0:00';
23
+ const minutes = Math.floor(seconds / 60);
24
+ const remainingSeconds = Math.floor(seconds % 60);
25
+ return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`;
26
+ }
34
27
 
35
- function togglePlay() {
36
- if (isPlaying) {
37
- mediaElement?.pause();
28
+ function togglePlay(event?: Event) {
29
+ event?.stopPropagation();
30
+ if (!mediaElement) return;
31
+ if (mediaElement.paused) {
32
+ mediaElement.play().catch((error) => {
33
+ console.error('Error playing audio:', error);
34
+ });
38
35
  } else {
39
- mediaElement?.play();
36
+ mediaElement.pause();
40
37
  }
41
38
  }
42
39
 
43
- function handleKeydown(event: KeyboardEvent) {
44
- // if (event.code === 'Space' && document.activeElement !== mediaElement) {
45
- // event.preventDefault();
46
- // togglePlay();
47
- // }
40
+ function handleSeek(event: MouseEvent) {
41
+ if (!mediaElement) return;
42
+ const target = event.currentTarget as HTMLElement;
43
+ const rect = target.getBoundingClientRect();
44
+ const ratio = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));
45
+ if (mediaElement.duration) {
46
+ mediaElement.currentTime = ratio * mediaElement.duration;
47
+ }
48
48
  }
49
49
 
50
50
  function handleError() {
@@ -60,61 +60,78 @@
60
60
  isPlaying = false;
61
61
  }
62
62
 
63
+ function handleTimeUpdate() {
64
+ if (!mediaElement) return;
65
+ currentTime = mediaElement.currentTime;
66
+ duration = mediaElement.duration || duration;
67
+ }
68
+
69
+ function handleLoadedMetadata() {
70
+ if (!mediaElement) return;
71
+ duration = mediaElement.duration || 0;
72
+ isLoading = false;
73
+ }
74
+
63
75
  onMount(() => {
64
- window.addEventListener('keydown', handleKeydown);
65
- return () => {
66
- window.removeEventListener('keydown', handleKeydown);
67
- };
76
+ if (mediaElement && autoplay) {
77
+ mediaElement.play().catch(() => {});
78
+ }
79
+ setTimeout(() => {
80
+ isLoading = false;
81
+ }, 100);
68
82
  });
69
83
  </script>
70
84
 
71
85
  {#if hasError}
72
86
  <ErrorPreview message={$t('preview.audioFailed')} />
73
87
  {:else}
74
- <!-- svelte-ignore a11y-click-events-have-key-events -->
75
- <!-- svelte-ignore a11y-no-static-element-interactions -->
76
- <div
77
- class="audio-preview-container w-full px-4 aspect-[410/160] relative overflow-hidden group widgetic-colors"
78
- onclick={togglePlay}
79
- >
80
- <!-- Audio visualization -->
81
- <div class="audio-visualizer-container w-full h-full bg-[hsl(var(--grey1))] rounded-large overflow-hidden">
88
+ <div class="audio-preview-container flex w-full flex-col items-center gap-4 px-0">
89
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
90
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
91
+ <div
92
+ class="audio-wave-hit w-full max-w-[22.625rem] cursor-pointer"
93
+ onclick={handleSeek}
94
+ role="presentation"
95
+ >
82
96
  {#if mediaElement}
83
97
  <WaveformVisualizer {mediaElement} />
84
98
  {/if}
85
99
  </div>
86
100
 
87
- <!-- Play/Pause button overlay -->
88
- {#if !isLoading}
89
- <div class="audio-play-pause-container absolute inset-x-4 inset-y-0 flex items-center justify-center rounded-large">
90
- <div
91
- class="cursor-pointer group/button {isPlaying ? 'opacity-0 group-hover:opacity-100' : ''} transition-opacity duration-200"
101
+ <div class="flex w-full max-w-[22.625rem] items-center justify-between gap-3">
102
+ <span class="text-caption-medium text-foreground tabular-nums">{formatTime(currentTime)}</span>
103
+
104
+ {#if !isLoading}
105
+ <IconButton
106
+ variant="primary"
107
+ class="press-feedback size-12 rounded-full"
108
+ label={isPlaying ? $t('action.pause') : $t('action.play')}
109
+ onclick={togglePlay}
92
110
  >
93
111
  {#if isPlaying}
94
- <IconPlayerPauseFilled
95
- class="w-20 h-20 text-[hsl(var(--grey7))] group-hover/button:text-[hsl(var(--deep-forest-green))] transition-colors duration-200"
96
- />
112
+ <IconPlayerPauseFilled class="size-5" />
97
113
  {:else}
98
- <IconPlayerPlayFilled
99
- class="w-20 h-20 text-[hsl(var(--grey7))] group-hover/button:text-[hsl(var(--deep-forest-green))] transition-colors duration-200"
100
- />
114
+ <IconPlayerPlayFilled class="size-5" />
101
115
  {/if}
102
- </div>
103
- </div>
104
- {/if}
105
-
106
- <!-- Hidden audio element -->
107
- <audio
108
- bind:this={mediaElement}
109
- {src}
116
+ </IconButton>
117
+ {/if}
118
+
119
+ <span class="text-caption-medium text-foreground tabular-nums">{formatTime(duration)}</span>
120
+ </div>
121
+
122
+ <audio
123
+ bind:this={mediaElement}
124
+ {src}
110
125
  {autoplay}
111
126
  crossorigin="anonymous"
112
- class="hidden"
127
+ class="hidden"
113
128
  onerror={handleError}
114
129
  onplay={handlePlay}
115
130
  onpause={handlePause}
131
+ ontimeupdate={handleTimeUpdate}
132
+ onloadedmetadata={handleLoadedMetadata}
116
133
  >
117
134
  {$t('preview.audioUnsupported')}
118
135
  </audio>
119
136
  </div>
120
- {/if}
137
+ {/if}
@@ -1,15 +1,18 @@
1
1
  <script lang="ts">
2
+ // Design system imports
3
+ import { EmptyState } from '@widgetic/design-system/components';
4
+ import { IconAlertTriangle } from '@widgetic/design-system/icons';
5
+
2
6
  // Local utils imports
3
- import { getAssetUrl } from '../../utils/fileUtils';
4
7
  import { useI18n } from '../../i18n';
5
8
 
6
9
  const { t } = useI18n();
7
10
 
8
- // Component props: the sentence under the icon. Left out, "File not found" (in the page's language).
11
+ // Component props: the title of the state. Left out, "File not found" (in the page's language).
9
12
  export let message: string | undefined = undefined;
10
13
  </script>
11
14
 
12
- <div class="error-preview-container flex flex-col items-center justify-center h-[60vh] space-y-4">
13
- <img src={getAssetUrl('/icons/error.svg')} alt={$t('preview.errorAlt')} class="w-16 h-16" />
14
- <p class="text-gray-600">{message ?? $t('preview.fileNotFound')}</p>
15
- </div>
15
+ <!-- Figma "Preview Dialog / Error": a holder 160px tall with the state (icon tile and title) centred in it -->
16
+ <div class="error-preview-container flex h-40 w-full items-center justify-center">
17
+ <EmptyState message={message ?? $t('preview.fileNotFound')} icon={IconAlertTriangle} showActions={false} height="auto" />
18
+ </div>