Skip to content

Commit a9f0919

Browse files
committed
一旦モバイル幅は非対応で
1 parent a00f1ce commit a9f0919

File tree

1 file changed

+48
-29
lines changed

1 file changed

+48
-29
lines changed

src/components/layout/MainLayout.tsx

+48-29
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
AlertDialogHeader,
2020
AlertDialogBody,
2121
AlertDialogFooter,
22+
useBreakpointValue,
2223
} from "@chakra-ui/react";
2324
import { FiMenu } from "react-icons/fi";
2425
import { IconType } from "react-icons";
@@ -45,6 +46,7 @@ export default function SimpleSidebar() {
4546
const { isOpen, onOpen, onClose } = useDisclosure();
4647
const navigate = useNavigate();
4748
const [selectedPath, setSelectedPath] = useState("/");
49+
const isMobile = useBreakpointValue({ base: true, md: false });
4850
const bg = useColorModeValue("gray.100", "gray.900");
4951
const sidebarBg = useColorModeValue("white", "gray.900");
5052
const borderColor = useColorModeValue("gray.200", "gray.700");
@@ -53,43 +55,60 @@ export default function SimpleSidebar() {
5355

5456
return (
5557
<Box minH="100vh" bg={bg}>
56-
<SidebarContent
57-
onClose={onClose}
58-
display={{ base: "none", md: "block" }}
59-
navigate={navigate}
60-
selectedPath={selectedPath}
61-
setSelectedPath={setSelectedPath}
62-
bg={sidebarBg}
63-
borderColor={borderColor}
64-
/>
65-
<Drawer
66-
isOpen={isOpen}
67-
placement="left"
68-
onClose={onClose}
69-
returnFocusOnClose={false}
70-
onOverlayClick={onClose}
71-
size="full"
72-
>
73-
<DrawerContent>
58+
{isMobile ? (
59+
<Flex
60+
direction="column"
61+
align="center"
62+
justify="center"
63+
h="100vh"
64+
w="100vw"
65+
bg="gray.200"
66+
>
67+
<Text fontSize="xl" mb="4">
68+
現在モバイル幅での表示はサポートしていません。
69+
</Text>
70+
</Flex>
71+
) : (
72+
<>
7473
<SidebarContent
7574
onClose={onClose}
75+
display={{ base: "none", md: "block" }}
7676
navigate={navigate}
7777
selectedPath={selectedPath}
7878
setSelectedPath={setSelectedPath}
7979
bg={sidebarBg}
8080
borderColor={borderColor}
8181
/>
82-
</DrawerContent>
83-
</Drawer>
84-
<MobileNav
85-
display={{ base: "flex", md: "none" }}
86-
onOpen={onOpen}
87-
bg={mobileNavBg}
88-
borderColor={mobileBorderColor}
89-
/>
90-
<Box ml={{ base: 0 }} p="4">
91-
{/* ここで各コンポーネントの中身を表示 */}
92-
</Box>
82+
<Drawer
83+
isOpen={isOpen}
84+
placement="left"
85+
onClose={onClose}
86+
returnFocusOnClose={false}
87+
onOverlayClick={onClose}
88+
size="full"
89+
>
90+
<DrawerContent>
91+
<SidebarContent
92+
onClose={onClose}
93+
navigate={navigate}
94+
selectedPath={selectedPath}
95+
setSelectedPath={setSelectedPath}
96+
bg={sidebarBg}
97+
borderColor={borderColor}
98+
/>
99+
</DrawerContent>
100+
</Drawer>
101+
<MobileNav
102+
display={{ base: "flex", md: "none" }}
103+
onOpen={onOpen}
104+
bg={mobileNavBg}
105+
borderColor={mobileBorderColor}
106+
/>
107+
<Box ml={{ base: 0 }} p="4">
108+
{/* ここで各コンポーネントの中身を表示 */}
109+
</Box>
110+
</>
111+
)}
93112
</Box>
94113
);
95114
}

0 commit comments

Comments
 (0)