

{% liquid
  if section.settings.collection_list != blank
    assign section_collections = section.settings.collection_list
    assign max_items = section.settings.collection_list.count
  elsif section.settings.layout_type == 'editorial'
    assign max_items = section.settings.max_collections
  elsif section.settings.layout_type == 'bento'
    assign max_items = 4
  elsif section.settings.layout_type == 'carousel'
    assign max_items = section.settings.columns | plus: 2
  elsif section.settings.layout_type == 'grid'
    assign max_items = section.settings.columns
  endif
%}

<div class="section-background color-{{ section.settings.color_scheme }}"></div>

<div
  class="
    section
    section--{{ section.settings.section_width }}
    color-{{ section.settings.color_scheme }}
    section-resource-list
    spacing-style
    gap-style
  "
  style="
    {% render 'spacing-style', settings: section.settings %}
    {% render 'gap-style', value: section.settings.gap %}
  "
  data-testid="collection-list"
>
  <div class="section-resource-list__content">
    {%- content_for 'blocks' -%}
  </div>

  {% if section_collections == null %}
    {% for i in (1..max_items) %}
      {% assign section_collections = section_collections | append: ', ' %}
    {% endfor %}

    {% assign section_collections = section_collections | split: ',' %}
  {% endif %}

  {% capture list_items %}
    {% for collection in section_collections limit: max_items %}
      <div class="resource-list__item">
        {% content_for 'block', type: '_collection-card', id: 'static-collection-card', closest.collection: collection %}
      </div>
      {% unless forloop.last %}
        <!--@list/split-->
      {% endunless %}
    {% endfor %}
  {% endcapture %}

  {% liquid
    # Create an array from the list items to be used for different layout types
    assign list_items_array = list_items | strip | split: '<!--@list/split-->'
  %}

  {% render 'resource-list',
    list_items: list_items,
    list_items_array: list_items_array,
    settings: section.settings,
    carousel_ref: 'collectionList',
    slide_count: max_items,
    content_type: 'collections',
    test_id: 'collections-list-grid'
  %}
</div>

