Skip to content

Commit

Permalink
feat(shs-6080): update twig filters and modernize js code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari Nez committed Mar 4, 2025
1 parent bbb20ce commit 4f415b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import togglerHandler from './toggler-handler';
for (let i = 0; i < togglers.length; i += 1) {
const toggler = togglers[i];
const togglerID = toggler.getAttribute('aria-controls');
const togglerContent = document.querySelector('[id="'.concat(togglerID, '"]'));
const togglerContent = document.querySelector(`[id="${togglerID}"]`);
const togglerParent = toggler.parentNode;
const activeTrail = togglerParent.classList.contains('hb-secondary-nav__item--active-trail');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
acts as the button to toggle the nested navigation.
#}
{% set link_attributes = link_attributes.addClass('hb-secondary-toggler') %}
{% set randomInt = random(0, 100) %}
<a{{ link_attributes }} aria-controls="{{ item.title|replace({' ': ''}) }}{{ menu_level }}{{ randomInt }}" aria-expanded="true" role="button">{{ item.title }}</a>
{% set unique_id = item.title|clean_class|clean_unique_id %}
<a{{ link_attributes }} aria-controls="{{ unique_id }}" aria-expanded="true" role="button">{{ item.title }}</a>

{% if item.below %}
<div class="{{ class_prefix }}__menu-container" id="{{ item.title|replace({' ': ''}) }}{{ menu_level }}{{ randomInt }}" aria-hidden="false">
<div class="{{ class_prefix }}__menu-container" id="{{ unique_id }}" aria-hidden="false">
{{ menus.secondary_nav_menu(item.below, menu_level + 1, class_prefix, item) }}
</div>
{% endif %}
Expand All @@ -52,11 +52,11 @@
{{ link(item.title, item.url, link_attributes) }}

{% if item.below %}
{% set randomInt = random(0, 100) %}
<button class="{{ class_prefix }}__button hb-secondary-toggler" aria-controls="{{ item.title|replace({' ': ''}) }}{{ menu_level }}{{ randomInt }}" aria-expanded="true">
{% set unique_id = item.title|clean_class|clean_unique_id %}
<button class="{{ class_prefix }}__button hb-secondary-toggler" aria-controls="{{ unique_id }}" aria-expanded="true">
Toggle {{ item.title }}
</button>
<div class="{{ class_prefix }}__menu-container" id="{{ item.title|replace({' ': ''}) }}{{ menu_level }}{{ randomInt }}" aria-hidden="false">
<div class="{{ class_prefix }}__menu-container" id="{{ unique_id }}" aria-hidden="false">
{{ menus.secondary_nav_menu(item.below, menu_level + 1, class_prefix, item) }}
</div>
{% endif %}
Expand Down

0 comments on commit 4f415b9

Please sign in to comment.