@bytebrand/fe-ui-core 4.1.27 → 4.1.29
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/package.json +1 -1
- package/source/components/SearchWidget/EnvironmentWidget/EnvironmentWidget.tsx +1 -1
- package/source/components/_common/UserMenu/{UserMenu.story.js → MaterialMenu.story.js} +4 -4
- package/source/components/_common/UserMenu/{UserMenu.styled.tsx → MaterialMenu.styled.tsx} +5 -2
- package/source/components/_common/UserMenu/MaterialMenu.tsx +78 -0
- package/source/components/_common/UserMenu/{MenuItem.tsx → MaterialMenuItem.tsx} +2 -2
- package/source/framework/factories/BreadcrumbsFactory.tsx +14 -0
- package/source/components/_common/UserMenu/UserMenu.tsx +0 -53
package/package.json
CHANGED
|
@@ -132,7 +132,7 @@ const EnvironmentWidget: React.FC<IEnvironmentWidgetProps> = ({
|
|
|
132
132
|
<MaterialAutocomplete
|
|
133
133
|
size='custom'
|
|
134
134
|
value={getConsumption ? getValue(getConsumption) : null}
|
|
135
|
-
onChange={(value: string) => onFilterChange(CONSUMPTION_KEY, { from: void value, to: value })}
|
|
135
|
+
// onChange={(value: string) => onFilterChange(CONSUMPTION_KEY, { from: void value, to: value })}
|
|
136
136
|
label={t('filters.consumption')}
|
|
137
137
|
unit='l/100 km'
|
|
138
138
|
items={getOptions(CONSUMPTION_FIX)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { storiesOf } from '@storybook/react';
|
|
4
|
-
import
|
|
4
|
+
import MaterialMenu from './MaterialMenu';
|
|
5
5
|
|
|
6
6
|
const superAdmin = true;
|
|
7
7
|
|
|
@@ -29,7 +29,7 @@ const userMenuItems = [
|
|
|
29
29
|
{
|
|
30
30
|
icon: 'favoritesIcon',
|
|
31
31
|
content: 'Favorites',
|
|
32
|
-
amount:
|
|
32
|
+
amount: 0
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
icon: 'dealersIcon',
|
|
@@ -41,7 +41,7 @@ const userMenuItems = [
|
|
|
41
41
|
icon: 'imageSettingsIcon',
|
|
42
42
|
content: 'Image Settings'
|
|
43
43
|
},
|
|
44
|
-
superAdmin && {
|
|
44
|
+
!superAdmin && {
|
|
45
45
|
icon: 'supportCallbackIcon',
|
|
46
46
|
content: 'Support & Call back',
|
|
47
47
|
divider: true
|
|
@@ -53,4 +53,4 @@ const userMenuItems = [
|
|
|
53
53
|
|
|
54
54
|
];
|
|
55
55
|
|
|
56
|
-
storiesOf('_Common_UI', module).add('UserMenu', () => <
|
|
56
|
+
storiesOf('_Common_UI', module).add('UserMenu', () => <MaterialMenu menuItems={userMenuItems} headerComponent='Firstname Lastname' />);
|
|
@@ -21,9 +21,8 @@ export const Theme = createTheme({
|
|
|
21
21
|
styleOverrides: {
|
|
22
22
|
root: {
|
|
23
23
|
overflow: 'visible',
|
|
24
|
-
|
|
24
|
+
boxShadow: '0px 2px 8px rgba(0,0,0,0.32)',
|
|
25
25
|
marginTop: 1.5,
|
|
26
|
-
width: '230px',
|
|
27
26
|
borderRadius: '10px'
|
|
28
27
|
}
|
|
29
28
|
}
|
|
@@ -61,3 +60,7 @@ export const AmountBlock = styled('span')({
|
|
|
61
60
|
fontSize: '12px',
|
|
62
61
|
fontWeight: 'bold'
|
|
63
62
|
});
|
|
63
|
+
|
|
64
|
+
export const FlexContainer = styled('div')({
|
|
65
|
+
display: 'flex'
|
|
66
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import Menu from '@mui/material/Menu';
|
|
3
|
+
import ListItem from './MaterialMenuItem';
|
|
4
|
+
import { ThemeProvider } from '@mui/material/styles';
|
|
5
|
+
import { Theme, FlexContainer } from './MaterialMenu.styled';
|
|
6
|
+
import IconSVG from '../IconSVG/IconSVG';
|
|
7
|
+
|
|
8
|
+
export interface ILoggedInUserInfoProps {
|
|
9
|
+
profileName?: string;
|
|
10
|
+
menuItems: any;
|
|
11
|
+
headerComponent?: any;
|
|
12
|
+
isLang?: boolean;
|
|
13
|
+
onChange?: (value: string) => void;
|
|
14
|
+
containerClassname?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const MaterialMenu = ({ menuItems, headerComponent, onChange, isLang, containerClassname }: ILoggedInUserInfoProps) => {
|
|
18
|
+
|
|
19
|
+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
20
|
+
const [selectedIndex, setSelectedIndex] = React.useState(1);
|
|
21
|
+
const open = Boolean(anchorEl);
|
|
22
|
+
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
|
|
23
|
+
setAnchorEl(event.currentTarget);
|
|
24
|
+
};
|
|
25
|
+
const handleClose = () => {
|
|
26
|
+
setAnchorEl(null);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const onHandleChange = (value: any, index: number) => {
|
|
30
|
+
setSelectedIndex(index);
|
|
31
|
+
onChange(value);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const containerRef = useRef(null);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ThemeProvider theme={Theme}>
|
|
38
|
+
<div className={containerClassname} ref={containerRef} onMouseEnter={handleClick}>
|
|
39
|
+
{headerComponent && headerComponent}
|
|
40
|
+
{isLang &&
|
|
41
|
+
<FlexContainer>
|
|
42
|
+
<IconSVG
|
|
43
|
+
customDimensions
|
|
44
|
+
width='42px'
|
|
45
|
+
height='27px'
|
|
46
|
+
name={`new_lang_${menuItems[selectedIndex].value}`}
|
|
47
|
+
/>
|
|
48
|
+
</FlexContainer>
|
|
49
|
+
}
|
|
50
|
+
<Menu
|
|
51
|
+
anchorEl={anchorEl}
|
|
52
|
+
open={open}
|
|
53
|
+
onClose={handleClose}
|
|
54
|
+
onClick={handleClose}
|
|
55
|
+
PaperProps={{
|
|
56
|
+
onMouseLeave: handleClose,
|
|
57
|
+
elevation: 0
|
|
58
|
+
}}
|
|
59
|
+
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
|
60
|
+
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
|
61
|
+
>
|
|
62
|
+
{menuItems.map((listItemProps: any, index: number) => {
|
|
63
|
+
const { value } = listItemProps;
|
|
64
|
+
return !!listItemProps &&
|
|
65
|
+
<ListItem
|
|
66
|
+
key={listItemProps.text}
|
|
67
|
+
selected={index === selectedIndex}
|
|
68
|
+
onClick={() => onHandleChange(value, index)}
|
|
69
|
+
{ ...listItemProps }
|
|
70
|
+
/>;
|
|
71
|
+
})}
|
|
72
|
+
</Menu>
|
|
73
|
+
</div>
|
|
74
|
+
</ThemeProvider>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default MaterialMenu;
|
|
@@ -3,7 +3,7 @@ import MenuItem from '@mui/material/MenuItem';
|
|
|
3
3
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
4
4
|
import IconSVG from '../IconSVG/IconSVG';
|
|
5
5
|
import ListItemText from '@mui/material/ListItemText';
|
|
6
|
-
import { AmountBlock } from './
|
|
6
|
+
import { AmountBlock } from './MaterialMenu.styled';
|
|
7
7
|
import { Link } from '@mui/material';
|
|
8
8
|
|
|
9
9
|
interface IListItem {
|
|
@@ -26,7 +26,7 @@ const ListItem = ({ icon, content, amount, divider, onClick, href, isComponent }
|
|
|
26
26
|
>
|
|
27
27
|
{icon && <ListItemIcon><IconSVG customDimensions name={icon} /></ListItemIcon>}
|
|
28
28
|
<ListItemText>{content}</ListItemText>
|
|
29
|
-
{amount && <AmountBlock>{amount}</AmountBlock>}
|
|
29
|
+
{(amount || amount === 0) && <AmountBlock>{amount}</AmountBlock>}
|
|
30
30
|
</MenuItem>
|
|
31
31
|
</Link>
|
|
32
32
|
);
|
|
@@ -71,6 +71,20 @@ const BreadcrumbsFactory: IBreadcrumbsFactoryConfig = {
|
|
|
71
71
|
]
|
|
72
72
|
}),
|
|
73
73
|
|
|
74
|
+
ADDRESSES_SETTINGS: (props: any) => ({
|
|
75
|
+
list: [
|
|
76
|
+
{ link: '/account/addresses', title: props.t('common:breadcrumbs.DashboardNew') },
|
|
77
|
+
{ link: '', title: props.t('common:breadcrumbs.Address') }
|
|
78
|
+
]
|
|
79
|
+
}),
|
|
80
|
+
|
|
81
|
+
KONTAKT_SETTINGS: (props: any) => ({
|
|
82
|
+
list: [
|
|
83
|
+
{ link: '/account/kontakt', title: props.t('common:breadcrumbs.DashboardNew') },
|
|
84
|
+
{ link: '', title: props.t('common:breadcrumbs.Kontakt') }
|
|
85
|
+
]
|
|
86
|
+
}),
|
|
87
|
+
|
|
74
88
|
IMAGE_SETTINGS: (props: any) => ({
|
|
75
89
|
list: [
|
|
76
90
|
{ link: '', title: props.t('common:breadcrumbs.ImageSettings') }
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef } from 'react';
|
|
2
|
-
import Menu from '@mui/material/Menu';
|
|
3
|
-
import ListItem from './MenuItem';
|
|
4
|
-
import { ThemeProvider } from '@mui/material/styles';
|
|
5
|
-
import { Theme } from './UserMenu.styled';
|
|
6
|
-
|
|
7
|
-
export interface ILoggedInUserInfoProps {
|
|
8
|
-
profileName?: string;
|
|
9
|
-
userMenuItems: any;
|
|
10
|
-
headerComponent?: any;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const LoggedInUserInfo = ({ userMenuItems, headerComponent }: ILoggedInUserInfoProps) => {
|
|
14
|
-
|
|
15
|
-
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
16
|
-
const open = Boolean(anchorEl);
|
|
17
|
-
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
|
|
18
|
-
setAnchorEl(event.currentTarget);
|
|
19
|
-
};
|
|
20
|
-
const handleClose = () => {
|
|
21
|
-
setAnchorEl(null);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const containerRef = useRef(null);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<ThemeProvider theme={Theme}>
|
|
28
|
-
<div ref={containerRef} onMouseEnter={handleClick}>
|
|
29
|
-
<div>
|
|
30
|
-
{headerComponent}
|
|
31
|
-
</div>
|
|
32
|
-
<Menu
|
|
33
|
-
anchorEl={anchorEl}
|
|
34
|
-
open={open}
|
|
35
|
-
onClose={handleClose}
|
|
36
|
-
onClick={handleClose}
|
|
37
|
-
PaperProps={{
|
|
38
|
-
onMouseLeave: handleClose,
|
|
39
|
-
elevation: 0
|
|
40
|
-
}}
|
|
41
|
-
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
|
42
|
-
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
|
43
|
-
>
|
|
44
|
-
{userMenuItems.map((listItemProps: any) => {
|
|
45
|
-
return !!listItemProps && <ListItem key={listItemProps.text} { ...listItemProps } />;
|
|
46
|
-
})}
|
|
47
|
-
</Menu>
|
|
48
|
-
</div>
|
|
49
|
-
</ThemeProvider>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default LoggedInUserInfo;
|