From 828befceb196df6b4b28d6a33654e1bba8cf4b67 Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Sun, 20 Sep 2026 02:32:23 +0200 Subject: [PATCH] Show success flashes as a centered popup with an animated checkmark Only the "success" flash type moves to the new popup (a self-dismissing centered overlay with an SVG checkmark that draws itself in, closes automatically after ~2.8s or on click). Error/other flash types keep the existing top banner, since those usually carry details worth reading rather than a quick confirmation. header.php now splits get_flashes() once into success vs. other so both the logged-in and guest layouts pick up the same split. Co-Authored-By: Claude Sonnet 5 --- assets/css/style.css | 81 ++++++++++++++++++++++++++++++++++++++ assets/js/success-popup.js | 26 ++++++++++++ includes/header.php | 25 +++++++++++- 3 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 assets/js/success-popup.js diff --git a/assets/css/style.css b/assets/css/style.css index 95e3d36..4c47df6 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -498,6 +498,87 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator { .flash-error { background: rgba(217, 83, 79, 0.15); border: 1px solid var(--danger); color: var(--danger); } .text-muted { color: var(--text-muted); } + +/* --- Erfolgs-Popup: zentriert mit animiertem Haken statt Balken oben --- */ + +.success-popup-overlay { + position: fixed; + inset: 0; + z-index: 1100; + display: flex; + align-items: center; + justify-content: center; + background: rgba(0, 0, 0, 0.4); + opacity: 0; + cursor: pointer; + transition: opacity 0.25s ease; +} + +.success-popup-overlay.visible { opacity: 1; } +.success-popup-overlay.closing { opacity: 0; } + +.success-popup { + display: flex; + flex-direction: column; + align-items: center; + gap: 0.75rem; + padding: 2.25rem 2.5rem; + background: var(--bg-panel); + border: 1px solid var(--border); + border-radius: 12px; + box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55); + text-align: center; + max-width: 360px; + transform: scale(0.85); + transition: transform 0.25s ease; +} + +.success-popup-overlay.visible .success-popup { transform: scale(1); } + +.success-popup p { + margin: 0; + color: var(--text); + font-size: 1rem; + font-weight: 600; +} + +.success-check { + width: 64px; + height: 64px; + flex-shrink: 0; +} + +.success-check-circle { + stroke: var(--success); + stroke-width: 2.5; + stroke-dasharray: 151; + stroke-dashoffset: 151; +} + +.success-check-mark { + stroke: var(--success); + stroke-width: 4; + stroke-linecap: round; + stroke-linejoin: round; + stroke-dasharray: 40; + stroke-dashoffset: 40; +} + +.success-popup-overlay.visible .success-check-circle { + animation: success-circle-draw 0.5s ease-out forwards; +} + +.success-popup-overlay.visible .success-check-mark { + animation: success-mark-draw 0.35s 0.45s ease-out forwards; +} + +@keyframes success-circle-draw { + to { stroke-dashoffset: 0; } +} + +@keyframes success-mark-draw { + to { stroke-dashoffset: 0; } +} .text-muted.error { color: var(--danger); } .hero { diff --git a/assets/js/success-popup.js b/assets/js/success-popup.js new file mode 100644 index 0000000..8847c5d --- /dev/null +++ b/assets/js/success-popup.js @@ -0,0 +1,26 @@ +(function () { + 'use strict'; + + var popup = document.getElementById('success-popup'); + if (!popup) return; + + var AUTO_CLOSE_MS = 2800; + var closeTimer = null; + + function close() { + if (closeTimer) clearTimeout(closeTimer); + popup.classList.remove('visible'); + popup.classList.add('closing'); + setTimeout(function () { + if (popup.parentNode) popup.parentNode.removeChild(popup); + }, 250); + } + + popup.addEventListener('click', close); + + requestAnimationFrame(function () { + popup.classList.add('visible'); + }); + + closeTimer = setTimeout(close, AUTO_CLOSE_MS); +})(); diff --git a/includes/header.php b/includes/header.php index 670f1f2..107ce4b 100644 --- a/includes/header.php +++ b/includes/header.php @@ -35,6 +35,13 @@ $pageBackgrounds = [ 'reports.php' => 'bg-reports', ]; $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? ''; + +// Erfolgsmeldungen ("Bestätigungen") bekommen ein zentriertes Popup mit Haken-Animation statt +// des Balkens oben - andere Meldungstypen (z.B. Fehler) bleiben als Balken, da die dort meist +// wichtige Details/Handlungsaufforderungen stehen, die man nicht nur kurz einblenden will. +$allFlashes = get_flashes(); +$successFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($f['type'] ?? '') === 'success')); +$otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($f['type'] ?? '') !== 'success')); ?> @@ -51,6 +58,20 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? ''; > + +
+
+ + +

+ +
+
+ +
@@ -119,7 +140,7 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
- +
@@ -130,7 +151,7 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
- +