{% sw_extends '@Storefront/storefront/component/buy-widget/configurator.html.twig' %}
{% block buy_widget_configurator %}
<div class="product-detail-configurator">
{% if elementId is defined and elementId is not null and pageType != 'product_detail' %}
{% set config = {
url: url('frontend.cms.buybox.switch', { productId: product.parentId }),
elementId: elementId,
pageType: pageType
} %}
{% else %}
{% set config = {
url: url('frontend.detail.switch', { productId: product.parentId }),
pageType: pageType
} %}
{% endif %}
{% block buy_widget_configurator_form %}
<form data-variant-switch="true" data-variant-switch-options="{{ config|json_encode }}"
class="grid grid-gap-2">
{# @deprecated tag:v6.5.0 - Block buy_widget_configurator_csrf will be removed. #}
{% block buy_widget_configurator_csrf %}
{% if elementId is defined and elementId is not null %}
{{ sw_csrf('frontend.cms.buybox.switch') }}
{% else %}
{{ sw_csrf('frontend.detail.switch') }}
{% endif %}
{% endblock %}
{% block buy_widget_configurator_groups %}
{% for group in configuratorSettings %}
{% block buy_widget_configurator_group %}
<div class="product-detail-configurator-group">
{% if group.displayType == 'select' %}
{% sw_include '@Storefront/storefront/page/product-detail/configurator/select.html.twig' %}
{% else %}
{% block buy_widget_configurator_group_title %}
<div class="product-detail-configurator-group-title flex uppercase text-sm grey-600">
<div class="text-grey-600 font-medium">
{% block buy_widget_configurator_group_title_text %}
{{ group.translated.name }}
{% endblock %}
</div>
{% for option in group.options %}
{% if option.id in product.optionIds %}
<div class="configurator-selected-item ml-2 font-bold grey-900">
{{ option.translated.name }}
</div>
{% endif %}
{% endfor %}
</div>
{% endblock %}
{% block buy_widget_configurator_options %}
<div class="product-detail-configurator-options flex flex-wrap grid-gap-3 mt-2">
{% for option in group.options %}
{% if elementId is defined and elementId is not null %}
{% set optionIdentifier = [group.id, option.id, elementId]|join('-') %}
{% else %}
{% set optionIdentifier = [group.id, option.id]|join('-') %}
{% endif %}
{% set isActive = false %}
{% set isCombinableCls = 'is-combinable' %}
{% if option.id in product.optionIds %}
{% set isActive = true %}
{% endif %}
{% if not option.combinable %}
{% set isCombinableCls = false %}
{% endif %}
{% if option.configuratorSetting.media %}
{% set displayType = 'media' %}
{% set media = option.configuratorSetting.media %}
{% else %}
{% set displayType = group.displayType %}
{% if option.media %}
{% set media = option.media %}
{% else %}
{% set media = false %}
{% endif %}
{% endif %}
{% block buy_widget_configurator_option %}
<div class="product-detail-configurator-option">
{% block buy_widget_configurator_option_radio %}
<input type="radio"
name="{{ group.id }}"
value="{{ option.id }}"
class="product-detail-configurator-option-input peer hidden{% if isCombinableCls %} {{ isCombinableCls }}{% endif %}"
title="{{ optionIdentifier }}"
id="{{ optionIdentifier }}"
{% if isActive %}checked="checked"{% endif %}>
{% block buy_widget_configurator_option_radio_label %}
<label class="product-detail-configurator-option-label block px-4 py-2 transition rounded-sm bg-white border border-grey-300 text-grey-600 cursor-pointer hover:border-white outline outline-2 outline-transparent hover:outline-teal-400 outline-offset-2 peer-checked:bg-green-50 peer-checked:border-white peer-checked:outline-teal-400 peer-checked:text-grey-800 hover:bg-green-50{% if isCombinableCls %} {{ isCombinableCls }}{% endif %} is-display-{{ displayType }}"
{% if displayType == 'color' and option.colorHexCode %}
style="background-color: {{ option.colorHexCode }}"
{% endif %}
title="{{ option.translated.name }}"
for="{{ optionIdentifier }}">
{% if displayType == 'media' and media %}
{% block buy_widget_configurator_option_radio_label_media %}
{% sw_thumbnails 'configurator-option-img-thumbnails' with {
media: media,
sizes: {
'default': '52px'
},
attributes: {
'class': 'product-detail-configurator-option-image',
'alt': option.translated.name,
'title': option.translated.name
}
} %}
{% endblock %}
{% elseif displayType == 'text' or
(displayType == 'media' and not media) or
(displayType == 'color' and not option.colorHexCode) %}
{% block buy_widget_configurator_option_radio_label_text %}
{{ option.translated.name }}
{% endblock %}
{% endif %}
</label>
{% endblock %}
{% endblock %}
</div>
{% endblock %}
{% endfor %}
</div>
{% endblock %}
{% endif %}
</div>
{% endblock %}
{% endfor %}
{% endblock %}
</form>
{% endblock %}
</div>
{% endblock %}