-
+ {heading ?
: null}
-
-
- {tabContent.map((tc) => (
-
- {tc.content}
-
- ))}
-
-
+
+ {tabContent.map((tc) => (
+
+ {tc.content}
+
+ ))}
+
);
};
diff --git a/src/components/layout/LayoutContextProvider.tsx b/src/components/layout/LayoutContextProvider.tsx
index c04ccc37..0b3c4a20 100644
--- a/src/components/layout/LayoutContextProvider.tsx
+++ b/src/components/layout/LayoutContextProvider.tsx
@@ -7,10 +7,12 @@ type LayoutMode = "desktop" | "mobile";
type WindowContextProps = {
layoutMode?: LayoutMode;
+ windowWidth?: number;
};
export const WindowContext = createContext
({
layoutMode: undefined,
+ windowWidth: undefined,
});
export const LayoutContextProvider = ({
@@ -21,16 +23,22 @@ export const LayoutContextProvider = ({
const MAX_WIDTH = 1040;
const [layoutMode, setLayoutMode] = useState();
+ const [windowWidth, setWindowWidth] = useState();
const getLayoutMode = (windowWidth: number) => {
return windowWidth < MAX_WIDTH ? "mobile" : "desktop";
};
useEffect(() => {
- setLayoutMode(getLayoutMode(document.documentElement.clientWidth));
+ const setState = () => {
+ setLayoutMode(getLayoutMode(document.documentElement.clientWidth));
+ setWindowWidth(document.documentElement.clientWidth);
+ };
+
+ setState();
const handleResize = throttle(() => {
- setLayoutMode(getLayoutMode(document.documentElement.clientWidth));
+ setState();
}, 500);
window.addEventListener("resize", handleResize);
@@ -41,7 +49,7 @@ export const LayoutContextProvider = ({
}, []);
return (
-
+
{children}
);
diff --git a/src/components/layout/LayoutHeader.tsx b/src/components/layout/LayoutHeader.tsx
index 8ca069d7..ed686573 100644
--- a/src/components/layout/LayoutHeader.tsx
+++ b/src/components/layout/LayoutHeader.tsx
@@ -48,7 +48,7 @@ const NAV = [
];
export const LayoutHeader = () => {
- const { layoutMode } = useContext(WindowContext);
+ const { windowWidth } = useContext(WindowContext);
const { setTheme } = useStore();
const route = useRouter();
const pathname = usePathname();
@@ -143,10 +143,10 @@ export const LayoutHeader = () => {
<>
- {flattenFormattedNav.map((fn) => (
-