@bytebrand/fe-ui-core 4.1.25 → 4.1.26

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.1.25",
3
+ "version": "4.1.26",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -3,29 +3,29 @@ 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 './MenuItem.styled';
6
+ import { AmountBlock } from './UserMenu.styled';
7
7
  import { Link } from '@mui/material';
8
8
 
9
9
  interface IListItem {
10
10
  icon: string;
11
- text: string;
11
+ content: any;
12
12
  amount?: number;
13
13
  divider?: boolean;
14
14
  onClick?: () => void;
15
15
  href?: string;
16
+ isComponent?: string;
16
17
  }
17
18
 
18
- const ListItem = ({ icon, text, amount, divider, onClick, href }: IListItem) => {
19
+ const ListItem = ({ icon, content, amount, divider, onClick, href, isComponent }: IListItem) => {
19
20
  return (
20
21
  <Link color='#4C4E64DE' variant='caption' href={href} underline='none' onClick={onClick}>
21
22
  <MenuItem
22
- sx={{ height: 44 }}
23
23
  divider={divider}
24
+ disableRipple={isComponent ? true : false}
25
+ isComponent={isComponent}
24
26
  >
25
- <ListItemIcon>
26
- <IconSVG name={icon} />
27
- </ListItemIcon>
28
- <ListItemText>{text}</ListItemText>
27
+ {icon && <ListItemIcon><IconSVG customDimensions name={icon} /></ListItemIcon>}
28
+ <ListItemText>{content}</ListItemText>
29
29
  {amount && <AmountBlock>{amount}</AmountBlock>}
30
30
  </MenuItem>
31
31
  </Link>
@@ -8,53 +8,49 @@ const superAdmin = true;
8
8
  const userMenuItems = [
9
9
  {
10
10
  icon: 'dashboardIcon',
11
- text: 'Dashboard'
11
+ content: 'Dashboard'
12
12
  },
13
13
  {
14
14
  icon: 'userProfileIcon',
15
- text: 'Profile'
15
+ content: 'Profile'
16
16
  },
17
17
  {
18
18
  icon: 'addressIcon',
19
- text: 'Address'
19
+ content: 'Address'
20
20
  },
21
21
  {
22
22
  icon: 'myVehiclesIcon',
23
- text: 'My Vehicles'
23
+ content: 'My Vehicles'
24
24
  },
25
25
  {
26
26
  icon: 'savedSearchsIcon',
27
- text: 'Saved searchs'
27
+ content: 'Saved searchs'
28
28
  },
29
29
  {
30
30
  icon: 'favoritesIcon',
31
- text: 'Favorites',
31
+ content: 'Favorites',
32
32
  amount: 122
33
33
  },
34
34
  {
35
35
  icon: 'dealersIcon',
36
- text: 'Dealers',
36
+ content: 'Dealers',
37
37
  amount: 1234,
38
38
  divider: true
39
39
  },
40
40
  {
41
41
  icon: 'imageSettingsIcon',
42
- text: 'Image Settings'
42
+ content: 'Image Settings'
43
43
  },
44
44
  superAdmin && {
45
45
  icon: 'supportCallbackIcon',
46
- text: 'Support & Call back',
46
+ content: 'Support & Call back',
47
47
  divider: true
48
48
  },
49
49
  {
50
50
  icon: 'logoutIcon',
51
- text: 'Logout'
51
+ content: 'Logout'
52
52
  },
53
53
 
54
54
  ];
55
55
 
56
- storiesOf('_Common_UI', module).add('UserMenu', () => (
57
- <div>
58
- <UserMenu userMenuItems={userMenuItems} profileName='Firstname Lastname' />
59
- </div>
60
- ));
56
+ storiesOf('_Common_UI', module).add('UserMenu', () => <UserMenu userMenuItems={userMenuItems} headerComponent='Firstname Lastname' />);
@@ -0,0 +1,63 @@
1
+ import { styled } from '@mui/system';
2
+ import { createTheme } from '@mui/material/styles';
3
+
4
+ export const Theme = createTheme({
5
+ components: {
6
+ MuiTypography: {
7
+ styleOverrides: {
8
+ root: {
9
+ fontSize: '14px'
10
+ }
11
+ }
12
+ },
13
+ MuiListItemText: {
14
+ styleOverrides: {
15
+ root: {
16
+ color: '#4C4E64DE'
17
+ }
18
+ }
19
+ },
20
+ MuiPaper: {
21
+ styleOverrides: {
22
+ root: {
23
+ overflow: 'visible',
24
+ filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
25
+ marginTop: 1.5,
26
+ width: '230px',
27
+ borderRadius: '10px'
28
+ }
29
+ }
30
+ },
31
+ MuiList: {
32
+ styleOverrides: {
33
+ root: {
34
+ padding: 0
35
+ }
36
+ }
37
+ },
38
+ MuiMenuItem: {
39
+ styleOverrides: {
40
+ root: ({ ownerState }) => ({
41
+ minHeight: '44px !important',
42
+ fontSize: '14px important',
43
+ ...(ownerState.isComponent && {
44
+ cursor: 'initial !important',
45
+ '&:hover': {
46
+ background: 'transparent !important'
47
+ }
48
+ })
49
+ })
50
+ }
51
+ }
52
+ }
53
+ });
54
+
55
+ export const AmountBlock = styled('span')({
56
+ backgroundColor: '#5C88FF',
57
+ color: '#fff',
58
+ borderRadius: '64px',
59
+ padding: '0 6px',
60
+ lineHeight: '20px',
61
+ fontSize: '12px',
62
+ fontWeight: 'bold'
63
+ });
@@ -1,16 +1,16 @@
1
1
  import React, { useState, useRef } from 'react';
2
2
  import Menu from '@mui/material/Menu';
3
- import MenuItem from '@mui/material/MenuItem';
4
- import Typography from '@mui/material/Typography';
5
- import Tooltip from '@mui/material/Tooltip';
6
3
  import ListItem from './MenuItem';
4
+ import { ThemeProvider } from '@mui/material/styles';
5
+ import { Theme } from './UserMenu.styled';
7
6
 
8
7
  export interface ILoggedInUserInfoProps {
9
- profileName: string;
8
+ profileName?: string;
10
9
  userMenuItems: any;
10
+ headerComponent?: any;
11
11
  }
12
12
 
13
- const LoggedInUserInfo = ({ profileName, userMenuItems }: ILoggedInUserInfoProps) => {
13
+ const LoggedInUserInfo = ({ userMenuItems, headerComponent }: ILoggedInUserInfoProps) => {
14
14
 
15
15
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
16
16
  const open = Boolean(anchorEl);
@@ -24,55 +24,29 @@ const LoggedInUserInfo = ({ profileName, userMenuItems }: ILoggedInUserInfoProps
24
24
  const containerRef = useRef(null);
25
25
 
26
26
  return (
27
- <>
28
- <div
29
- ref={containerRef}
30
- onMouseEnter={handleClick}
31
- >
27
+ <ThemeProvider theme={Theme}>
28
+ <div ref={containerRef} onMouseEnter={handleClick}>
32
29
  <div>
33
- <Tooltip title='Account settings'>
34
- <Typography sx={{ minWidth: 100 }} onClick={handleClick}>{profileName}</Typography>
35
- </Tooltip>
30
+ {headerComponent}
36
31
  </div>
37
32
  <Menu
38
33
  anchorEl={anchorEl}
39
- id='account-menu'
40
34
  open={open}
41
35
  onClose={handleClose}
42
36
  onClick={handleClose}
43
37
  PaperProps={{
44
- elevation: 0,
45
- sx: {
46
- overflow: 'visible',
47
- filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
48
- mt: 1.5,
49
- width: '230px',
50
- borderRadius: '10px',
51
- '& .MuiAvatar-root': {
52
- width: 32,
53
- height: 32,
54
- ml: -0.5,
55
- mr: 1
56
- }
57
- }
38
+ onMouseLeave: handleClose,
39
+ elevation: 0
58
40
  }}
59
41
  transformOrigin={{ horizontal: 'right', vertical: 'top' }}
60
42
  anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
61
43
  >
62
- <MenuItem
63
- divider={true}
64
- sx={{ justifyContent: 'center', height: 48 }}
65
- disableRipple={true}
66
- >
67
- {profileName}
68
- </MenuItem>
69
-
70
44
  {userMenuItems.map((listItemProps: any) => {
71
45
  return !!listItemProps && <ListItem key={listItemProps.text} { ...listItemProps } />;
72
46
  })}
73
47
  </Menu>
74
48
  </div>
75
- </>
49
+ </ThemeProvider>
76
50
  );
77
51
  };
78
52
 
@@ -1,11 +0,0 @@
1
- import { styled } from '@mui/system';
2
-
3
- export const AmountBlock = styled('span')({
4
- backgroundColor: '#5C88FF',
5
- color: '#fff',
6
- borderRadius: '64px',
7
- padding: '0 6px',
8
- lineHeight: '20px',
9
- fontSize: '12px',
10
- fontWeight: 'bold'
11
- });