feat: render flash messages as toasts

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5 committed 2026-09-18 09:47:20 +02:00
1 parent 5a6db29205
commit 9b35c730ab
9 files changed
+75 -14

No files matched your search

+6 -8
View File
@@ -1,12 +1,10 @@
{# Just the alerts. The positioned container with id="flashes" lives in layout.html.twig, because
that is the element htmx swaps out of band after a booking. Flat inline alerts for now: myep
renders these as Toastify toasts, which would mean adopting toastify-js (plan step 2/7). #}
{% set levels = { error: 'bg-red-600', warning: 'bg-amber-600', success: 'bg-emerald-600', info: 'bg-primary' } %}
{# Just the toast triggers. The container with id="flashes" lives in layout.html.twig, because
that is the element htmx swaps out of band after a booking. Each element is empty: the
toast_controller hands the message to Toastify, which renders it at the top right. #}
{% set levels = ['error', 'warning', 'success', 'info'] %}
{% for level, messages in app.flashes(levels|keys) %}
{% for level, messages in app.flashes(levels) %}
{% for message in messages %}
<div class="{{ levels[level] }} text-white rounded shadow-lg px-4 py-3 text-sm">
{{ message|trans }}
</div>
<div {{ stimulus_controller('toast', { text: message|trans, class: 'toastify--' ~ level }) }}></div>
{% endfor %}
{% endfor %}