{% set dropdown = type === 'dropdown' %}
{% set radio = type === 'radio' %}
{% set getParameter = app.request.query.get('size') %}
{% set buttonText = "tapBar.selectSizeLabel"|trans %}
{% if getParameter %}
{% set buttonText = getParameter %}
{% endif %}
{% if options is null %}
{% set options = page.product.children %}
{% endif %}
{% block custom_select_container %}
<section class="custom-select-container relative"
x-data="{show: false, value: null}"
{% if shopTheLook %} data-custom-variation-switch="false" {% else %}data-custom-variation-switch="true" {% endif %}>
{% if label %}
{% block custom_select_label %}
<div class="custom-select-label-container flex items-center mb-2">
<div class="flex items-center">
<label class="custom-select-label font-medium text-grey-600" for="{{ group.id }}">
{{ "tapBar.sizeLabel"|trans }}
</label>
<span x-text="value" class="font-accent font-bold text-sm ml-2 w-12"></span>
</div>
{# {% if sizeGuide %}#}
{# <a class="nav-link block ml-4 underline text-xs uppercase font-accent opacity-50 product-detail-tab-navigation-link"#}
{# id="size-guide-tab" data-toggle="tab" data-offcanvas-tabs="true" href="#size-guide-tab-pane"#}
{# role="tab"#}
{# aria-controls="size-guide-tab-pane" aria-selected="true">#}
{# {{ "tapBar.sizeGuideLabel"|trans }}#}
{# </a>#}
{# {% endif %}#}
</div>
{% endblock %}
{% endif %}
{% block custom_select_size_advise %}
{% if tapBar !== true %}
{% for properties in page.product.properties.elements %}
{% if properties.groupId == 'b511785c24a84c68b73e2a5b4846e479' %}
<div class="size-advice mt-3">
<i>{{ properties.name }}</i>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}
{% if dropdown %}
{% block custom_select_button %}
<button class="custom-select-button capitalize custom-select transition {% if product %}bg-white text-grey-600 border-grey-300{% endif %} {% if tapBar %}{% endif %} {% if shopTheLook %} pr-12 w-full lg:w-full {% endif %}"
type="button"
data-error-classes="border border-red-500 italic text-red-500"
@click="show = !show; $el.classList.remove('border', 'border-red-500', 'italic', 'text-red-500')"
:class="show ? 'active' : ''">
<span x-text="value == null ? '{{ buttonText }}' : value"
class="{% if shopTheLook %}shop-the-look-select-placeholder-text capitalize{% else %}custom-select-placeholder-text{% endif %}">
{% block custom_select_button_text %}
{{ buttonText }}
{% endblock %}
</span>
</button>
{% endblock %}
{% endif %}
{% block custom_select_options %}
<div {% if dropdown %}x-show="show"{% endif %}
@click.outside="show = false"
id="{{ group.id }}"
class="custom-select-options {% if radio %}flex flex-wrap gap-2{% endif %}{% if dropdown %}absolute left-0 right-0 bg-white shadow-md py-1 z-10 max-h-80 overflow-y-scroll bg-grey-200 {% if position == 'top' %}bottom-100{% else %}top-100{% endif %}{% endif %}">
{% for key, option in options %}
{% set name = option.options.elements|first.name %}
{% set outOfStock = option.stock <= 0 %}
{% set selected = false %}
{% if getParameter == name %}
{% set selected = true %}
{% elseif option.id in page.product.optionIds %}
{% set selected = true %}
{% endif %}
{% if outOfStock %}
{% continue %}
{% endif %}
{% block custom_select_option %}
<div class="custom-select-option">
<input type="radio"
class="{% if shopTheLook %}shop-the-look-select-option-radio{% else %}custom-select-option-radio{% endif %} hidden peer"
value="{{ key }}"
id="{{ name }}_{{ product.id }}"
data-friendlyname="{{ name }}"
@change="value = $el.dataset.friendlyname"
{% if selected %}checked="checked"{% endif %}
{% if outOfStock %}disabled{% endif %}
name="custom_select">
<label for="{{ name }}_{{ product.id }}"
@click="show = false"
title="{% if outOfStock %}{{ "tapBar.soldOutLabel"|trans }}{% else %}{{ name }}{% endif %}"
class="custom-select-option-label transition font-accent font-bold relative {% if not outOfStock %}cursor-pointer {% endif %}
{% if radio %}flex items-center justify-center w-12 h-12 bg-grey-50 border border-transparent rounded-sm peer-checked:border-grey-900{% if not outOfStock %} hover:border-grey-900{% endif %}{% endif %}
{% if dropdown %}block py-2 px-3 hover:bg-grey-200 peer-checked:bg-grey-200 {% endif %}
{% if selected %}bg-grey-200{% endif %}
{% if outOfStock %}text-grey-500 cursor-default {% if radio %}bg-red-100{% endif %}{% endif %}
">
{{ name }}
{% if outOfStock %}
{% if dropdown %}
<span class="out-of-stock-label"> - {{ "tapBar.soldOutLabel"|trans }}</span>
{% elseif radio %}
<span class="out-of-stock-icon w-full h-px bg-grey-700 absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rotate-45"></span>
{% endif %}
{% endif %}
</label>
</div>
{% endblock %}
{% endfor %}
</div>
{% endblock %}
<span class="absolute text-red-500 text-xs italic{% if dropdown %} bottom-100{% elseif radio %} top-100 mt-1{% endif %}"
data-error-message="Selecteer een maat" style="display: none"
aria-hidden="true"></span>
</section>
{% endblock %}