Badges use secondary BG by default; add custom option

This commit is contained in:
jeremystretch 2021-08-06 15:41:26 -04:00
parent 939bcfec4b
commit 65659fb676
3 changed files with 4 additions and 3 deletions

View File

@ -34,7 +34,7 @@
<li class="nav-item" role="presentation">
<button class="nav-link" id="filters-form-tab" data-bs-toggle="tab" data-bs-target="#filters-form" type="button" role="tab" aria-controls="object-list" aria-selected="false">
Filters
{% if filter_form %}{% badge filter_form.changed_data|length %}{% endif %}
{% if filter_form %}{% badge filter_form.changed_data|length bg_class="primary" %}{% endif %}
</button>
</li>
{% endif %}

View File

@ -1 +1 @@
{% if value or show_empty %}<span class="badge bg-primary">{{ value }}</span>{% endif %}
{% if value or show_empty %}<span class="badge bg-{{ bg_class }}">{{ value }}</span>{% endif %}

View File

@ -386,12 +386,13 @@ def tag(tag, url_name=None):
@register.inclusion_tag('utilities/templatetags/badge.html')
def badge(value, show_empty=False):
def badge(value, bg_class='secondary', show_empty=False):
"""
Display the specified number as a badge.
"""
return {
'value': value,
'bg_class': bg_class,
'show_empty': show_empty,
}