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

{%- liquid
  assign color_scheme = section.settings.color_scheme
  assign column = section.settings.columns_carousel
  assign gap = section.settings.gap
  assign title = section.settings.title
  assign sub = section.settings.sub
-%}

<section {% render 'section-attr', color_scheme: color_scheme, background_color: section.settings.background_color %}>
  {% render 'section-bg-image' %}
  <div class='collection-v53'>
    <xo-container {% render 'section-layout' %}>
      <div class='collection-v53__heading'>
        {%- if title != blank -%}
          <div class='collection-v53__title'>
            {{ title }}
          </div>
        {%- endif -%}
        {%- if sub != blank -%}
          <div class='collection-v53__sub'>
            {{ sub }}
          </div>
        {%- endif -%}
      </div>
      <div class='collection-v53__block'>
        <xo-grid style=' --xs:1;--sm:2;--md:3;--lg:3;--xl: {{ column }}; --xo-grid-col-gap: {{gap}}px; --xo-grid-row-gap : {{gap}}px'>
          {% for block in section.blocks %}
            {% case block.type %}
              {% when 'review' %}
                <div class='collection-v53'>
                  <div class='collection-v53__box'>
                    <a href='{{ block.settings.collection.url }}' class='collection-v53__img {%render 'hover-style'%}'>
                      {%- if block.settings.image -%}
                        {% render 'image', image: block.settings.image %}
                      {%- else -%}
                        {% render 'image', image: block.settings.collection.featured_image %}
                      {%- endif -%}
                    </a>
                    {%- if block.settings.collection.featured_image -%}
                      <div class='collection-v53-content'>
                        <div class='collection-v53-content__title'>
                          {{ block.settings.collection.title }}
                        </div>
                        <div class='collection-v53-content__desc'>
                          {{ block.settings.collection.description }}
                        </div>
                        <a href='{{ block.settings.collection.url }}'>
                          <div class='collection-v53-content__link-text'>{{ block.settings.text_button }}</div>
                        </a>
                      </div>
                    {%- endif -%}
                  </div>
                </div>
            {% endcase %}
          {% endfor %}
        </xo-grid>
      </div>
    </xo-container>
  </div>
</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": "text",
      "id": "title",
      "label": "t:sections.collection_v1.settings.title.label",
      "default": "Title"
    },
    {
      "type": "text",
      "id": "sub",
      "label": "t:sections.collection_v1.settings.sub.label",
      "default": "Subtitle"
    },
    {
      "type": "header",
      "content": "Setting additional"
    },
    {
      "type": "select",
      "id": "hover",
      "label": "t:sections.all.hover.label",
      "default": "hover1",
      "options": [
        {
          "value": "hover1",
          "label": "t:sections.all.hover.option__1.label"
        },
        {
          "value": "hover2",
          "label": "Style 02"
        },
        {
          "value": "hover3",
          "label": "Style 03"
        },
        {
          "value": "hover4",
          "label": "Style 04"
        },
        {
          "value": "hover5",
          "label": "Style 05"
        },
        {
          "value": "hover6",
          "label": "Style 06"
        }
      ]
    },
    {
      "type": "range",
      "id": "columns_carousel",
      "min": 2,
      "max": 4,
      "step": 1,
      "label": "t:sections.collection_v1.settings.columns_carousel.label",
      "default": 3
    },
    {
      "type": "range",
      "id": "gap",
      "min": 10,
      "max": 40,
      "step": 1,
      "unit": "px",
      "label": "t:sections.collection_v1.settings.gap.label",
      "default": 25
    },
    {
      "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": "review",
      "name": " Collection",
      "settings": [
        {
          "type": "collection",
          "id": "collection",
          "label": "t:sections.collection_v1.blocks.settings.collection.label"
        },
        {
          "type": "image_picker",
          "id": "image",
          "label": "t:sections.collection_v1.blocks.settings.image.label",
          "info": "Support jpg, jpeg, png, svg"
        },
        {
          "type": "text",
          "id": "text_button",
          "label": "t:sections.collection_v1.blocks.settings.text_button.label",
          "default": "Text"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "t:sections.collection_v1.presets.name"
    }
  ]
}
{% endschema %}
