diff --git a/src/lib/components/admin/MediaDetailsModal.svelte b/src/lib/components/admin/MediaDetailsModal.svelte index fd14cae..bfc792c 100644 --- a/src/lib/components/admin/MediaDetailsModal.svelte +++ b/src/lib/components/admin/MediaDetailsModal.svelte @@ -9,8 +9,11 @@ import CloseButton from '$components/icons/CloseButton.svelte' import FileIcon from '$components/icons/FileIcon.svelte' import CopyIcon from '$components/icons/CopyIcon.svelte' + import MediaMetadataPanel from './MediaMetadataPanel.svelte' + import MediaUsageList from './MediaUsageList.svelte' import { authenticatedFetch } from '$lib/admin-auth' import { toast } from '$lib/stores/toast' + import { formatFileSize, getFileType } from '$lib/utils/mediaHelpers' import type { Media } from '@prisma/client' interface Props { @@ -45,15 +48,11 @@ let loadingAlbums = $state(false) let showAlbumSelector = $state(false) - // EXIF toggle state - let showExif = $state(false) - // Initialize form when media changes $effect(() => { if (media) { description = media.description || '' isPhotography = media.isPhotography || false - showExif = false loadUsage() // Only load albums for images if (media.mimeType?.startsWith('image/')) { @@ -204,21 +203,6 @@ } } - function formatFileSize(bytes: number): string { - if (bytes === 0) return '0 Bytes' - const k = 1024 - const sizes = ['Bytes', 'KB', 'MB', 'GB'] - const i = Math.floor(Math.log(bytes) / Math.log(k)) - return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i] - } - - function getFileType(mimeType: string): string { - if (mimeType.startsWith('image/')) return 'Image' - if (mimeType.startsWith('video/')) return 'Video' - if (mimeType.startsWith('audio/')) return 'Audio' - if (mimeType.includes('pdf')) return 'PDF' - return 'File' - } {#if media} @@ -262,120 +246,8 @@
-
-
-
- Type - {getFileType(media.mimeType)} -
-
- Size - {formatFileSize(media.size)} -
-
- - {#if showExif} -
- - - - - {#if media.exifData && Object.keys(media.exifData).length > 0} - - - {/if} -
- {/if} - - -
+ +
@@ -421,45 +293,7 @@ {/if}
- {#if loadingUsage} -
-
- Loading usage information... -
- {:else if usage.length > 0} - - {:else} -

This media file is not currently used in any content.

- {/if} -
+ {#if albums.length > 0} @@ -611,86 +445,6 @@ gap: $unit-6x; } - .file-info { - display: flex; - flex-direction: column; - gap: $unit-3x; - padding: $unit-3x; - background-color: $gray-90; - border-bottom: $unit-1px solid rgba(0, 0, 0, 0.08); - } - - .info-grid { - display: grid; - grid-template-columns: 1fr 1fr; - gap: $unit-3x; - } - - .info-item { - display: flex; - flex-direction: column; - gap: $unit-half; - - &.vertical { - grid-column: 1 / -1; - } - - .label { - font-size: 0.75rem; - font-weight: 500; - color: $gray-50; - text-transform: uppercase; - letter-spacing: 0.05em; - } - - .value { - font-size: 0.875rem; - color: $gray-10; - font-weight: 500; - - &.color-value { - display: flex; - align-items: center; - gap: $unit-2x; - } - } - } - - .color-swatch { - display: inline-block; - width: $unit-20px; - height: $unit-20px; - border-radius: $corner-radius-xs; - border: $unit-1px solid rgba(0, 0, 0, 0.1); - box-shadow: inset 0 0 0 $unit-1px rgba(255, 255, 255, 0.1); - } - - :global(.btn.btn-ghost.exif-toggle) { - margin-top: $unit-2x; - justify-content: center; - background: transparent; - border: $unit-1px solid $gray-70; - - &:hover { - background: rgba(0, 0, 0, 0.02); - border-color: $gray-70; - } - } - - .media-metadata, - .exif-metadata { - display: grid; - grid-template-columns: 1fr 1fr; - gap: $unit-3x; - } - - .metadata-divider { - border-radius: $unit-1px; - height: $unit-2px; - background: $gray-80; - margin: $unit-3x 0; - } - .edit-form { display: flex; flex-direction: column; @@ -816,98 +570,6 @@ flex-shrink: 0; } } - - .usage-list { - list-style: none; - padding: 0; - margin: $unit-2x 0 0 0; - display: flex; - flex-direction: column; - gap: $unit; - } - - .usage-loading { - display: flex; - align-items: center; - gap: $unit-2x; - padding: $unit-2x; - color: $gray-50; - - .spinner { - width: $unit-2x; - height: $unit-2x; - border: $unit-2px solid $gray-90; - border-top: $unit-2px solid $gray-50; - border-radius: 50%; - animation: spin 1s linear infinite; - } - } - - .usage-item { - padding: $unit-3x; - background: $gray-95; - border-radius: $corner-radius-xl; - border: $unit-1px solid $gray-90; - - .usage-content { - display: flex; - flex-direction: column; - gap: $unit; - } - - .usage-header { - display: flex; - align-items: center; - justify-content: space-between; - gap: $unit-2x; - - .usage-title { - font-weight: 600; - color: $gray-10; - text-decoration: none; - transition: color 0.2s ease; - - &:hover { - color: $blue-60; - } - } - - .usage-type { - background: $gray-85; - color: $gray-30; - padding: $unit-half $unit; - border-radius: $corner-radius-sm; - font-size: 0.75rem; - font-weight: 500; - text-transform: uppercase; - letter-spacing: 0.5px; - flex-shrink: 0; - } - } - - .usage-details { - display: flex; - align-items: center; - gap: $unit-3x; - - .usage-field { - color: $gray-40; - font-size: 0.875rem; - font-weight: 500; - } - - .usage-date { - color: $gray-50; - font-size: 0.75rem; - } - } - } - - .no-usage { - color: $gray-50; - font-style: italic; - margin: $unit-2x 0 0 0; - } } // Albums inline display @@ -973,14 +635,6 @@ } } - @keyframes spin { - 0% { - transform: rotate(0deg); - } - 100% { - transform: rotate(360deg); - } - } // Responsive adjustments @media (max-width: 768px) { diff --git a/src/lib/components/admin/MediaUploadModal.svelte b/src/lib/components/admin/MediaUploadModal.svelte index 5a399e8..40e7284 100644 --- a/src/lib/components/admin/MediaUploadModal.svelte +++ b/src/lib/components/admin/MediaUploadModal.svelte @@ -1,6 +1,9 @@