{{ 'section-collection-v1.css' | asset_url | stylesheet_tag }}

<section {% render 'section-attr' %}>
  {% render 'section-bg-image' %}
  <xo-container {% render 'section-layout' %}>
    <div class='collection-v47' style='--gap: {{ section.settings.gap }}px'>
      {%- for block in section.blocks -%}
        {%- if block.settings.collection != blank -%}
          <xo-animate xo-cascade>
            <a href='{{ block.settings.collection.url }}'>
              <xo-parallax>
                <div class='collection-v47__item'>
                  <h3 class='collection-v47__item-title'>{{ block.settings.collection.title }}</h3>
                  {% if block.settings.collection.products_count > 1 %}
                    {% assign item_name = 'products.facets.product_count_simple.other' | t: count: block.settings.collection.products_count %}
                  {% else %}
                    {% assign item_name = 'products.facets.product_count_simple.one' | t: count: block.settings.collection.products_count %}
                  {% endif %}
                  <span class='collection-v47__item-count'>{{ item_name }}</span>
                </div>
                <xo-parallax-hover xo-strength='160' class='collection-v47__img'>
                  {% if block.settings.image != blank %}
                    {% assign image = block.settings.image %}
                  {% else %}
                    {% assign image = block.settings.collection.featured_image %}
                  {% endif %}
                  {% render 'image', image: image, media_aspect_ratio: section.settings.aspect_ratio %}
                </xo-parallax-hover>
              </xo-parallax>
            </a>
          </xo-animate>
        {%- endif -%}
      {%- endfor -%}
    </div>
  </xo-container>
</section>

{% schema %}
{
  "name": "t:sections.collection_v1.name",
  "tag": "section",
  "class": "section",
  "settings": [
    {
      "type": "select",
      "id": "width",
      "label": "t:sections.all.width.label",
      "default": "box",
      "options": [
        {
          "value": "box",
          "label": "t:sections.all.width.options__1.label"
        },
        {
          "value": "wide",
          "label": "t:sections.all.width.options__2.label"
        },
        {
          "value": "fullwidth",
          "label": "t:sections.all.width.options__3.label"
        }
      ]
    },
    {
      "type": "range",
      "id": "gap",
      "min": 10,
      "max": 100,
      "step": 5,
      "unit": "px",
      "label": "t:sections.collection_v1.settings.gap.label",
      "default": 50
    },
    {
      "type": "text",
      "id": "aspect_ratio",
      "label": "t:sections.collection_v1.settings.aspect_ratio.label",
      "default": "1/1"
    },
    {
      "type": "header",
      "content": "t:sections.all.heading.content"
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:sections.all.color_scheme.label"
    },
    {
      "type": "color",
      "id": "background_color",
      "label": "t:sections.all.bg_color.label"
    },
    {
      "type": "color_background",
      "id": "background_gradient",
      "label": "t:sections.all.bg_gradient.label"
    },
    {
      "type": "image_picker",
      "id": "background_image_desktop",
      "label": "t:sections.all.background_image_desktop.label"
    },
    {
      "type": "image_picker",
      "id": "background_image_mobile",
      "label": "t:sections.all.background_image_mobile.label"
    },
    {
      "type": "checkbox",
      "id": "use_parallax",
      "label": "t:sections.all.use_parallax.label",
      "default": true
    },
    {
      "type": "number",
      "id": "padding_top",
      "label": "t:sections.all.padding_top.label",
      "default": 50
    },
    {
      "type": "number",
      "id": "padding_bottom",
      "label": "t:sections.all.padding_bottom.label",
      "default": 50
    }
  ],
  "blocks": [
    {
      "type": "collection",
      "name": "t:sections.collection_v1.blocks.name",
      "settings": [
        {
          "type": "image_picker",
          "id": "image",
          "label": "t:sections.collection_v1.blocks.settings.image.label"
        },
        {
          "type": "collection",
          "id": "collection",
          "label": "t:sections.collection_v1.blocks.settings.collection.label"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "t:sections.collection_v1.presets.name"
    }
  ]
}
{% endschema %}
