[TASK] refactor alert messages

This commit is contained in:
Marie Birner 2023-04-07 09:57:38 +02:00
parent 1490b191af
commit 7190e14c2f
5 changed files with 19 additions and 20 deletions

View File

@ -7,3 +7,4 @@
@import 'components/btns';
@import 'components/links';
@import 'components/input';
@import 'components/alert';

View File

@ -0,0 +1,9 @@
.alert {
&-success {
@apply bg-[#15803d];
}
&-error {
@apply bg-[#f43f5e];
}
}

View File

@ -8,16 +8,7 @@
</div>
{% if flash %}
{% if flash.0 == "success" %}
<div class="bg-[#4ade80] text-white px-3 py-1 rounded-md text-center">
{{ flash.1 }}
</div>
{% endif %}
{% if flash.0 == "error" %}
<div class="bg-[#f43f5e] text-white px-3 py-1 rounded-md text-center">
{{ flash.1 }}
</div>
{% endif %}
{{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }}
{% endif %}
<form class="mt-8 space-y-6" method="post" action="/auth">
<input type="hidden" name="remember" value="true">

View File

@ -34,3 +34,10 @@
<input type="checkbox" id="{{ name }}{{ id }}" name="{{ name }}" {% if checked %} checked {% endif %} class="h-4 w-4 accent-primary-600 mr-2"/> {{ label }}
</label>
{% endmacro checkbox %}
{% macro alert(message, type, class='') %}
<div class="{{ class }} alert-{{ type }} text-white px-3 py-1 rounded-md text-center">
{{ message }}
</div>
{% endmacro alert %}

View File

@ -5,16 +5,7 @@
{% block content %}
<div class="max-w-screen-xl w-full grid sm:grid-cols-2 lg:grid-cols-3 gap-4">
{% if flash %}
{% if flash.0 == "success" %}
<div class="sm:col-span-2 lg:col-span-3 bg-[#4ade80] text-white px-3 py-1 rounded-md text-center">
{{ flash.1 }}
</div>
{% endif %}
{% if flash.0 == "error" %}
<div class="sm:col-span-2 lg:col-span-3 bg-[#f43f5e] text-white px-3 py-1 rounded-md text-center">
{{ flash.1 }}
</div>
{% endif %}
{{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }}
{% endif %}
<h1 class="h1 sm:col-span-2 lg:col-span-3">Ausfahrten</h1>