feat: unify admin photo gallery with drag-and-drop + arrows

- Merge separate 'Hauptfoto' and 'Weitere Fotos' uploads into single upload zone
- Add drag-and-drop support for photo reorder
- Add ← → arrow buttons for photo reorder
- Increase thumbnail size to 200px
- Show Hauptfoto badge, ★ set primary, × delete on each thumbnail
- Auto-promote next photo when primary is deleted
- Keep vehicle.photo_url synced with primary photo
This commit is contained in:
2026-05-31 10:29:07 +02:00
parent 8be7d5aad2
commit 9bc08d994c
3 changed files with 344 additions and 70 deletions
+166
View File
@@ -1135,6 +1135,172 @@ table.admin-table td:last-child { white-space: nowrap; }
filter: brightness(1.1);
}
/* ---- Unified Photo Upload Zone ---- */
.admin-photo-upload-zone {
width: 100%;
min-height: 120px;
border: 2px dashed var(--line);
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: border-color 0.2s ease, background 0.2s ease;
background: var(--bg-elev);
margin-bottom: 0.5rem;
position: relative;
}
.admin-photo-upload-zone:hover {
border-color: var(--accent-strong);
}
.admin-photo-upload-zone.drag-active {
border-color: var(--accent-strong);
background: rgba(245, 158, 11, 0.08);
}
.admin-photo-upload-zone input[type="file"] {
position: absolute;
inset: 0;
opacity: 0;
cursor: pointer;
}
.admin-photo-upload-content {
text-align: center;
pointer-events: none;
}
.admin-photo-upload-icon {
font-size: 2rem;
display: block;
margin-bottom: 0.3rem;
}
/* ---- Photo Gallery ---- */
.admin-photo-gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 0.8rem;
margin-top: 1rem;
}
.admin-photo-card {
position: relative;
border-radius: 10px;
overflow: hidden;
aspect-ratio: 16/10;
background: #1a1a1a;
border: 2px solid transparent;
transition: border-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
cursor: grab;
}
.admin-photo-card:hover {
border-color: var(--accent-strong);
transform: scale(1.02);
}
.admin-photo-card:active {
cursor: grabbing;
}
.admin-photo-card-drag-over {
border-color: #f59e0b !important;
transform: scale(1.05);
}
.admin-photo-card img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
pointer-events: none;
}
.admin-photo-card-arrows {
position: absolute;
top: 6px;
left: 6px;
display: flex;
gap: 3px;
z-index: 2;
}
.admin-photo-arrow {
width: 26px;
height: 26px;
border-radius: 6px;
border: none;
background: rgba(0, 0, 0, 0.7);
color: #fff;
font-size: 1rem;
font-weight: 700;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s ease;
}
.admin-photo-arrow:hover {
background: rgba(0, 0, 0, 0.9);
}
.admin-photo-card-actions {
position: absolute;
top: 6px;
right: 6px;
display: flex;
gap: 3px;
z-index: 2;
}
.admin-photo-set-primary {
width: 26px;
height: 26px;
border-radius: 6px;
border: none;
background: rgba(245, 158, 11, 0.85);
color: #000;
font-size: 1rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s ease;
}
.admin-photo-set-primary:hover {
background: #f59e0b;
}
.admin-photo-delete {
width: 26px;
height: 26px;
border-radius: 6px;
border: none;
background: rgba(239, 68, 68, 0.85);
color: #fff;
font-size: 1rem;
font-weight: 700;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s ease;
}
.admin-photo-delete:hover {
background: #ef4444;
}
.admin-photo-badge {
position: absolute;
bottom: 6px;
left: 6px;
background: #22c55e;
color: #fff;
border-radius: 5px;
padding: 2px 8px;
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 0.05em;
z-index: 2;
}
.admin-photo-drag-handle {
position: absolute;
bottom: 6px;
right: 6px;
color: rgba(255, 255, 255, 0.5);
font-size: 1.1rem;
z-index: 2;
pointer-events: none;
}
/* ---------------- Forms / Toggle Switch ---------------- */
.toggle-switch {
position: relative;