{{ 'section-instagram-v1.css' | asset_url | stylesheet_tag }}
<section {% render 'section-attr' %}>
  <xo-animate>
    <xo-container {% render 'section-layout' %}>
      <div class='instagram-v4'>
        {% if section.settings.title !=blank %}
          <div class='instagram-v4__box-title instagram-v4__box-title--center'>
            <h2 class='instagram-v4__title'>
              {{ section.settings.title | escape }}
            </h2>
          </div>
        {% endif %}
        
        <div class='instagram-v4__box'>
          <div class='instagram-v4__box-icon'>
            {{ section.settings.item_icon }}
          </div>
          <xo-instagram
            xo-open-mode='newtab'
            xo-access-token='{{section.settings.ins_access_token}}'
          >
            <xo-carousel
              xo-per-move='1'
              xo-per-view='{{section.settings.limit_image}}'
              xo-gap='0'
              xo-loop
              xo-speed='2000'
              xo-hover-pause='true'
              {% if section.settings.auto_play %}
                xo-autoplay='5000'
              {% endif %}
              xo-breakpoints='
                {
                  600: {
                    perView: 2,
                    perMove: 1,
                  },
                  900: {
                    perView: 4,
                    perMove: 1,
                  },
                  800: {
                    perView: 3,
                    perMove: 1,
                  },
                  1000: {
                    perView: 5,
                    perMove: 1,
                  },
                }
              '
            >
              <xo-carousel-inner>
                <xo-carousel-list>
                  {% if section.settings.ins_access_token == blank %}
                    {% assign b = section.settings.limit_image %}
                    {% assign a = b | plus: 1 %}
                    {% for i in (1..a) %}
                      <xo-carousel-slide>
                        <div class='instagram-v4__slide'>
                          <div class='instagram-v4__box-img'>
                             <img src='{{ 'instagram' | append: i | append: '.jpg' | file_img_url: 'master' }}' class='instagram-v3__image' alt='instagram' width='1000' height='1000'>
                          </div>
                          <div class='instagram-v4__item-link'>
                            <a href='https://www.instagram.com/' class='instagram-v4__link' target='_blank'>{{ section.settings.item_icon }}</a>
                          </div>
                        </div>
                      </xo-carousel-slide>
                    {% endfor %}
                  {% else %}
                    <xo-instagram-template>
                     <img class='instagram-v3__image' data-src='{ url }' alt='' width='1000' height='1000'>
                      <div class='instagram-v4__icon-ig'>
                        {{ section.settings.item_icon }}
                      </div>
                    </xo-instagram-template>
                  {% endif %}
                </xo-carousel-list>
              </xo-carousel-inner>
            </xo-carousel>
          </xo-instagram>
        </div>
      </div>
    </xo-container>
  </xo-animate>
</section>

{% schema %}
{
  "name": "t:sections.instagram_v1.name",
  "tag": "section",
  "class": "section",
  "settings": [
    {
      "type": "text",
      "id": "title",
      "label": "t:sections.instagram_v1.settings.title.label"
    },
    {
      "type": "text",
      "id": "ins_access_token",
      "label": "t:sections.instagram_v1.settings.ins_access_token.label",
      "info": "[Get access token](https://developers.facebook.com/docs/instagram-basic-display-api/getting-started)"
    },
    {
      "type": "html",
      "id": "item_icon",
      "label": "t:sections.instagram_v1.settings.item_icon.label",
      "default": "<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" x=\"0px\" y=\"0px\" viewbox=\"0 0 150 150\" style=\"enable-background:new 0 0 150 150;\" height=\"1em\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:space=\"preserve\">\n  <g>\n   <path d=\"M131.95,12.84c-5.03,5.87-10.06,11.74-15.1,17.6c-9.93,11.54-19.88,23.07-29.81,34.6c-0.11,0.12-0.2,0.25-0.37,0.47\n     c16.38,23.8,32.77,47.61,49.27,71.57c-0.51,0.03-0.84,0.07-1.18,0.07c-11.35,0-22.7-0.01-34.06,0.02c-0.78,0-1.22-0.24-1.67-0.89\n     c-10.58-15.41-21.18-30.79-31.78-46.18c-0.25-0.36-0.51-0.71-0.82-1.14c-2.93,3.39-5.79,6.7-8.64,10.01\n     c-10.7,12.42-21.41,24.84-32.09,37.28c-0.59,0.68-1.18,0.94-2.07,0.92c-3.07-0.05-6.15-0.02-9.54-0.02\n     c15.95-18.51,31.74-36.82,47.57-55.19c-2.56-3.72-5.09-7.41-7.63-11.1C40.93,51.86,27.85,32.87,14.78,13.88\n     c-0.22-0.33-0.38-0.7-0.57-1.04c12.08,0,24.16,0,36.25,0c0.08,0.14,0.15,0.28,0.24,0.42c10.22,14.85,20.44,29.71,30.67,44.56\n     c0.13,0.19,0.29,0.36,0.5,0.6c0.35-0.38,0.66-0.68,0.94-1.01c11.76-13.64,23.51-27.27,35.26-40.92c1.02-1.18,1.96-2.43,2.94-3.64\n     C124.65,12.84,128.3,12.84,131.95,12.84z M121.13,129.4c-0.24-0.4-0.34-0.58-0.45-0.74C95.71,93.01,70.74,57.36,45.74,21.73\n     c-0.3-0.43-1.04-0.77-1.58-0.77c-4.78-0.06-9.57-0.04-14.35-0.03c-0.26,0-0.53,0.03-0.99,0.06c0.4,0.59,0.68,1.02,0.97,1.44\n     c8.98,12.82,17.97,25.65,26.95,38.47c15.78,22.53,31.57,45.06,47.33,67.61c0.48,0.68,0.97,0.93,1.78,0.92\n     c4.66-0.04,9.32-0.02,13.99-0.02C120.2,129.4,120.55,129.4,121.13,129.4\"></path>\n  </g>\n</svg>"
    },
    {
      "type": "range",
      "id": "limit_image",
      "min": 3,
      "max": 6,
      "step": 1,
      "label": "t:sections.instagram_v1.settings.limit_image.label",
      "default": 6
    },
    {
      "type": "checkbox",
      "id": "auto_play",
      "label": "t:sections.instagram_v1.settings.auto_play.label",
      "default": false
    },
    {
      "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": "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": "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
    }
  ],
  "presets": [
    {
      "name": "t:sections.instagram_v1.presets.name"
    }
  ]
}
{% endschema %}
