{% macro item(taxon, lvl) %}
    {% import _self as macros %}

    <li {% if taxon.children|length > 0 %}class="has-submenu"{% endif %}>

        <div class="menu-title title-menu-lvl{{ lvl }}">
            <a class="menu-link" href="{{ path('sylius_shop_product_index', {'slug': taxon.slug, '_locale': taxon.translation.locale}) }}" {{ sylius_test_html_attribute('menu-item') }}>
                {{ taxon.name }}
            </a>
            {% if taxon.children|length > 0 %}
                <span class="menu-link-icon"></span>
            {% endif %}
        </div>

        {% if taxon.children|length > 0 %}
            <div class="menu-block">
                <div class="container">
                    <div class="menu-back">
                        <span class="menu-back-icon"></span>
                        <span class="menu-back-link">
                            {{ taxon.name }}
                        </span>
                    </div>
                    <ul class="menu-lvl{{ lvl+1 }}">
                        {% for childTaxon in taxon.children %}
                            {{ macros.item(childTaxon, lvl+1) }}
                        {% endfor %}
                    </ul>
                    <a class="menu-link menu-see-all" href="{{ path('sylius_shop_product_index', {'slug': taxon.slug, '_locale': taxon.translation.locale}) }}">
                        {{ 'app.ui.menu.see_all'|trans }}
                        {% include '@SyliusShop/Icons/arrow.html.twig' %}
                    </a>
                </div>
            </div>
        {% endif %}
    </li>

{% endmacro %}

{% import _self as macros %}

{% if taxons|length > 0 %}
<ul class="main-menu menu-lvl1" {{ sylius_test_html_attribute('menu') }}>
    {% for taxon in taxons %}
        {{ macros.item(taxon, 1) }}
    {% endfor %}
</ul>
{% endif %}
