From 7190e14c2fdcb445c1603163dea81b14201d2839 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Fri, 7 Apr 2023 09:57:38 +0200 Subject: [PATCH] [TASK] refactor alert messages --- frontend/scss/app.scss | 1 + frontend/scss/components/_alert.scss | 9 +++++++++ templates/auth/login.html.tera | 11 +---------- templates/includes/macros.html.tera | 7 +++++++ templates/index.html.tera | 11 +---------- 5 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 frontend/scss/components/_alert.scss diff --git a/frontend/scss/app.scss b/frontend/scss/app.scss index 5f1ce76..3740b27 100644 --- a/frontend/scss/app.scss +++ b/frontend/scss/app.scss @@ -7,3 +7,4 @@ @import 'components/btns'; @import 'components/links'; @import 'components/input'; +@import 'components/alert'; diff --git a/frontend/scss/components/_alert.scss b/frontend/scss/components/_alert.scss new file mode 100644 index 0000000..f423405 --- /dev/null +++ b/frontend/scss/components/_alert.scss @@ -0,0 +1,9 @@ +.alert { + &-success { + @apply bg-[#15803d]; + } + + &-error { + @apply bg-[#f43f5e]; + } +} diff --git a/templates/auth/login.html.tera b/templates/auth/login.html.tera index 47c8857..f16fe0c 100644 --- a/templates/auth/login.html.tera +++ b/templates/auth/login.html.tera @@ -8,16 +8,7 @@ {% if flash %} - {% if flash.0 == "success" %} -
- {{ flash.1 }} -
- {% endif %} - {% if flash.0 == "error" %} -
- {{ flash.1 }} -
- {% endif %} + {{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }} {% endif %}
diff --git a/templates/includes/macros.html.tera b/templates/includes/macros.html.tera index 279506f..1c5de4f 100644 --- a/templates/includes/macros.html.tera +++ b/templates/includes/macros.html.tera @@ -34,3 +34,10 @@ {{ label }} {% endmacro checkbox %} + +{% macro alert(message, type, class='') %} +
+ {{ message }} +
+{% endmacro alert %} + diff --git a/templates/index.html.tera b/templates/index.html.tera index 4c87478..b43a2ae 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -5,16 +5,7 @@ {% block content %}
{% if flash %} - {% if flash.0 == "success" %} -
- {{ flash.1 }} -
- {% endif %} - {% if flash.0 == "error" %} -
- {{ flash.1 }} -
- {% endif %} + {{ macros::alert(message=flash.1, type=flash.0, class="sm:col-span-2 lg:col-span-3") }} {% endif %}

Ausfahrten