@widgetic/file-browser 0.5.17
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 +131 -0
- package/dist/components/FolderTree.svelte +143 -0
- package/dist/components/FolderTree.svelte.d.ts +32 -0
- package/dist/components/core/FileBrowser.css +79 -0
- package/dist/components/core/FileBrowser.svelte +3989 -0
- package/dist/components/core/FileBrowser.svelte.d.ts +55 -0
- package/dist/components/core/FileUploader.svelte +1152 -0
- package/dist/components/core/FileUploader.svelte.d.ts +43 -0
- package/dist/components/core/Header.svelte +143 -0
- package/dist/components/core/Header.svelte.d.ts +36 -0
- package/dist/components/core/RecentFiles.svelte +753 -0
- package/dist/components/core/RecentFiles.svelte.d.ts +37 -0
- package/dist/components/core/UploadStatus.svelte +133 -0
- package/dist/components/core/UploadStatus.svelte.d.ts +28 -0
- package/dist/components/core/UploadStatusList.svelte +138 -0
- package/dist/components/core/UploadStatusList.svelte.d.ts +33 -0
- package/dist/components/core/index.d.ts +4 -0
- package/dist/components/core/index.js +4 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +8 -0
- package/dist/components/items/FileItem.svelte +684 -0
- package/dist/components/items/FileItem.svelte.d.ts +34 -0
- package/dist/components/items/FolderItem.svelte +77 -0
- package/dist/components/items/FolderItem.svelte.d.ts +27 -0
- package/dist/components/items/index.d.ts +2 -0
- package/dist/components/items/index.js +2 -0
- package/dist/components/modals/MoveDialog.svelte +539 -0
- package/dist/components/modals/MoveDialog.svelte.d.ts +32 -0
- package/dist/components/modals/NewFolderButton.svelte +25 -0
- package/dist/components/modals/NewFolderButton.svelte.d.ts +20 -0
- package/dist/components/modals/README.md +99 -0
- package/dist/components/modals/SearchModal.svelte +500 -0
- package/dist/components/modals/SearchModal.svelte.d.ts +28 -0
- package/dist/components/modals/SelectedFilesModal.svelte +291 -0
- package/dist/components/modals/SelectedFilesModal.svelte.d.ts +32 -0
- package/dist/components/modals/index.d.ts +6 -0
- package/dist/components/modals/index.js +9 -0
- package/dist/components/previews/AudioPlayer.svelte +117 -0
- package/dist/components/previews/AudioPlayer.svelte.d.ts +22 -0
- package/dist/components/previews/ErrorPreview.svelte +12 -0
- package/dist/components/previews/ErrorPreview.svelte.d.ts +20 -0
- package/dist/components/previews/FilePreview.svelte +475 -0
- package/dist/components/previews/FilePreview.svelte.d.ts +31 -0
- package/dist/components/previews/FontPreview.svelte +82 -0
- package/dist/components/previews/FontPreview.svelte.d.ts +22 -0
- package/dist/components/previews/ImagePreview.svelte +551 -0
- package/dist/components/previews/ImagePreview.svelte.d.ts +27 -0
- package/dist/components/previews/TextPreview.svelte +92 -0
- package/dist/components/previews/TextPreview.svelte.d.ts +20 -0
- package/dist/components/previews/VideoPlayer.svelte +268 -0
- package/dist/components/previews/VideoPlayer.svelte.d.ts +22 -0
- package/dist/components/previews/WaveformVisualizer.svelte +240 -0
- package/dist/components/previews/WaveformVisualizer.svelte.d.ts +20 -0
- package/dist/components/previews/index.d.ts +8 -0
- package/dist/components/previews/index.js +8 -0
- package/dist/components/ui/ControlToolbar.svelte +342 -0
- package/dist/components/ui/ControlToolbar.svelte.d.ts +36 -0
- package/dist/components/ui/DragSelect.svelte +815 -0
- package/dist/components/ui/DragSelect.svelte.d.ts +31 -0
- package/dist/components/ui/DropdownMenu.svelte +83 -0
- package/dist/components/ui/DropdownMenu.svelte.d.ts +25 -0
- package/dist/components/ui/FileIcon.svelte +65 -0
- package/dist/components/ui/FileIcon.svelte.d.ts +25 -0
- package/dist/components/ui/FileMetadata.svelte +26 -0
- package/dist/components/ui/FileMetadata.svelte.d.ts +21 -0
- package/dist/components/ui/LoadingSkeleton.svelte +26 -0
- package/dist/components/ui/LoadingSkeleton.svelte.d.ts +22 -0
- package/dist/components/ui/SearchResults.svelte +37 -0
- package/dist/components/ui/SearchResults.svelte.d.ts +21 -0
- package/dist/components/ui/VirtualList.svelte +106 -0
- package/dist/components/ui/VirtualList.svelte.d.ts +45 -0
- package/dist/components/ui/index.d.ts +8 -0
- package/dist/components/ui/index.js +8 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.js +14 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +11 -0
- package/dist/static/favicon.png +0 -0
- package/dist/static/files/audio/audio-file.mp3 +0 -0
- package/dist/static/files/document/-missing-file.txt +1 -0
- package/dist/static/files/document/HeliosDesign Website Project Brief Sample.pdf +0 -0
- package/dist/static/files/document/RFP-NEC_Website-Development_2021-August.pdf +0 -0
- package/dist/static/files/document/The World Before Calculus.pdf +0 -0
- package/dist/static/files/document/specs.txt +15 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Bold.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-BoldItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Book.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-BookItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Heavy.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-HeavyItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Light.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-LightItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Medium.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-MediumItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Semibold.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-SemiboldItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Thin.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-ThinItalic.otf +0 -0
- package/dist/static/files/font/Kimpo/Kimpo-Bold.otf +0 -0
- package/dist/static/files/font/Kimpo/Kimpo-Regular.otf +0 -0
- package/dist/static/files/image/image 1.jpg +0 -0
- package/dist/static/files/image/image 10.jpg +0 -0
- package/dist/static/files/image/image 11.jpg +0 -0
- package/dist/static/files/image/image 12.jpg +0 -0
- package/dist/static/files/image/image 13.jpg +0 -0
- package/dist/static/files/image/image 14.jpg +0 -0
- package/dist/static/files/image/image 15.jpg +0 -0
- package/dist/static/files/image/image 16.jpg +0 -0
- package/dist/static/files/image/image 17.jpg +0 -0
- package/dist/static/files/image/image 18.jpg +0 -0
- package/dist/static/files/image/image 19.jpg +0 -0
- package/dist/static/files/image/image 2.jpg +0 -0
- package/dist/static/files/image/image 20.jpg +0 -0
- package/dist/static/files/image/image 21.jpg +0 -0
- package/dist/static/files/image/image 22.jpg +0 -0
- package/dist/static/files/image/image 23.jpg +0 -0
- package/dist/static/files/image/image 24.jpg +0 -0
- package/dist/static/files/image/image 25.jpg +0 -0
- package/dist/static/files/image/image 26.jpg +0 -0
- package/dist/static/files/image/image 27.jpg +0 -0
- package/dist/static/files/image/image 28.jpg +0 -0
- package/dist/static/files/image/image 29.jpg +0 -0
- package/dist/static/files/image/image 3.jpg +0 -0
- package/dist/static/files/image/image 30.jpg +0 -0
- package/dist/static/files/image/image 31.jpg +0 -0
- package/dist/static/files/image/image 32.jpg +0 -0
- package/dist/static/files/image/image 33.jpg +0 -0
- package/dist/static/files/image/image 34.jpg +0 -0
- package/dist/static/files/image/image 35.jpg +0 -0
- package/dist/static/files/image/image 36.jpg +0 -0
- package/dist/static/files/image/image 37.jpg +0 -0
- package/dist/static/files/image/image 38.jpg +0 -0
- package/dist/static/files/image/image 39.jpg +0 -0
- package/dist/static/files/image/image 4.jpg +0 -0
- package/dist/static/files/image/image 40.jpg +0 -0
- package/dist/static/files/image/image 41.jpg +0 -0
- package/dist/static/files/image/image 42.jpg +0 -0
- package/dist/static/files/image/image 43.jpg +0 -0
- package/dist/static/files/image/image 44.jpg +0 -0
- package/dist/static/files/image/image 45.jpg +0 -0
- package/dist/static/files/image/image 46.jpg +0 -0
- package/dist/static/files/image/image 47.jpg +0 -0
- package/dist/static/files/image/image 48.jpg +0 -0
- package/dist/static/files/image/image 49.jpg +0 -0
- package/dist/static/files/image/image 5.jpg +0 -0
- package/dist/static/files/image/image 50.jpg +0 -0
- package/dist/static/files/image/image 51.jpg +0 -0
- package/dist/static/files/image/image 52.jpg +0 -0
- package/dist/static/files/image/image 53.jpg +0 -0
- package/dist/static/files/image/image 54.jpg +0 -0
- package/dist/static/files/image/image 55.jpg +0 -0
- package/dist/static/files/image/image 56.jpg +0 -0
- package/dist/static/files/image/image 57.jpg +0 -0
- package/dist/static/files/image/image 58.jpg +0 -0
- package/dist/static/files/image/image 59.jpg +0 -0
- package/dist/static/files/image/image 6.jpg +0 -0
- package/dist/static/files/image/image 60.jpg +0 -0
- package/dist/static/files/image/image 61.jpg +0 -0
- package/dist/static/files/image/image 62.jpg +0 -0
- package/dist/static/files/image/image 63.jpg +0 -0
- package/dist/static/files/image/image 64.jpg +0 -0
- package/dist/static/files/image/image 65.jpg +0 -0
- package/dist/static/files/image/image 66.jpg +0 -0
- package/dist/static/files/image/image 67.jpg +0 -0
- package/dist/static/files/image/image 68.jpg +0 -0
- package/dist/static/files/image/image 7.jpg +0 -0
- package/dist/static/files/image/image 8.jpg +0 -0
- package/dist/static/files/image/image 9.jpg +0 -0
- package/dist/static/files/svg/astronaut.svg +30 -0
- package/dist/static/files/svg/cook.svg +30 -0
- package/dist/static/files/svg/dj.svg +28 -0
- package/dist/static/files/svg/doctor.svg +29 -0
- package/dist/static/files/svg/farmer.svg +43 -0
- package/dist/static/files/svg/fire fighter.svg +40 -0
- package/dist/static/files/svg/plumber.svg +32 -0
- package/dist/static/files/svg/santa.svg +34 -0
- package/dist/static/files/svg/scientist.svg +31 -0
- package/dist/static/files/svg/student.svg +32 -0
- package/dist/static/files/thumbnail/image 1.jpg +0 -0
- package/dist/static/files/thumbnail/image 10.jpg +0 -0
- package/dist/static/files/thumbnail/image 11.jpg +0 -0
- package/dist/static/files/thumbnail/image 12.jpg +0 -0
- package/dist/static/files/thumbnail/image 13.jpg +0 -0
- package/dist/static/files/thumbnail/image 14.jpg +0 -0
- package/dist/static/files/thumbnail/image 15.jpg +0 -0
- package/dist/static/files/thumbnail/image 16.jpg +0 -0
- package/dist/static/files/thumbnail/image 17.jpg +0 -0
- package/dist/static/files/thumbnail/image 18.jpg +0 -0
- package/dist/static/files/thumbnail/image 19.jpg +0 -0
- package/dist/static/files/thumbnail/image 2.jpg +0 -0
- package/dist/static/files/thumbnail/image 20.jpg +0 -0
- package/dist/static/files/thumbnail/image 21.jpg +0 -0
- package/dist/static/files/thumbnail/image 22.jpg +0 -0
- package/dist/static/files/thumbnail/image 23.jpg +0 -0
- package/dist/static/files/thumbnail/image 24.jpg +0 -0
- package/dist/static/files/thumbnail/image 25.jpg +0 -0
- package/dist/static/files/thumbnail/image 26.jpg +0 -0
- package/dist/static/files/thumbnail/image 27.jpg +0 -0
- package/dist/static/files/thumbnail/image 28.jpg +0 -0
- package/dist/static/files/thumbnail/image 29.jpg +0 -0
- package/dist/static/files/thumbnail/image 3.jpg +0 -0
- package/dist/static/files/thumbnail/image 30.jpg +0 -0
- package/dist/static/files/thumbnail/image 31.jpg +0 -0
- package/dist/static/files/thumbnail/image 32.jpg +0 -0
- package/dist/static/files/thumbnail/image 33.jpg +0 -0
- package/dist/static/files/thumbnail/image 34.jpg +0 -0
- package/dist/static/files/thumbnail/image 35.jpg +0 -0
- package/dist/static/files/thumbnail/image 36.jpg +0 -0
- package/dist/static/files/thumbnail/image 37.jpg +0 -0
- package/dist/static/files/thumbnail/image 38.jpg +0 -0
- package/dist/static/files/thumbnail/image 39.jpg +0 -0
- package/dist/static/files/thumbnail/image 4.jpg +0 -0
- package/dist/static/files/thumbnail/image 40.jpg +0 -0
- package/dist/static/files/thumbnail/image 41.jpg +0 -0
- package/dist/static/files/thumbnail/image 42.jpg +0 -0
- package/dist/static/files/thumbnail/image 43.jpg +0 -0
- package/dist/static/files/thumbnail/image 44.jpg +0 -0
- package/dist/static/files/thumbnail/image 45.jpg +0 -0
- package/dist/static/files/thumbnail/image 46.jpg +0 -0
- package/dist/static/files/thumbnail/image 47.jpg +0 -0
- package/dist/static/files/thumbnail/image 48.jpg +0 -0
- package/dist/static/files/thumbnail/image 49.jpg +0 -0
- package/dist/static/files/thumbnail/image 5.jpg +0 -0
- package/dist/static/files/thumbnail/image 50.jpg +0 -0
- package/dist/static/files/thumbnail/image 51.jpg +0 -0
- package/dist/static/files/thumbnail/image 52.jpg +0 -0
- package/dist/static/files/thumbnail/image 53.jpg +0 -0
- package/dist/static/files/thumbnail/image 54.jpg +0 -0
- package/dist/static/files/thumbnail/image 55.jpg +0 -0
- package/dist/static/files/thumbnail/image 56.jpg +0 -0
- package/dist/static/files/thumbnail/image 57.jpg +0 -0
- package/dist/static/files/thumbnail/image 58.jpg +0 -0
- package/dist/static/files/thumbnail/image 59.jpg +0 -0
- package/dist/static/files/thumbnail/image 6.jpg +0 -0
- package/dist/static/files/thumbnail/image 60.jpg +0 -0
- package/dist/static/files/thumbnail/image 61.jpg +0 -0
- package/dist/static/files/thumbnail/image 62.jpg +0 -0
- package/dist/static/files/thumbnail/image 63.jpg +0 -0
- package/dist/static/files/thumbnail/image 64.jpg +0 -0
- package/dist/static/files/thumbnail/image 65.jpg +0 -0
- package/dist/static/files/thumbnail/image 66.jpg +0 -0
- package/dist/static/files/thumbnail/image 67.jpg +0 -0
- package/dist/static/files/thumbnail/image 68.jpg +0 -0
- package/dist/static/files/thumbnail/image 7.jpg +0 -0
- package/dist/static/files/thumbnail/image 8.jpg +0 -0
- package/dist/static/files/thumbnail/image 9.jpg +0 -0
- package/dist/static/files/video/video-file.mp4 +0 -0
- package/dist/static/files/video/video-file.png +0 -0
- package/dist/static/icons/audio.svg +7 -0
- package/dist/static/icons/check.svg +3 -0
- package/dist/static/icons/checked.svg +4 -0
- package/dist/static/icons/close.svg +11 -0
- package/dist/static/icons/document.svg +11 -0
- package/dist/static/icons/dots.svg +1 -0
- package/dist/static/icons/download.svg +1 -0
- package/dist/static/icons/empty-folder.svg +24 -0
- package/dist/static/icons/error.svg +5 -0
- package/dist/static/icons/file-upload.svg +1 -0
- package/dist/static/icons/folder-plus.svg +1 -0
- package/dist/static/icons/folder.svg +28 -0
- package/dist/static/icons/jump-to-folder.svg +1 -0
- package/dist/static/icons/move.svg +1 -0
- package/dist/static/icons/new-folder.svg +5 -0
- package/dist/static/icons/pdf.svg +6 -0
- package/dist/static/icons/player-pause.svg +1 -0
- package/dist/static/icons/player-play.svg +3 -0
- package/dist/static/icons/plus.svg +1 -0
- package/dist/static/icons/rename.svg +1 -0
- package/dist/static/icons/search.svg +1 -0
- package/dist/static/icons/trash.svg +1 -0
- package/dist/static/icons/unorganized-folder.svg +60 -0
- package/dist/stores/dragStore.d.ts +2 -0
- package/dist/stores/dragStore.js +2 -0
- package/dist/stores/fileStore.d.ts +36 -0
- package/dist/stores/fileStore.js +166 -0
- package/dist/stores/folderCountStore.d.ts +5 -0
- package/dist/stores/folderCountStore.js +49 -0
- package/dist/stores/index.d.ts +7 -0
- package/dist/stores/index.js +8 -0
- package/dist/stores/missingFilesStore.d.ts +3 -0
- package/dist/stores/missingFilesStore.js +14 -0
- package/dist/stores/navigationStore.d.ts +36 -0
- package/dist/stores/navigationStore.js +615 -0
- package/dist/stores/persistentSelectStore.d.ts +17 -0
- package/dist/stores/persistentSelectStore.js +170 -0
- package/dist/stores/searchStore.d.ts +1 -0
- package/dist/stores/searchStore.js +2 -0
- package/dist/stores/uploadApiStore.d.ts +13 -0
- package/dist/stores/uploadApiStore.js +36 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/pdf.d.ts +3 -0
- package/dist/types.d.ts +23 -0
- package/dist/types.js +1 -0
- package/dist/utils/apiConfig.d.ts +9 -0
- package/dist/utils/apiConfig.js +19 -0
- package/dist/utils/dateUtils.d.ts +2 -0
- package/dist/utils/dateUtils.js +38 -0
- package/dist/utils/fileOperations.d.ts +36 -0
- package/dist/utils/fileOperations.js +573 -0
- package/dist/utils/fileTypes.d.ts +17 -0
- package/dist/utils/fileTypes.js +110 -0
- package/dist/utils/fileUtils.d.ts +15 -0
- package/dist/utils/fileUtils.js +112 -0
- package/dist/utils/folderUtils.d.ts +4 -0
- package/dist/utils/folderUtils.js +26 -0
- package/dist/utils/imageTransform.d.ts +22 -0
- package/dist/utils/imageTransform.js +60 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/resolveFileUrl.d.ts +6 -0
- package/dist/utils/resolveFileUrl.js +21 -0
- package/dist/utils/userUploadsStorage.d.ts +27 -0
- package/dist/utils/userUploadsStorage.js +168 -0
- package/dist/utils/widgeticTusUpload.d.ts +18 -0
- package/dist/utils/widgeticTusUpload.js +131 -0
- package/dist/utils/widgeticUpload.d.ts +29 -0
- package/dist/utils/widgeticUpload.js +105 -0
- package/package.json +156 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* FilePreview Component
|
|
4
|
+
* Modal component for previewing different types of files in the browser window size
|
|
5
|
+
* Supports image, video, audio, and PDF file previews with fallback for unsupported types
|
|
6
|
+
*/
|
|
7
|
+
// Svelte imports
|
|
8
|
+
import { onMount } from 'svelte';
|
|
9
|
+
import { createEventDispatcher } from 'svelte';
|
|
10
|
+
const dispatch = createEventDispatcher();
|
|
11
|
+
|
|
12
|
+
// Design System Components imports
|
|
13
|
+
import { BaseModal, PDFViewer } from '@widgetic/design-system/components';
|
|
14
|
+
|
|
15
|
+
// Local Components imports
|
|
16
|
+
import { ImagePreview, VideoPlayer, AudioPlayer, ErrorPreview, FontPreview, TextPreview } from './';
|
|
17
|
+
import { FileMetadata } from '../ui';
|
|
18
|
+
|
|
19
|
+
// Types
|
|
20
|
+
import type { FileSystemItem } from '../../types';
|
|
21
|
+
|
|
22
|
+
// Utils
|
|
23
|
+
import { getFileType } from '../../utils/fileUtils';
|
|
24
|
+
|
|
25
|
+
// Stores
|
|
26
|
+
import { missingFiles } from '../../stores/missingFilesStore';
|
|
27
|
+
import { validSelections } from '../../stores/persistentSelectStore';
|
|
28
|
+
import { type FileFilterType, isPreviewableTextFile } from '../../utils/fileTypes';
|
|
29
|
+
|
|
30
|
+
// Component props
|
|
31
|
+
export let file: FileSystemItem;
|
|
32
|
+
export let open = false;
|
|
33
|
+
export let allowSelecting: boolean = false;
|
|
34
|
+
export let currentFiles: FileSystemItem[] = [];
|
|
35
|
+
export let currentFilter: FileFilterType = 'all';
|
|
36
|
+
export let target: string = 'file-preview-modal'; // target for Portal
|
|
37
|
+
// Update constants for modal spacing to account for all padding
|
|
38
|
+
const MODAL_PADDING = 32; // 16px top + 16px bottom padding
|
|
39
|
+
const TITLE_HEIGHT = 70; // Height of the title bar
|
|
40
|
+
const CONTENT_PADDING = 16; // 16px padding from content div
|
|
41
|
+
const SCROLL_AREA_PADDING = 16; // 16px padding from ScrollArea
|
|
42
|
+
const TOTAL_VERTICAL_SPACE = MODAL_PADDING + TITLE_HEIGHT + CONTENT_PADDING + SCROLL_AREA_PADDING;
|
|
43
|
+
|
|
44
|
+
// STATE VARS
|
|
45
|
+
let showLogs = false;
|
|
46
|
+
|
|
47
|
+
// Function to determine modal dimensions based on file type
|
|
48
|
+
function getModalDimensions(fileType: string) {
|
|
49
|
+
|
|
50
|
+
// Get grid system margins from CSS variables
|
|
51
|
+
const element = document.querySelector('.widgetic-breakpoints');
|
|
52
|
+
let margin = 24; // Default margin
|
|
53
|
+
if (element) {
|
|
54
|
+
const styles = getComputedStyle(element);
|
|
55
|
+
margin = parseInt(styles.getPropertyValue('--app-margin').trim()) || margin;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Calculate maximum available width based on window size and margins
|
|
59
|
+
let maxWidth = window.innerWidth - (2 * margin); // Default max width (margin on each side)
|
|
60
|
+
|
|
61
|
+
// Calculate maximum available height for content
|
|
62
|
+
const maxAvailableHeight = window.innerHeight - TOTAL_VERTICAL_SPACE - 100; // 100px for top/bottom margins
|
|
63
|
+
|
|
64
|
+
// Calculate aspect ratio based dimensions for video
|
|
65
|
+
const calculateVideoDimensions = () => {
|
|
66
|
+
const aspectRatio = 16/9; // Standard video aspect ratio
|
|
67
|
+
let width = Math.min(800, maxWidth);
|
|
68
|
+
let height = width / aspectRatio;
|
|
69
|
+
|
|
70
|
+
// If height is too large, scale down maintaining aspect ratio
|
|
71
|
+
if (height > maxAvailableHeight) {
|
|
72
|
+
height = maxAvailableHeight;
|
|
73
|
+
width = height * aspectRatio;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Add the UI space to the final height
|
|
77
|
+
return {
|
|
78
|
+
width: Math.floor(width),
|
|
79
|
+
height: Math.floor(height + TOTAL_VERTICAL_SPACE)
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Determine modal dimensions based on file type
|
|
84
|
+
switch (fileType) {
|
|
85
|
+
case 'audio':
|
|
86
|
+
return {
|
|
87
|
+
width: '410px',
|
|
88
|
+
height: '234px'
|
|
89
|
+
};
|
|
90
|
+
case 'image': {
|
|
91
|
+
const maxDim = maxWidth;
|
|
92
|
+
const contentHeight = Math.min(maxAvailableHeight, maxDim * 0.75);
|
|
93
|
+
return {
|
|
94
|
+
width: `${maxDim}px`,
|
|
95
|
+
height: `${contentHeight + TOTAL_VERTICAL_SPACE}px`,
|
|
96
|
+
dynamicHeight: true // Flag to indicate this can be resized
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
case 'video': {
|
|
100
|
+
const { width, height } = calculateVideoDimensions();
|
|
101
|
+
return {
|
|
102
|
+
width: `${width}px`,
|
|
103
|
+
height: `${height}px`
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
case 'font':
|
|
107
|
+
return {
|
|
108
|
+
width: '600px',
|
|
109
|
+
height: `${400 + TOTAL_VERTICAL_SPACE}px`
|
|
110
|
+
};
|
|
111
|
+
case 'document': {
|
|
112
|
+
// For PDFs, use larger dimensions similar to images
|
|
113
|
+
if (file.name.toLowerCase().endsWith('.pdf')) {
|
|
114
|
+
const maxDim = maxWidth;
|
|
115
|
+
const contentHeight = Math.min(maxAvailableHeight, maxDim * 0.75);
|
|
116
|
+
return {
|
|
117
|
+
width: `${maxDim}px`,
|
|
118
|
+
height: `${contentHeight + TOTAL_VERTICAL_SPACE}px`,
|
|
119
|
+
dynamicHeight: true
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// For other document types (txt, md, csv, etc.), use smaller dimensions
|
|
123
|
+
return {
|
|
124
|
+
width: `${Math.min(566, maxWidth)}px`,
|
|
125
|
+
height: `${360 + TOTAL_VERTICAL_SPACE}px`
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
case 'svg':
|
|
129
|
+
return {
|
|
130
|
+
width: '566px',
|
|
131
|
+
height: `${360 + TOTAL_VERTICAL_SPACE}px`
|
|
132
|
+
};
|
|
133
|
+
default:
|
|
134
|
+
return {
|
|
135
|
+
width: '410px',
|
|
136
|
+
height: `${260 + TOTAL_VERTICAL_SPACE}px`
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
$: isSelected = allowSelecting && $validSelections(currentFilter, [file]).length > 0;
|
|
142
|
+
$: modalDimensions = getModalDimensions(fileType);
|
|
143
|
+
|
|
144
|
+
$: currentIndex = currentFiles.findIndex((f: FileSystemItem) => f.id === file.id);
|
|
145
|
+
|
|
146
|
+
function findNextAvailableFile(startIndex: number, direction: 'next' | 'prev'): FileSystemItem | null {
|
|
147
|
+
console.log('Finding next available file from index:', startIndex, 'direction:', direction);
|
|
148
|
+
let index = startIndex;
|
|
149
|
+
const totalFiles = currentFiles.length;
|
|
150
|
+
|
|
151
|
+
// Check up to one full cycle through the files
|
|
152
|
+
for (let i = 0; i < totalFiles; i++) {
|
|
153
|
+
if (direction === 'next') {
|
|
154
|
+
index = (index + 1) % totalFiles;
|
|
155
|
+
} else {
|
|
156
|
+
index = index > 0 ? index - 1 : totalFiles - 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const candidateFile = currentFiles[index];
|
|
160
|
+
if(showLogs) console.log('Checking file:', {
|
|
161
|
+
index,
|
|
162
|
+
name: candidateFile.name,
|
|
163
|
+
isMissing: $missingFiles.has(candidateFile.id)
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
if (!$missingFiles.has(candidateFile.id)) {
|
|
167
|
+
if(showLogs) console.log('Found available file:', candidateFile.name);
|
|
168
|
+
return candidateFile;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if(showLogs) console.log('No available files found');
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
176
|
+
if (!open || !allowSelecting) return;
|
|
177
|
+
|
|
178
|
+
if (event.key === 'ArrowLeft') {
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
console.log('Left arrow pressed, current index:', currentIndex);
|
|
181
|
+
const prevFile = findNextAvailableFile(currentIndex, 'prev');
|
|
182
|
+
if (prevFile) {
|
|
183
|
+
console.log('Navigating to previous file:', prevFile.name);
|
|
184
|
+
dispatch('navigate', prevFile);
|
|
185
|
+
}
|
|
186
|
+
} else if (event.key === 'ArrowRight') {
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
console.log('Right arrow pressed, current index:', currentIndex);
|
|
189
|
+
const nextFile = findNextAvailableFile(currentIndex, 'next');
|
|
190
|
+
if (nextFile) {
|
|
191
|
+
console.log('Navigating to next file:', nextFile.name);
|
|
192
|
+
dispatch('navigate', nextFile);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Set open to true after component is mounted
|
|
198
|
+
onMount(() => {
|
|
199
|
+
// Only set open to true if it's not already open (from restored state)
|
|
200
|
+
if (!open) {
|
|
201
|
+
open = true;
|
|
202
|
+
}
|
|
203
|
+
window.addEventListener('keydown', handleKeydown);
|
|
204
|
+
return () => {
|
|
205
|
+
window.removeEventListener('keydown', handleKeydown);
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Closes the preview modal
|
|
211
|
+
* Dispatches close event to parent component
|
|
212
|
+
*/
|
|
213
|
+
function handleClose() {
|
|
214
|
+
// Stop media playback when closing preview
|
|
215
|
+
if (videoElement || audioElement) {
|
|
216
|
+
const mediaElement = videoElement || audioElement;
|
|
217
|
+
if (mediaElement) {
|
|
218
|
+
mediaElement.pause();
|
|
219
|
+
mediaElement.currentTime = 0;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
open = false;
|
|
223
|
+
// Wait for the transition to complete before dispatching close
|
|
224
|
+
setTimeout(() => {
|
|
225
|
+
dispatch('close');
|
|
226
|
+
}, 200);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Declare variables before using them in reactive statements
|
|
230
|
+
let fileType: string;
|
|
231
|
+
let fileUrl: string;
|
|
232
|
+
let hasValidUrl: boolean;
|
|
233
|
+
let fontName: string;
|
|
234
|
+
|
|
235
|
+
// when file changes, update the file type, url, and valid url
|
|
236
|
+
$: {
|
|
237
|
+
if(showLogs) console.log('FilePreview: file changed reactive statement:', file);
|
|
238
|
+
fileType = getFileType(file.url || file.name);
|
|
239
|
+
fileUrl = file.url || '';
|
|
240
|
+
hasValidUrl = !!file.url && fileUrl.length > 0 && !$missingFiles.has(file.id);
|
|
241
|
+
fontName = file.name.replace(/\.[^/.]+$/, '');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let videoElement: HTMLVideoElement;
|
|
245
|
+
let audioElement: HTMLAudioElement;
|
|
246
|
+
let autoplay = true;
|
|
247
|
+
|
|
248
|
+
$: isVideo = fileType === 'video';
|
|
249
|
+
$: isAudio = fileType === 'audio';
|
|
250
|
+
$: isImage = fileType === 'image';
|
|
251
|
+
$: isPDF = fileType === 'document' && file.name.toLowerCase().endsWith('.pdf');
|
|
252
|
+
$: isPreviewableText = fileType === 'document' && isPreviewableTextFile(file.name);
|
|
253
|
+
|
|
254
|
+
// Autoplay when component mounts
|
|
255
|
+
onMount(() => {
|
|
256
|
+
|
|
257
|
+
if(showLogs) console.log('FilePreview: onMount: file:', file);
|
|
258
|
+
|
|
259
|
+
// Autoplay media when component mounts
|
|
260
|
+
if (videoElement || audioElement) {
|
|
261
|
+
const mediaElement = videoElement || audioElement;
|
|
262
|
+
mediaElement.play().catch(error => {
|
|
263
|
+
console.log('Autoplay prevented:', error);
|
|
264
|
+
// Handle cases where autoplay is blocked by browser policy
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Add the checkFileExists function
|
|
270
|
+
async function checkFileExists(url: string | undefined): Promise<boolean> {
|
|
271
|
+
if (!url) return false;
|
|
272
|
+
try {
|
|
273
|
+
const response = await fetch(url, { method: 'HEAD' });
|
|
274
|
+
return response.ok;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Add reactive statement to check if current file is missing
|
|
281
|
+
$: isMissing = $missingFiles.has(file.id);
|
|
282
|
+
|
|
283
|
+
let imageLoaded = false;
|
|
284
|
+
|
|
285
|
+
// Check if image is already in browser cache
|
|
286
|
+
async function checkImageLoaded(url: string): Promise<boolean> {
|
|
287
|
+
return new Promise((resolve) => {
|
|
288
|
+
const img = new Image();
|
|
289
|
+
img.onload = () => {
|
|
290
|
+
// If image loads immediately, it was in cache
|
|
291
|
+
resolve(true);
|
|
292
|
+
};
|
|
293
|
+
img.onerror = () => resolve(false);
|
|
294
|
+
img.src = url;
|
|
295
|
+
// If complete is true and naturalWidth is not zero, image is already loaded
|
|
296
|
+
if (img.complete && img.naturalWidth !== 0) {
|
|
297
|
+
resolve(true);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Update imageLoaded state when file changes
|
|
303
|
+
$: if (fileUrl && fileType === 'image') {
|
|
304
|
+
checkImageLoaded(fileUrl).then(loaded => {
|
|
305
|
+
imageLoaded = loaded;
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
let pdfLoadError: string | null = null;
|
|
310
|
+
</script>
|
|
311
|
+
|
|
312
|
+
<!-- Preview Modal Container -->
|
|
313
|
+
<BaseModal
|
|
314
|
+
class="file-preview-modal"
|
|
315
|
+
bind:open
|
|
316
|
+
title={file.name}
|
|
317
|
+
width={modalDimensions.width}
|
|
318
|
+
height={modalDimensions.height}
|
|
319
|
+
{target}
|
|
320
|
+
showScroll={false}
|
|
321
|
+
on:close={handleClose}
|
|
322
|
+
enableSpaceKey={allowSelecting && !isMissing}
|
|
323
|
+
isSelected={isSelected}
|
|
324
|
+
modalType="filePreview"
|
|
325
|
+
modalData={{
|
|
326
|
+
file,
|
|
327
|
+
currentFiles,
|
|
328
|
+
currentFilter,
|
|
329
|
+
allowSelecting
|
|
330
|
+
}}
|
|
331
|
+
on:restore={(event) => {
|
|
332
|
+
if (event.detail) {
|
|
333
|
+
file = event.detail.file;
|
|
334
|
+
currentFiles = event.detail.currentFiles;
|
|
335
|
+
currentFilter = event.detail.currentFilter;
|
|
336
|
+
allowSelecting = event.detail.allowSelecting;
|
|
337
|
+
|
|
338
|
+
// Re-trigger file type checks and URL validation
|
|
339
|
+
fileType = getFileType(file.url || file.name);
|
|
340
|
+
fileUrl = file.url || '';
|
|
341
|
+
hasValidUrl = !!file.url && fileUrl.length > 0 && !$missingFiles.has(file.id);
|
|
342
|
+
fontName = file.name.replace(/\.[^/.]+$/, '');
|
|
343
|
+
|
|
344
|
+
// Reset image loaded state when file changes
|
|
345
|
+
imageLoaded = false;
|
|
346
|
+
|
|
347
|
+
// Re-calculate current index for navigation
|
|
348
|
+
currentIndex = currentFiles.findIndex((f: FileSystemItem) => f.id === file.id);
|
|
349
|
+
}
|
|
350
|
+
}}
|
|
351
|
+
on:spaceKey={() => dispatch('select', file)}
|
|
352
|
+
>
|
|
353
|
+
<!-- Preview Content Area -->
|
|
354
|
+
{#if !hasValidUrl || $missingFiles.has(file.id)}
|
|
355
|
+
<ErrorPreview />
|
|
356
|
+
{:else if fileType === 'font'}
|
|
357
|
+
<FontPreview
|
|
358
|
+
src={fileUrl}
|
|
359
|
+
{fontName}
|
|
360
|
+
previewText={file.previewText || 'The quick brown fox jumps over the lazy dog'}
|
|
361
|
+
/>
|
|
362
|
+
{:else if fileType === 'image' || fileType === 'svg'}
|
|
363
|
+
{#if fileType === 'svg'}
|
|
364
|
+
<div class="svg-preview-container h-[600px] mx-4 flex items-center justify-center bg-[hsl(var(--grey1))] rounded-large overflow-hidden widgetic-colors">
|
|
365
|
+
<div class="svg-preview-image-container w-[400px] h-[400px] flex items-center justify-center">
|
|
366
|
+
<img
|
|
367
|
+
src={fileUrl}
|
|
368
|
+
alt={file.name}
|
|
369
|
+
class="w-full h-full object-contain fade-in"
|
|
370
|
+
on:load={() => imageLoaded = true}
|
|
371
|
+
/>
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
{:else}
|
|
375
|
+
<ImagePreview
|
|
376
|
+
hash={file.hash}
|
|
377
|
+
src={fileUrl}
|
|
378
|
+
alt={file.name}
|
|
379
|
+
width={file.width}
|
|
380
|
+
height={file.height}
|
|
381
|
+
initiallyLoaded={imageLoaded}
|
|
382
|
+
on:load={() => imageLoaded = true}
|
|
383
|
+
on:dimensions={(event) => {
|
|
384
|
+
// Only update dimensions if they're smaller than our max
|
|
385
|
+
const { width, height } = event.detail;
|
|
386
|
+
|
|
387
|
+
// Get grid system margins from CSS variables
|
|
388
|
+
const element = document.querySelector('.widgetic-breakpoints');
|
|
389
|
+
let maxWidth = window.innerWidth - 48; // 24px padding on each side
|
|
390
|
+
|
|
391
|
+
if (element) {
|
|
392
|
+
const styles = getComputedStyle(element);
|
|
393
|
+
const margin = parseInt(styles.getPropertyValue('--app-margin').trim()) || 24;
|
|
394
|
+
// Calculate maximum available width based on window size and margins
|
|
395
|
+
maxWidth = window.innerWidth - (2 * margin);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const maxHeight = window.innerHeight - TOTAL_VERTICAL_SPACE - 100;
|
|
399
|
+
|
|
400
|
+
// Calculate scale to fit within bounds
|
|
401
|
+
const scaleWidth = maxWidth / width;
|
|
402
|
+
const scaleHeight = maxHeight / height;
|
|
403
|
+
const scale = Math.min(1, scaleWidth, scaleHeight);
|
|
404
|
+
|
|
405
|
+
// Apply scale to dimensions
|
|
406
|
+
const finalWidth = Math.round(width * scale);
|
|
407
|
+
const finalHeight = Math.round(height * scale);
|
|
408
|
+
|
|
409
|
+
// Always update dimensions to fit content exactly
|
|
410
|
+
modalDimensions = {
|
|
411
|
+
width: `${finalWidth}px`,
|
|
412
|
+
height: `${finalHeight + TOTAL_VERTICAL_SPACE}px`,
|
|
413
|
+
dynamicHeight: true
|
|
414
|
+
};
|
|
415
|
+
}}
|
|
416
|
+
/>
|
|
417
|
+
{/if}
|
|
418
|
+
{:else if isVideo}
|
|
419
|
+
<VideoPlayer
|
|
420
|
+
src={fileUrl}
|
|
421
|
+
bind:mediaElement={videoElement}
|
|
422
|
+
{autoplay}
|
|
423
|
+
/>
|
|
424
|
+
{:else if isAudio}
|
|
425
|
+
<AudioPlayer
|
|
426
|
+
src={fileUrl}
|
|
427
|
+
bind:mediaElement={audioElement}
|
|
428
|
+
{autoplay}
|
|
429
|
+
/>
|
|
430
|
+
{:else if isPreviewableText}
|
|
431
|
+
<TextPreview
|
|
432
|
+
src={fileUrl}
|
|
433
|
+
/>
|
|
434
|
+
{:else if isPDF}
|
|
435
|
+
<PDFViewer class="fb-pdf-viewer"
|
|
436
|
+
url={fileUrl}
|
|
437
|
+
enableCacheClearing={true}
|
|
438
|
+
on:error={(e) => pdfLoadError = e.detail.message || 'Error loading PDF'}
|
|
439
|
+
on:cacheCleared={() => console.log('PDF cache cleared from FilePreview')}
|
|
440
|
+
/>
|
|
441
|
+
{:else}
|
|
442
|
+
<p class="no-preview-container text-center py-8">Preview not available for this file type.</p>
|
|
443
|
+
{/if}
|
|
444
|
+
|
|
445
|
+
<!-- File Metadata Display -->
|
|
446
|
+
<!-- <FileMetadata {file} /> -->
|
|
447
|
+
</BaseModal>
|
|
448
|
+
|
|
449
|
+
<style>
|
|
450
|
+
.fade-in {
|
|
451
|
+
opacity: 0;
|
|
452
|
+
transition: opacity 250ms ease-out;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
img[src].fade-in {
|
|
456
|
+
opacity: 1;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/* Prevent dragging on media elements while allowing hover/click */
|
|
460
|
+
:global(img),
|
|
461
|
+
:global(video),
|
|
462
|
+
:global(audio),
|
|
463
|
+
:global(button),
|
|
464
|
+
:global(.no-drag) {
|
|
465
|
+
-webkit-user-drag: none !important;
|
|
466
|
+
-khtml-user-drag: none !important;
|
|
467
|
+
-moz-user-drag: none !important;
|
|
468
|
+
-o-user-drag: none !important;
|
|
469
|
+
-webkit-user-select: none !important;
|
|
470
|
+
-khtml-user-select: none !important;
|
|
471
|
+
-moz-user-select: none !important;
|
|
472
|
+
-ms-user-select: none !important;
|
|
473
|
+
user-select: none !important;
|
|
474
|
+
}
|
|
475
|
+
</style>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FileSystemItem } from '../../types';
|
|
2
|
+
import { type FileFilterType } from '../../utils/fileTypes';
|
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const FilePreview: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
file: FileSystemItem;
|
|
18
|
+
open?: boolean;
|
|
19
|
+
allowSelecting?: boolean;
|
|
20
|
+
currentFiles?: FileSystemItem[];
|
|
21
|
+
currentFilter?: FileFilterType;
|
|
22
|
+
target?: string;
|
|
23
|
+
}, {
|
|
24
|
+
select: CustomEvent<any>;
|
|
25
|
+
navigate: CustomEvent<any>;
|
|
26
|
+
close: CustomEvent<any>;
|
|
27
|
+
} & {
|
|
28
|
+
[evt: string]: CustomEvent<any>;
|
|
29
|
+
}, {}, {}, string>;
|
|
30
|
+
type FilePreview = InstanceType<typeof FilePreview>;
|
|
31
|
+
export default FilePreview;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import ErrorPreview from './ErrorPreview.svelte';
|
|
4
|
+
|
|
5
|
+
export let src: string;
|
|
6
|
+
export let fontName: string;
|
|
7
|
+
export let previewText: string = 'The quick brown fox jumps over the lazy dog';
|
|
8
|
+
|
|
9
|
+
let hasError = false;
|
|
10
|
+
let fontLoaded = false;
|
|
11
|
+
let fontFace: FontFace;
|
|
12
|
+
|
|
13
|
+
onMount(async () => {
|
|
14
|
+
try {
|
|
15
|
+
// Create a new FontFace object
|
|
16
|
+
fontFace = new FontFace(fontName, `url(${src})`);
|
|
17
|
+
|
|
18
|
+
// Wait for the font to load
|
|
19
|
+
await fontFace.load();
|
|
20
|
+
|
|
21
|
+
// Add the font to the document
|
|
22
|
+
document.fonts.add(fontFace);
|
|
23
|
+
fontLoaded = true;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('FontPreview: Error loading font from url:', src, error);
|
|
26
|
+
hasError = true;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
{#if hasError}
|
|
32
|
+
<ErrorPreview />
|
|
33
|
+
{:else}
|
|
34
|
+
<div class="font-preview-container flex flex-col mx-4 space-y-8 p-8 bg-[hsl(var(--grey1))] rounded-large widgetic-radius widgetic-colors">
|
|
35
|
+
<!-- Font Name and Sample Letters -->
|
|
36
|
+
<div class="flex flex-col items-center space-y-4">
|
|
37
|
+
<!-- <h3 class="text-lg font-medium text-gray-700">{fontName}</h3> -->
|
|
38
|
+
<div
|
|
39
|
+
style="font-family: '{fontName}', sans-serif;"
|
|
40
|
+
class="text-6xl {fontLoaded ? '' : 'opacity-0'} transition-opacity duration-300"
|
|
41
|
+
>
|
|
42
|
+
aA
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<!-- Preview Text -->
|
|
47
|
+
<div class="space-y-6">
|
|
48
|
+
<!-- Large Size -->
|
|
49
|
+
<div class="space-y-2">
|
|
50
|
+
<p class="text-sm text-gray-500">32px</p>
|
|
51
|
+
<p
|
|
52
|
+
style="font-family: '{fontName}', sans-serif; font-size: 32px;"
|
|
53
|
+
class="leading-normal {fontLoaded ? '' : 'opacity-0'} transition-opacity duration-300"
|
|
54
|
+
>
|
|
55
|
+
{previewText}
|
|
56
|
+
</p>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<!-- Medium Size -->
|
|
60
|
+
<div class="space-y-2">
|
|
61
|
+
<p class="text-sm text-gray-500">24px</p>
|
|
62
|
+
<p
|
|
63
|
+
style="font-family: '{fontName}', sans-serif; font-size: 24px;"
|
|
64
|
+
class="leading-normal {fontLoaded ? '' : 'opacity-0'} transition-opacity duration-300"
|
|
65
|
+
>
|
|
66
|
+
{previewText}
|
|
67
|
+
</p>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<!-- Small Size -->
|
|
71
|
+
<div class="space-y-2">
|
|
72
|
+
<p class="text-sm text-gray-500">16px</p>
|
|
73
|
+
<p
|
|
74
|
+
style="font-family: '{fontName}', sans-serif; font-size: 16px;"
|
|
75
|
+
class="leading-normal {fontLoaded ? '' : 'opacity-0'} transition-opacity duration-300"
|
|
76
|
+
>
|
|
77
|
+
{previewText}
|
|
78
|
+
</p>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const FontPreview: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
src: string;
|
|
16
|
+
fontName: string;
|
|
17
|
+
previewText?: string;
|
|
18
|
+
}, {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
}, {}, {}, string>;
|
|
21
|
+
type FontPreview = InstanceType<typeof FontPreview>;
|
|
22
|
+
export default FontPreview;
|