{{ 'section-newsletter-v2.css' | asset_url | stylesheet_tag }}

<section {% render 'section-attr', style: 'border-top: solid 0.1rem rgba(var(--color-border),0.1); --pt-mobile: 50px; --pb-mobile: 50px' %}>
  {% render 'section-bg-image' %}
  <div class='newsletter-v2'>
    <div class='newsletter-v2__all'>
      <div class='newsletter-v2__info'>
        <h3 class='newsletter-v2__title'>
          {{ section.settings.title }}
        </h3>
        <div class='newsletter-v2__title-sub'>
          {{ section.settings.title_sub }}
        </div>
      </div>
      <div class='newsletter-v2__form'>
        {%- form 'customer', id: 'ContactFooter', class: 'xo-footer-block__form' -%}
          <input type='hidden' name='contact[tags]' value='newsletter'>
          <div class='newsletter-v2__input-btn'>
            {% assign value = form.email %}
            {% assign label = 'newsletter.label' | t %}
            {% capture attr %}
              aria-required='true'
              autocorrect='off'
              {% if form.errors %}
                autofocus
                aria-invalid='true'
                aria-describedby='ContactFooter-error'
              {% elsif form.posted_successfully? %}
                aria-describedby='ContactFooter-success'
              {% endif %}
                required
              {% endcapture %}
            {% render 'field-input', type: 'email', name: 'contact[email]', value: value, placeholder: 'Your email address...', attr: attr %}

            <div class='newsletter-v2__btn'>
              {% render 'button', text: section.settings.button_text, class: 'email-v2', style: 'secondary', type: 'submit', size: 'md' %}
            </div>

            {%- if form.errors -%}
              <small class='newsletter-form__message form__message' id='ContactFooter-error'>
                {%- render 'icon-error' -%}
                {{- form.errors.translated_fields.email | capitalize }}
                {{ form.errors.messages.email -}}
              </small>
            {%- endif -%}
            {%- if form.posted_successfully? -%}
              <h3
                class='newsletter-form__message newsletter-form__message--success form__message'
                id='ContactFooter-success'
                tabindex='-1'
                autofocus
              >
                {% render 'icon-success' -%}
                {{- 'newsletter.success' | t }}
              </h3>
            {%- endif -%}
          </div>
        {%- endform -%}
      </div>
    </div>
  </div>
</section>

{% schema %}
{
  "name": "t:sections.newsletter_v2.name",
  "tag": "section",
  "class": "section",
  "settings": [
    {
      "type": "text",
      "id": "title",
      "label": "t:sections.newsletter_v2.settings.title.label"
    },
    {
      "type": "text",
      "id": "title_sub",
      "label": "t:sections.newsletter_v2.settings.title-sub.label"
    },
    {
      "type": "text",
      "id": "button_text",
      "label": "t:sections.newsletter_v2.settings.button_text.label",
      "default": "Submit now"
    },
    {
      "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.newsletter_v2.presets.name"
    }
  ]
}
{% endschema %}
