87 lines
3.2 KiB
Plaintext
87 lines
3.2 KiB
Plaintext
{% doc %}
|
|
Renders one item of the storefront navigation.
|
|
|
|
Parent links with nested items include a submenu. The same markup is used
|
|
on desktop and mobile.
|
|
|
|
@param {string} title - Link label
|
|
@param {string} url - Link URL
|
|
@param {link[]} [child_links] - Nested links from a menu
|
|
@param {string} [child_menu] - Fallback items as `Label::/url`, separated by `|`
|
|
@param {boolean} [show_caret] - Shows a decorative caret when there are no child links
|
|
|
|
@example
|
|
{% render 'header-menu-item', title: link.title, url: link.url, child_links: link.links %}
|
|
{% enddoc %}
|
|
|
|
{% liquid
|
|
assign child_count = 0
|
|
assign manual_items = blank
|
|
|
|
if child_links != blank and child_links.size > 0
|
|
assign child_count = child_links.size
|
|
elsif child_menu != blank
|
|
assign manual_items = child_menu | strip | split: '|'
|
|
assign child_count = manual_items.size
|
|
endif
|
|
%}
|
|
|
|
<li class="header__item relative flex items-center self-stretch gap-2.5" data-menu-item>
|
|
<a
|
|
class="text-[16px] font-medium uppercase leading-none text-black no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-black"
|
|
href="{{ url }}"
|
|
>
|
|
{{ title }}
|
|
</a>
|
|
|
|
{% if child_count > 0 %}
|
|
<button
|
|
type="button"
|
|
class="header__caret-button grid size-[10px] shrink-0 cursor-pointer appearance-none items-center justify-center border-0 bg-transparent p-0"
|
|
data-submenu-toggle
|
|
aria-expanded="false"
|
|
aria-label="{{ 'header.submenu' | t: menu_title: title }}"
|
|
>
|
|
<span class="header__icon header__icon--caret" aria-hidden="true">
|
|
{{ 'icon-caret-down.svg' | inline_asset_content }}
|
|
</span>
|
|
</button>
|
|
<ul class="header__submenu absolute left-0 top-full z-30 m-0 hidden min-w-[260px] list-none bg-white px-5 py-4 shadow-[0_12px_40px_rgba(0,0,0,0.08)]">
|
|
{% if child_links != blank and child_links.size > 0 %}
|
|
{% for child in child_links %}
|
|
<li>
|
|
<a
|
|
class="block py-2 text-[14px] font-medium uppercase leading-none text-black no-underline hover:text-brand-ink focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-black"
|
|
href="{{ child.url }}"
|
|
>
|
|
{{ child.title }}
|
|
</a>
|
|
</li>
|
|
{% endfor %}
|
|
{% else %}
|
|
{% for item in manual_items %}
|
|
{% liquid
|
|
assign item_parts = item | split: '::'
|
|
assign item_title = item_parts[0] | strip
|
|
assign item_url = item_parts[1] | strip
|
|
%}
|
|
{% if item_title != blank %}
|
|
<li>
|
|
<a
|
|
class="block py-2 text-[14px] font-medium uppercase leading-none text-black no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-black"
|
|
href="{{ item_url }}"
|
|
>
|
|
{{ item_title }}
|
|
</a>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
</ul>
|
|
{% elsif show_caret %}
|
|
<span class="header__icon header__icon--caret" aria-hidden="true">
|
|
{{ 'icon-caret-down.svg' | inline_asset_content }}
|
|
</span>
|
|
{% endif %}
|
|
</li>
|