-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
- Loading branch information
Showing
2 changed files
with
73 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 44 additions & 37 deletions
81
frontend-next-migration/src/widgets/Navbar/ui/NavbarMain/NavbarMain.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,51 @@ | ||
'use client' | ||
import { memo } from "react"; | ||
import useIsMobileSize from "@/shared/lib/hooks/useIsMobileSize"; | ||
import NavbarDesktopV2 from "../NavbarDesktopV2/NavbarDesktopV2"; | ||
import NavbarMobileV2 from "../NavbarMobileV2/NavbarMobileV2"; | ||
import { FixedProvider } from "@/widgets/Navbar/model/FixedProvider"; | ||
import { NavBarType } from "../../model/types"; | ||
import { getNavbarBuildByTypeAndSize } from "../../model/getNavbarBuildByTypeAndSize"; | ||
import useSizes from "@/shared/lib/hooks/useSizes"; | ||
|
||
|
||
/* This code snippet is defining a React functional component called `NavbarMain`. It imports necessary | ||
dependencies such as `memo` from React, and components like `NavbarDesktopV2` and `NavbarMobileV2`. | ||
It also imports some types and functions related to the navbar. */ | ||
'use client'; | ||
import { memo } from 'react'; | ||
import NavbarDesktopV2 from '../NavbarDesktopV2/NavbarDesktopV2'; | ||
import NavbarMobileV2 from '../NavbarMobileV2/NavbarMobileV2'; | ||
import { FixedProvider } from '@/widgets/Navbar/model/FixedProvider'; | ||
import { NavBarType } from '../../model/types'; | ||
import { getNavbarBuildByTypeAndSize } from '../../model/getNavbarBuildByTypeAndSize'; | ||
import useSizes from '@/shared/lib/hooks/useSizes'; | ||
|
||
interface NavbarMainProps { | ||
overlaid?: boolean; | ||
marginTop?: number; | ||
className?: string; | ||
navBarType?: NavBarType; | ||
overlaid?: boolean; | ||
marginTop?: number; | ||
className?: string; | ||
navBarType?: NavBarType; | ||
} | ||
|
||
|
||
|
||
export const NavbarMain = memo((props: NavbarMainProps) => { | ||
const { | ||
overlaid, | ||
marginTop, | ||
className, | ||
navBarType = "Default" } = props; | ||
// const { isMobileSize } = useIsMobileSize(); | ||
const { isMobileSize, isTabletSize} = useSizes(); | ||
const navbarBuild = getNavbarBuildByTypeAndSize(navBarType, isMobileSize); | ||
|
||
return ( | ||
<FixedProvider> | ||
{isMobileSize || isTabletSize ? ( | ||
<NavbarMobileV2 overlaid={overlaid} marginTop={marginTop} className={className} navbarBuild={navbarBuild} navBarType={navBarType}/> | ||
) : ( | ||
<NavbarDesktopV2 overlaid={overlaid} marginTop={marginTop} className={className} navbarBuild={navbarBuild} navBarType={navBarType} /> | ||
)} | ||
</FixedProvider> | ||
); | ||
const { overlaid, marginTop, className, navBarType = 'Default' } = props; | ||
const { isMobileSize, isTabletSize } = useSizes(); | ||
/* The line `const size = isMobileSize || isTabletSize ? 'mobile' : 'desktop';` is determining the | ||
size of the navbar based on the screen size. */ | ||
const size = isMobileSize || isTabletSize ? 'mobile' : 'desktop'; | ||
const navbarBuild = getNavbarBuildByTypeAndSize(navBarType, size); | ||
|
||
return ( | ||
<FixedProvider> | ||
{isMobileSize || isTabletSize ? ( | ||
<NavbarMobileV2 | ||
overlaid={overlaid} | ||
marginTop={marginTop} | ||
className={className} | ||
navbarBuild={navbarBuild} | ||
navBarType={navBarType} | ||
/> | ||
) : ( | ||
<NavbarDesktopV2 | ||
overlaid={overlaid} | ||
marginTop={marginTop} | ||
className={className} | ||
navbarBuild={navbarBuild} | ||
navBarType={navBarType} | ||
/> | ||
)} | ||
</FixedProvider> | ||
); | ||
}); | ||
|
||
NavbarMain.displayName = "NavbarMain"; | ||
|
||
NavbarMain.displayName = 'NavbarMain'; |