Refatora CSS e templates do menu estrutural

Reescreve structural-pages-menu.css com layout horizontal como padrão
(análogo ao microsite-nav) e flyout lateral apenas em contexto sidebar.
Extrai renderização de itens para structural-pages-menu-item.html.twig
e adiciona link "Home" apontando para a URL do ancestral.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 09:54:44 -03:00
parent 072e64b771
commit 724f1336d0
3 changed files with 236 additions and 112 deletions

View File

@@ -5,64 +5,31 @@
*
* Available variables:
* - ancestor: The ancestor entity (term, user, or group).
* - ancestor_url: The ancestor URL string.
* - tree: Array of menu tree items, each containing:
* - id: Node ID.
* - title: Node title.
* - url: Node URL.
* - is_redirect: Whether the link is a redirect.
* - depth: Current depth level.
* - children: Array of child items.
* - entity: The node entity.
* - children: Array of child items (same structure).
* - active_trail: Array of node IDs in the active trail.
* - show_ancestor_title: Whether to show the ancestor title as header.
*/
#}
{{ attach_library('structural_pages/menu') }}
{% if tree is not empty %}
<nav class="block-menu navigation structural-pages-menu" aria-label="{{ 'Site structure navigation'|t }}">
{% if show_ancestor_title and ancestor %}
<h2 class="structural-pages-menu__title block-title">
<span>
{% if ancestor_url %}
<a href="{{ ancestor_url }}">{{ ancestor.label }}</a>
{% else %}
{{ ancestor.label }}
{% endif %}
</span>
</h2>
{% endif %}
<div class="block-content">
<ul class="gva_menu structural-pages-menu__list structural-pages-menu__list--level-1">
{% if ancestor_url %}
<li class="menu-item structural-pages-menu__item structural-pages-menu__item--level-1">
<a href="{{ ancestor_url }}" class="structural-pages-menu__link">{{ 'Home'|t }}</a>
</li>
{% endif %}
{% for item in tree %}
{{ _self.menu_item(item, active_trail, 1) }}
{% include '@structural_pages/structural-pages-menu-item.html.twig' with {'item': item, 'active_trail': active_trail, 'depth': 1} only %}
{% endfor %}
</ul>
</div>
</nav>
{% endif %}
{% macro menu_item(item, active_trail, depth) %}
{% set is_active = item.id in active_trail %}
{% set has_children = item.children is not empty %}
{% set classes = [
'menu-item',
'structural-pages-menu__item',
'structural-pages-menu__item--level-' ~ depth,
is_active ? 'menu-item--active-trail structural-pages-menu__item--active-trail',
has_children ? 'menu-item--expanded structural-pages-menu__item--has-children',
] %}
<li{{ create_attribute().addClass(classes) }}>
<a href="{{ item.url }}"{% if item.is_redirect %} target="_blank"{% endif %} class="structural-pages-menu__link{% if is_active %} is-active structural-pages-menu__link--active-trail{% endif %}">
{{- item.title -}}
</a>
{% if has_children %}
<ul class="menu sub-menu structural-pages-menu__list structural-pages-menu__list--level-{{ depth + 1 }}">
{% for child in item.children %}
{{ _self.menu_item(child, active_trail, depth + 1) }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}