{{ 'testimonials.css' | asset_url | stylesheet_tag }}

{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}

{%- liquid
  assign columns_desktop_int = section.settings.columns_desktop | plus: 0.5
  if section.settings.columns_desktop >= 1
    assign columns_tablet_int = columns_desktop_int | minus: 1
  else
    assign columns_tablet_int = columns_desktop_int
  endif
  assign columns_mobile_int = section.settings.columns_mobile | plus: 0.5
-%}

<div class="color-{{ section.settings.color_scheme }} gradient">
  <div class="collection-list-wrapper page-width isolate section-{{ section.id }}-padding">

    <!-- Heading with heart icon -->
    <div class="testimonial-heading {{ section.settings.heading_alignment }}">
      {% if section.settings.heading_icon != blank %}
        {{ section.settings.heading_icon |  image_url: width: section.settings.heading_icon.width | image_tag }}
      {% endif %}
      <h2 class="{{ section.settings.heading_size }}">{{ section.settings.title }}</h2>
    </div>

    <!-- Swiper slider -->
    <div class="{% if settings.animations_reveal_on_scroll %}scroll-trigger animate--slide-in{% endif %}">
      <div
        class="swiper-container"
        data-section-id="{{ section.id }}"
        data-perview-desktop="{{ columns_desktop_int }}"
        data-perview-tablet="{{ columns_tablet_int }}"
        data-perview-mobile="{{ columns_mobile_int }}">

        <div class="swiper swiper-slider-{{ section.id }}">
          <div class="swiper-wrapper">
            {%- for block in section.blocks -%}
              <div
                id="Slide-{{ section.id }}-{{ forloop.index }}"
                class="swiper-slide testimonial-list__item"
                {{ block.shopify_attributes }}>
                <div class="testimonial-wrapper {{ section.settings.text_alignment }}">
                  <p class="testimonial-text">“{{ block.settings.testimonial_text }}”</p>
                </div>
              </div>
            {%- endfor -%}
          </div>
          <!-- Navigation & pagination -->
          <div class="swiper-footer">
            <div class="swiper-button-prev">{{ 'swiper-prev.svg' | inline_asset_content }}</div>
            <div class="swiper-button-next">{{ 'swiper-next.svg' | inline_asset_content }}</div>
            <div class="swiper-pagination"></div>
          </div>
        </div>
      </div>
    </div>

  </div>
</div>

{% schema %}
  {
    "name": "Testimonials",
    "tag": "section",
    "class": "section testimonial-list",
    "max_blocks": 15,
    "settings": [
      {
        "type": "image_picker",
        "id": "heading_icon",
        "label": "Heading icon"
      },
      {
        "type": "inline_richtext",
        "id": "title",
        "default": "LOVE FROM OUR CUSTOMERS",
        "label": "Heading"
      },
      {
        "type": "select",
        "id": "heading_alignment",
        "options": [
          {
            "value": "left",
            "label": "t:sections.announcement-bar.blocks.announcement.settings.text_alignment.options__1.label"
          },
          {
            "value": "center",
            "label": "t:sections.announcement-bar.blocks.announcement.settings.text_alignment.options__2.label"
          },
          {
            "value": "right",
            "label": "t:sections.announcement-bar.blocks.announcement.settings.text_alignment.options__3.label"
          }
        ],
        "default": "left",
        "label": "t:sections.collapsible_content.settings.heading_alignment.label"
      },
      {
        "type": "select",
        "id": "heading_size",
        "options": [
          {
            "value": "h4",
            "label": "Small"
          },
          {
            "value": "h3",
            "label": "Medium"
          },
          {
            "value": "h2",
            "label": "Large"
          },
          {
            "value": "h1",
            "label": "Extra Large"
          }
        ],
        "default": "h2",
        "label": "Heading size"
      },
      {
        "type": "range",
        "id": "columns_desktop",
        "min": 1,
        "max": 8,
        "step": 1,
        "default": 5,
        "label": "Columns on desktop"
      },
      {
        "type": "select",
        "id": "columns_mobile",
        "options": [
          {
            "value": "1",
            "label": "1 column"
          },
          {
            "value": "2",
            "label": "2 columns"
          }
        ],
        "default": "1",
        "label": "Columns on mobile"
      },
      {
        "type": "select",
        "id": "color_scheme",
        "options": [
          {
            "value": "accent-1",
            "label": "Accent 1"
          },
          {
            "value": "accent-2",
            "label": "Accent 2"
          },
          {
            "value": "background-1",
            "label": "Background 1"
          },
          {
            "value": "background-2",
            "label": "Background 2"
          },
          {
            "value": "inverse",
            "label": "Inverse"
          }
        ],
        "default": "background-1",
        "label": "Color scheme"
      },
      {
        "type": "select",
        "id": "text_alignment",
        "options": [
          {
            "value": "left",
            "label": "t:sections.announcement-bar.blocks.announcement.settings.text_alignment.options__1.label"
          },
          {
            "value": "center",
            "label": "t:sections.announcement-bar.blocks.announcement.settings.text_alignment.options__2.label"
          },
          {
            "value": "right",
            "label": "t:sections.announcement-bar.blocks.announcement.settings.text_alignment.options__3.label"
          }
        ],
        "default": "left",
        "label": "t:sections.announcement-bar.blocks.announcement.settings.text_alignment.label"
      },
      {
        "type": "range",
        "id": "padding_top",
        "min": 0,
        "max": 100,
        "step": 4,
        "unit": "px",
        "label": "Padding top",
        "default": 36
      },
      {
        "type": "range",
        "id": "padding_bottom",
        "min": 0,
        "max": 100,
        "step": 4,
        "unit": "px",
        "label": "Padding bottom",
        "default": 36
      }
    ],
    "blocks": [
      {
        "type": "testimonial",
        "name": "Testimonial",
        "settings": [
          {
            "type": "textarea",
            "id": "testimonial_text",
            "label": "Testimonial text"
          }
        ]
      }
    ],
    "presets": [
      {
        "name": "Testimonials"
      }
    ]
  }
{% endschema %}