@bytebrand/fe-ui-core 4.1.29 → 4.1.31
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/SearchPage/SearchTopBar/SearchTopBar.styl +10 -2
- package/source/components/SearchPage/SearchTopBar/SearchTopBar.tsx +22 -4
- package/source/components/_common/UserMenu/MaterialMenu.story.js +1 -1
- package/source/components/_common/UserMenu/MaterialMenu.tsx +12 -5
- package/source/components/_common/UserMenu/MaterialMenuItem.tsx +22 -6
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
margin-top: 10px;
|
|
12
12
|
box-sizing: border-box
|
|
13
13
|
justify-content: space-between
|
|
14
|
+
column-gap: 10px
|
|
14
15
|
+media-tablet-landscape-down()
|
|
15
16
|
height: 50px
|
|
16
17
|
+media-tablet-down()
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
|
|
46
47
|
.sorting
|
|
47
48
|
flex-basis: 20%
|
|
48
|
-
min-width:
|
|
49
|
+
min-width: 140px
|
|
49
50
|
[class*='MuiPaper-root'], [class*='MuiOutlinedInput-root']
|
|
50
51
|
font-size: 14px !important
|
|
51
52
|
|
|
@@ -86,4 +87,11 @@
|
|
|
86
87
|
+media-tablet-down()
|
|
87
88
|
.sorting
|
|
88
89
|
flex-basis: 0
|
|
89
|
-
margin-left: auto;
|
|
90
|
+
margin-left: auto;
|
|
91
|
+
|
|
92
|
+
.searchFilterComponent
|
|
93
|
+
text-align: right;
|
|
94
|
+
|
|
95
|
+
.sortingHeader
|
|
96
|
+
color: $skyBlue
|
|
97
|
+
font-size: 13px
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import _get from 'lodash/get';
|
|
3
|
-
import MaterialAutocomplete from '../../_common/MaterialAutocomplete/MaterialAutocomplete';
|
|
4
3
|
import { DEFAULT_LANG } from '../../../framework/constants/app';
|
|
5
4
|
import styles from './SearchTopBar.styl';
|
|
6
5
|
import { searchTopBarTranslate } from '../../../locales/data';
|
|
6
|
+
import MaterialMenu from '../../_common/UserMenu/MaterialMenu';
|
|
7
|
+
import { isMobileOnly } from 'react-device-detect';
|
|
8
|
+
import MaterialAutocomplete from '../../_common/MaterialAutocomplete/MaterialAutocomplete';
|
|
7
9
|
|
|
8
10
|
interface ISearchTopBarProps {
|
|
9
11
|
t?: (key: string, options?: object) => string;
|
|
@@ -37,6 +39,14 @@ class SearchTopBar extends React.Component<ISearchTopBarProps, {}> {
|
|
|
37
39
|
);
|
|
38
40
|
};
|
|
39
41
|
|
|
42
|
+
renderSortingHeader = (value: string) => {
|
|
43
|
+
return (
|
|
44
|
+
<span className={styles.sortingHeader}>
|
|
45
|
+
{value}
|
|
46
|
+
</span>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
renderSorting = () => {
|
|
41
51
|
const {
|
|
42
52
|
t = (phrase: string) => _get(searchTopBarTranslate(), phrase, phrase),
|
|
@@ -50,8 +60,17 @@ class SearchTopBar extends React.Component<ISearchTopBarProps, {}> {
|
|
|
50
60
|
);
|
|
51
61
|
|
|
52
62
|
const value = activeSorting ? { label: t(`sortingOptions.${activeSorting}`), value: activeSorting } : null;
|
|
63
|
+
|
|
64
|
+
const headerValue = value && value.label || t('sortingPlaceholder');
|
|
53
65
|
|
|
54
|
-
return
|
|
66
|
+
return isMobileOnly ?
|
|
67
|
+
<MaterialMenu
|
|
68
|
+
onChange={onSortChange}
|
|
69
|
+
headerComponent={this.renderSortingHeader(headerValue)}
|
|
70
|
+
menuItems={translatedSortingOptions}
|
|
71
|
+
containerClassname={styles.searchFilterComponent}
|
|
72
|
+
/>
|
|
73
|
+
:
|
|
55
74
|
<MaterialAutocomplete
|
|
56
75
|
size={'custom'}
|
|
57
76
|
freeSolo={false}
|
|
@@ -63,8 +82,7 @@ class SearchTopBar extends React.Component<ISearchTopBarProps, {}> {
|
|
|
63
82
|
onChange={onSortChange}
|
|
64
83
|
name='mobileSearch'
|
|
65
84
|
disableClearable={true}
|
|
66
|
-
|
|
67
|
-
);
|
|
85
|
+
/>;
|
|
68
86
|
};
|
|
69
87
|
|
|
70
88
|
render(): JSX.Element {
|
|
@@ -12,9 +12,12 @@ export interface ILoggedInUserInfoProps {
|
|
|
12
12
|
isLang?: boolean;
|
|
13
13
|
onChange?: (value: string) => void;
|
|
14
14
|
containerClassname?: string;
|
|
15
|
+
isSelect?: boolean;
|
|
16
|
+
value?: any;
|
|
17
|
+
Link?: any
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
const MaterialMenu = ({ menuItems, headerComponent, onChange, isLang, containerClassname }: ILoggedInUserInfoProps) => {
|
|
20
|
+
const MaterialMenu = ({ menuItems, headerComponent, onChange, isLang, containerClassname, isSelect, value, Link }: ILoggedInUserInfoProps) => {
|
|
18
21
|
|
|
19
22
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
20
23
|
const [selectedIndex, setSelectedIndex] = React.useState(1);
|
|
@@ -28,22 +31,24 @@ const MaterialMenu = ({ menuItems, headerComponent, onChange, isLang, containerC
|
|
|
28
31
|
|
|
29
32
|
const onHandleChange = (value: any, index: number) => {
|
|
30
33
|
setSelectedIndex(index);
|
|
31
|
-
onChange
|
|
34
|
+
if (!!onChange) {
|
|
35
|
+
onChange(value);
|
|
36
|
+
}
|
|
32
37
|
};
|
|
33
38
|
|
|
34
39
|
const containerRef = useRef(null);
|
|
35
40
|
|
|
36
41
|
return (
|
|
37
42
|
<ThemeProvider theme={Theme}>
|
|
38
|
-
<div className={containerClassname} ref={containerRef} onMouseEnter={handleClick}>
|
|
43
|
+
<div className={containerClassname} ref={containerRef} onClick={handleClick} onMouseEnter={handleClick}>
|
|
39
44
|
{headerComponent && headerComponent}
|
|
40
|
-
{isLang &&
|
|
45
|
+
{(isLang && !!value) &&
|
|
41
46
|
<FlexContainer>
|
|
42
47
|
<IconSVG
|
|
43
48
|
customDimensions
|
|
44
49
|
width='42px'
|
|
45
50
|
height='27px'
|
|
46
|
-
name={`new_lang_${
|
|
51
|
+
name={`new_lang_${value}`}
|
|
47
52
|
/>
|
|
48
53
|
</FlexContainer>
|
|
49
54
|
}
|
|
@@ -66,6 +71,8 @@ const MaterialMenu = ({ menuItems, headerComponent, onChange, isLang, containerC
|
|
|
66
71
|
key={listItemProps.text}
|
|
67
72
|
selected={index === selectedIndex}
|
|
68
73
|
onClick={() => onHandleChange(value, index)}
|
|
74
|
+
isSelect={isSelect}
|
|
75
|
+
Link={Link}
|
|
69
76
|
{ ...listItemProps }
|
|
70
77
|
/>;
|
|
71
78
|
})}
|
|
@@ -4,31 +4,47 @@ import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
4
4
|
import IconSVG from '../IconSVG/IconSVG';
|
|
5
5
|
import ListItemText from '@mui/material/ListItemText';
|
|
6
6
|
import { AmountBlock } from './MaterialMenu.styled';
|
|
7
|
-
import { Link } from '@mui/material';
|
|
8
7
|
|
|
9
8
|
interface IListItem {
|
|
10
9
|
icon: string;
|
|
11
|
-
|
|
10
|
+
label: any;
|
|
12
11
|
amount?: number;
|
|
13
12
|
divider?: boolean;
|
|
14
13
|
onClick?: () => void;
|
|
15
14
|
href?: string;
|
|
16
15
|
isComponent?: string;
|
|
16
|
+
isSelect?: boolean;
|
|
17
|
+
Link?: any;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const ListItem = ({ icon,
|
|
20
|
-
return (
|
|
21
|
-
<Link color='#4C4E64DE' variant='caption'
|
|
20
|
+
const ListItem = ({ icon, label, amount, divider, onClick, href, isComponent, Link }: IListItem) => {
|
|
21
|
+
return !!href ? (
|
|
22
|
+
<Link color='#4C4E64DE' variant='caption' to={href} underline='none' onClick={onClick}>
|
|
22
23
|
<MenuItem
|
|
23
24
|
divider={divider}
|
|
24
25
|
disableRipple={isComponent ? true : false}
|
|
25
26
|
isComponent={isComponent}
|
|
26
27
|
>
|
|
27
28
|
{icon && <ListItemIcon><IconSVG customDimensions name={icon} /></ListItemIcon>}
|
|
28
|
-
<ListItemText>
|
|
29
|
+
<ListItemText>
|
|
30
|
+
{label}
|
|
31
|
+
</ListItemText>
|
|
29
32
|
{(amount || amount === 0) && <AmountBlock>{amount}</AmountBlock>}
|
|
30
33
|
</MenuItem>
|
|
31
34
|
</Link>
|
|
35
|
+
) : (
|
|
36
|
+
<MenuItem
|
|
37
|
+
onClick={onClick}
|
|
38
|
+
divider={divider}
|
|
39
|
+
disableRipple={isComponent ? true : false}
|
|
40
|
+
isComponent={isComponent}
|
|
41
|
+
>
|
|
42
|
+
{icon && <ListItemIcon><IconSVG customDimensions name={icon} /></ListItemIcon>}
|
|
43
|
+
<ListItemText>
|
|
44
|
+
{label}
|
|
45
|
+
</ListItemText>
|
|
46
|
+
{(amount || amount === 0) && <AmountBlock>{amount}</AmountBlock>}
|
|
47
|
+
</MenuItem>
|
|
32
48
|
);
|
|
33
49
|
};
|
|
34
50
|
|