Skip to content

Commit 6cb77b9

Browse files
committed
update responsive styles
1 parent fc58622 commit 6cb77b9

File tree

36 files changed

+278
-115
lines changed

36 files changed

+278
-115
lines changed

src/components/layouts/HorizontalLayout/HorizontalLayout.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Flex } from "@chakra-ui/react";
2-
import HorizontalLayoutHeader from "./HorizontalLayoutHeader";
3-
import { HorizontalLayoutSidebar } from "./HorizontalLayoutSidebar";
2+
import { Sidebar, SubHeader } from "../common";
43

54
interface HorizontalLayoutProps {
65
children?: React.ReactNode;
@@ -9,7 +8,7 @@ interface HorizontalLayoutProps {
98
const HorizontalLayout = ({ children }: HorizontalLayoutProps) => {
109
return (
1110
<Flex>
12-
<HorizontalLayoutSidebar />
11+
<Sidebar />
1312
<Flex
1413
flex={1}
1514
direction={"column"}
@@ -18,7 +17,7 @@ const HorizontalLayout = ({ children }: HorizontalLayoutProps) => {
1817
maxH={"100vh"}
1918
overflow={"hidden"}
2019
>
21-
<HorizontalLayoutHeader />
20+
<SubHeader />
2221
<Flex
2322
as={"main"}
2423
flex={1}

src/components/layouts/HorizontalLayout/HorizontalLayoutSidebar/HorizontalLayoutNavbar/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/layouts/HorizontalLayout/HorizontalLayoutSidebar/HorizontalLayoutSidebar.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/components/layouts/HorizontalLayout/HorizontalLayoutSidebar/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Logo } from "@/components";
2+
import { PageRoutes } from "@/constants";
3+
import { useAlphaColor, useSafePush } from "@/hooks";
4+
import { toUrl } from "@/utils";
5+
import { Flex, Icon, IconButton } from "@chakra-ui/react";
6+
import { GiHamburgerMenu } from "react-icons/gi";
7+
8+
interface MobileHeaderProps {
9+
onClick?: () => void;
10+
}
11+
12+
const MobileHeader = ({ onClick }: MobileHeaderProps) => {
13+
const { push } = useSafePush();
14+
const alphaColor = useAlphaColor();
15+
16+
return (
17+
<Flex
18+
as={"header"}
19+
pos={"sticky"}
20+
align={"center"}
21+
bgColor={alphaColor(50)}
22+
top={"0"}
23+
gap={"4"}
24+
p={"4"}
25+
>
26+
<IconButton
27+
aria-label={"Open Sidebar"}
28+
variant={"outline"}
29+
onClick={onClick}
30+
>
31+
<Icon as={GiHamburgerMenu} />
32+
</IconButton>
33+
<Logo onClick={() => push(toUrl(PageRoutes.Home))} />
34+
</Flex>
35+
);
36+
};
37+
38+
export default MobileHeader;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Flex } from "@chakra-ui/react";
2+
import { useCallback, useState } from "react";
3+
import { Footer, SubHeader } from "../common";
4+
import MobileHeader from "./MobileHeader";
5+
import MobileNavigation from "./MobileNavigation";
6+
7+
interface MobileLayoutProps {
8+
children?: React.ReactNode;
9+
}
10+
11+
const MobileLayout = ({ children }: MobileLayoutProps) => {
12+
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
13+
14+
const handleSidebarOpen = useCallback(() => {
15+
setIsSidebarOpen((prev) => !prev);
16+
}, []);
17+
18+
return (
19+
<Flex direction={{ base: "column", lg: "row" }} minH={"100vh"}>
20+
<MobileHeader onClick={handleSidebarOpen} />
21+
<MobileNavigation isOpen={isSidebarOpen} onClose={handleSidebarOpen} />
22+
<Flex
23+
flex={1}
24+
direction={"column"}
25+
p={"8"}
26+
gap={"4"}
27+
maxH={{ base: "initial", lg: "100vh" }}
28+
overflow={"hidden"}
29+
>
30+
<SubHeader />
31+
<Flex
32+
as={"main"}
33+
flex={1}
34+
direction={"column"}
35+
overflow={"hidden"}
36+
p={"0.5"}
37+
>
38+
{children}
39+
</Flex>
40+
</Flex>
41+
<Footer />
42+
</Flex>
43+
);
44+
};
45+
46+
export default MobileLayout;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Drawer, DrawerContent, DrawerOverlay } from "@chakra-ui/react";
2+
import { Sidebar } from "../common";
3+
4+
interface MobileNavigationProps {
5+
isOpen: boolean;
6+
onClose: () => void;
7+
}
8+
9+
const MobileNavigation = ({ isOpen, onClose }: MobileNavigationProps) => {
10+
return (
11+
<Drawer isOpen={isOpen} onClose={onClose} placement={"left"}>
12+
<DrawerOverlay />
13+
<DrawerContent maxW={"fit-content"}>
14+
<Sidebar />
15+
</DrawerContent>
16+
</Drawer>
17+
);
18+
};
19+
20+
export default MobileNavigation;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as MobileLayout } from "./MobileLayout";
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { useLayout } from "@/hooks";
2+
import { useMemo } from "react";
3+
import { HorizontalLayout } from "../HorizontalLayout";
4+
import { MobileLayout } from "../MobileLayout";
5+
import { VerticalLayout } from "../VerticalLayout";
6+
7+
interface ResponsiveLayoutProps {
8+
children?: React.ReactNode;
9+
}
10+
11+
const ResponsiveLayout = ({ children }: ResponsiveLayoutProps) => {
12+
const { layout } = useLayout();
13+
14+
const Layout = useMemo(() => {
15+
switch (layout) {
16+
case "horizontal":
17+
return HorizontalLayout;
18+
case "vertical":
19+
return VerticalLayout;
20+
case "mobile":
21+
return MobileLayout;
22+
default:
23+
throw new Error(`Invalid layout: ${layout}`);
24+
}
25+
}, [layout]);
26+
27+
return <Layout>{children}</Layout>;
28+
};
29+
30+
export default ResponsiveLayout;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as ResponsiveLayout } from "./ResponsiveLayout";

0 commit comments

Comments
 (0)