{% schema %}
{
  "name": "t:names.collection_list",
  "class": "ui-test-collection-list",
  "blocks": [
    {
      "type": "@theme"
    },
    {
      "type": "@app"
    },
    {
      "type": "text"
    },
    {
      "type": "icon"
    },
    {
      "type": "image"
    },
    {
      "type": "button"
    },
    {
      "type": "video"
    },
    {
      "type": "group"
    },
    {
      "type": "spacer"
    },
    {
      "type": "_divider"
    }
  ],
  "disabled_on": {
    "groups": ["header", "footer"]
  },
  "settings": [
    {
      "type": "collection_list",
      "id": "collection_list",
      "label": "t:settings.collection_list"
    },
    {
      "type": "header",
      "content": "t:content.cards_layout"
    },
    {
      "type": "select",
      "id": "layout_type",
      "label": "t:settings.layout_type",
      "options": [
        {
          "value": "grid",
          "label": "t:options.grid"
        },
        {
          "value": "carousel",
          "label": "t:options.carousel"
        },
        {
          "value": "bento",
          "label": "t:options.bento"
        },
        {
          "value": "editorial",
          "label": "t:options.editorial"
        }
      ],
      "default": "grid"
    },
    {
      "type": "checkbox",
      "id": "carousel_on_mobile",
      "label": "t:settings.carousel_on_mobile",
      "default": false,
      "visible_if": "{{ section.settings.layout_type != 'carousel' }}"
    },
    {
      "type": "range",
      "id": "columns",
      "label": "t:settings.columns",
      "min": 1,
      "max": 8,
      "step": 1,
      "default": 4,
      "visible_if": "{{ section.settings.layout_type == 'grid' or section.settings.layout_type == 'carousel' }}"
    },
    {
      "type": "select",
      "id": "mobile_columns",
      "label": "t:settings.mobile_columns",
      "options": [
        {
          "value": "1",
          "label": "t:options.one_number"
        },
        {
          "value": "2",
          "label": "t:options.two_number"
        }
      ],
      "default": "2",
      "visible_if": "{{ section.settings.layout_type == 'grid' and section.settings.carousel_on_mobile == false }}"
    },
    {
      "type": "select",
      "id": "mobile_card_size",
      "label": "t:settings.mobile_columns",
      "options": [
        {
          "value": "60cqw",
          "label": "t:options.one_number"
        },
        {
          "value": "44cqw",
          "label": "t:options.two_number"
        }
      ],
      "default": "60cqw",
      "visible_if": "{{ section.settings.layout_type == 'carousel' or section.settings.carousel_on_mobile == true }}"
    },
    {
      "type": "range",
      "id": "columns_gap",
      "label": "t:settings.horizontal_gap",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "default": 8,
      "visible_if": "{{ section.settings.layout_type == 'grid' or section.settings.layout_type == 'carousel' }}"
    },
    {
      "type": "range",
      "id": "bento_gap",
      "label": "t:settings.gap",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "default": 8,
      "visible_if": "{{ section.settings.layout_type == 'bento' }}"
    },
    {
      "type": "range",
      "id": "rows_gap",
      "label": "t:settings.vertical_gap",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "default": 8,
      "visible_if": "{{ section.settings.layout_type == 'grid'}}"
    },
    {
      "type": "range",
      "id": "max_collections",
      "label": "t:settings.collection_count",
      "min": 1,
      "max": 16,
      "step": 1,
      "default": 4,
      "visible_if": "{{ section.settings.layout_type == 'editorial' }}"
    },
    {
      "type": "header",
      "content": "t:content.carousel_navigation",
      "visible_if": "{{ section.settings.layout_type == 'carousel' or section.settings.carousel_on_mobile == true }}"
    },
    {
      "type": "select",
      "id": "icons_style",
      "label": "t:settings.icon",
      "options": [
        {
          "value": "arrow",
          "label": "t:options.arrows"
        },
        {
          "value": "chevron",
          "label": "t:options.chevrons"
        },
        {
          "value": "arrows_large",
          "label": "t:options.arrows_large"
        },
        {
          "value": "chevron_large",
          "label": "t:options.chevron_large"
        },
        {
          "value": "none",
          "label": "t:options.none"
        }
      ],
      "default": "arrow",
      "visible_if": "{{ section.settings.layout_type == 'carousel' or section.settings.carousel_on_mobile == true }}"
    },
    {
      "type": "select",
      "id": "icons_shape",
      "label": "t:settings.icon_background",
      "options": [
        {
          "value": "none",
          "label": "t:options.none"
        },
        {
          "value": "circle",
          "label": "t:options.circle"
        },
        {
          "value": "square",
          "label": "t:options.square"
        }
      ],
      "default": "none",
      "visible_if": "{{ section.settings.icons_style != 'none' and section.settings.layout_type == 'carousel' or section.settings.carousel_on_mobile == true }}"
    },
    {
      "type": "header",
      "content": "t:content.section_layout"
    },
    {
      "type": "select",
      "id": "section_width",
      "label": "t:settings.width",
      "options": [
        {
          "value": "page-width",
          "label": "t:options.page"
        },
        {
          "value": "full-width",
          "label": "t:options.full"
        }
      ],
      "default": "page-width"
    },
    {
      "type": "range",
      "id": "gap",
      "label": "t:settings.gap",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "default": 12
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:settings.color_scheme",
      "default": "scheme-1"
    },
    {
      "type": "header",
      "content": "t:content.padding"
    },
    {
      "type": "range",
      "id": "padding-block-start",
      "label": "t:settings.top",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "default": 0
    },
    {
      "type": "range",
      "id": "padding-block-end",
      "label": "t:settings.bottom",
      "min": 0,
      "max": 100,
      "step": 1,
      "unit": "px",
      "default": 0
    }
  ],
  "presets": [
    {
      "name": "t:names.collections_bento",
      "category": "t:categories.collections",
      "settings": {
        "layout_type": "bento",
        "bento_gap": 8,
        "section_width": "page-width",
        "carousel_on_mobile": false,
        "padding-block-start": 24,
        "padding-block-end": 24
      },
      "blocks": {
        "group_Lg9LkF": {
          "type": "group",
          "name": "t:names.header",
          "settings": {
            "content_direction": "column",
            "vertical_on_mobile": true,
            "horizontal_alignment": "flex-start",
            "vertical_alignment": "center",
            "horizontal_alignment_flex_direction_column": "flex-start",
            "vertical_alignment_flex_direction_column": "center",
            "gap": 16,
            "width": "fill",
            "custom_width": 100,
            "width_mobile": "fill",
            "custom_width_mobile": 100,
            "height": "fit",
            "custom_height": 100,
            "inherit_color_scheme": true,
            "color_scheme": "",
            "background_media": "none",
            "video_position": "cover",
            "background_image_position": "cover",
            "border": "none",
            "border_width": 1,
            "border_opacity": 100,
            "border_radius": 0,
            "padding-block-start": 0,
            "padding-block-end": 0,
            "padding-inline-start": 0,
            "padding-inline-end": 0
          },
          "blocks": {
            "text_bc98Wh": {
              "type": "text",
              "name": "t:names.text",
              "settings": {
                "text": "t:html_defaults.shop_by_collection",
                "type_preset": "rte",
                "font": "var(--font-body--family)",
                "font_size": "",
                "line_height": "normal",
                "letter_spacing": "normal",
                "case": "none",
                "wrap": "pretty",
                "width": "fit-content",
                "max_width": "normal",
                "alignment": "left",
                "padding-block-start": 0,
                "padding-block-end": 16,
                "padding-inline-start": 0,
                "padding-inline-end": 0
              }
            }
          },
          "block_order": ["text_bc98Wh"]
        },
        "static-collection-card": {
          "type": "_collection-card",
          "name": "t:names.collection_card",
          "static": true,
          "settings": {
            "horizontal_alignment": "flex-start",
            "vertical_alignment": "flex-end",
            "placement": "on_image",
            "inherit_color_scheme": true,
            "color_scheme": "",
            "border": "none",
            "border_width": 1,
            "border_opacity": 100,
            "border_radius": 0
          },
          "blocks": {
            "collection-card-image": {
              "type": "_collection-card-image",
              "name": "t:names.collection_card_image",
              "static": true,
              "settings": {
                "image_ratio": "adapt"
              }
            },
            "collection-title": {
              "type": "collection-title",
              "name": "t:names.collection_title",
              "settings": {
                "type_preset": "rte",
                "font": "var(--font-body--family)",
                "font_size": "",
                "line_height": "normal",
                "letter_spacing": "normal",
                "case": "none",
                "wrap": "pretty",
                "width": "fit-content",
                "max_width": "normal",
                "alignment": "left",
                "background": true,
                "background_color": "#ffffff",
                "padding-block-start": 4,
                "padding-block-end": 4,
                "padding-inline-start": 8,
                "padding-inline-end": 8
              }
            }
          },
          "block_order": ["collection-title"]
        }
      },
      "block_order": ["group_Lg9LkF"]
    },
    {
      "name": "t:names.collections_grid",
      "category": "t:categories.collections",
      "blocks": {
        "group_Lg9LkF": {
          "type": "group",
          "name": "t:names.header",
          "settings": {
            "content_direction": "column",
            "vertical_on_mobile": true,
            "horizontal_alignment": "flex-start",
            "vertical_alignment": "center",
            "horizontal_alignment_flex_direction_column": "flex-start",
            "vertical_alignment_flex_direction_column": "center",
            "gap": 12,
            "width": "fill",
            "custom_width": 100,
            "width_mobile": "fill",
            "custom_width_mobile": 100,
            "height": "fit",
            "custom_height": 100,
            "inherit_color_scheme": true,
            "color_scheme": "",
            "background_media": "none",
            "video_position": "cover",
            "background_image_position": "cover",
            "border": "none",
            "border_width": 1,
            "border_opacity": 100,
            "border_radius": 0,
            "padding-block-start": 0,
            "padding-block-end": 0,
            "padding-inline-start": 0,
            "padding-inline-end": 0
          },
          "blocks": {
            "text_bc98Wh": {
              "type": "text",
              "name": "t:names.text",
              "settings": {
                "text": "t:html_defaults.shop_by_collection",
                "type_preset": "rte",
                "font": "var(--font-body--family)",
                "font_size": "",
                "line_height": "normal",
                "letter_spacing": "normal",
                "case": "none",
                "wrap": "pretty",
                "width": "fit-content",
                "max_width": "normal",
                "alignment": "left",
                "padding-block-start": 0,
                "padding-block-end": 16,
                "padding-inline-start": 0,
                "padding-inline-end": 0
              }
            }
          },
          "block_order": ["text_bc98Wh"]
        },
        "static-collection-card": {
          "type": "_collection-card",
          "name": "t:names.collection_card",
          "static": true,
          "settings": {
            "horizontal_alignment": "flex-start",
            "vertical_alignment": "flex-start",
            "placement": "on_image",
            "inherit_color_scheme": true,
            "color_scheme": "",
            "border": "none",
            "border_width": 1,
            "border_opacity": 100,
            "border_radius": 0
          },
          "blocks": {
            "collection-card-image": {
              "type": "_collection-card-image",
              "name": "t:names.collection_card_image",
              "static": true,
              "settings": {
                "image_ratio": "adapt"
              }
            },
            "collection-title": {
              "type": "collection-title",
              "name": "t:names.collection_title",
              "settings": {
                "type_preset": "rte",
                "font": "var(--font-body--family)",
                "font_size": "",
                "line_height": "normal",
                "letter_spacing": "normal",
                "case": "none",
                "wrap": "pretty",
                "width": "fit-content",
                "max_width": "normal",
                "alignment": "left",
                "background": true,
                "background_color": "#ffffff",
                "padding-block-start": 4,
                "padding-block-end": 4,
                "padding-inline-start": 8,
                "padding-inline-end": 8
              }
            }
          },
          "block_order": ["collection-title"]
        }
      },
      "block_order": ["group_Lg9LkF"],
      "settings": {
        "collection_list": [],
        "layout_type": "grid",
        "carousel_on_mobile": false,
        "columns": 3,
        "mobile_columns": "2",
        "columns_gap": 8,
        "rows_gap": 8,
        "icons_style": "arrow",
        "icons_shape": "none",
        "section_width": "page-width",
        "gap": 12,
        "color_scheme": "",
        "padding-block-start": 48,
        "padding-block-end": 48
      }
    },
    {
      "name": "t:names.collections_carousel",
      "category": "t:categories.collections",
      "blocks": {
        "group_EYUh3J": {
          "type": "group",
          "name": "t:names.header",
          "settings": {
            "content_direction": "column",
            "vertical_on_mobile": true,
            "horizontal_alignment": "flex-start",
            "vertical_alignment": "center",
            "horizontal_alignment_flex_direction_column": "flex-start",
            "vertical_alignment_flex_direction_column": "center",
            "gap": 12,
            "width": "fit",
            "custom_width": 100,
            "width_mobile": "fit",
            "custom_width_mobile": 100,
            "height": "fit",
            "custom_height": 100,
            "inherit_color_scheme": true,
            "color_scheme": "",
            "background_media": "none",
            "video_position": "cover",
            "background_image_position": "cover",
            "border": "none",
            "border_width": 1,
            "border_opacity": 100,
            "border_radius": 0,
            "padding-block-start": 0,
            "padding-block-end": 0,
            "padding-inline-start": 0,
            "padding-inline-end": 0
          },
          "blocks": {
            "text_nQEaGV": {
              "type": "text",
              "name": "t:names.text",
              "settings": {
                "text": "t:html_defaults.shop_by_collection",
                "type_preset": "rte",
                "font": "var(--font-body--family)",
                "font_size": "",
                "line_height": "normal",
                "letter_spacing": "normal",
                "case": "none",
                "wrap": "pretty",
                "width": "fit-content",
                "max_width": "normal",
                "alignment": "left",
                "padding-block-start": 0,
                "padding-block-end": 16,
                "padding-inline-start": 0,
                "padding-inline-end": 0
              }
            }
          },
          "block_order": ["text_nQEaGV"]
        },
        "static-collection-card": {
          "type": "_collection-card",
          "name": "t:names.collection_card",
          "static": true,
          "settings": {
            "horizontal_alignment": "flex-start",
            "vertical_alignment": "center",
            "placement": "below_image",
            "inherit_color_scheme": true,
            "color_scheme": "",
            "border": "none",
            "border_width": 1,
            "border_opacity": 100,
            "border_radius": 0
          },
          "blocks": {
            "collection-card-image": {
              "type": "_collection-card-image",
              "name": "t:names.collection_card_image",
              "static": true,
              "settings": {
                "image_ratio": "adapt"
              }
            },
            "collection-title": {
              "type": "collection-title",
              "name": "t:names.collection_title",
              "settings": {
                "type_preset": "rte",
                "font": "var(--font-body--family)",
                "font_size": "",
                "line_height": "normal",
                "letter_spacing": "normal",
                "case": "none",
                "wrap": "pretty",
                "width": "fit-content",
                "max_width": "normal",
                "alignment": "left",
                "padding-block-start": 0,
                "padding-block-end": 0,
                "padding-inline-start": 0,
                "padding-inline-end": 0
              }
            }
          },
          "block_order": ["collection-title"]
        }
      },
      "block_order": ["group_EYUh3J"],
      "settings": {
        "collection_list": [],
        "layout_type": "carousel",
        "carousel_on_mobile": false,
        "columns": 3,
        "mobile_columns": "2",
        "columns_gap": 8,
        "rows_gap": 8,
        "icons_style": "arrow",
        "icons_shape": "circle",
        "section_width": "page-width",
        "gap": 12,
        "color_scheme": "",
        "padding-block-start": 48,
        "padding-block-end": 48
      }
    },
    {
      "name": "t:names.collections_editorial",
      "category": "t:categories.collections",
      "blocks": {
        "group": {
          "type": "group",
          "name": "t:names.header",
          "settings": {
            "link": "",
            "open_in_new_tab": false,
            "content_direction": "column",
            "vertical_on_mobile": true,
            "horizontal_alignment": "flex-start",
            "vertical_alignment": "center",
            "align_baseline": false,
            "horizontal_alignment_flex_direction_column": "flex-start",
            "vertical_alignment_flex_direction_column": "center",
            "gap": 12,
            "width": "fill",
            "custom_width": 100,
            "width_mobile": "fill",
            "custom_width_mobile": 100,
            "height": "fit",
            "custom_height": 100,
            "inherit_color_scheme": true,
            "color_scheme": "",
            "background_media": "none",
            "video_position": "cover",
            "background_image_position": "cover",
            "border": "none",
            "border_width": 1,
            "border_opacity": 100,
            "border_radius": 0,
            "toggle_overlay": false,
            "overlay_color": "#00000026",
            "overlay_style": "solid",
            "gradient_direction": "to top",
            "padding-block-start": 0,
            "padding-block-end": 0,
            "padding-inline-start": 0,
            "padding-inline-end": 0
          },
          "blocks": {
            "text": {
              "type": "text",
              "name": "t:names.text",
              "settings": {
                "text": "t:html_defaults.shop_by_collection",
                "width": "fit-content",
                "max_width": "normal",
                "alignment": "left",
                "type_preset": "rte",
                "font": "var(--font-body--family)",
                "font_size": "",
                "line_height": "normal",
                "letter_spacing": "normal",
                "case": "none",
                "wrap": "pretty",
                "color": "var(--color-foreground)",
                "background": false,
                "background_color": "#00000026",
                "corner_radius": 0,
                "padding-block-start": 0,
                "padding-block-end": 0,
                "padding-inline-start": 0,
                "padding-inline-end": 0
              },
              "blocks": {}
            }
          },
          "block_order": ["text"]
        },
        "static-collection-card": {
          "type": "_collection-card",
          "name": "t:names.collection_card",
          "static": true,
          "settings": {
            "placement": "below_image",
            "horizontal_alignment": "flex-start",
            "vertical_alignment": "center",
            "collection_card_gap": 8,
            "inherit_color_scheme": true,
            "color_scheme": "",
            "border": "none",
            "border_width": 1,
            "border_opacity": 100,
            "border_radius": 0
          },
          "blocks": {
            "collection-title": {
              "type": "collection-title",
              "name": "t:names.collection_title",
              "settings": {
                "width": "fit-content",
                "max_width": "normal",
                "alignment": "left",
                "type_preset": "h5",
                "font": "var(--font-body--family)",
                "font_size": "",
                "line_height": "normal",
                "letter_spacing": "normal",
                "case": "none",
                "wrap": "pretty",
                "color": "var(--color-foreground)",
                "background": false,
                "background_color": "#00000026",
                "corner_radius": 0,
                "padding-block-start": 4,
                "padding-block-end": 0,
                "padding-inline-start": 0,
                "padding-inline-end": 0
              },
              "blocks": {}
            },
            "collection-card-image": {
              "type": "_collection-card-image",
              "name": "t:names.collection_card_image",
              "static": true,
              "settings": {
                "image_ratio": "adapt",
                "toggle_overlay": false,
                "overlay_color": "#00000026",
                "overlay_style": "solid",
                "gradient_direction": "to top",
                "border": "none",
                "border_width": 1,
                "border_opacity": 100,
                "border_radius": 0
              },
              "blocks": {}
            }
          },
          "block_order": ["collection-title"]
        }
      },
      "block_order": ["group"],
      "settings": {
        "collection_list": [],
        "layout_type": "editorial",
        "carousel_on_mobile": false,
        "columns": 3,
        "mobile_columns": "2",
        "columns_gap": 8,
        "bento_gap": 8,
        "rows_gap": 8,
        "max_collections": 4,
        "icons_style": "arrow",
        "icons_shape": "none",
        "section_width": "page-width",
        "gap": 64,
        "color_scheme": "",
        "padding-block-start": 48,
        "padding-block-end": 48
      }
    }
  ]
}
{% endschema %}
