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 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-20 02:32:23 +02:00
parent 8588c2fd58
commit 828befceb1
3 changed files with 130 additions and 2 deletions

View file

@ -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 {

View file

@ -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);
})();

View file

@ -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'));
?>
<!DOCTYPE html>
<html lang="de">
@ -51,6 +58,20 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
<link rel="stylesheet" href="/assets/css/style.css">
</head>
<body<?= $currentUser ? '' : ' class="guest-bg"' ?>>
<?php if (!empty($successFlashes)): ?>
<div class="success-popup-overlay" id="success-popup" role="status" title="Klicken zum Schließen">
<div class="success-popup">
<svg class="success-check" viewBox="0 0 52 52" aria-hidden="true">
<circle class="success-check-circle" cx="26" cy="26" r="24" fill="none"/>
<path class="success-check-mark" fill="none" d="M14 27l7 7 16-16"/>
</svg>
<?php foreach ($successFlashes as $flash): ?>
<p><?= e($flash['message']) ?></p>
<?php endforeach; ?>
</div>
</div>
<script src="/assets/js/success-popup.js"></script>
<?php endif; ?>
<?php if ($currentUser): ?>
<div class="app-shell">
<div class="mobile-topbar">
@ -119,7 +140,7 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
</aside>
<div class="app-content<?= $pageBackgroundClass ? ' ' . e($pageBackgroundClass) : '' ?>">
<main class="container">
<?php foreach (get_flashes() as $flash): ?>
<?php foreach ($otherFlashes as $flash): ?>
<div class="flash flash-<?= e($flash['type']) ?>"><?= e($flash['message']) ?></div>
<?php endforeach; ?>
<?php else: ?>
@ -130,7 +151,7 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
</div>
</header>
<main class="container">
<?php foreach (get_flashes() as $flash): ?>
<?php foreach ($otherFlashes as $flash): ?>
<div class="flash flash-<?= e($flash['type']) ?>"><?= e($flash['message']) ?></div>
<?php endforeach; ?>
<?php endif; ?>