

<div {% render 'section-attr' %}>
  <div class='slideshow-v1__carousel'>
    <div class='list'>
      {% for block in section.blocks %}
        <div class='item'>
          <img src='{{ block.settings.img_product | image_url }}' width='1000' height='1000'>
          <div class='introduce'>
            <div class='title'>{{ block.settings.title }}</div>
            <div class='topic'>{{ block.settings.subtitle }}</div>
            <div class='des'>
              {{ block.settings.desc }}
            </div>
            <div class='seeMore'>
              {% render 'button',
                text: block.settings.button_text,
                link: block.settings.button_link,
                mode: block.settings.button_mode,
                style: block.settings.button_style,
                size: block.settings.button_size,
                radius: block.settings.button_radius,
                padding: block.settings.button_padding
              %}
            </div>
          </div>
        </div>
      {% endfor %}
    </div>
    <div class='arrows'>
      <button id='prev'>
        {%- render 'icon', name: 'arrow-left', icon_size: '15' -%}
      </button>
      <button id='next'>
        {%- render 'icon', name: 'arrow-right', icon_size: '15' -%}
      </button>
    </div>
  </div>
</div>

<script>
  let nextButton = document.getElementById('next');
  let prevButton = document.getElementById('prev');
  let carousel = document.querySelector('.slideshow-v1__carousel');
  let listHTML = document.querySelector('.slideshow-v1__carousel .list');
  let seeMoreButtons = document.querySelectorAll('.seeMore');
  let backButton = document.getElementById('back');
  if (nextButton) {
    nextButton.onclick = function () {
      showSlider('next');
    };
  }
  if (prevButton) {
    prevButton.onclick = function () {
      showSlider('prev');
    };
  }
  let unAcceppClick;
  const showSlider = (type) => {
    carousel.classList.remove('next', 'prev');
    let items = document.querySelectorAll('.slideshow-v1__carousel .list .item');
    if (type === 'next') {
      listHTML.appendChild(items[0]);
      carousel.classList.add('next');
    } else {
      listHTML.prepend(items[items.length - 1]);
      carousel.classList.add('prev');
    }
  };
  seeMoreButtons.forEach((button) => {
    if (button) {
      button.onclick = function () {
        carousel.classList.remove('next', 'prev');
        carousel.classList.add('showDetail');
      };
    }
  });
  if (backButton) {
    backButton.onclick = function () {
      carousel.classList.remove('showDetail');
    };
  }
</script>

{% schema %}
{
  "name": "t:sections.slideshow_v1.name",
  "tag": "section",
  "class": "section",
  "settings": [
    {
      "type": "header",
      "content": "t:sections.all.heading.content"
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:sections.all.color_scheme.label"
    },
    {
      "type": "select",
      "id": "background_type",
      "label": "t:sections.all.background_type.label",
      "options": [
        {
          "value": "color",
          "label": "t:sections.all.background_type.option__1.label"
        },
        {
          "value": "gradient",
          "label": "t:sections.all.background_type.option__2.label"
        },
        {
          "value": "image",
          "label": "t:sections.all.background_type.option__3.label"
        },
        {
          "value": "video",
          "label": "t:sections.all.background_type.option__4.label"
        }
      ],
      "default": "color"
    },
    {
      "type": "color",
      "id": "background_color",
      "label": "t:sections.all.background_color.label",
      "alpha": true,
      "visible_if": "{{ section.settings.background_type == 'color' }}"
    },
    {
      "type": "color_background",
      "id": "background_gradient",
      "label": "t:sections.all.background_gradient.label",
      "visible_if": "{{ section.settings.background_type == 'gradient' }}"
    },
    {
      "type": "number",
      "id": "background_margin",
      "label": "t:sections.all.background_margin.label",
      "default": 0
    },
    {
      "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
    }
  ],
  "blocks": [
    {
      "type": "slideshow",
      "name": "t:sections.slideshow_v1.settings.blocks.name",
      "settings": [
        {
          "type": "image_picker",
          "id": "img_product",
          "label": "t:sections.slideshow_v1.settings.blocks.img_product.label"
        },
        {
          "type": "text",
          "id": "title",
          "label": "t:sections.slideshow_v1.settings.blocks.title.label",
          "default": "SLIDESHOW TITLE"
        },
        {
          "type": "text",
          "id": "subtitle",
          "label": "t:sections.slideshow_v1.settings.blocks.subtitle.label",
          "default": "SUBTITLE"
        },
        {
          "type": "richtext",
          "id": "desc",
          "label": "t:sections.slideshow_v1.settings.blocks.desc.label",
          "default": "<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia, laborum cumque dignissimos quidem atque et eligendi aperiam voluptates beatae maxime.</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"
            },
            {
              "value": "accent",
              "label": "t:sections.all.button_mode.option__3.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
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "t:sections.slideshow_v1.presets.name"
    }
  ]
}
{% endschema %}
