Skip to content

Commit

Permalink
set custom list attributes on list item not link
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccar committed Sep 10, 2024
1 parent 2b9adba commit ddeb99b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/components/list/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
{% set listEl = 'ul' %}
{% endif %}

{# Remove "and not params.itemsList[0].url" in future update #}
{% if listLength < 2 and not params.attributes and not params.itemsList[0].url %}
{% if listLength < 2 and not params.attributes %}
{% set attributes = params.itemsList[0].attributes %}
{% else %}
{% set attributes = params.attributes %}
Expand Down Expand Up @@ -82,11 +81,10 @@
})
}}
{%- else -%}
{# Remove setting attributes on link in future update #}
<a
href="{{ item.url }}"
class="ons-list__link{{ ' ons-js-inpagelink' if item.variants == 'inPageLink' }}{{ ' ' + item.classes if item.classes else '' }}"
{% if item.target %}target="{{ item.target }}"{% endif %}{% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}
{% if item.target %}target="{{ item.target }}"{% endif %}
>
{%- if item.prefix -%}<span class="ons-u-vh">{{- item.prefix -}}</span>{%- endif -%} {{- itemText | safe -}}
{%- if item.target == "_blank" -%}
Expand Down Expand Up @@ -124,11 +122,10 @@
{% endset %}

{% if listLength > 1 or listEl == 'ul' %}
{# Remove if not item.url in future update #}
<li
class="ons-list__item{{ ' ' + item.listClasses if item.listClasses else '' }}"
{% if item.current %}aria-current="true"{% endif %}
{% if not item.url %}{% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}{% endif %}
{% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{ ' ' }}{{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}
>
{{- listItem | safe -}}
</li>
Expand Down

0 comments on commit ddeb99b

Please sign in to comment.