Skip to content

Commit 7a3bacc

Browse files
committed
feat: mobile navigation
1 parent fec8beb commit 7a3bacc

File tree

5 files changed

+21
-91
lines changed

5 files changed

+21
-91
lines changed

src/navigation/components/MobileNavigation/MobileNavigation.scss

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ $block: '.#{$ns}mobile-navigation';
1515
border-bottom-left-radius: $borderRadius;
1616
background-color: var(--yc-color-base-background);
1717
box-shadow: 0 3px 10px var(--yc-color-sfx-shadow);
18+
overflow-y: scroll;
19+
20+
scrollbar-width: none;
21+
-ms-overflow-style: none;
22+
23+
&::-webkit-scrollbar {
24+
display: none;
25+
}
1826

1927
@include text-size(body-2);
2028
@include mobile-tablet-only();
@@ -27,9 +35,6 @@ $block: '.#{$ns}mobile-navigation';
2735
margin-top: $indentSM;
2836
}
2937

30-
// &__nav {
31-
// }
32-
3338
&__rows {
3439
position: relative;
3540

src/navigation/components/MobileNavigation/MobileNavigation.tsx

Lines changed: 10 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, {MouseEventHandler, useCallback, useRef} from 'react';
1+
import React from 'react';
22

3-
import {Popup, Portal} from '@gravity-ui/uikit';
3+
import {Portal} from '@gravity-ui/uikit';
44

55
import Foldable from '../../../components/Foldable/Foldable';
6-
import {NavigationDropdownItem, NavigationItemModel, NavigationItemType} from '../../../models';
6+
import {NavigationItemModel} from '../../../models';
77
import {block} from '../../../utils';
88
import {ItemColumnName} from '../../constants';
99
import {getItemClickHandler} from '../../utils';
@@ -13,42 +13,7 @@ import './MobileNavigation.scss';
1313

1414
const b = block('mobile-navigation');
1515

16-
// interface MobileNavigationDropdownProps {
17-
// data: NavigationDropdownItem;
18-
// isOpened?: boolean;
19-
// onItemClick?: MouseEventHandler;
20-
// onToggle?: MouseEventHandler;
21-
// }
22-
23-
// const MobileNavigationDropdown: React.FC<MobileNavigationDropdownProps> = ({
24-
// data,
25-
// onItemClick,
26-
// onToggle,
27-
// isOpened = false,
28-
// }) => {
29-
// const ref = useRef(null);
30-
31-
// return (
32-
// <div ref={ref} className={b('dropdown')}>
33-
// <NavigationItem data={data} onClick={onToggle} isOpened={isOpened} />
34-
// {isOpened && (
35-
// <Popup anchorRef={ref} open={isOpened} className={b('popup')}>
36-
// {data.items.map((item) => (
37-
// <NavigationItem
38-
// key={item.text}
39-
// data={item}
40-
// className={b('dropdown-item')}
41-
// onClick={onItemClick}
42-
// />
43-
// ))}
44-
// </Popup>
45-
// )}
46-
// </div>
47-
// );
48-
// };
49-
50-
interface MobileNavigationItemProps
51-
extends Pick<MobileNavigationProps, 'onActiveItemChange' | 'onClose'> {
16+
interface MobileNavigationItemProps extends Pick<MobileNavigationProps, 'onActiveItemChange'> {
5217
item: NavigationItemModel;
5318
column: ItemColumnName;
5419
index: number;
@@ -64,48 +29,13 @@ const MobileNavigationItem = ({
6429
activeItemId,
6530
onActiveItemChange,
6631
column,
67-
onClose,
6832
hidePopup,
6933
}: MobileNavigationItemProps) => {
70-
// const id = `${column}-${index}`;
71-
// const isActive = id === activeItemId && isOpened;
72-
// const toggleActive: MouseEventHandler = useCallback(
73-
// (e) => {
74-
// e.stopPropagation();
75-
76-
// if (onActiveItemChange) {
77-
// onActiveItemChange(isActive ? undefined : `${column}-${index}`);
78-
// }
79-
// },
80-
// [onActiveItemChange, isActive, column, index],
81-
// );
82-
83-
// const onItemClick: MouseEventHandler = useCallback(
84-
// (e) => {
85-
// toggleActive(e);
86-
// onClose();
87-
// },
88-
// [toggleActive, onClose],
89-
// );
90-
91-
// return (
92-
// <li key={index} className={b('rows-item')}>
93-
// {item.type === NavigationItemType.Dropdown ? (
94-
// <MobileNavigationDropdown
95-
// data={item}
96-
// onToggle={toggleActive}
97-
// isOpened={isActive}
98-
// onItemClick={onItemClick}
99-
// />
100-
// ) : (
101-
// <NavigationItem data={item} onClick={onItemClick} />
102-
// )}
103-
// </li>
104-
// );
105-
const id = `${ItemColumnName.Left}-${index}`;
34+
const id = `${column}-${index}`;
10635
const isActive = id === activeItemId;
36+
10737
const onClick = getItemClickHandler({
108-
column: ItemColumnName.Left,
38+
column,
10939
index,
11040
activeItemId,
11141
onActiveItemChange,
@@ -118,8 +48,10 @@ const MobileNavigationItem = ({
11848
data={item}
11949
onClick={onClick}
12050
isActive={isActive}
51+
isOpened={isOpened}
12152
hidePopup={hidePopup}
12253
isTopLevel={true}
54+
isMobile={true}
12355
/>
12456
);
12557
};
@@ -130,7 +62,6 @@ export interface MobileNavigationProps {
13062
topItems?: NavigationItemModel[];
13163
bottomItems?: NavigationItemModel[];
13264
activeItemId?: string;
133-
onClose: () => void;
13465
onActiveItemChange: (id?: string) => void;
13566
hidePopup: () => void;
13667
}
@@ -140,7 +71,7 @@ const MobileNavigation: React.FC<MobileNavigationProps> = (props) => {
14071
return null;
14172
}
14273

143-
const {isOpened, topItems, bottomItems, activeItemId, onActiveItemChange, onClose, hidePopup} = props;
74+
const {isOpened, topItems, bottomItems, activeItemId, onActiveItemChange, hidePopup} = props;
14475

14576
return (
14677
<Portal>
@@ -155,7 +86,6 @@ const MobileNavigation: React.FC<MobileNavigationProps> = (props) => {
15586
index={index}
15687
isOpened={isOpened}
15788
activeItemId={activeItemId}
158-
onClose={onClose}
15989
onActiveItemChange={onActiveItemChange}
16090
hidePopup={hidePopup}
16191
/>
@@ -170,7 +100,6 @@ const MobileNavigation: React.FC<MobileNavigationProps> = (props) => {
170100
index={index}
171101
isOpened={isOpened}
172102
activeItemId={activeItemId}
173-
onClose={onClose}
174103
onActiveItemChange={onActiveItemChange}
175104
hidePopup={hidePopup}
176105
/>

src/navigation/components/Navigation/Navigation.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ export const Header: React.FC<HeaderProps> = ({data, logo}) => {
4545
setIsSidebarOpened(isOpen);
4646
}, []);
4747

48-
const hideSidebar = useCallback(() => {
49-
setIsSidebarOpened(false);
50-
}, []);
51-
5248
return (
5349
<Grid className={b()}>
5450
<Row>
@@ -71,7 +67,6 @@ export const Header: React.FC<HeaderProps> = ({data, logo}) => {
7167
isOpened={isSidebarOpened}
7268
activeItemId={activeItemId}
7369
onActiveItemChange={onActiveItemChange}
74-
onClose={hideSidebar}
7570
hidePopup={hidePopup}
7671
/>
7772
</OutsideClick>

src/navigation/components/NavigationItem/NavigationItem.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface NavigationItemProps {
2424
hidePopup?: () => void;
2525
isActive?: boolean;
2626
isTopLevel?: boolean;
27+
isMobile?: boolean;
2728
}
2829

2930
//todo: add types support form component in map
@@ -41,6 +42,7 @@ const NavigationItem: React.FC<NavigationItemProps> = ({
4142
className,
4243
isActive,
4344
isTopLevel,
45+
isMobile,
4446
...props
4547
}: NavigationItemProps) => {
4648
const {type = NavigationItemType.Link} = data;
@@ -58,7 +60,7 @@ const NavigationItem: React.FC<NavigationItemProps> = ({
5860
<BlockIdContext.Provider value={ANALYTICS_ID}>
5961
<li className={b({'top-level': isTopLevel}, className)}>
6062
<Component {...componentProps} className={b('content')} />
61-
{isActive && (
63+
{!isMobile && isActive && (
6264
<div className={b('slider-container')}>
6365
<div className={b('slider')} />
6466
</div>

src/navigation/components/NavigationPopup/NavigationPopup.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ $block: '.#{$ns}navigation-popup';
99
margin-left: $offset;
1010
margin-top: -#{$indentXS};
1111

12-
@include desktop-only();
1312
@include navigation-popup();
1413

1514
&__list {

0 commit comments

Comments
 (0)