{#
/**
 * @file
 * Vartheme BS5 Starter Kit implementation for the Badge component.
 *
 * Available Properties:
 * - html_tag: The HTML tag to use for the badge. Defaults to span.
 * - color: Background and Text Color.Set a background-color with contrasting
 *          foreground color with our .text-bg-{color} helpers. Previously it
 *          was required to manually pair your choice of .text-{color}
 *          and .bg-{color} utilities for styling,
 *				  which you still may use if you prefer.
 *          (primary|secondary|success|info|warning|danger|light|dark)
 * - url: The HTML tag will automatically be set to a if an anchor is added to the URL.
 * - badge_utility_classes: An array of utility classes that can be used to add extra
 *                    Bootstrap utility classes or custom classes to this component.
 *
 * Available attributes
 * - N/A
 *
 * Available slots
 * - content: The content of the badge.
 */
#}
{% set html_tag = html_tag ?? 'span' %}
{% set color = color ? ['text-bg-' ~ color] : ['text-bg-secondary'] %}
{% set badge_utility_classes = badge_utility_classes ? badge_utility_classes : [] %}

{%
  set classes = [
    'badge',
  ]|merge(color)|merge(badge_utility_classes)
%}

{% if not attributes %}
  {% set attributes = create_attribute() %}
{% endif %}

{% if url %}
	{% set html_tag = 'a' %}
	{% set url = url|render %}
	{% set attributes = attributes.setAttribute('href', url) %}
{% endif %}

{% if content %}
	<{{html_tag}}{{ attributes.addClass(classes)}}">{% apply spaceless %}
		{% block content %}
			{{ content }}
		{% endblock %}
	{% endapply %}</{{html_tag}}>
{% endif %}
