@buerokratt-ria/menu 0.1.5 → 0.1.7
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 +8 -0
- package/buerokratt-ria-menu-0.1.7.tgz +0 -0
- package/package.json +1 -1
- package/src/menu/components/icons/icon/icon.tsx +4 -3
- package/src/menu/components/icons/icon.scss +5 -0
- package/src/menu/index.tsx +58 -45
- package/src/menu/main-navigation.scss +23 -3
- package/buerokratt-ria-menu-0.1.5.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.1.7] - 27-05-2024
|
|
6
|
+
|
|
7
|
+
- Fix close menu button
|
|
8
|
+
|
|
9
|
+
## [0.1.6] - 25-04-2024
|
|
10
|
+
|
|
11
|
+
- Updated api call addresses
|
|
12
|
+
|
|
5
13
|
## [0.1.5] - 27-02-2024
|
|
6
14
|
|
|
7
15
|
- Added path /auto-services menu element to Training module
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -12,12 +12,13 @@ import '../icon.scss';
|
|
|
12
12
|
type IconProps = StyleHTMLAttributes<CSSProperties> & {
|
|
13
13
|
label?: string | null;
|
|
14
14
|
icon: ReactNode;
|
|
15
|
-
size?: 'small' | 'medium';
|
|
15
|
+
size?: 'small' | 'medium' | 'large';
|
|
16
|
+
className?: string;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const IconComponent = forwardRef<HTMLSpanElement, IconProps>(
|
|
19
|
-
({ label, icon, size = 'small', ...rest }, ref) => {
|
|
20
|
-
const iconClasses = clsx('icon', `icon--${size}
|
|
20
|
+
({ label, icon, className, size = 'small', ...rest }, ref) => {
|
|
21
|
+
const iconClasses = clsx('icon', `icon--${size}`, className);
|
|
21
22
|
|
|
22
23
|
return (
|
|
23
24
|
<AccessibleIcon.Root label={label ?? ''}>
|
package/src/menu/index.tsx
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import React, {FC, MouseEvent, useState} from 'react';
|
|
2
|
-
|
|
3
|
-
import {NavLink, useLocation} from 'react-router-dom';
|
|
1
|
+
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
+
import { NavLink } from 'react-router-dom';
|
|
4
3
|
import clsx from 'clsx';
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
MdOutlineForum,
|
|
6
|
+
MdOutlineAdb,
|
|
7
|
+
MdOutlineEqualizer,
|
|
8
|
+
MdKeyboardArrowDown,
|
|
9
|
+
MdMiscellaneousServices,
|
|
10
|
+
MdSettings,
|
|
11
|
+
MdOutlineMonitorWeight,
|
|
12
|
+
MdKeyboardArrowRight,
|
|
13
|
+
MdKeyboardArrowLeft,
|
|
14
|
+
} from 'react-icons/md';
|
|
15
|
+
import Icon from './components/icons/icon/icon';
|
|
7
16
|
import './main-navigation.scss';
|
|
8
17
|
import { useQuery } from '@tanstack/react-query';
|
|
9
|
-
import {useTranslation} from "react-i18next";
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
10
19
|
import menuStructure from './data/menu-structure.json';
|
|
11
20
|
|
|
12
21
|
interface MenuItem {
|
|
@@ -29,43 +38,42 @@ const MainNavigation: FC<{items: MenuItem[], serviceId: string[]}> = ( {items, s
|
|
|
29
38
|
const { t, i18n } = useTranslation();
|
|
30
39
|
const currentlySelectedLanguage = i18n.language;
|
|
31
40
|
const [menuItems, setMenuItems] = useState<MenuItem[]>([]);
|
|
41
|
+
|
|
32
42
|
const menuData = [
|
|
33
43
|
{
|
|
34
44
|
id: 'conversations',
|
|
35
|
-
icon: <MdOutlineForum />,
|
|
45
|
+
icon: <MdOutlineForum className='menu-item-icon' />,
|
|
36
46
|
url: import.meta.env.REACT_APP_CONVERSATIONS_BASE_URL,
|
|
37
47
|
},
|
|
38
48
|
{
|
|
39
49
|
id: 'training',
|
|
40
|
-
icon: <MdOutlineAdb />,
|
|
50
|
+
icon: <MdOutlineAdb className='menu-item-icon' />,
|
|
41
51
|
url: import.meta.env.REACT_APP_TRAINING_BASE_URL,
|
|
42
52
|
},
|
|
43
53
|
{
|
|
44
54
|
id: 'analytics',
|
|
45
|
-
icon: <MdOutlineEqualizer />,
|
|
55
|
+
icon: <MdOutlineEqualizer className='menu-item-icon' />,
|
|
46
56
|
url: import.meta.env.REACT_APP_ANALYTICS_BASE_URL,
|
|
47
57
|
},
|
|
48
58
|
{
|
|
49
59
|
id: "services",
|
|
50
|
-
icon: <MdMiscellaneousServices />,
|
|
60
|
+
icon: <MdMiscellaneousServices className='menu-item-icon' />,
|
|
51
61
|
url: import.meta.env.REACT_APP_SERVICES_BASE_URL,
|
|
52
62
|
},
|
|
53
63
|
{
|
|
54
64
|
id: 'settings',
|
|
55
|
-
icon: <MdSettings />,
|
|
65
|
+
icon: <MdSettings className='menu-item-icon' />,
|
|
56
66
|
url: import.meta.env.REACT_APP_SETTINGS_BASE_URL,
|
|
57
67
|
},
|
|
58
68
|
{
|
|
59
69
|
id: 'monitoring',
|
|
60
|
-
icon: <MdOutlineMonitorWeight />,
|
|
70
|
+
icon: <MdOutlineMonitorWeight className='menu-item-icon' />,
|
|
61
71
|
url: import.meta.env.REACT_APP_MONITORING_BASE_URL,
|
|
62
72
|
},
|
|
63
73
|
];
|
|
64
74
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const { data } = useQuery({
|
|
68
|
-
queryKey: ['account/user-role', 'prod'],
|
|
75
|
+
useQuery({
|
|
76
|
+
queryKey: ['accounts/user-role', 'prod'],
|
|
69
77
|
onSuccess: (res: any) => {
|
|
70
78
|
const filteredItems =
|
|
71
79
|
items.filter((item) => {
|
|
@@ -88,10 +96,10 @@ const MainNavigation: FC<{items: MenuItem[], serviceId: string[]}> = ( {items, s
|
|
|
88
96
|
},
|
|
89
97
|
});
|
|
90
98
|
|
|
91
|
-
const location = useLocation();
|
|
92
99
|
const [navCollapsed, setNavCollapsed] = useState(false);
|
|
93
100
|
|
|
94
101
|
const handleNavToggle = (event: MouseEvent) => {
|
|
102
|
+
setNavCollapsed(false);
|
|
95
103
|
const isExpanded = event.currentTarget.getAttribute('aria-expanded') === 'true';
|
|
96
104
|
event.currentTarget.setAttribute('aria-expanded', isExpanded ? 'false' : 'true');
|
|
97
105
|
};
|
|
@@ -102,55 +110,60 @@ const MainNavigation: FC<{items: MenuItem[], serviceId: string[]}> = ( {items, s
|
|
|
102
110
|
{!!menuItem.children ? (
|
|
103
111
|
<>
|
|
104
112
|
<button
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
113
|
+
className={clsx('nav__toggle', { 'nav__toggle--icon': !!menuItem.id })}
|
|
114
|
+
aria-expanded={menuItem.path && (isSameRoot(menuItem)) ? 'true' : 'false'}
|
|
115
|
+
onClick={handleNavToggle}
|
|
108
116
|
>
|
|
109
|
-
{
|
|
110
|
-
|
|
117
|
+
{menuItem.id && (
|
|
118
|
+
<Icon icon={menuData.find(dataItem => dataItem.id === menuItem.id)?.icon} size='large' />
|
|
111
119
|
)}
|
|
112
|
-
|
|
113
|
-
<
|
|
114
|
-
<Icon icon={<MdKeyboardArrowDown />} />
|
|
120
|
+
<span className='menu-item-title'>{menuItem.label[currentlySelectedLanguage]}</span>
|
|
121
|
+
<Icon icon={<MdKeyboardArrowDown />} className='menu-item-arrow' />
|
|
115
122
|
</button>
|
|
116
123
|
<ul className='nav__submenu'>
|
|
117
124
|
{renderMenuTree(menuItem.children.map((item) => ({id: menuItem.id, ...item})))}
|
|
118
125
|
</ul>
|
|
119
126
|
</>
|
|
120
127
|
) : (
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
serviceId.includes(menuItem.id)
|
|
129
|
+
? <NavLink to={menuItem.path || '#'}>
|
|
130
|
+
{menuItem.label[currentlySelectedLanguage]}
|
|
131
|
+
</NavLink>
|
|
132
|
+
: <a href={menuData.find(dataItem => dataItem.id === menuItem.id)?.url + menuItem.path}>
|
|
133
|
+
{menuItem.label[currentlySelectedLanguage]}
|
|
134
|
+
</a>
|
|
126
135
|
)}
|
|
127
|
-
</li>
|
|
136
|
+
</li>
|
|
137
|
+
),
|
|
128
138
|
);
|
|
129
139
|
};
|
|
130
140
|
|
|
131
141
|
const base = window.location.pathname.split("/")[1];
|
|
132
142
|
const currentService = base === 'chat' ? serviceId : [base];
|
|
133
143
|
const isSameRoot = (menuItem) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
result = menuItem.children.some((item: MenuItem) => item.path?.includes("/" + window.location.pathname.split("/")[2]));
|
|
144
|
+
if(currentService.includes(menuItem.id)) {
|
|
145
|
+
return menuItem.children.some((item: MenuItem) => item.path?.includes("/" + window.location.pathname.split("/")[2]));
|
|
137
146
|
}
|
|
138
|
-
return
|
|
147
|
+
return false;
|
|
139
148
|
}
|
|
140
149
|
|
|
141
150
|
if (!menuItems) return null;
|
|
142
151
|
|
|
143
152
|
return (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
</
|
|
152
|
-
</
|
|
153
|
+
<nav className={clsx('nav', { 'collapsed': navCollapsed })}>
|
|
154
|
+
<button className='nav__menu-toggle close-button-item' onClick={() => setNavCollapsed(!navCollapsed)}>
|
|
155
|
+
{
|
|
156
|
+
navCollapsed
|
|
157
|
+
? <Icon icon={<MdKeyboardArrowRight className='menu-item-icon' />} size='large' />
|
|
158
|
+
: <Icon icon={<MdKeyboardArrowLeft className='menu-item-icon' />} size='large' />
|
|
159
|
+
}
|
|
160
|
+
<span className='menu-item-title'>{t('mainMenu.closeMenu')}</span>
|
|
161
|
+
</button>
|
|
162
|
+
<ul className='nav__menu'>
|
|
163
|
+
{renderMenuTree(menuItems)}
|
|
164
|
+
</ul>
|
|
165
|
+
</nav>
|
|
153
166
|
);
|
|
154
167
|
};
|
|
155
168
|
|
|
156
|
-
export default MainNavigation;
|
|
169
|
+
export default MainNavigation;
|
|
@@ -57,9 +57,6 @@
|
|
|
57
57
|
&.active {
|
|
58
58
|
font-weight: 700;
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
&:focus {
|
|
62
|
-
}
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
&__toggle {
|
|
@@ -117,3 +114,26 @@
|
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
116
|
}
|
|
117
|
+
|
|
118
|
+
.collapsed {
|
|
119
|
+
width: 64px;
|
|
120
|
+
|
|
121
|
+
.menu-item-arrow,
|
|
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;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.nav__submenu {
|
|
137
|
+
display: none !important;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
Binary file
|