{% extends '@nucleus/partials/particle.html.twig' %}

{% block stylesheets %}
{% if particle.particle_title_color or particle.particle_title_fontsize or particle.title_color or particle.title_link_color or particle.title_link_hover_color or particle.title_fontsize %}
<style>
{% if particle.particle_title_color or particle.particle_title_fontsize %}
#{{ id }}.g5-particle-title { {% if particle.particle_title_color %}color: {{ particle.particle_title_color }};{% endif %}{% if particle.particle_title_fontsize %}font-size: {{particle.particle_title_fontsize}}px;{% endif %} }
{% endif %}
{% if particle.contact_style == 'subnav' %}
{% if particle.title_fontsize %}#{{ id }} .jl-subnav>*>:first-child {font-size: {{ particle.title_fontsize|default('15')|e }}px;text-transform: none;}{% endif %}
{% if particle.title_color %}#{{ id }} .jl-subnav>*>:first-child {color: {{ particle.title_color|e }};}{% endif %}
{% if particle.title_link_hover_color %}
#{{ id }} .jl-subnav>*>a:focus,#{{ id }} .jl-subnav>*>a:hover {color: {{ particle.title_link_hover_color|e }};}
{% endif %}
{% endif %}
{% if particle.contact_style == 'default' %}
{% if particle.title_color %}#{{ id }} {color: {{ particle.title_color|e }};}{% endif %}
{% if particle.title_link_color %}
#{{ id }} a {color: {{ particle.title_color|e }};}
{% endif %}
{% if particle.title_link_hover_color %}
#{{ id }} a:hover,#{{ id }} a:focus,#{{ id }} a:active {color: {{ particle.title_link_hover_color|e }};}
{% endif %}
{% endif %}
</style>
{% endif %}
{% endblock %}

{# Set Animation #}
{% set animation %}
{% if particle.animation != 'inherit' %} jl-scrollspy="cls: jl-animation-{{particle.animation|e}};{% if particle.animation_repeat == 'enabled' %} repeat: true;{% endif %}{% if particle.animation_delay %} delay: {{particle.animation_delay|e}};{% endif %}"{% endif %}
{% endset %}

{# Set Max-Width Content #}
{% set content_maxwidth %}
{% if particle.g_maxwidth != 'inherit' %} jl-width-{{particle.g_maxwidth}}{% if particle.g_maxwidth_breakpoint != 'always' %}@{{particle.g_maxwidth_breakpoint}}{% endif %}{% if particle.g_maxwidth_alignment == 'left' %}{% elseif particle.g_maxwidth_alignment == 'center' %} jl-margin-auto{% else %} jl-margin-auto-left{% endif %}{% endif %}
{% endset %}

{# Set Particle Alignment #}
{% set particle_alignment %}
{% if particle.align != 'inherit' %} jl-text-{{particle.align|e}}{% if particle.breakpoint != 'always' %}@{{particle.breakpoint|e}}{% endif %}{% endif %}{% if particle.align != 'inherit' and particle.breakpoint != 'always' %} {% if particle.fallback != 'inherit' %} jl-text-{{particle.fallback|e}}{% endif %}{% endif %}
{% endset %}

{# Set Particle Subnav Alignment #}
{% set subnav_alignment %}
{% if particle.align != 'inherit' %} jl-flex-{{particle.align|e}}{% if particle.breakpoint != 'always' %}@{{particle.breakpoint|e}}{% endif %}{% endif %}{% if particle.align != 'inherit' and particle.breakpoint != 'always' %} {% if particle.fallback != 'inherit' %} jl-flex-{{particle.fallback|e}}{% endif %}{% endif %}
{% endset %}

{# set Particle Title Style #}
{% set particle_title_style %}
{% if particle.particle_title %}
<{{particle.particle_title_element|e}} id="{{ id }}" class="g5-particle-title{% if particle.particle_title_align != 'inherit' %} jl-text-{{particle.particle_title_align|e}}{% endif %}{% if particle.particle_predefined_color != 'default' %} jl-text-{{particle.particle_predefined_color|e}}{% endif %}{% if particle.particle_title_style != 'default' %} jl-{{particle.particle_title_style|e}}{% endif %}{% if particle.particle_title_decoration != 'none' %} jl-heading-{{particle.particle_title_decoration|e}}{% endif %}">
{% if particle.particle_title_decoration == 'line' %} <span>{{particle.particle_title|raw}}</span>
{% else %} {{particle.particle_title|raw}}
{% endif %}
</{{particle.particle_title_element|e}}>
{% endif %}
{% endset %}

{% set grid_column_gap = particle.grid_column_gap != 'default' ? ' jl-grid-column-' ~ particle.grid_column_gap ~ '' %}

{# Set Item Content #}
{% set item_content %}
{% set total = particle.items|length %}

{% if particle.contact_style == 'default' %}
{% if total > 1 %}
<div class="jl-flex-middle{{grid_column_gap}}{{subnav_alignment}}" jl-grid>
{% else %}
<div class="tm-item{{particle_alignment}}">
{% endif %}

{% for item in particle.items %}
{% if total > 1 %}
<div class="tm-item{% if item.item_class %} {{ item.item_class }}{% endif %}">
{% endif %}
{% if item.link %}
<a href="{{ item.link|e }}" target="{{ item.link_target|default('_self')|e }}">
{% endif %}
{% if item.icon %}<span class="{{item.icon}}" aria-hidden="true"></span> {% endif %}
{{item.title|raw}}
{% if item.link %}
</a>
{% endif %}
{% if total > 1 %}
</div>
{% endif %}
{% endfor %}

</div>

{% else %}
<ul class="jl-subnav jl-margin-remove-bottom{% if particle.subnav_style != 'default' %} jl-subnav-{{particle.subnav_style}}{% endif %}{{subnav_alignment}}" jl-margin>
{% for item in particle.items %}
<li class="tm-item{% if item.item_class %} {{ item.item_class }}{% endif %}">
{% if item.link %}
<a href="{{ item.link|e }}" target="{{ item.link_target|default('_self')|e }}">
{% else %}
<span>
{% endif %}
{% if item.icon %}<span class="{{item.icon}}" aria-hidden="true"> </span> {% endif %}
{{item.title|raw}}
{% if item.link %}
</a>
{% else %}
</span>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}

{% endset %}

{% block particle %}
{% if particle.enabled %}
{{particle_title_style}}
<div id="{{ id }}" class="subnav-wrapper{{content_maxwidth}}{% if particle.class %} {{ particle.class }}{% endif %}{% if particle.margin == 'inherit' %}{% elseif particle.margin == 'default' %} jl-margin{% else %} jl-margin-{{particle.margin|e}}{% endif %}{% if particle.visibility != 'inherit' %} jl-visible@{{particle.visibility|e}}{% endif %}"{{animation}}>
    {{item_content}}
</div>
{% endif %}
{% endblock %}
