Skip to content

Commit

Permalink
feat: scroll to top on nav touch
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMarin committed Jul 6, 2024
1 parent 9353e55 commit c3a5fb4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/components/header/layouts/MobileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,42 @@ interface MobileHeaderProps {
isSiderOpened: boolean;
}

const handleScrollToTop = () => {
document.querySelector('#main-content')?.scrollTo({ top: 0, behavior: 'smooth' });
};

const handleTouchStart = (event: React.TouchEvent) => {
const target = event.target as HTMLElement;
if (target.closest('.header-button')) {
return;
}
handleScrollToTop();
};

export const MobileHeader: React.FC<MobileHeaderProps> = ({ toggleSider, isSiderOpened }) => {
return (
<BaseRow justify="space-between" align="middle">
<BaseRow onTouchStart={handleTouchStart} justify="space-between" align="middle">
<BaseCol>
<ProfileDropdown />
</BaseCol>

<BaseCol>
<BaseRow align="middle">
<BaseCol>
<BaseCol className="mobile-header-button">
<NotificationsDropdown />
</BaseCol>

<BaseCol>
<BaseCol className="mobile-header-button">
<HeaderSearch />
</BaseCol>

<BaseCol>
<BaseCol className="mobile-header-button">
<SettingsDropdown />
</BaseCol>
</BaseRow>
</BaseCol>

<S.BurgerCol>
<S.BurgerCol className="mobile-header-button">
<S.MobileBurger onClick={toggleSider} isCross={isSiderOpened} />
</S.BurgerCol>
</BaseRow>
Expand Down

0 comments on commit c3a5fb4

Please sign in to comment.