P 系列 width/height=null 不裁切保留原比例;blade 尺寸標示對 null 做防護 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
95 lines
5.8 KiB
PHP
95 lines
5.8 KiB
PHP
@extends('layouts.admin')
|
|
|
|
@section('content')
|
|
<div class="container mx-auto px-4 py-6" x-data="{ showCreate: false }">
|
|
@include('admin.app._tabs', ['active' => 'elements'])
|
|
|
|
<div class="mb-4">
|
|
<button type="button" @click="showCreate = true"
|
|
class="bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-4 rounded-lg">
|
|
+ {{ __('New') }}
|
|
</button>
|
|
</div>
|
|
|
|
<div class="bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden">
|
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
|
<thead class="bg-gray-50 dark:bg-gray-900/40">
|
|
<tr class="text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">
|
|
<th class="px-4 py-3">{{ __('Preview') }}</th>
|
|
<th class="px-4 py-3">{{ __('Name') }}</th>
|
|
<th class="px-4 py-3">{{ __('Category') }}</th>
|
|
<th class="px-4 py-3">{{ __('Created At') }}</th>
|
|
<th class="px-4 py-3 text-right">{{ __('Actions') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100 dark:divide-gray-700/60 text-sm text-gray-700 dark:text-gray-200">
|
|
@forelse($elements as $element)
|
|
<tr>
|
|
<td class="px-4 py-3">
|
|
@if($element->image_url)
|
|
<img src="{{ $element->image_url }}" alt="{{ $element->name }}"
|
|
class="h-12 w-auto max-w-[140px] object-contain rounded border border-gray-200 dark:border-gray-700 bg-gray-50">
|
|
@else
|
|
<span class="text-gray-400">—</span>
|
|
@endif
|
|
</td>
|
|
<td class="px-4 py-3">{{ $element->name }}</td>
|
|
<td class="px-4 py-3">
|
|
<span class="inline-flex items-center px-2 py-0.5 rounded bg-gray-100 dark:bg-gray-700 text-xs">
|
|
{{ $element->part_label }}
|
|
</span>
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-500 dark:text-gray-400">{{ $element->created_at?->format('Y-m-d H:i') }}</td>
|
|
<td class="px-4 py-3 text-right">
|
|
<form action="{{ route('admin.app.ui-elements.destroy', $element) }}" method="POST"
|
|
onsubmit="return confirm('{{ __('Are you sure?') }}')" class="inline">
|
|
@csrf @method('DELETE')
|
|
<button type="submit" class="text-rose-600 hover:text-rose-800 text-sm">{{ __('Delete') }}</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="5" class="px-4 py-10 text-center text-gray-400">{{ __('No data') }}</td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{{-- 新增 UI 元素 Modal --}}
|
|
<div x-show="showCreate" x-cloak style="display:none"
|
|
class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4">
|
|
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-xl w-full max-w-lg p-6" @click.outside="showCreate = false">
|
|
<h4 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">{{ __('New') }} — {{ __('UI Elements') }}</h4>
|
|
<form action="{{ route('admin.app.ui-elements.store') }}" method="POST" enctype="multipart/form-data" class="space-y-4">
|
|
@csrf
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1">{{ __('Name') }} <span class="text-rose-500">*</span></label>
|
|
<input type="text" name="name" required
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 py-2 px-3 text-sm">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1">{{ __('Category') }} <span class="text-rose-500">*</span></label>
|
|
<select name="part_key" required
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 py-2 px-3 text-sm">
|
|
@foreach($parts as $key => $part)
|
|
<option value="{{ $key }}">{{ $part['label'] }}{{ $part['width'] ? ' — '.$part['width'].'x'.$part['height'] : '' }}</option>
|
|
@endforeach
|
|
</select>
|
|
<p class="text-xs text-gray-400 mt-1">{{ __('Image will be center-cropped to the category size.') }}</p>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-600 dark:text-gray-300 mb-1">{{ __('Upload Image') }} <span class="text-rose-500">*</span></label>
|
|
<input type="file" name="file" accept="image/*" required
|
|
class="block w-full text-sm text-gray-600 dark:text-gray-300 file:mr-3 file:py-2 file:px-4 file:rounded-md file:border-0 file:bg-blue-600 file:text-white hover:file:bg-blue-700">
|
|
</div>
|
|
<div class="flex justify-end gap-2 pt-2">
|
|
<button type="button" @click="showCreate = false"
|
|
class="px-4 py-2 rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700">{{ __('Cancel') }}</button>
|
|
<button type="submit" class="px-4 py-2 rounded-md bg-blue-600 hover:bg-blue-700 text-white font-semibold">{{ __('Save') }}</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|