{{ 'section-related-article.css' | asset_url | stylesheet_tag }}

<div {% render 'section-attr' %}>
  {% render 'section-bg-image' %}
  <xo-container {% render 'section-layout' %}>
    {% render 'section-heading', title: section.settings.heading_title, align: section.settings.heading_align %}
    <xo-carousel
      xo-per-view='{{section.settings.columns_desktop}}'
      class='related-article__carousel'
      xo-render-bullet='<span class="carousel-pagination-style1__bullet"></span>'
      xo-breakpoints='
        {
          575: {
            perView: 1
          },
          768: {
            perView: 2
          },
          992: {
            perView: {{ section.settings.columns_desktop | minus: 1 }}
          }
        }
      '
    >
      <xo-carousel-inner>
        <xo-carousel-list>
          {%- for article in section.settings.blog.articles -%}
            {%- assign placeholder_image_index = forloop.index0 | modulo: 4 | plus: 1 -%}
            {%- assign placeholder_image = 'product-apparel-' | append: placeholder_image_index -%}
            <xo-carousel-slide>
              {% render 'article-card-style4',
                article: article,
                media_aspect_ratio: '4/3',
                show_image: section.settings.article_card_show_image,
                show_date: section.settings.article_card_show_date,
                show_excerpt: section.settings.article_card_show_excerpt,
                placeholder_image: placeholder_image,
                color_scheme: section.settings.article_card_color_scheme
              %}
            </xo-carousel-slide>
          {%- endfor -%}
        </xo-carousel-list>
      </xo-carousel-inner>
      {% render 'carousel-navigation-style1', display_navigation_desktop: 'flex', display_navigation_mobile: 'none' %}
      {% render 'carousel-pagination-style1', display_pagination_desktop: 'flex', display_pagination_mobile: 'flex' %}
    </xo-carousel>
  </xo-container>
</div>

{% schema %}
{
  "name": "t:sections.related_article.name",
  "tag": "section",
  "class": "section",
  "presets": [
    {
      "name": "t:sections.related_article.presets.name"
    }
  ],
  "settings": [
    {
      "type": "select",
      "id": "width",
      "label": "t:sections.related_article.settings.width.label",
      "options": [
        {
          "value": "box",
          "label": "Box"
        },
        {
          "value": "wide",
          "label": "Wide"
        }
      ],
      "default": "box"
    },
    {
      "type": "text",
      "id": "heading_title",
      "label": "t:sections.all.title.label",
      "default": "Section title"
    },
    {
      "type": "select",
      "id": "heading_align",
      "label": "t:sections.all.heading_align.label",
      "default": "center",
      "options": [
        {
          "value": "left",
          "label": "t:sections.all.heading_align.option__1.label"
        },
        {
          "value": "center",
          "label": "t:sections.all.heading_align.option__2.label"
        },
        {
          "value": "right",
          "label": "t:sections.all.heading_align.option__3.label"
        }
      ]
    },
    {
      "type": "blog",
      "id": "blog",
      "label": "t:sections.related_article.settings.blog.label"
    },
    {
      "type": "range",
      "id": "columns_desktop",
      "min": 1,
      "max": 5,
      "step": 1,
      "default": 3,
      "label": "t:sections.related_article.settings.columns_desktop.label"
    },
    {
      "type": "header",
      "content": "t:sections.all.article_card_header.content"
    },
    {
      "type": "checkbox",
      "id": "article_card_show_image",
      "default": true,
      "label": "t:sections.all.article_card_show_image.label"
    },
    {
      "type": "checkbox",
      "id": "article_card_show_date",
      "default": true,
      "label": "t:sections.all.article_card_show_date.label"
    },
    {
      "type": "checkbox",
      "id": "article_card_show_excerpt",
      "default": false,
      "label": "t:sections.all.article_card_show_excerpt.label"
    },
    {
      "type": "color_scheme",
      "id": "article_card_color_scheme",
      "default": "scheme_1",
      "label": "t:sections.all.article_card_color_scheme.label"
    },
    {
      "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
    }
  ]
}
{% endschema %}
