Move label display logic into the Label macro

This commit is contained in:
leigh-mil
2019-11-19 11:01:07 -05:00
parent 58a0b2dd9d
commit 8aa302357b
7 changed files with 29 additions and 37 deletions

View File

@@ -1,8 +1,19 @@
{% from "components/icon.html" import Icon %}
{% macro Label(icon, text, type=None, classes="") -%}
{% macro Label(type=None, classes="") -%}
{% set label_info = {
"invite_pending": {"icon": "envelope", "text": "invite pending", "color": "success",},
"invite_expired": {"icon": "envelope", "text": "invite expired", "color": "error",},
"changes_pending": {
"icon": "exchange",
"text": "changes pending",
"color": "default",
},
} %}
<span class='label {% if type %}label--{{ type }}{% endif %} {{ classes }}'>
{{ Icon(icon) }} {{ text }}
</span>
{% if type -%}
<span class='label label--{{ label_info[type]["color"] }} {{ classes }}'>
{{ Icon(label_info[type]["icon"]) }} {{ label_info[type]["text"] }}
</span>
{%- endif %}
{%- endmacro %}