{#
/**
 * @file
 * Theme override for a local task link.
 *
 * Available variables:
 * - attributes: HTML attributes for the wrapper element.
 * - is_active: Whether the task item is an active tab.
 * - link: A rendered link element.
 *
 * Note: This template renders the content for each task item in
 * menu-local-tasks.html.twig.
 *
 * @see template_preprocess_menu_local_task()
 */
#}

{%
  set classes = [
    'solo-button',
    'task-local',
    is_active ? 'is-active',
  ]
%}
{% set route_name = element['#link']['url'].getRouteName() %}

{# Determine and add a specific class based on the route name #}
{% if route_name == 'entity.node.canonical' %}
  {% set classes = classes|merge(['core-task view-task']) %}
  {% set icon_include = '@solo/partials/svg/_view-icon.html.twig' %}
{% elseif route_name == 'entity.node.edit_form' %}
  {% set classes = classes|merge(['core-task edit-task']) %}
  {% set icon_include = '@solo/partials/svg/_edit-icon.html.twig' %}
{% elseif route_name == 'entity.node.delete_form' %}
  {% set classes = classes|merge(['core-task delete-task']) %}
  {% set icon_include = '@solo/partials/svg/_delete-icon.html.twig' %}
{% elseif route_name == 'entity.node.version_history' %}
  {% set classes = classes|merge(['core-task revisions-task']) %}
  {% set icon_include = '@solo/partials/svg/_revisions-icon.html.twig' %}
{% else %}
  {% set icon_include = '' %}
{% endif %}

<li{{ attributes.addClass(classes) }}>
  {{ link }}
  {% if icon_include %}
    {% include icon_include %}
  {% endif %}
</li>
