Skip to content

Commit

Permalink
feat(sidebar): plus / minus icon interactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Neox63 committed Jul 15, 2024
1 parent cca748c commit c715143
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions components/Molecules/MenuButton/MainMenuButton.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
<div class="MainMenuButton-plus">
{{ source("/icons/plus.svg") }}
</div>
<div class="hidden MainMenuButton-minus">
{{ source("/icons/minus.svg") }}
</div>
{% endif %}
</a>
6 changes: 4 additions & 2 deletions components/Molecules/MenuButton/menuButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
margin-right: rem-convert(8px);
}

&-plus {
&-plus,
&-minus {
margin-left: auto;
}

&-icon,
&-plus {
&-plus,
&-minus {
width: rem-convert(22px);
height: rem-convert(22px);
}
Expand Down
2 changes: 1 addition & 1 deletion components/Organisms/Sidebar/Sidebar.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% include '../../Molecules/MenuButton/MainMenuButton.twig' with { label: ' Dashboard', icon: "dashboard", href: "#" } %}
</li>
<li class='Sidebar-menu-item'>
{% include '../../Molecules/MenuButton/MainMenuButton.twig' with { label: 'Commandes', icon: "orders", hasSubMenus: true, href: "#" } %}
{% include '../../Molecules/MenuButton/MainMenuButton.twig' with { label: 'Commandes', icon: "orders", hasSubMenus: true, isOpen: false, href: "#" } %}
<ul class="Sidebar-menu-item-submenu">
{% include '../../Molecules/MenuButton/SubMenuButton.twig' with { label: 'Toutes mes commandes', count: 24, labelClasses: "bg-white text-black" } %}
{% include '../../Molecules/MenuButton/SubMenuButton.twig' with { label: 'Non payée', count: 2, labelClasses: "bg-warning text-black" } %}
Expand Down
15 changes: 14 additions & 1 deletion components/Organisms/Sidebar/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ export const sidebar = () => {
b.classList.remove('MainMenuButton--selected');
if (b.classList.contains('MainMenuButton--hasSubMenus')) {
const bSubMenus = b.nextElementSibling;
if (bSubMenus)
if (bSubMenus) {
bSubMenus.classList.remove('Sidebar-menu-item-submenu--open');
b.querySelector('.MainMenuButton-minus').classList.add('hidden');
b.querySelector('.MainMenuButton-plus').classList.remove(
'hidden'
);
}
}
}
});
Expand All @@ -27,6 +32,14 @@ export const sidebar = () => {
'Sidebar-menu-item-submenu--open',
!isSelected
);

button
.querySelector('.MainMenuButton-plus')
.classList.toggle('hidden', !isSelected);

button
.querySelector('.MainMenuButton-minus')
.classList.toggle('hidden', isSelected);
}
});
});
Expand Down

0 comments on commit c715143

Please sign in to comment.