Files
myep-team/templates/_partials/_tabs.html.twig
T

24 lines
1.5 KiB
Twig

{#
Renders a KnpMenu as the back link and a row of tabs above the content, for the sections of one
record (AdminMenuBuilder::createTeamerMenu()). Dividers are skipped; the item marked `back` by
AbstractMenuBuilder::addBackItem() becomes the link above the tabs.
#}
{% block root %}
{% set back = item.children|filter(child => child.extras.back is defined)|first %}
{% if back %}
<a href="{{ back.uri }}" class="inline-flex items-center gap-x-1 pb-4 text-sm font-bold text-brand hover:text-brand-dark">
{{ icon('arrow-left', 'w-4 h-4 shrink-0') }}
<span>{{ back.label|raw }}</span>
</a>
{% endif %}
<nav aria-label="Bereiche" class="flex overflow-x-auto border-b border-line mb-8">
{% for child in item.children|filter(child => child.displayed and child.extras.divider is not defined and child.extras.back is not defined) %}
{# by route name: the items carry the return url, which the matcher would compare as well #}
{% set current = child.extras.routes|default([])|filter(r => r.route is defined and r.route == app.request.attributes.get('_route'))|length > 0 %}
<a href="{{ child.uri }}"
class="{{ html_classes('-mb-px shrink-0 whitespace-nowrap border-b-4 px-3 py-2 text-sm', { 'border-brand-bright font-bold text-brand': current, 'border-transparent text-ink hover:text-brand': not current }) }}"
{% if current %}aria-current="page"{% endif %}>{{ child.label|raw }}</a>
{% endfor %}
</nav>
{% endblock %}