Skip to content

Commit

Permalink
ISSUE-565: Allow client to pass attributes to the pagination list.
Browse files Browse the repository at this point in the history
  • Loading branch information
msnassar committed Dec 15, 2023
1 parent 13a2396 commit 039a173
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/components/bcl-pagination/pagination.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
}
- icon_path (string) (default: '')
- attributes (drupal attrs)
- list_attributes (drupal attrs)
#}

{% set _size = size|default('') %}
Expand Down Expand Up @@ -102,19 +103,23 @@

{% set _internal_items = _internal_items|merge([_next, _last]) %}

{% if attributes is empty %}
{% set attributes = create_attribute() %}
{% if list_attributes is empty %}
{% set list_attributes = create_attribute() %}
{% endif %}

{% set _classes = ['pagination'] %}
{% set list_attributes = list_attributes.addClass('pagination') %}
{% if _size is not empty %}
{% set _classes = _classes|merge(['pagination-' ~ _size]) %}
{% set list_attributes = list_attributes.addClass('pagination-' ~ _size) %}
{% endif %}
{% if _variant is not empty %}
{% set _classes = _classes|merge(['pagination--' ~ _variant]) %}
{% set list_attributes = list_attributes.addClass('pagination--' ~ _variant) %}
{% endif %}
{% if _alignment is not empty %}
{% set _classes = _classes|merge(['justify-content-' ~ _alignment]) %}
{% set list_attributes = list_attributes.addClass('justify-content-' ~ _alignment) %}
{% endif %}

{% if attributes is empty %}
{% set attributes = create_attribute() %}
{% endif %}

{% set attributes = attributes.setAttribute('role', 'navigation') %}
Expand All @@ -130,7 +135,7 @@
<nav
{{ attributes }}
>
<ul class="{{ _classes|join(' ') }}">
<ul {{ list_attributes }}>
{% if _internal_items is not empty and _internal_items is iterable %}
{% for _item in _internal_items %}
{% if _item is not empty %}
Expand Down

0 comments on commit 039a173

Please sign in to comment.