{#
/**
 * @file
 * Vartheme BS5 Starter Kit implementation for views to display items in a grid.
 *
 * Available variables:
 * - attributes: HTML attributes for the wrapping element.
 * - title: The title of this group of items.
 * - view: The view object.
 * - items: The rendered view results.
 * - options: The view plugin style options.
 *   - row_class_default: A flag indicating whether default classes should be
 *     used on items.
 *   - col_class_default: A flag indicating whether default classes should be
 *     used on data_items.
 * - items: A list of grid items. Each item contains a list of items or data_items.
 *   The order in what comes first (row or item) depends on which alignment
 *   type is chosen (horizontal or vertical).
 *   - attributes: HTML attributes for each row or item.
 *   - content: A list of data_items or items. Each row or item contains:
 *     - attributes: HTML attributes for each row or item.
 *     - content: The row or item contents.
 *
 */
#}

{% set col_xs = col_xs ? [col_xs] : [] %}
{% set col_sm = col_sm ? [col_sm] : [] %}
{% set col_md = col_md ? [col_md] : [] %}
{% set col_lg = col_lg ? [col_lg] : [] %}
{% set col_xl = col_xl ? [col_xl] : [] %}
{% set col_xxl = col_xxl ? [col_xxl] : [] %}

{% set grid_utility_classes = grid_utility_classes ?? [] %}
{% set column_utility_classes = column_utility_classes ?? [] %}


{%
  set classes = [
    'grid',
    'row',
    'clearfix',
  ]|merge(grid_utility_classes)
%}

{% if not attributes %}
  {% set attributes = create_attribute() %}
{% endif %}

{% set attributes = attributes.addClass(classes) %}

{% if items is iterable %}
<div{{ attributes }}>
  {% for item in items %}
    {% set item_attributes = create_attribute() %}
    {% set item_classes = []|merge(column_utility_classes)|merge(col_xs)|merge(col_sm)|merge(col_md)|merge(col_lg)|merge(col_xl)|merge(col_xxl) %}
    {% set item_attributes = item_attributes.addClass(item_classes) %}
    <div{{ item_attributes }}>
      {{ item }}
    </div>
  {% endfor %}
</div>
{% endif %}