@buerokratt-ria/menu 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/menu/index.tsx
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState, useMemo } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
4
|
-
MdKeyboardArrowRight,
|
|
5
|
-
MdKeyboardArrowLeft,
|
|
6
|
-
} from 'react-icons/md';
|
|
3
|
+
import { MdClose } from 'react-icons/md';
|
|
7
4
|
import Icon from './components/icons/icon/icon';
|
|
8
5
|
import { useTranslation } from "react-i18next";
|
|
9
6
|
import MenuTree from './components/menuTree';
|
|
@@ -23,17 +20,19 @@ const MainNavigation: FC = () => {
|
|
|
23
20
|
event.currentTarget.setAttribute('aria-expanded', isExpanded ? 'false' : 'true');
|
|
24
21
|
};
|
|
25
22
|
|
|
23
|
+
const handleCloseButtonClick = () => {
|
|
24
|
+
const doesMenuHasExpandedItem = !!document.querySelector('button[aria-expanded="true"]');
|
|
25
|
+
if(doesMenuHasExpandedItem)
|
|
26
|
+
setNavCollapsed(!navCollapsed);
|
|
27
|
+
}
|
|
28
|
+
|
|
26
29
|
if (!menuItems) return null;
|
|
27
30
|
|
|
28
31
|
return (
|
|
29
32
|
<nav className={clsx('nav', { 'collapsed': navCollapsed })}>
|
|
30
|
-
<button className='nav__menu-toggle close-button-item' onClick={
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
? <Icon icon={<MdKeyboardArrowRight className='menu-item-icon' />} size='large' />
|
|
34
|
-
: <Icon icon={<MdKeyboardArrowLeft className='menu-item-icon' />} size='large' />
|
|
35
|
-
}
|
|
36
|
-
<span className='menu-item-title'>{t('mainMenu.closeMenu')}</span>
|
|
33
|
+
<button className='nav__menu-toggle close-button-item' onClick={handleCloseButtonClick}>
|
|
34
|
+
<Icon icon={<MdClose />} />
|
|
35
|
+
<span className='menu-item-title'>{t(navCollapsed ? 'mainMenu.openMenu' : 'mainMenu.closeMenu' )}</span>
|
|
37
36
|
</button>
|
|
38
37
|
<ul className='nav__menu'>
|
|
39
38
|
<MenuTree
|
|
@@ -116,24 +116,14 @@
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
.collapsed {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
.menu-item-title {
|
|
123
|
-
display: none !important;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.menu-item-icon {
|
|
127
|
-
height: 24px;
|
|
128
|
-
width: 24px;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.close-button-item,
|
|
132
|
-
button.nav__toggle {
|
|
133
|
-
justify-content: center;
|
|
119
|
+
.nav__submenu {
|
|
120
|
+
visibility: hidden;
|
|
121
|
+
height: 0;
|
|
134
122
|
}
|
|
135
123
|
|
|
136
|
-
|
|
137
|
-
|
|
124
|
+
button[aria-expanded=true] {
|
|
125
|
+
.icon {
|
|
126
|
+
transform: rotate(0deg);
|
|
127
|
+
}
|
|
138
128
|
}
|
|
139
129
|
}
|
|
Binary file
|