diff --git a/src/components/TitleBar.tsx b/src/components/TitleBar.tsx index 9808d73..4f5a4c4 100644 --- a/src/components/TitleBar.tsx +++ b/src/components/TitleBar.tsx @@ -1,12 +1,24 @@ +import { useEffect, useState } from "react"; import { getCurrentWindow } from "@tauri-apps/api/window"; import { useStore } from "../store"; +function useWindowWidth() { + const [width, setWidth] = useState(window.innerWidth); + useEffect(() => { + const handler = () => setWidth(window.innerWidth); + window.addEventListener("resize", handler); + return () => window.removeEventListener("resize", handler); + }, []); + return width; +} + interface Props { onOpenSettings: () => void; } export default function TitleBar({ onOpenSettings }: Props) { const { view, closeGuide, activeGuideData } = useStore(); + const windowWidth = useWindowWidth(); function handleDragMouseDown(e: React.MouseEvent) { if (e.button === 0) { @@ -43,7 +55,7 @@ export default function TitleBar({ onOpenSettings }: Props) { TougliGui - {view === "guide" && activeGuideData && ( + {view === "guide" && activeGuideData && windowWidth >= 400 && ( <> {activeGuideData.name}