@bytebrand/fe-ui-core 4.1.37 → 4.1.38

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.37",
3
+ "version": "4.1.38",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import useModal from '../../../framework/hooks/useModal';
4
+
5
+ import Modal from './Modal';
6
+
7
+ const ModalComponent = () => {
8
+ const { isVisible, toggleModal } = useModal();
9
+ return (
10
+ <>
11
+ <button onClick={toggleModal}>
12
+ open modal
13
+ </button>
14
+ <Modal isVisible={isVisible} toggleModal={toggleModal} name='TEST_MODAL' />
15
+ </>
16
+ )
17
+ }
18
+
19
+
20
+ storiesOf('_Common_UI', module)
21
+ .add('Modal', () => <ModalComponent />)
@@ -0,0 +1,12 @@
1
+ import { styled } from '@mui/system';
2
+
3
+ export const BaseModalWrapper = styled('div')({
4
+ position: 'absolute',
5
+ top: '50%',
6
+ left: '50%',
7
+ transform: 'translate(-50%, -50%)',
8
+ width: 400,
9
+ backgroundColor: '#fff',
10
+ boxShadow: 24,
11
+ padding: 20
12
+ });
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import Modal from '@mui/material/Modal';
3
+ import ModalsConfig from './ModalsConfig';
4
+ import { BaseModalWrapper } from './Modal.styled';
5
+
6
+ interface IBasicModal {
7
+ isVisible: boolean;
8
+ toggleModal: () => void;
9
+ name: string;
10
+ modalProps?: any;
11
+ }
12
+
13
+ const BasicModal = ({ isVisible, toggleModal, name, modalProps }: IBasicModal) => {
14
+
15
+ return (
16
+ <Modal open={isVisible} onClose={toggleModal}>
17
+ <BaseModalWrapper>
18
+ {ModalsConfig[name](modalProps)}
19
+ </BaseModalWrapper>
20
+ </Modal>
21
+ );
22
+ };
23
+
24
+ export default BasicModal;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+
3
+ import TestModal from './modals/TestModal';
4
+
5
+ const ModalsConfig = {
6
+ TEST_MODAL: (props: any) => {
7
+ return <TestModal { ...props } />;
8
+ }
9
+ };
10
+
11
+ export default ModalsConfig;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ const TestModal = () => {
4
+ return <div>test modal</div>;
5
+ };
6
+
7
+ export default TestModal;
@@ -8,47 +8,47 @@ const superAdmin = true;
8
8
  const userMenuItems = [
9
9
  {
10
10
  icon: 'dashboardIcon',
11
- content: 'Dashboard'
11
+ label: 'Dashboard'
12
12
  },
13
13
  {
14
14
  icon: 'userProfileIcon',
15
- content: 'Profile'
15
+ label: 'Profile'
16
16
  },
17
17
  {
18
18
  icon: 'addressIcon',
19
- content: 'Address'
19
+ label: 'Address'
20
20
  },
21
21
  {
22
22
  icon: 'myVehiclesIcon',
23
- content: 'My Vehicles'
23
+ label: 'My Vehicles'
24
24
  },
25
25
  {
26
26
  icon: 'savedSearchsIcon',
27
- content: 'Saved searchs'
27
+ label: 'Saved searchs'
28
28
  },
29
29
  {
30
30
  icon: 'favoritesIcon',
31
- content: 'Favorites',
31
+ label: 'Favorites',
32
32
  amount: 0
33
33
  },
34
34
  !superAdmin && {
35
35
  icon: 'dealersIcon',
36
- content: 'Dealers',
36
+ label: 'Dealers',
37
37
  amount: 1234,
38
38
  divider: true
39
39
  },
40
40
  {
41
41
  icon: 'imageSettingsIcon',
42
- content: 'Image Settings'
42
+ label: 'Image Settings'
43
43
  },
44
44
  !superAdmin && {
45
45
  icon: 'supportCallbackIcon',
46
- content: 'Support & Call back',
46
+ label: 'Support & Call back',
47
47
  divider: true
48
48
  },
49
49
  {
50
50
  icon: 'logoutIcon',
51
- content: 'Logout'
51
+ label: 'Logout'
52
52
  },
53
53
 
54
54
  ];
@@ -65,12 +65,11 @@ const MaterialMenu = ({ menuItems, headerComponent, onChange, isLang, containerC
65
65
  anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
66
66
  >
67
67
  {menuItems.map((listItemProps: any, index: number) => {
68
- const { value } = listItemProps;
69
68
  return !!listItemProps &&
70
69
  <ListItem
71
70
  key={listItemProps.text}
72
71
  selected={index === selectedIndex}
73
- onClick={() => onHandleChange(value, index)}
72
+ onClick={() => onHandleChange(listItemProps.value, index)}
74
73
  isSelect={isSelect}
75
74
  Link={Link}
76
75
  { ...listItemProps }
@@ -0,0 +1,13 @@
1
+ import { useState } from 'react';
2
+
3
+ const useModal = () => {
4
+ const [isVisible, setIsVisible] = useState(false);
5
+
6
+ const toggleModal = () => {
7
+ setIsVisible(!isVisible);
8
+ };
9
+
10
+ return { isVisible, toggleModal };
11
+ };
12
+
13
+ export default useModal;