diff --git a/web/src/components/HomeSidebarDrawer.tsx b/web/src/components/HomeSidebarDrawer.tsx index e48691dd..98f84e48 100644 --- a/web/src/components/HomeSidebarDrawer.tsx +++ b/web/src/components/HomeSidebarDrawer.tsx @@ -21,7 +21,7 @@ const HomeSidebarDrawer = () => { }; return ( -
+ <> @@ -30,7 +30,7 @@ const HomeSidebarDrawer = () => {
- + ); }; diff --git a/web/src/components/MobileHeader.tsx b/web/src/components/MobileHeader.tsx index 6f2b1dc8..3d9ffcb8 100644 --- a/web/src/components/MobileHeader.tsx +++ b/web/src/components/MobileHeader.tsx @@ -1,4 +1,5 @@ import { useState } from "react"; +import useResponsiveWidth from "@/hooks/useResponsiveWidth"; import NavigationDrawer from "./NavigationDrawer"; interface Props { @@ -7,12 +8,13 @@ interface Props { const MobileHeader = (props: Props) => { const { children } = props; + const { sm } = useResponsiveWidth(); const [titleText] = useState("MEMOS"); return (
- + {!sm && } location.reload()} diff --git a/web/src/components/NavigationDrawer.tsx b/web/src/components/NavigationDrawer.tsx index 21fc7a39..563d246c 100644 --- a/web/src/components/NavigationDrawer.tsx +++ b/web/src/components/NavigationDrawer.tsx @@ -21,7 +21,7 @@ const NavigationDrawer = () => { }; return ( -
+ <> @@ -30,7 +30,7 @@ const NavigationDrawer = () => {
-
+ ); }; diff --git a/web/src/hooks/useResponsiveWidth.ts b/web/src/hooks/useResponsiveWidth.ts new file mode 100644 index 00000000..e73804bf --- /dev/null +++ b/web/src/hooks/useResponsiveWidth.ts @@ -0,0 +1,18 @@ +import useWindowSize from "react-use/lib/useWindowSize"; + +enum TailwindResponsiveWidth { + sm = 640, + md = 768, + lg = 1024, +} + +const useResponsiveWidth = () => { + const { width } = useWindowSize(); + return { + sm: width >= TailwindResponsiveWidth.sm, + md: width >= TailwindResponsiveWidth.md, + lg: width >= TailwindResponsiveWidth.lg, + }; +}; + +export default useResponsiveWidth; diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx index 2b8f4c33..75f978b1 100644 --- a/web/src/pages/Home.tsx +++ b/web/src/pages/Home.tsx @@ -3,20 +3,22 @@ import HomeSidebarDrawer from "@/components/HomeSidebarDrawer"; import MemoEditor from "@/components/MemoEditor"; import MemoList from "@/components/MemoList"; import MobileHeader from "@/components/MobileHeader"; +import useResponsiveWidth from "@/hooks/useResponsiveWidth"; const Home = () => { + const { md } = useResponsiveWidth(); return (
- - - + {!md && }
-
- -
+ {md && ( +
+ +
+ )}
); };