diff --git a/src/lib/components/admin/AlbumSelectorModal.svelte b/src/lib/components/admin/AlbumSelectorModal.svelte new file mode 100644 index 0000000..8483789 --- /dev/null +++ b/src/lib/components/admin/AlbumSelectorModal.svelte @@ -0,0 +1,241 @@ + + + +
+ + + + + + + + +
+
+ + diff --git a/src/lib/components/admin/InlineComposerModal.svelte b/src/lib/components/admin/InlineComposerModal.svelte new file mode 100644 index 0000000..4af376c --- /dev/null +++ b/src/lib/components/admin/InlineComposerModal.svelte @@ -0,0 +1,840 @@ + + +{#if mode === 'modal'} + +
+
+ +
+ + +
+
+ +
+ { + content = newContent + }} + onCharacterCount={(count) => { + characterCount = count + }} + placeholder="What's on your mind?" + minHeight={80} + autofocus={true} + variant="inline" + /> + + {#if attachedPhotos.length > 0} +
+ {#each attachedPhotos as photo} +
+ + +
+ {/each} +
+ {/if} + + +
+
+
+{:else if mode === 'page'} + {#if postType === 'essay'} +
+
+

New Essay

+
+ + +
+
+ + + + + + +
+ {#if essayTab === 0} + + {:else} +
+ { + content = newContent + }} + onCharacterCount={(count) => { + characterCount = count + }} + placeholder="Start writing your essay..." + minHeight={500} + autofocus={true} + variant="full" + /> +
+ {/if} +
+
+ {:else} +
+ {#if hasContent()} + + {/if} +
+ { + content = newContent + }} + onCharacterCount={(count) => { + characterCount = count + }} + placeholder="What's on your mind?" + minHeight={120} + autofocus={true} + variant="inline" + /> + + {#if attachedPhotos.length > 0} +
+ {#each attachedPhotos as photo} +
+ + +
+ {/each} +
+ {/if} + + +
+
+ {/if} +{/if} + + + + + + + + +{#if selectedMedia} + +{/if} + + diff --git a/src/lib/components/admin/MediaLibraryModal.svelte b/src/lib/components/admin/MediaLibraryModal.svelte deleted file mode 100644 index 2f2ee11..0000000 --- a/src/lib/components/admin/MediaLibraryModal.svelte +++ /dev/null @@ -1,225 +0,0 @@ - - - -
- - - - - - - -
- - -
-
-
- - diff --git a/src/lib/components/admin/MediaSelector.svelte b/src/lib/components/admin/MediaSelector.svelte deleted file mode 100644 index a0400e0..0000000 --- a/src/lib/components/admin/MediaSelector.svelte +++ /dev/null @@ -1,631 +0,0 @@ - - -
- -
-
- - - - - -
- - {#if showSelectAll} - - {/if} -
- - - {#if total > 0} -
- {total} file{total !== 1 ? 's' : ''} found -
- {/if} - - -
- {#if loading && media.length === 0} -
- -

Loading media...

-
- {:else if media.length === 0} -
- - - - - -

No media found

-

Try adjusting your search or upload some files

-
- {:else} -
- {#each media as item (item.id)} - - {/each} -
- - - {#if hasMore} -
- -
- {/if} - {/if} -
-
- - diff --git a/src/lib/components/admin/UnifiedMediaModal.svelte b/src/lib/components/admin/UnifiedMediaModal.svelte new file mode 100644 index 0000000..fadd52c --- /dev/null +++ b/src/lib/components/admin/UnifiedMediaModal.svelte @@ -0,0 +1,864 @@ + + + +
+ + + + +
+ {#if isInitialLoad && media.length === 0} + +
+ {#each Array(12) as _, i} + + {/each} +
+ {:else if media.length === 0 && currentPage === 1} +
+ + + + + +

No media found

+

+ {#if fileType !== 'all'} + Try adjusting your filters or search + {:else} + Try adjusting your search or filters + {/if} +

+
+ {:else} +
+ {#each media as item, i (item.id)} + + {/each} +
+ + + +
+ + {#snippet loading()} +
+ +
+ {/snippet} + + {#snippet error()} +
+

Failed to load media

+ +
+ {/snippet} + + {#snippet noData()} + + {/snippet} +
+ {/if} +
+ + + +
+
+ + diff --git a/src/lib/stores/media-selection.ts b/src/lib/stores/media-selection.ts new file mode 100644 index 0000000..66bb488 --- /dev/null +++ b/src/lib/stores/media-selection.ts @@ -0,0 +1,40 @@ +import { writable } from 'svelte/store' +import type { Media } from '@prisma/client' + +interface MediaSelectionState { + isOpen: boolean + mode: 'single' | 'multiple' + fileType?: 'image' | 'video' | 'all' + albumId?: number + onSelect?: (media: Media | Media[]) => void + onClose?: () => void +} + +function createMediaSelectionStore() { + const { subscribe, set, update } = writable({ + isOpen: false, + mode: 'single', + fileType: 'all' + }) + + return { + subscribe, + open: (options: Partial) => { + update((state) => ({ + ...state, + ...options, + isOpen: true + })) + }, + close: () => { + update((state) => ({ + ...state, + isOpen: false, + onSelect: undefined, + onClose: undefined + })) + } + } +} + +export const mediaSelectionStore = createMediaSelectionStore()