Skip to content
Snippets Groups Projects
Commit 770a7738 authored by Florent Torregrosa's avatar Florent Torregrosa
Browse files

Issue #3403816 by Grimreaper: Fix navbar text items.

parent d071a48c
No related branches found
No related tags found
1 merge request!193Resolve #3403816 "Simplify dark options"
Pipeline #194790 passed
......@@ -3,10 +3,28 @@
{% endif %}
{% set attributes = attributes.addClass('navbar-nav') %}
{% set list_opened = false %}
{% if items %}
<ul{{ attributes }}>
{% for item in items %}
{#
When finding a text item. it should be outside the list. So handle text
items by opening/closing lists around if needed.
#}
{% set item_is_link = false %}
{% if item.below or item.url %}
{% set item_is_link = true %}
{% endif %}
{% if item_is_link and not list_opened %}
{% set list_opened = true %}
<ul{{ attributes }}>
{% elseif not item_is_link and list_opened %}
{% set list_opened = false %}
</ul>
{% endif %}
{% set item_attributes = item.attributes|default(create_attribute()) %}
{% set link_attributes = item.link_attributes|default(create_attribute()) %}
{% if item.below %}
{{ pattern('dropdown', {
......@@ -20,15 +38,16 @@
}),
'button_attributes': link_attributes
}, 'dropdown') }}
{% else %}
<li{{ item.attributes.addClass('nav-item') }}>
{% if item.url %}
<a{{ link_attributes.setAttribute('href', item.url).addClass('nav-link') }}>{{ item.title }}</a>
{% else %}
<span{{ link_attributes }}>{{ item.title }}</span>
{% endif %}
{% elseif item.url %}
<li{{ item_attributes.addClass('nav-item') }}>
<a{{ link_attributes.setAttribute('href', item.url).addClass('nav-link') }}>{{ item.title }}</a>
</li>
{% else %}
<span{{ link_attributes.addClass('navbar-text') }}>{{ item.title }}</span>
{% endif %}
{% if loop.last and list_opened %}
</ul>
{% endif %}
{% endfor %}
</ul>
{% endif %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment