Skip to content

Commit

Permalink
Merge pull request #3 from bonuz-market:develop
Browse files Browse the repository at this point in the history
fix(header): hide mobile nav on item click
fix(header): make header sticky not fixed
  • Loading branch information
Mostafatalaat770 authored Jul 20, 2022
2 parents d6e7067 + a2c3b72 commit 3f7c9c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/components/atoms/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
import React, { FC } from 'react';
import './Navigation.scss';

export const Navigation: FC<React.PropsWithChildren<unknown>> = ({
interface NavigationProps {
onItemClick: () => void;
}
export const Navigation: FC<React.PropsWithChildren<NavigationProps>> = ({
children,
onItemClick,
}) => {
const childrenModified = React.Children.map(children, (child) => {
if (!React.isValidElement(child)) {
return null;
}
return <li className="nav-item">{child}</li>;
return (
<li className="nav-item" onClick={onItemClick}>
{child}
</li>
);
});
return <ul className="nav">{childrenModified}</ul>;
};
2 changes: 0 additions & 2 deletions src/components/molecules/Header/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ header {
display: flex;
width: 100%;
justify-content: center;
position: fixed;
z-index: 1000;
padding: 40px 0;
transition: all 0.2s ease-in-out;
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export const Header: FC<React.PropsWithChildren<HeaderProps>> = ({

setIsVisible((prevState) => !prevState);
};

return (
<header>
<header className="sticky">
<div
className={classnames('header-outer', {
header__fixed: isScrolled,
Expand Down Expand Up @@ -95,7 +95,7 @@ export const Header: FC<React.PropsWithChildren<HeaderProps>> = ({
active: isVisible,
})}
>
<Navigation>
<Navigation onItemClick={handleChangeIsVisible}>
{NavigationElements}
{SignInElement}
</Navigation>
Expand Down

0 comments on commit 3f7c9c6

Please sign in to comment.