{{ 'section-mega-menu-v5.css' | asset_url | stylesheet_tag }}
{% assign index_number = section.settings.index | append: '' %}

<template xo-mega-menu-name='header-mega-menu-v1' xo-mega-menu-index='{{ index_number }}'>
  <div data-id='{{ section.id }}' {% render 'section-attr' %}>
    {% render 'section-bg-image' %}
    <xo-container>
      <div class='container-header-v5'>
        <xo-grid style='--col-width: 40rem;'>
          {%- if section.settings.menu_style1 != blank -%}
            <xo-grid style='--col-width: 20rem;'>
              <div>
                {%- if section.settings.menu_style1 != blank -%}
                  <div style='--xs: 12; ' class='menu-header-v5'>
                    {%- if section.settings.heading_1 != blank -%}
                      <h2 class='menu-header-v5__heading'>{{- section.settings.heading_1 -}}</h2>
                    {%- endif -%}
                    <ul class='menu-header-v5__list-item'>
                      {%- for link in section.settings.menu_style1.links -%}
                        <li class='menu-header-v5__item'>
                          <a
                            href='{{ link.url }}'
                          >
                            {{ link.title }}
                          </a>
                        </li>
                      {%- endfor -%}
                    </ul>
                  </div>
                {%- endif -%}
                {%- if section.settings.menu_style2 != blank -%}
                  <div style='--xs: 12; ' class='menu-header-v5'>
                    {%- if section.settings.heading_2 != blank -%}
                      <h2 class='menu-header-v5__heading'>{{- section.settings.heading_2 -}}</h2>
                    {%- endif -%}
                    <ul class='menu-header-v5__list-item'>
                      {%- for link in section.settings.menu_style2.links -%}
                        <li class='menu-header-v5__item'>
                          <a
                            href='{{ link.url }}'
                          >
                            {{ link.title }}
                          </a>
                        </li>
                      {%- endfor -%}
                    </ul>
                  </div>
                {%- endif -%}
              </div>
              <div>
                {%- if section.settings.menu_style3 != blank -%}
                  <div style='--xs: 12; ' class='menu-header-v5'>
                    {%- if section.settings.heading_3 != blank -%}
                      <h2 class='menu-header-v5__heading'>{{- section.settings.heading_3 -}}</h2>
                    {%- endif -%}
                    <ul class='menu-header-v5__list-item'>
                      {%- for link in section.settings.menu_style3.links -%}
                        <li class='menu-header-v5__item'>
                          <a
                            href='{{ link.url }}'
                          >
                            {{ link.title }}
                          </a>
                        </li>
                      {%- endfor -%}
                    </ul>
                  </div>
                {%- endif -%}
                {%- if section.settings.menu_style4 != blank -%}
                  <div style='--xs: 12; ' class='menu-header-v5'>
                    {%- if section.settings.heading_4 != blank -%}
                      <h2 class='menu-header-v5__heading'>{{- section.settings.heading_4 -}}</h2>
                    {%- endif -%}
                    <ul class='menu-header-v5__list-item'>
                      {%- for link in section.settings.menu_style4.links -%}
                        <li class='menu-header-v5__item'>
                          <a
                            href='{{ link.url }}'
                          >
                            {{ link.title }}
                          </a>
                        </li>
                      {%- endfor -%}
                    </ul>
                  </div>
                {%- endif -%}
              </div>
            </xo-grid>
          {%- endif -%}

          <div class='menu-header-v5__blog'>
            {%- if section.settings.heading_3 != blank -%}
              <h2 class='menu-header-v5__heading'>{{- section.settings.heading_5 -}}</h2>
            {%- endif -%}
            {%- if section.settings.blog != blank -%}
                {%- for article in section.settings.blog.articles limit: section.settings.limit -%}
                  <div>
                    {%- assign placeholder_image_index = forloop.index0 | modulo: 4 | plus: 1 -%}
                    {%- assign placeholder_image = 'product-apparel-' | append: placeholder_image_index -%}
                    {% render 'article-card-style18',
                      article: article,
                      media_aspect_ratio: '4/3',
                      show_image: section.settings.article_card_show_image,
                      show_date: section.settings.article_card_show_date,
                      show_author: section.settings.article_card_show_author,
                      show_excerpt: section.settings.article_card_show_excerpt,
                      show_tags: section.settings.article_card_show_tags,
                      placeholder_image: placeholder_image,
                      color_scheme: section.settings.card_color_scheme
                    %}
                  </div>
                {%- endfor -%}
            {%- endif -%}
          </div>
        </xo-grid>
      </div>
    </xo-container>
  </div>
</template>

{% schema %}
{
  "name": "t:sections.mega_menu_v5.name",
  "class": "section-mega-menu",
  "settings": [
    {
      "type": "select",
      "id": "index",
      "label": "t:sections.mega_menu_v5.settings.index_number.label",
      "default": "3",
      "options": [
        {
          "value": "0",
          "label": "t:sections.mega_menu_v5.settings.index_number.option_1.label"
        },
        {
          "value": "1",
          "label": "t:sections.mega_menu_v5.settings.index_number.option_2.label"
        },
        {
          "value": "2",
          "label": "t:sections.mega_menu_v5.settings.index_number.option_3.label"
        },
        {
          "value": "3",
          "label": "t:sections.mega_menu_v5.settings.index_number.option_4.label"
        },
        {
          "value": "4",
          "label": "t:sections.mega_menu_v5.settings.index_number.option_5.label"
        },
        {
          "value": "5",
          "label": "t:sections.mega_menu_v5.settings.index_number.option_6.label"
        }
      ]
    },
    {
      "type": "text",
      "id": "heading_1",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v5.settings.heading_1.label"
    },
    {
      "type": "link_list",
      "id": "menu_style1",
      "label": "t:sections.mega_menu_v5.settings.menu_style1.label",
      "info": "t:sections.mega_menu_v5.settings.menu_style1.info"
    },
    {
      "type": "text",
      "id": "heading_2",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v5.settings.heading_2.label"
    },
    {
      "type": "link_list",
      "id": "menu_style2",
      "label": "t:sections.mega_menu_v5.settings.menu_style2.label",
      "info": "t:sections.mega_menu_v5.settings.menu_style2.info"
    },
    {
      "type": "text",
      "id": "heading_3",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v5.settings.heading_3.label"
    },
    {
      "type": "link_list",
      "id": "menu_style3",
      "label": "t:sections.mega_menu_v5.settings.menu_style3.label",
      "info": "t:sections.mega_menu_v5.settings.menu_style3.info"
    },
    {
      "type": "text",
      "id": "heading_4",
      "default": "Quick links",
      "label": "t:sections.mega_menu_v5.settings.heading_4.label"
    },
    {
      "type": "link_list",
      "id": "menu_style4",
      "label": "t:sections.mega_menu_v5.settings.menu_style4.label",
      "info": "t:sections.mega_menu_v5.settings.menu_style4.info"
    },
    {
      "type": "text",
      "id": "heading_5",
      "default": "Blog post",
      "label": "t:sections.mega_menu_v5.settings.heading_5.label"
    },
    {
      "type": "range",
      "id": "limit",
      "min": 2,
      "max": 4,
      "step": 1,
      "default": 3,
      "label": "t:sections.mega_menu_v5.settings.limit.label"
    },
    {
      "type": "blog",
      "id": "blog",
      "label": "t:sections.mega_menu_v5.settings.blog.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
    }
  ],
  "presets": [
    {
      "name": "t:sections.mega_menu_v5.presets.name",
      "settings": {
        "blog": "Test"
      }
    }
  ]
}
{% endschema %}
