dsfr4drupal-1.x-dev/components/tag/tag.twig

components/tag/tag.twig
{% set attributes = attributes|default(create_attribute()) %}

{% if variant and variant != 'md' %}
  {% set attributes = attributes.addClass('fr-tag--' ~ variant) %}
{% endif %}

{% if not dismissible and icon %}
  {% set attributes = attributes.addClass('fr-icon-' ~ icon).addClass('fr-tag--icon-left') %}
{% endif %}

{% if url %}
  {% if color_schema %}
    {% set attributes = attributes.addClass('fr-tag--' ~ color_schema) %}
  {% endif %}

  {% if disabled %}
    {% set attributes = attributes.setAttribute('aria-disabled', 'true').setAttribute('role', 'link') %}
  {% else %}
    {% set attributes = attributes.setAttribute('href', url) %}
  {% endif %}

  <a{{ attributes.addClass('fr-tag') }}>
    {{ label }}
  </a>
{% else %}
  {% set tag = tag|default(attributes.hasAttribute('aria-pressed') or dismissible ? 'button' : 'p') %}

  {% if tag == 'button' %}
    {% set attributes = attributes.setAttribute('type', 'button') %}

    {% if disabled %}
      {% set attributes = attributes.setAttribute('disabled', true) %}
    {% endif %}

    {% if dismissible %}
      {% set attributes = attributes.addClass('fr-tag--dismiss').setAttribute('aria-label', 'Remove @label'|t({'@label': label})) %}
    {% endif %}
  {% endif %}

  <{{ tag }}{{ attributes.addClass('fr-tag') }}>
    {{ label }}
  </{{ tag }}>
{% endif %}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc