{#
Title: General CTA
Description: Sitewide Inline CTA
Category: formatting
Icon: admin-comments
Keywords: CTA global text
Mode: preview
Align: full
SupportsAlign: full false
#}
{% extends '/views/parts/logic/block-settings.twig' %}
{% block blocksettings  %}
    {% block inlineCTA %}
        {% set ctaIndex = fields.cta ? (fields.cta|number_format(0, '', '') - 1) : null %}
        {% set globalCtas = theme_settings['global_ctas'] ?? {} %}
        {% set ctas = globalCtas.ctas ?? [] %}
        {% set cta = (ctaIndex is not null and ctas[ctaIndex] is defined) ? ctas[ctaIndex] : null %}

        {% if cta %}
            {% set bgImageId = cta.background_image ?? null %}
            {% set bgImageUrl = bgImageId ? function('wp_get_attachment_image_url', bgImageId, 'full') : '' %}
            {% set layout = cta.layout ?? 'inline' %}

            <div
                    class="cta general-cta cta--{{ layout }} {{ outer_classes }} cta--{{ ctaIndex }} {{ fields.custom_identifier_class }}"
                    {% if bgImageUrl %}style="background-image: url('{{ bgImageUrl }}');"{% endif %}
            >
                <div class="content align-content-center {{ inner_classes }}">
                    <div class="general-cta__row">
                        <div class="general-cta__text">
                            {% if cta.title %}<h3>{{ cta.title }}</h3>{% endif %}
                            {% if cta.tagline %}<div class="general-cta__tagline">{{ cta.tagline }}</div>{% endif %}
                        </div>

                        <div class="general-cta__actions">
                            {% if cta.button %}
                                {% set button = cta.button %}
                                {{ include('views/parts/button.twig') }}
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
        {% endif %}
    {% endblock %}
{% endblock %}