{{ 'section-instagram-v7.css' | asset_url | stylesheet_tag }}

{%- assign reverse_layout = section.settings.reverse_layout -%}

<section {% render 'section-attr' %}>
  <xo-container {% render 'section-layout' %}>
    <div class='instagram-v7'>
      <xo-instagram
        xo-open-mode='newtab'
        xo-limit='2'
        xo-access-token='{{section.settings.ins_access_token}}'
      >
        <xo-grid>
          <div
            class='instagram-v7__detail'

            style='
              {%- if reverse_layout -%}
                --xs: 12; --order-xs: 2; --sm: 12; --order-sm: 2; --lg: 6; --order-lg: 2;
                {%- else -%}
                --xs: 12; --order-xs: 1; --sm: 12; --order-sm: 1; --lg: 6; --order-lg: 1;
              {%- endif -%}
            '
          >
            <div class='instagram-v7__content'>
              {%- if section.settings.show_icon_insta -%}
                <div class='instagram-v7__icon'>
                  {% render 'icon', name: 'instagram', icon_size: '15', color: 'rgba(var(--color-accent))' %}
                  <div class='instagram-v7__icon-text'>instagram</div>
                </div>
              {%- endif -%}
              <div class='instagram-v7__title'>
                {{ section.settings.title }}
              </div>
              <div class='instagram-v7__desc'>
                {{ section.settings.desc }}
              </div>
              <div class='instagram-v7__button'>
                {% render 'button', text: section.settings.button_text, link: section.settings.button_url, style: 'secondary', size: 'md' %}
              </div>
            </div>
          </div>
          <div
            style='
              {%- if reverse_layout -%}
                --xs: 12; --order-xs: 1; --sm: 12; --order-sm: 1; --lg: 6; --order-lg: 1;
                {%- else -%}
                --xs: 12; --order-xs: 2; --sm: 12; --order-sm: 2; --lg: 6; --order-lg: 2;
              {%- endif -%}
            '
          >
            <div class='instagram-v7__box-img'>
              {% if section.settings.ins_access_token == blank %}
                {% for i in (1..2) %}
                  <div class='instagram-v7__img'>
                    <img src='{{ 'instagram' | append: i | append: '.jpg' | file_img_url: 'master' }}' class='instagram__img' alt='instagram'  width='1000' height='1000'>
                  </div>
                {% endfor %}

              {% else %}
                <xo-instagram-template>
                  <img data-src='{ url }' alt=''  width='1000' height='1000'>
                </xo-instagram-template>
              {% endif %}
            </div>
          </div>
        </xo-grid>
      </xo-instagram>
    </div>
  </xo-container>
</section>

{% schema %}
{
  "name": "t:sections.instagram_v7.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": "checkbox",
      "id": "reverse_layout",
      "label": "t:sections.instagram_v7.settings.reverse_layout.label",
      "default": false
    },
    {
      "type": "text",
      "id": "ins_access_token",
      "label": "t:sections.instagram_v7.settings.ins_access_token.label",
      "default": "IGQWRPaDE5a281eWpxUUU4OUJtZA25BMzZAKcWNlek1ucTh1OW1CTG4zYUYtMDd4amFqblVWZAHRuMExpMndyRHJPcXVFVVhqUWdYNTRBbUdIWkdoNXdCc2MzajJrM1dEQWk1UWhpVGYtampsMFV4UEN2WGltbmJUYVUZD",
      "info": "[Get access token](https://developers.facebook.com/docs/instagram-basic-display-api/getting-started)"
    },
    {
      "type": "checkbox",
      "id": "show_icon_insta",
      "label": "t:sections.instagram_v7.settings.show_icon_insta.label",
      "default": true
    },
    {
      "type": "text",
      "id": "title",
      "label": "t:sections.instagram_v7.settings.title.label",
      "default": "Title"
    },
    {
      "type": "richtext",
      "id": "desc",
      "label": "t:sections.instagram_v7.settings.desc.label",
      "default": "<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum, alias dolorum expedita dicta labore animi.</p>"
    },
    {
      "type": "text",
      "id": "button_text",
      "label": "t:sections.instagram_v7.settings.button_text.label",
      "default": "Button"
    },
    {
      "type": "url",
      "id": "button_link",
      "label": "t:sections.instagram_v7.settings.button_url.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_v7.presets.name"
    }
  ]
}
{% endschema %}
