{% comment %}
  Renders a popup-newsletter-v1

  Accepts:
  - subtitle: {String} subtitle of the popup-newsletter
  - title: {String} Subsubtitle of the popup-newsletter (Optional)
  - description: {String} Description of the popup-newsletter (Optional)
  - placeholder: {String} Placeholder for the input signup form (Optional)
  - button_label: {String} Label for the button
  - image: {String} Image for the popup-newsletter

  Usage:
  {% render 'popup-newsletter-v1',
    subtitle: 'SIGNUP FOR EMAILS',
    title: 'Get 20% discount shipped to your inbox',
    description: 'Subscribe to our newsletter and we will ship <strong>20% discount code</strong> today',
    button_label: 'Subscribe',
     image: '{{image}}'
   %}
{% endcomment %}

{% assign subtitle = settings.popup_newsletter_subtitle %}
{% assign title = settings.popup_newsletter_title %}
{% assign description = settings.popup_newsletter_description %}
{% assign placeholder = 'newsletter.email' | t %}
{% assign button_text = 'newsletter.button_label' | t %}
{% assign image = settings.popup_newsletter_image %}

<div class='popup-newsletter-v1'>
  <xo-grid style='--xs: 1; --md: 2; --xo-grid-col-gap: 0;'>
    <div class='popup-newsletter-v1__left'>
      <div class='popup-newsletter-v1__close popup-newsletter-v1__close--mb'>
        <xo-modal-trigger class='xo-modal-content-style1__close{% if close_class %} {{ close_class }}{% endif %}'>
          {% render 'icon', name: 'close2', icon_size: '15' %}
        </xo-modal-trigger>
      </div>
      <div class='popup-newsletter-v1__content'>
        {%- if subtitle != blank -%}
          <div class='popup-newsletter-v1__subtitle'>{{ subtitle }}</div>
        {%- endif -%}
        {%- if title != blank -%}
          <h1 class='popup-newsletter-v1__title'>{{ title }}</h1>
        {%- endif -%}
        {%- if description != blank -%}
          <div class='popup-newsletter-v1__description'>
            {{ description }}
          </div>
        {%- endif -%}

        <div class='popup-newsletter-v1__signup'>
          {%- form 'customer', id: 'ContactFooter' -%}
            <input type='hidden' name='contact[tags]' value='newsletter'>
            <div class='popup-newsletter-v1__form'>
              {% assign value = form.email %}
              {% 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: placeholder, attr: attr %}
              {% render 'newsletter-form-message', form: form %}
              {% render 'button', type: 'submit', text: button_text, style: 'secondary', mode: settings.popup_newsletter_button_mode, size: 'md', padding: 3 %}
            </div>
          {%- endform -%}
        </div>

        <xo-modal-trigger>
          <div class='popup-newsletter-v1__close-text'>{{ 'newsletter.ignore' | t }}</div>
        </xo-modal-trigger>
      </div>
    </div>

    <div class='popup-newsletter-v1__right'>
      <div class='popup-newsletter-v1__close'>
        <xo-modal-trigger class='xo-modal-content-style1__close{% if close_class %} {{ close_class }}{% endif %}'>
          {% render 'icon', name: 'close2', icon_size: '15' %}
        </xo-modal-trigger>
      </div>
      <div class='popup-newsletter-v1__img'>
        {% render 'image', image: image %}
      </div>
    </div>
  </xo-grid>
</div>
