124 lines
6.4 KiB
PHP
124 lines
6.4 KiB
PHP
<div>
|
||
<div class="flex items-end gap-3">
|
||
<div class="flex-1">
|
||
@if ($selectedMedia)
|
||
<div class="flex items-center gap-3 rounded-lg border border-zinc-200 p-2 dark:border-zinc-700">
|
||
@if ($selectedMedia->isImage())
|
||
<img src="{{ $selectedMedia->hasConversion('thumb') ? $selectedMedia->getConversionUrl('thumb') : $selectedMedia->getUrl() }}"
|
||
alt="{{ $selectedMedia->filename }}"
|
||
class="h-16 w-16 rounded-md object-cover" />
|
||
@elseif ($selectedMedia->isPdf())
|
||
<div class="flex h-16 w-16 items-center justify-center rounded-md bg-red-50 dark:bg-red-900/20">
|
||
<x-heroicon-o-document-text class="h-8 w-8 text-red-500" />
|
||
</div>
|
||
@endif
|
||
<div class="min-w-0 flex-1">
|
||
<p class="truncate text-sm font-medium text-zinc-700 dark:text-zinc-300">
|
||
{{ $selectedMedia->filename }}
|
||
</p>
|
||
<p class="text-xs text-zinc-400">
|
||
{{ $selectedMedia->getHumanFileSize() }}
|
||
@if ($selectedMedia->getDimensionsLabel())
|
||
— {{ $selectedMedia->getDimensionsLabel() }}
|
||
@endif
|
||
</p>
|
||
@if ($selectedMedia->isImage() && $selectedMedia->hasConversion($profile))
|
||
@php
|
||
$pConfig = config("flux-cms.media.profiles.{$profile}", []);
|
||
@endphp
|
||
<flux:badge size="sm" color="green" class="mt-1">
|
||
{{ $profile }}: {{ $pConfig['width'] ?? '?' }}×{{ $pConfig['height'] ?? '?' }}
|
||
</flux:badge>
|
||
@endif
|
||
</div>
|
||
<flux:button size="xs" variant="ghost" icon="x-mark" wire:click="clearSelection" />
|
||
</div>
|
||
@else
|
||
<div class="rounded-lg border-2 border-dashed border-zinc-300 px-4 py-3 text-center text-sm text-zinc-400 dark:border-zinc-600">
|
||
Kein Medium ausgewählt
|
||
</div>
|
||
@endif
|
||
</div>
|
||
<flux:button size="sm" variant="ghost" icon="photo" wire:click="openPicker">
|
||
{{ $label }}
|
||
</flux:button>
|
||
</div>
|
||
|
||
<flux:modal wire:model="showModal" class="w-full max-w-4xl space-y-4 overflow-y-auto max-h-[85vh]">
|
||
<flux:heading size="lg">{{ $label }}</flux:heading>
|
||
|
||
<div class="flex flex-col gap-3">
|
||
<flux:input wire:model.live.debounce.300ms="search" placeholder="Suchen..." icon="magnifying-glass"
|
||
size="sm" />
|
||
|
||
<flux:file-upload wire:model="quickUploads" multiple
|
||
accept="{{ $type === 'image' ? 'image/jpeg,image/png,image/gif,image/webp,.jpg,.jpeg,.png' : ($type === 'pdf' ? '.pdf,application/pdf' : '*') }}">
|
||
<flux:file-upload.dropzone
|
||
heading="Neue Datei hochladen"
|
||
text="Direkt hier hochladen und zuweisen"
|
||
with-progress />
|
||
</flux:file-upload>
|
||
|
||
@if (isset($quickUploads) && count($quickUploads) > 0)
|
||
<div class="flex flex-wrap items-center gap-2">
|
||
@foreach ($quickUploads as $index => $upload)
|
||
<flux:file-item
|
||
:heading="$upload->getClientOriginalName()"
|
||
:image="(str_starts_with($upload->getMimeType() ?? '', 'image/') && $upload->isPreviewable())
|
||
? $upload->temporaryUrl()
|
||
: null"
|
||
:size="$upload->getSize()">
|
||
<x-slot name="actions">
|
||
<flux:file-item.remove wire:click="removeQuickUpload({{ $index }})" />
|
||
</x-slot>
|
||
</flux:file-item>
|
||
@endforeach
|
||
</div>
|
||
@endif
|
||
|
||
<flux:error name="quickUploads" />
|
||
</div>
|
||
|
||
@php $profileConfig = config("flux-cms.media.profiles.{$profile}", []); @endphp
|
||
@if (!empty($profileConfig))
|
||
<flux:text class="text-xs">
|
||
Profil <strong>{{ $profile }}</strong>: {{ $profileConfig['width'] }}×{{ $profileConfig['height'] }} px,
|
||
{{ strtoupper($profileConfig['format'] ?? 'webp') }},
|
||
Qualität {{ $profileConfig['quality'] ?? 85 }}%
|
||
</flux:text>
|
||
@endif
|
||
|
||
<div class="grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-6">
|
||
@forelse ($mediaItems as $item)
|
||
<div wire:key="pick-{{ $item->id }}"
|
||
class="group cursor-pointer overflow-hidden rounded-lg border transition-all
|
||
{{ $value === $item->id ? 'border-blue-500 ring-2 ring-blue-200' : 'border-zinc-200 hover:border-blue-300 dark:border-zinc-700' }}"
|
||
wire:click="selectMedia({{ $item->id }})">
|
||
<div class="aspect-square bg-zinc-100 dark:bg-zinc-800">
|
||
@if ($item->isImage())
|
||
<img src="{{ $item->hasConversion('thumb') ? $item->getConversionUrl('thumb') : $item->getUrl() }}"
|
||
alt="{{ $item->filename }}" class="h-full w-full object-cover" loading="lazy" />
|
||
@elseif ($item->isPdf())
|
||
<div class="flex h-full w-full items-center justify-center text-red-500">
|
||
<x-heroicon-o-document-text class="h-8 w-8" />
|
||
</div>
|
||
@endif
|
||
</div>
|
||
<div class="p-1.5">
|
||
<p class="truncate text-[11px] text-zinc-600 dark:text-zinc-400">{{ $item->filename }}</p>
|
||
</div>
|
||
</div>
|
||
@empty
|
||
<div class="col-span-full py-8 text-center">
|
||
<flux:text>Keine Medien gefunden.</flux:text>
|
||
</div>
|
||
@endforelse
|
||
</div>
|
||
|
||
@if ($mediaItems->hasPages())
|
||
<div class="mt-2">
|
||
{{ $mediaItems->links() }}
|
||
</div>
|
||
@endif
|
||
</flux:modal>
|
||
</div>
|