{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_spinners') }}

{# VARIABLES #}
{% set spinner_type = spinner_type|default('border') %}
{% set status = status|default('default') %}
{% set loading = loading|default('Loading...') %}
{% set show_text = show_text|default(false) %}
{% set size = size|default('nm') %}
{% set hide = hide|default(false) %}
{% set ajax = ajax|default(false) %}
{% set elem = elem|default('div') %}

{% if ajax %}
  {% set size = 'sm' %}
  {% set hide = true %}
  {% set elem = 'span' %}
{% endif %}

{# TEMPLATE #}
<{{ elem }} class="spinner spinner-{{ spinner_type }} spinner-{{ spinner_type }}-{{ size }} text-{{ status }} {{ hide ? 'spin-hide' }}" role="status">
  {% if not show_text %}
    <span class="sr-only">{{ loading }}</span>
  {% endif %}
</{{ elem }}>
{% if show_text %}
  <span class="loading-text">{{ loading }}</span>
{% endif %}
