{%- liquid assign block_settings = block.settings for product_option in closest.product.options_with_values assign swatch_count = product_option.values | map: 'swatch' | compact | size if swatch_count > 0 assign product_has_swatches = true endif endfor -%} {% stylesheet %} product-swatches { width: 100%; display: flex; position: relative; overflow: hidden; gap: 0; flex-shrink: 0; } {% endstylesheet %} {% if product_has_swatches %} {% render 'variant-swatches', product_resource: closest.product %} {% endif %} {% schema %} { "name": "t:names.swatches", "tag": null, "settings": [ { "type": "paragraph", "content": "t:content.resource_reference_product_swatches" }, { "type": "select", "id": "product_swatches_alignment", "label": "t:settings.alignment", "options": [ { "value": "flex-start", "label": "t:options.direction_start" }, { "value": "center", "label": "t:options.direction_center" }, { "value": "flex-end", "label": "t:options.direction_end" } ], "default": "flex-start" }, { "type": "select", "id": "product_swatches_alignment_mobile", "label": "t:settings.alignment_mobile", "options": [ { "value": "flex-start", "label": "t:options.direction_start" }, { "value": "center", "label": "t:options.direction_center" }, { "value": "flex-end", "label": "t:options.direction_end" } ], "default": "flex-start" }, { "type": "header", "content": "t:content.padding", "visible_if": "{{ block.settings.hide_padding == false }}" }, { "type": "checkbox", "id": "hide_padding", "label": "t:settings.hide_padding", "default": false, "visible_if": "{{ false }}" }, { "type": "range", "id": "product_swatches_padding_top", "label": "t:settings.top", "min": 0, "max": 50, "step": 1, "unit": "px", "default": 4, "visible_if": "{{ block.settings.hide_padding == false }}" }, { "type": "range", "id": "product_swatches_padding_bottom", "label": "t:settings.bottom", "min": 0, "max": 50, "step": 1, "unit": "px", "default": 0, "visible_if": "{{ block.settings.hide_padding == false }}" }, { "type": "range", "id": "product_swatches_padding_left", "label": "t:settings.left", "min": 0, "max": 50, "step": 1, "unit": "px", "default": 0, "visible_if": "{{ block.settings.hide_padding == false }}" }, { "type": "range", "id": "product_swatches_padding_right", "label": "t:settings.right", "min": 0, "max": 50, "step": 1, "unit": "px", "default": 0, "visible_if": "{{ block.settings.hide_padding == false }}" } ], "presets": [ { "name": "t:names.swatches", "category": "t:categories.product" } ] } {% endschema %}