{{ 'section-instagram-v2.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
            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_link,
                  mode: section.settings.button_mode,
                  style: section.settings.button_style,
                  size: section.settings.button_size,
                  radius: section.settings.button_radius,
                  padding: section.settings.button_padding
                %}
              </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='instagram' width='1000' height='1000'>
                </xo-instagram-template>
              {% endif %}
            </div>
          </div>
        </xo-grid>
      </xo-instagram>
    </div>
  </xo-container>
</section>

{% schema %}
{
  "name": "t:sections.instagram_v2.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_v2.settings.reverse_layout.label",
      "default": false
    },
    {
      "type": "text",
      "id": "ins_access_token",
      "label": "t:sections.instagram_v2.settings.ins_access_token.label",
      "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_v2.settings.show_icon_insta.label",
      "default": true
    },
    {
      "type": "text",
      "id": "title",
      "label": "t:sections.instagram_v2.settings.title.label",
      "default": "Title"
    },
    {
      "type": "richtext",
      "id": "desc",
      "label": "t:sections.instagram_v2.settings.desc.label",
      "default": "<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum, alias dolorum expedita dicta labore animi.</p>"
    },
    {
      "type": "header",
      "content": "t:sections.all.button_heading.content"
    },
    {
      "type": "text",
      "id": "button_text",
      "label": "t:sections.all.button_text.label",
      "default": "ALL PRODUCTS"
    },
    {
      "type": "url",
      "id": "button_link",
      "label": "t:sections.all.button_link.label",
      "default": "/collections/all"
    },
    {
      "type": "select",
      "id": "button_mode",
      "label": "t:sections.all.button_mode.label",
      "options": [
        {
          "value": "light",
          "label": "t:sections.all.button_mode.option__1.label"
        },
        {
          "value": "dark",
          "label": "t:sections.all.button_mode.option__2.label"
        }
      ],
      "default": "light"
    },
    {
      "type": "select",
      "id": "button_style",
      "label": "t:sections.all.button_style.label",
      "options": [
        {
          "value": "primary",
          "label": "t:sections.all.button_style.option__1.label"
        },
        {
          "value": "secondary",
          "label": "t:sections.all.button_style.option__2.label"
        },
        {
          "value": "tertiary",
          "label": "t:sections.all.button_style.option__3.label"
        },
        {
          "value": "link",
          "label": "t:sections.all.button_style.option__4.label"
        }
      ],
      "default": "secondary"
    },
    {
      "type": "select",
      "id": "button_size",
      "label": "t:sections.all.button_size.label",
      "options": [
        {
          "value": "xs",
          "label": "t:sections.all.button_size.option__0.label"
        },
        {
          "value": "sm",
          "label": "t:sections.all.button_size.option__1.label"
        },
        {
          "value": "md",
          "label": "t:sections.all.button_size.option__2.label"
        },
        {
          "value": "lg",
          "label": "t:sections.all.button_size.option__3.label"
        }
      ],
      "default": "sm"
    },
    {
      "type": "range",
      "id": "button_radius",
      "label": "t:sections.all.button_radius.label",
      "max": 4,
      "min": 0,
      "step": 0.2,
      "unit": "rem",
      "default": 0.8
    },
    {
      "type": "range",
      "id": "button_padding",
      "label": "t:sections.all.button_padding.label",
      "info": "t:sections.all.button_padding.info",
      "max": 10,
      "min": 0,
      "step": 0.2,
      "unit": "rem",
      "default": 1.4
    },
    {
      "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_v2.presets.name",
      "category": "Text"
    }
  ]
}
{% endschema %}
