feat: render flash messages as toasts
Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
5a6db29205
commit
9b35c730ab
9 files changed
+75
-14
No files matched your search
@@ -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 %}
|
||||
Reference in new issue
Block a user