@widgetic/file-browser 0.5.35 → 0.5.37
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.
- package/README.md +1 -0
- package/dist/components/FolderTree.svelte +46 -97
- package/dist/components/FolderTree.svelte.d.ts +5 -1
- package/dist/components/core/Dropzone.svelte +127 -0
- package/dist/components/core/Dropzone.svelte.d.ts +15 -0
- package/dist/components/core/FileBrowser.css +11 -79
- package/dist/components/core/FileBrowser.svelte +277 -149
- package/dist/components/core/FileBrowser.svelte.d.ts +0 -1
- package/dist/components/core/FileUploader.svelte +204 -418
- package/dist/components/core/FileUploader.svelte.d.ts +1 -0
- package/dist/components/core/Header.svelte +51 -68
- package/dist/components/core/Header.svelte.d.ts +1 -0
- package/dist/components/core/RecentFiles.svelte +135 -562
- package/dist/components/core/RecentFiles.svelte.d.ts +2 -4
- package/dist/components/core/UploadPanel.svelte +169 -0
- package/dist/components/core/UploadPanel.svelte.d.ts +40 -0
- package/dist/components/core/UploadRow.svelte +90 -0
- package/dist/components/core/UploadRow.svelte.d.ts +21 -0
- package/dist/components/core/UploadStatus.svelte +34 -128
- package/dist/components/core/UploadStatus.svelte.d.ts +0 -1
- package/dist/components/core/UploadStatusList.svelte +61 -77
- package/dist/components/items/FileItem.svelte +190 -532
- package/dist/components/items/FileItem.svelte.d.ts +1 -1
- package/dist/components/items/FolderItem.svelte +46 -36
- package/dist/components/items/FolderItem.svelte.d.ts +1 -1
- package/dist/components/modals/MoveDialog.svelte +142 -281
- package/dist/components/modals/NewFolderButton.svelte +13 -14
- package/dist/components/modals/SearchModal.svelte +112 -264
- package/dist/components/modals/SearchModal.svelte.d.ts +0 -1
- package/dist/components/modals/SelectedFilesModal.svelte +91 -167
- package/dist/components/previews/AudioPlayer.svelte +75 -58
- package/dist/components/previews/ErrorPreview.svelte +9 -6
- package/dist/components/previews/FilePreview.svelte +173 -53
- package/dist/components/previews/FontPreview.svelte +37 -54
- package/dist/components/previews/ImagePreview.svelte +9 -2
- package/dist/components/previews/ImagePreview.svelte.d.ts +1 -0
- package/dist/components/previews/PreviewHeaderBar.svelte +70 -0
- package/dist/components/previews/PreviewHeaderBar.svelte.d.ts +32 -0
- package/dist/components/previews/TextPreview.svelte +32 -40
- package/dist/components/previews/VideoPlayer.svelte +124 -149
- package/dist/components/previews/WaveformVisualizer.svelte +42 -222
- package/dist/components/previews/WaveformVisualizer.svelte.d.ts +1 -1
- package/dist/components/ui/ControlToolbar.svelte +113 -288
- package/dist/components/ui/ControlToolbar.svelte.d.ts +2 -3
- package/dist/components/ui/DragSelect.svelte +41 -248
- package/dist/components/ui/DropdownMenu.svelte +56 -55
- package/dist/components/ui/DropdownMenu.svelte.d.ts +1 -1
- package/dist/components/ui/FileIcon.svelte +168 -51
- package/dist/components/ui/FileIcon.svelte.d.ts +13 -20
- package/dist/components/ui/FileMetadata.svelte +20 -9
- package/dist/components/ui/LoadingSkeleton.svelte +5 -20
- package/dist/components/ui/SearchResults.svelte +50 -26
- package/dist/components/ui/SearchResults.svelte.d.ts +4 -0
- package/dist/components/ui/SelectedBadge.svelte +25 -0
- package/dist/components/ui/SelectedBadge.svelte.d.ts +9 -0
- package/dist/components/ui/TileSkeleton.svelte +15 -0
- package/dist/components/ui/TileSkeleton.svelte.d.ts +18 -0
- package/dist/components/ui/VirtualList.svelte +3 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/i18n/messages.d.ts +38 -25
- package/dist/i18n/messages.js +39 -26
- package/dist/utils/gridLayout.d.ts +2 -0
- package/dist/utils/gridLayout.js +10 -0
- package/package.json +3 -4
|
@@ -1,46 +1,39 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
// Svelte imports
|
|
3
2
|
import { onMount } from 'svelte';
|
|
4
|
-
|
|
5
|
-
// Imports from Design System
|
|
6
3
|
import { WScrollArea } from '@widgetic/design-system/components';
|
|
4
|
+
import { IconLoader2 } from '@widgetic/design-system/icons';
|
|
7
5
|
import { useI18n } from '../../i18n';
|
|
8
6
|
|
|
9
7
|
const { t } = useI18n();
|
|
10
8
|
|
|
11
9
|
export let src: string;
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
const scrolledAreaMaxHeight = 600;
|
|
11
|
+
const scrolledAreaMaxHeight = 360;
|
|
15
12
|
|
|
16
|
-
let content
|
|
13
|
+
let content = '';
|
|
17
14
|
let isLoading = true;
|
|
18
|
-
/** True when the file could not be read. */
|
|
19
15
|
let loadFailed = false;
|
|
20
|
-
/** The server's own words for why (its status text, "Not Found"), when it gave any. */
|
|
21
16
|
let failureReason = '';
|
|
22
|
-
let formattedContent
|
|
23
|
-
let contentElement: HTMLPreElement;
|
|
24
|
-
let contentHeight = 0;
|
|
17
|
+
let formattedContent = '';
|
|
25
18
|
|
|
26
19
|
function formatContent(text: string, fileType: string): string {
|
|
27
20
|
try {
|
|
28
|
-
switch(fileType.toLowerCase()) {
|
|
21
|
+
switch (fileType.toLowerCase()) {
|
|
29
22
|
case 'json':
|
|
30
23
|
return JSON.stringify(JSON.parse(text), null, 2);
|
|
31
24
|
case 'xml':
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
return text
|
|
26
|
+
.replace(/></g, '>\n<')
|
|
27
|
+
.replace(/(<[^>]+>)/g, '\n$1\n')
|
|
28
|
+
.split('\n')
|
|
29
|
+
.filter((line) => line.trim())
|
|
30
|
+
.join('\n');
|
|
38
31
|
case 'csv':
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
return text
|
|
33
|
+
.split('\n')
|
|
34
|
+
.map((line) => line.trim())
|
|
35
|
+
.filter((line) => line)
|
|
36
|
+
.join('\n');
|
|
44
37
|
default:
|
|
45
38
|
return text;
|
|
46
39
|
}
|
|
@@ -58,15 +51,8 @@
|
|
|
58
51
|
throw new Error(`Failed to load text file: ${response.statusText}`);
|
|
59
52
|
}
|
|
60
53
|
content = await response.text();
|
|
61
|
-
|
|
62
|
-
// Get file extension
|
|
63
54
|
const fileType = src.split('.').pop() || '';
|
|
64
55
|
formattedContent = formatContent(content, fileType);
|
|
65
|
-
|
|
66
|
-
// After content is loaded, check its height
|
|
67
|
-
if (contentElement) {
|
|
68
|
-
contentHeight = contentElement.scrollHeight;
|
|
69
|
-
}
|
|
70
56
|
} catch (err) {
|
|
71
57
|
loadFailed = true;
|
|
72
58
|
console.error('Error loading text file:', err);
|
|
@@ -76,18 +62,24 @@
|
|
|
76
62
|
});
|
|
77
63
|
</script>
|
|
78
64
|
|
|
79
|
-
<div class="text-preview-container w-full
|
|
65
|
+
<div class="text-preview-container w-full" style="max-height: {scrolledAreaMaxHeight}px">
|
|
80
66
|
{#if isLoading}
|
|
81
|
-
<div class="
|
|
67
|
+
<div class="flex min-h-[16rem] items-center justify-center gap-3 text-caption text-muted-foreground">
|
|
68
|
+
<IconLoader2 class="size-5 animate-spin stroke-[1.333] motion-reduce:animate-none" />
|
|
69
|
+
{$t('preview.loading')}
|
|
70
|
+
</div>
|
|
82
71
|
{:else if loadFailed}
|
|
83
|
-
<div class="text-[
|
|
72
|
+
<div class="text-body text-destructive min-h-[16rem] p-4">
|
|
73
|
+
{failureReason ? $t('preview.textFailedReason', { reason: failureReason }) : $t('preview.textFailed')}
|
|
74
|
+
</div>
|
|
84
75
|
{:else}
|
|
85
|
-
<WScrollArea
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
76
|
+
<WScrollArea
|
|
77
|
+
class="text-pre-scroll-area h-[22.5rem] w-full"
|
|
78
|
+
viewPortClass="rounded-lg bg-muted"
|
|
79
|
+
scrollOutside={true}
|
|
80
|
+
type="always"
|
|
81
|
+
>
|
|
82
|
+
<pre class="text-pre-container text-code w-full whitespace-pre-wrap break-words p-4 text-foreground">{formattedContent}</pre>
|
|
91
83
|
</WScrollArea>
|
|
92
84
|
{/if}
|
|
93
85
|
</div>
|
|
@@ -96,4 +88,4 @@
|
|
|
96
88
|
pre {
|
|
97
89
|
margin: 0;
|
|
98
90
|
}
|
|
99
|
-
</style>
|
|
91
|
+
</style>
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
|
|
3
|
-
|
|
3
|
+
import { IconButton } from '@widgetic/design-system/components';
|
|
4
|
+
import {
|
|
5
|
+
IconLoader2,
|
|
6
|
+
IconPlayerPause,
|
|
7
|
+
IconPlayerPlay,
|
|
8
|
+
IconVolume,
|
|
9
|
+
IconVolumeOff
|
|
10
|
+
} from '@widgetic/design-system/icons';
|
|
4
11
|
import ErrorPreview from './ErrorPreview.svelte';
|
|
5
12
|
import { useI18n } from '../../i18n';
|
|
6
13
|
|
|
14
|
+
const dispatch = createEventDispatcher();
|
|
7
15
|
const { t } = useI18n();
|
|
8
16
|
|
|
9
17
|
export let src: string;
|
|
10
18
|
export let autoplay = false;
|
|
11
19
|
export let mediaElement: HTMLVideoElement | undefined = undefined;
|
|
12
|
-
// The picture box, in pixels. The modal sizes itself from this content, so a percentage height collapses to nothing.
|
|
13
20
|
export let frameWidth = 0;
|
|
14
21
|
export let frameHeight = 0;
|
|
15
22
|
|
|
@@ -18,26 +25,20 @@
|
|
|
18
25
|
let isPlaying = autoplay;
|
|
19
26
|
let currentTime = 0;
|
|
20
27
|
let duration = 0;
|
|
21
|
-
let volume = 1;
|
|
22
28
|
let isMuted = false;
|
|
23
29
|
let showControls = true;
|
|
24
30
|
let controlsTimeout: ReturnType<typeof setTimeout>;
|
|
25
31
|
let progressBarContainer: HTMLDivElement;
|
|
26
32
|
let isDragging = false;
|
|
33
|
+
|
|
27
34
|
function togglePlay() {
|
|
28
35
|
if (!mediaElement) return;
|
|
29
|
-
|
|
30
36
|
if (mediaElement.paused) {
|
|
31
|
-
mediaElement.play()
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
.catch(err => {
|
|
36
|
-
console.error("Error playing video:", err);
|
|
37
|
-
});
|
|
37
|
+
mediaElement.play().catch((err) => {
|
|
38
|
+
console.error('Error playing video:', err);
|
|
39
|
+
});
|
|
38
40
|
} else {
|
|
39
41
|
mediaElement.pause();
|
|
40
|
-
isPlaying = false;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -48,8 +49,7 @@
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
function formatTime(seconds: number): string {
|
|
51
|
-
if (isNaN(seconds) || !isFinite(seconds)) return
|
|
52
|
-
|
|
52
|
+
if (isNaN(seconds) || !isFinite(seconds)) return '0:00';
|
|
53
53
|
const minutes = Math.floor(seconds / 60);
|
|
54
54
|
const remainingSeconds = Math.floor(seconds % 60);
|
|
55
55
|
return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`;
|
|
@@ -65,13 +65,8 @@
|
|
|
65
65
|
duration = mediaElement.duration;
|
|
66
66
|
isLoading = false;
|
|
67
67
|
dispatch('metadata', { width: mediaElement.videoWidth, height: mediaElement.videoHeight });
|
|
68
|
-
|
|
69
68
|
if (autoplay) {
|
|
70
69
|
isPlaying = !mediaElement.paused;
|
|
71
|
-
|
|
72
|
-
if (!isPlaying) {
|
|
73
|
-
// console.log('Autoplay was blocked by the browser');
|
|
74
|
-
}
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
72
|
|
|
@@ -81,11 +76,9 @@
|
|
|
81
76
|
|
|
82
77
|
function handleProgressClick(event: MouseEvent) {
|
|
83
78
|
if (!mediaElement || !progressBarContainer) return;
|
|
84
|
-
|
|
85
79
|
const rect = progressBarContainer.getBoundingClientRect();
|
|
86
80
|
const clickPosition = (event.clientX - rect.left) / rect.width;
|
|
87
81
|
const newTime = clickPosition * duration;
|
|
88
|
-
|
|
89
82
|
if (isFinite(newTime) && newTime >= 0 && newTime <= duration) {
|
|
90
83
|
mediaElement.currentTime = newTime;
|
|
91
84
|
}
|
|
@@ -94,7 +87,6 @@
|
|
|
94
87
|
function startDragging(event: MouseEvent) {
|
|
95
88
|
isDragging = true;
|
|
96
89
|
handleProgressClick(event);
|
|
97
|
-
|
|
98
90
|
event.preventDefault();
|
|
99
91
|
}
|
|
100
92
|
|
|
@@ -103,31 +95,17 @@
|
|
|
103
95
|
}
|
|
104
96
|
|
|
105
97
|
function handleDrag(event: MouseEvent) {
|
|
106
|
-
if (isDragging)
|
|
107
|
-
handleProgressClick(event);
|
|
108
|
-
}
|
|
98
|
+
if (isDragging) handleProgressClick(event);
|
|
109
99
|
}
|
|
110
100
|
|
|
111
101
|
function handleMouseMove() {
|
|
112
102
|
showControls = true;
|
|
113
103
|
clearTimeout(controlsTimeout);
|
|
114
|
-
|
|
115
104
|
controlsTimeout = setTimeout(() => {
|
|
116
|
-
if (isPlaying)
|
|
117
|
-
showControls = false;
|
|
118
|
-
}
|
|
105
|
+
if (isPlaying) showControls = false;
|
|
119
106
|
}, 3000);
|
|
120
107
|
}
|
|
121
108
|
|
|
122
|
-
function handleKeydown(event: KeyboardEvent) {
|
|
123
|
-
// if (!mediaElement) return;
|
|
124
|
-
|
|
125
|
-
// if (event.code === 'Space' && document.activeElement !== mediaElement) {
|
|
126
|
-
// event.preventDefault();
|
|
127
|
-
// togglePlay();
|
|
128
|
-
// }
|
|
129
|
-
}
|
|
130
|
-
|
|
131
109
|
function handleError() {
|
|
132
110
|
hasError = true;
|
|
133
111
|
isLoading = false;
|
|
@@ -142,12 +120,9 @@
|
|
|
142
120
|
}
|
|
143
121
|
|
|
144
122
|
onMount(() => {
|
|
145
|
-
window.addEventListener('keydown', handleKeydown);
|
|
146
123
|
window.addEventListener('mouseup', stopDragging);
|
|
147
124
|
window.addEventListener('mousemove', handleDrag);
|
|
148
|
-
|
|
149
125
|
return () => {
|
|
150
|
-
window.removeEventListener('keydown', handleKeydown);
|
|
151
126
|
window.removeEventListener('mouseup', stopDragging);
|
|
152
127
|
window.removeEventListener('mousemove', handleDrag);
|
|
153
128
|
};
|
|
@@ -156,129 +131,129 @@
|
|
|
156
131
|
onDestroy(() => {
|
|
157
132
|
clearTimeout(controlsTimeout);
|
|
158
133
|
});
|
|
134
|
+
|
|
135
|
+
$: progressPercent = duration > 0 ? (currentTime / duration) * 100 : 0;
|
|
159
136
|
</script>
|
|
160
137
|
|
|
161
138
|
{#if hasError}
|
|
162
139
|
<ErrorPreview message={$t('preview.videoFailed')} />
|
|
163
140
|
{:else}
|
|
164
|
-
<!-- svelte-ignore
|
|
141
|
+
<!-- svelte-ignore a11y_media_has_caption -->
|
|
165
142
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
166
|
-
<div
|
|
167
|
-
class="video-preview-container relative flex w-full items-center justify-center overflow-hidden
|
|
143
|
+
<div
|
|
144
|
+
class="video-preview-container relative flex w-full items-center justify-center overflow-hidden"
|
|
168
145
|
onmousemove={handleMouseMove}
|
|
169
|
-
onmouseenter={() => showControls = true}
|
|
146
|
+
onmouseenter={() => (showControls = true)}
|
|
170
147
|
>
|
|
148
|
+
<!-- Until the size of the video is known the frame is the loading holder (Figma "Preview Dialog / Loading": 160px tall, spinner and text) -->
|
|
171
149
|
<div
|
|
172
|
-
class="video-preview-frame relative max-w-full overflow-hidden rounded-
|
|
150
|
+
class="video-preview-frame relative max-w-full overflow-hidden rounded-xl {isLoading ? '' : 'bg-muted'}"
|
|
173
151
|
style={frameWidth > 0 && frameHeight > 0
|
|
174
152
|
? `width: ${frameWidth}px; height: ${frameHeight}px;`
|
|
175
|
-
:
|
|
153
|
+
: isLoading
|
|
154
|
+
? 'width: 100%; height: 10rem;'
|
|
155
|
+
: 'width: 68px; height: 68px;'}
|
|
176
156
|
>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
>
|
|
190
|
-
<track kind="captions" />
|
|
191
|
-
{$t('preview.videoUnsupported')}
|
|
192
|
-
</video>
|
|
193
|
-
|
|
194
|
-
<!-- Custom video controls -->
|
|
195
|
-
<div
|
|
196
|
-
class="custom-video-controls absolute bottom-0 inset-x-0 flex flex-col transition-opacity duration-300 bg-gradient-to-t from-black/60 to-transparent p-2"
|
|
197
|
-
class:opacity-0={!showControls && isPlaying}
|
|
198
|
-
class:pointer-events-none={!showControls && isPlaying}
|
|
199
|
-
>
|
|
200
|
-
<!-- Progress bar -->
|
|
201
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
202
|
-
<div
|
|
203
|
-
dir="ltr"
|
|
204
|
-
class="relative h-1 w-full bg-white/30 mb-3 cursor-pointer rounded-full"
|
|
205
|
-
bind:this={progressBarContainer}
|
|
206
|
-
onmousedown={startDragging}
|
|
207
|
-
onclick={handleProgressClick}
|
|
157
|
+
<video
|
|
158
|
+
{src}
|
|
159
|
+
bind:this={mediaElement}
|
|
160
|
+
{autoplay}
|
|
161
|
+
class="video-preview-media h-full w-full object-contain {isLoading ? 'opacity-0' : ''}"
|
|
162
|
+
onerror={handleError}
|
|
163
|
+
onended={handleVideoEnded}
|
|
164
|
+
ontimeupdate={handleTimeUpdate}
|
|
165
|
+
onloadedmetadata={handleMetadataLoaded}
|
|
166
|
+
onclick={togglePlay}
|
|
167
|
+
onplay={handlePlay}
|
|
168
|
+
onpause={handlePause}
|
|
208
169
|
>
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
<!-- Left side controls -->
|
|
218
|
-
<div class="flex items-center space-x-4">
|
|
219
|
-
<!-- Play/Pause button -->
|
|
220
|
-
<button
|
|
221
|
-
onclick={togglePlay}
|
|
222
|
-
class="flex items-center justify-center w-8 h-8 text-white focus:outline-none"
|
|
223
|
-
aria-label={isPlaying ? $t('action.pause') : $t('action.play')}
|
|
224
|
-
>
|
|
225
|
-
{#if isPlaying}
|
|
226
|
-
<!-- Pause icon -->
|
|
227
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
|
|
228
|
-
<path fill-rule="evenodd" d="M6.75 5.25a.75.75 0 01.75-.75H9a.75.75 0 01.75.75v13.5a.75.75 0 01-.75.75H7.5a.75.75 0 01-.75-.75V5.25zm7.5 0A.75.75 0 0115 4.5h1.5a.75.75 0 01.75.75v13.5a.75.75 0 01-.75.75H15a.75.75 0 01-.75-.75V5.25z" clip-rule="evenodd" />
|
|
229
|
-
</svg>
|
|
230
|
-
{:else}
|
|
231
|
-
<!-- Play icon -->
|
|
232
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
|
|
233
|
-
<path fill-rule="evenodd" d="M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z" clip-rule="evenodd" />
|
|
234
|
-
</svg>
|
|
235
|
-
{/if}
|
|
236
|
-
</button>
|
|
237
|
-
|
|
238
|
-
<!-- Time display -->
|
|
239
|
-
<div class="text-white text-sm">
|
|
240
|
-
{formatTime(currentTime)} / {formatTime(duration)}
|
|
241
|
-
</div>
|
|
170
|
+
<track kind="captions" />
|
|
171
|
+
{$t('preview.videoUnsupported')}
|
|
172
|
+
</video>
|
|
173
|
+
|
|
174
|
+
{#if isLoading}
|
|
175
|
+
<div class="video-preview-loader absolute inset-0 flex flex-col items-center justify-center gap-3">
|
|
176
|
+
<IconLoader2 class="size-8 animate-spin stroke-[1.333] text-primary motion-reduce:animate-none" />
|
|
177
|
+
<p class="text-caption text-muted-foreground">{$t('preview.loading')}</p>
|
|
242
178
|
</div>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
179
|
+
{/if}
|
|
180
|
+
|
|
181
|
+
<!-- Figma Video Controls 277:1499 -->
|
|
182
|
+
<div
|
|
183
|
+
class="custom-video-controls absolute inset-x-0 bottom-0 flex h-12 items-center gap-3 px-4 transition-opacity duration-base {!isLoading && (showControls || !isPlaying)
|
|
184
|
+
? 'opacity-100'
|
|
185
|
+
: 'opacity-0 pointer-events-none'}"
|
|
186
|
+
>
|
|
187
|
+
<div
|
|
188
|
+
class="pointer-events-none absolute inset-0 bg-foreground/60"
|
|
189
|
+
aria-hidden="true"
|
|
190
|
+
></div>
|
|
191
|
+
|
|
192
|
+
<IconButton
|
|
193
|
+
variant="ghost"
|
|
194
|
+
class="relative z-[1] text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground"
|
|
195
|
+
label={isPlaying ? $t('action.pause') : $t('action.play')}
|
|
196
|
+
onclick={togglePlay}
|
|
197
|
+
>
|
|
198
|
+
{#if isPlaying}
|
|
199
|
+
<IconPlayerPause class="size-4 stroke-[1.333]" />
|
|
200
|
+
{:else}
|
|
201
|
+
<IconPlayerPlay class="size-4 stroke-[1.333]" />
|
|
202
|
+
{/if}
|
|
203
|
+
</IconButton>
|
|
204
|
+
|
|
205
|
+
<span class="text-caption-medium relative z-[1] text-primary-foreground tabular-nums">
|
|
206
|
+
{formatTime(currentTime)}
|
|
207
|
+
</span>
|
|
208
|
+
|
|
209
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
210
|
+
<div
|
|
211
|
+
dir="ltr"
|
|
212
|
+
tabindex="0"
|
|
213
|
+
class="relative z-[1] h-1 min-w-0 flex-1 cursor-pointer overflow-hidden rounded-full bg-primary-foreground/30"
|
|
214
|
+
bind:this={progressBarContainer}
|
|
215
|
+
onmousedown={startDragging}
|
|
216
|
+
onclick={handleProgressClick}
|
|
217
|
+
role="slider"
|
|
218
|
+
aria-valuemin={0}
|
|
219
|
+
aria-valuemax={duration}
|
|
220
|
+
aria-valuenow={currentTime}
|
|
221
|
+
aria-label={$t('preview.videoProgress')}
|
|
222
|
+
>
|
|
223
|
+
<div
|
|
224
|
+
class="absolute inset-y-0 start-0 rounded-full bg-primary-foreground"
|
|
225
|
+
style="width: {progressPercent}%"
|
|
226
|
+
></div>
|
|
265
227
|
</div>
|
|
228
|
+
|
|
229
|
+
<span class="text-caption-medium relative z-[1] text-primary-foreground tabular-nums">
|
|
230
|
+
{formatTime(duration)}
|
|
231
|
+
</span>
|
|
232
|
+
|
|
233
|
+
<IconButton
|
|
234
|
+
variant="ghost"
|
|
235
|
+
class="relative z-[1] text-primary-foreground hover:bg-primary-foreground/10 hover:text-primary-foreground"
|
|
236
|
+
label={isMuted ? $t('action.unmute') : $t('action.mute')}
|
|
237
|
+
onclick={toggleMute}
|
|
238
|
+
>
|
|
239
|
+
{#if isMuted}
|
|
240
|
+
<IconVolumeOff class="size-4 stroke-[1.333]" />
|
|
241
|
+
{:else}
|
|
242
|
+
<IconVolume class="size-4 stroke-[1.333]" />
|
|
243
|
+
{/if}
|
|
244
|
+
</IconButton>
|
|
266
245
|
</div>
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
<path fill-rule="evenodd" d="M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z" clip-rule="evenodd" />
|
|
279
|
-
</svg>
|
|
280
|
-
</button>
|
|
281
|
-
{/if}
|
|
246
|
+
|
|
247
|
+
{#if !isPlaying && showControls && !isLoading}
|
|
248
|
+
<button
|
|
249
|
+
type="button"
|
|
250
|
+
onclick={togglePlay}
|
|
251
|
+
class="absolute start-1/2 top-1/2 flex size-16 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-foreground/40 text-primary-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
252
|
+
aria-label={$t('action.play')}
|
|
253
|
+
>
|
|
254
|
+
<IconPlayerPlay class="size-10 stroke-[1.667]" />
|
|
255
|
+
</button>
|
|
256
|
+
{/if}
|
|
282
257
|
</div>
|
|
283
258
|
</div>
|
|
284
|
-
{/if}
|
|
259
|
+
{/if}
|