{#
Title: Two Column Link Rows
Description: Repeating two-column rows of links with configurable Bootstrap widths
Category: formatting
Icon: columns
Keywords: two column rows links
Mode: preview
Align: full
SupportsAlign: full false
#}

{% extends '/views/parts/logic/block-settings.twig' %}

{% import 'views/parts/logic/bootstrap-col-classes.twig' as bscols %}

{% block blocksettings %}
    {% block twocolumnlinkrows %}

        {% set bps = fields.column_widths.breakpoints|default([]) %}
        {% set col1 = bscols.from_breakpoints(bps, 1, ['col-12','col-md-3']) %}
        {% set col2 = bscols.from_breakpoints(bps, 2, ['col-12','col-md-9']) %}

        <section class="two-column-rows {{ outer_classes }}">
            <div class="{{ inner_classes }}">
                {% if fields.main_header %}<h2>{{ fields.main_header }}</h2>{% endif %}

                {% for row in fields.rows|default([]) %}
                    <div class="row two-column-rows__row">
                        <div class="{{ col1 }} two-column-rows__col two-column-rows__col--title">
                            {% if row.title %}<h3>{{ row.title }}</h3>{% endif %}
                        </div>

                        <div class="{{ col2 }} two-column-rows__col two-column-rows__col--links">
                            {% if row.links %}
                                <div class="two-column-rows__links">
                                    {% set printed = 0 %}
                                    {% for item in row.links %}
                                        {% set l = item.link %}
                                        {% if l and l.url %}
                                            {% if printed > 0 %}<span class="two-column-rows__sep" aria-hidden="true">·</span>{% endif %}
                                            <a href="{{ l.url }}" {% if l.target %}target="{{ l.target }}"{% endif %}>
                                                {{ l.title ?: l.url }}
                                            </a>
                                            {% set printed = printed + 1 %}
                                        {% endif %}
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                    </div>
                {% endfor %}
            </div>
        </section>
    {% endblock %}
{% endblock %}