Remove conditional header component
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { memo } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { ConditionalHeaderView } from "./ConditionalHeader.view";
|
||||
import type { ConditionalHeaderProps } from "./ConditionalHeader.types";
|
||||
|
||||
const ConditionalHeaderContainer = memo<ConditionalHeaderProps>(() => {
|
||||
const pathname = usePathname();
|
||||
const isHomePage = pathname === "/";
|
||||
|
||||
return <ConditionalHeaderView isHomePage={isHomePage} />;
|
||||
});
|
||||
|
||||
ConditionalHeaderContainer.displayName = "ConditionalHeader";
|
||||
|
||||
export default ConditionalHeaderContainer;
|
||||
@@ -1,7 +0,0 @@
|
||||
export interface ConditionalHeaderProps {
|
||||
// Currently no props, but keeping interface for future extensibility
|
||||
}
|
||||
|
||||
export interface ConditionalHeaderViewProps {
|
||||
isHomePage: boolean;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import TopNav from "../TopNav";
|
||||
import type { ConditionalHeaderViewProps } from "./ConditionalHeader.types";
|
||||
|
||||
export function ConditionalHeaderView({
|
||||
isHomePage,
|
||||
}: ConditionalHeaderViewProps) {
|
||||
return <TopNav folderTop={isHomePage} />;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export { default } from "./ConditionalHeader.container";
|
||||
export type { ConditionalHeaderProps } from "./ConditionalHeader.types";
|
||||
@@ -0,0 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import { memo } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import TopNav from "./TopNav.container";
|
||||
import type { TopNavProps } from "./TopNav.types";
|
||||
|
||||
/**
|
||||
* TopNav wrapper that automatically determines folderTop based on current pathname.
|
||||
* Use this in layout.tsx instead of ConditionalHeader.
|
||||
*/
|
||||
const TopNavWithPathname = memo<Omit<TopNavProps, "folderTop">>((props) => {
|
||||
const pathname = usePathname();
|
||||
const isHomePage = pathname === "/";
|
||||
|
||||
return <TopNav {...props} folderTop={isHomePage} />;
|
||||
});
|
||||
|
||||
TopNavWithPathname.displayName = "TopNavWithPathname";
|
||||
|
||||
export default TopNavWithPathname;
|
||||
Reference in New Issue
Block a user