{% sw_extends '@Storefront/storefront/component/buy-widget/configurator.html.twig' %}
{% block buy_widget_configurator_group %}
{% if (config('SelfdelveCms.config.configuratorCmsPageName') == page.cmsPage.name) %}
{# Group is expanded on mobile devices if non-default option is selected #}
{% set groupIsActive = false %}
{% for option in group.options %}
{% if loop.index > 1 and option.id in product.optionIds %}
{% set groupIsActive = true %}
{% endif %}
{% endfor %}
<div class="mb-3">
<div class="w-100 group-collapse-header">
<div class="d-flex justify-content-between align-items-center">
<div class="h4 m-0">
{% block buy_widget_configurator_group_title_text %}
{{ group.translated.name }}
{% endblock %}
</div>
<button type="button"
class="btn btn-link d-inline-block d-md-none {% if groupIsActive !== true %}collapsed{% endif %}"
data-toggle="collapse"
data-target="#group-{{ group.id }}"
aria-expanded="false"
>
<span class="group-collapse-plus">
{% sw_icon 'plus' %}
</span>
<span class="group-collapse-minus">
{% sw_icon 'minus' %}
</span>
</button>
</div>
</div>
<div class="collapse d-md-block group-collapse-content {% if groupIsActive === true %}show{% endif %}" id="group-{{ group.id }}">
<div class="row 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 %}
<div class="col-6 col-sm-4 col-md-3 col-lg-2">
<input type="radio"
name="{{ group.id }}"
value="{{ option.id }}"
class="product-detail-configurator-option-input{% if isCombinableCls %} {{ isCombinableCls }}{% endif %}"
title="{{ optionIdentifier }}"
id="{{ optionIdentifier }}"
{% if isActive %}checked="checked"{% endif %}>
<label class="m-0 product-detail-configurator-option-label{% if isCombinableCls %} {{ isCombinableCls }}{% endif %} is-display-{{ displayType }} overflow-hidden "
title="{{ option.translated.name }}"
for="{{ optionIdentifier }}"
>
{% if media %}
<span class="d-flex align-items-center w-100 overflow-hidden" style="height: 90px;">
{% sw_thumbnails 'configurator-option-img-thumbnails' with {
media: media,
sizes: {
'default': '200px'
},
attributes: {
'class': 'product-detail-configurator-option-image',
'alt': option.translated.name,
'title': option.translated.name
}
} %}
</span>
{% endif %}
</label>
<div class="pt-1 pb-3 product-detail-configurator-option-title text-center">{{ option.translated.name }}</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% else %}
{{ parent() }}
{% endif %}
{% endblock %}