Skip to content

Commit

Permalink
rename to ibexa-tabs-switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
GrabowskiM committed Aug 9, 2023
1 parent 48016b3 commit 0646b2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
};
let currentlyVisibleSections = getSectionGroupActiveItems();
const attachSectionGroupsMenuListEvents = () => {
const items = doc.querySelectorAll('.ibexa-anchor-navigation-menu__section-groups--list .ibexa-switcher__item');
const items = doc.querySelectorAll('.ibexa-anchor-navigation-menu__section-groups--list .ibexa-tab-switcher__item');

items.forEach((item) => item.addEventListener('click', onSelectSectionGroupsMenuList, false));
};
Expand All @@ -38,10 +38,10 @@
const onSelectSectionGroupsMenuList = (event) => {
const { targetId } = event.currentTarget.dataset;
const sectionsMenuNode = doc.querySelector(`.ibexa-anchor-navigation-menu__sections[data-id="${targetId}"]`);
const sectionGroupsMenuItems = doc.querySelectorAll('.ibexa-anchor-navigation-menu__section-groups--list .ibexa-switcher__item');
const sectionGroupsMenuItems = doc.querySelectorAll('.ibexa-anchor-navigation-menu__section-groups--list .ibexa-tab-switcher__item');

sectionGroupsMenuItems.forEach((item) => {
item.classList.toggle('ibexa-switcher__item--active', item.isSameNode(event.currentTarget));
item.classList.toggle('ibexa-tab-switcher__item--active', item.isSameNode(event.currentTarget));
});
showSectionGroup(targetId);
showSectionsMenu(sectionsMenuNode);
Expand Down Expand Up @@ -201,17 +201,17 @@
const { id } = sectionGroup.dataset;
const hasGroupError = !!sectionGroup.querySelector('.is-invalid');
const correspondingMenuItem =
doc.querySelector(`.ibexa-switcher__item[data-target-id="${id}"]`) ??
doc.querySelector(`.ibexa-tab-switcher__item[data-target-id="${id}"]`) ??
doc.querySelector(`.ibexa-anchor-navigation-menu .ibexa-dropdown__item[data-value="${id}"]`);

if (!correspondingMenuItem) {
return;
}

const errorIconNode = correspondingMenuItem.querySelector('.ibexa-switcher__item-error');
const errorIconNode = correspondingMenuItem.querySelector('.ibexa-tab-switcher__item-error');
const dropdownWidget = doc.querySelector('.ibexa-anchor-navigation-menu .ibexa-dropdown');

errorIconNode.classList.toggle('ibexa-switcher__item-error--hidden', !hasGroupError);
errorIconNode.classList.toggle('ibexa-tab-switcher__item-error--hidden', !hasGroupError);

if (dropdownWidget) {
const hasError = !!dropdownWidget.querySelector(
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/public/scss/_switcher.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.ibexa-switcher {
.ibexa-tab-switcher {
padding: calculateRem(4px);
border-radius: $ibexa-border-radius;
background-color: $ibexa-color-light-300;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

{% block children_1st_level %}
{% for item in currentItem.children %}
{%- set itemClass = 'ibexa-switcher__item' %}
{%- set itemClass = 'ibexa-tab-switcher__item' %}
{%- if loop.first %}
{%- set itemClass = itemClass ~ ' ibexa-switcher__item--active' %}
{%- set itemClass = itemClass ~ ' ibexa-tab-switcher__item--active' %}
{%- endif %}
{%- do item.setAttribute('class', (item.getAttribute('class') ~ ' ' ~ itemClass)|trim) -%}
{%- do item.setAttribute('data-target-id', "#" ~ item.getAttribute('data-target-id')) -%}
Expand Down Expand Up @@ -140,9 +140,9 @@
{%- set itemTagElement = itemTagElement|default('button') %}

<{{ itemTagElement }}{{ knp_menu.attributes(attributes) }}>
<div class="ibexa-anchor-navigation-menu__item-label ibexa-switcher__item-label" title="{{ block('label')|raw }}">
<div class="ibexa-anchor-navigation-menu__item-label ibexa-tab-switcher__item-label" title="{{ block('label')|raw }}">
{{ block('label') }}
<svg class="ibexa-icon ibexa-icon--small ibexa-switcher__item-error ibexa-switcher__item-error--hidden">
<svg class="ibexa-icon ibexa-icon--small ibexa-tab-switcher__item-error ibexa-tab-switcher__item-error--hidden">
<use xlink:href="{{ ibexa_icon_path('warning-triangle') }}"></use>
</svg>
</div>
Expand All @@ -164,7 +164,7 @@
{% block root %}
<div class="ibexa-anchor-navigation">
{% if item.count() < 4 %}
{% set listAttributes = item.childrenAttributes|merge({'class': (listAttributes.class|default('') ~ ' ibexa-anchor-navigation-menu__section-groups ibexa-anchor-navigation-menu__section-groups--list ibexa-switcher')|trim}) %}
{% set listAttributes = item.childrenAttributes|merge({'class': (listAttributes.class|default('') ~ ' ibexa-anchor-navigation-menu__section-groups ibexa-anchor-navigation-menu__section-groups--list ibexa-tab-switcher')|trim}) %}
{% set innerChildrenBlock = 'children_1st_level' %}
{% set innerItemBlock = 'item_1st_level' %}
{% set tagElement = 'div' %}
Expand Down

0 comments on commit 0646b2f

Please sign in to comment.