diff --git a/src/app/TitleBar.tsx b/src/app/TitleBar.tsx index 68205fa..42162f8 100644 --- a/src/app/TitleBar.tsx +++ b/src/app/TitleBar.tsx @@ -78,13 +78,13 @@ export const TitleBar = () => { return ( <>
-
- Dyad Logo +
+ Dyad Logo ); } diff --git a/src/components/preview_panel/PreviewHeader.tsx b/src/components/preview_panel/PreviewHeader.tsx index aaa5be2..2f627a1 100644 --- a/src/components/preview_panel/PreviewHeader.tsx +++ b/src/components/preview_panel/PreviewHeader.tsx @@ -21,6 +21,12 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; import { showError, showSuccess } from "@/lib/toast"; import { useMutation } from "@tanstack/react-query"; import { useCheckProblems } from "@/hooks/useCheckProblems"; @@ -28,6 +34,9 @@ import { isPreviewOpenAtom } from "@/atoms/viewAtoms"; export type PreviewMode = "preview" | "code" | "problems" | "configure"; +const BUTTON_CLASS_NAME = + "cursor-pointer relative flex items-center gap-1 px-2 py-1 rounded-md text-[13px] font-medium z-10 hover:bg-[var(--background)]"; + // Preview Header component with preview mode toggle export const PreviewHeader = () => { const [previewMode, setPreviewMode] = useAtom(previewModeAtom); @@ -38,9 +47,22 @@ export const PreviewHeader = () => { const problemsRef = useRef(null); const configureRef = useRef(null); const [indicatorStyle, setIndicatorStyle] = useState({ left: 0, width: 0 }); + const [windowWidth, setWindowWidth] = useState(window.innerWidth); const { problemReport } = useCheckProblems(selectedAppId); const { restartApp, refreshAppIframe } = useRunApp(); + const isCompact = windowWidth < 840; + + // Track window width + useEffect(() => { + const handleResize = () => { + setWindowWidth(window.innerWidth); + }; + + window.addEventListener("resize", handleResize); + return () => window.removeEventListener("resize", handleResize); + }, []); + const selectPanel = (panel: PreviewMode) => { if (previewMode === panel) { setIsPreviewOpen(!isPreviewOpen); @@ -130,100 +152,128 @@ export const PreviewHeader = () => { // Small delay to ensure DOM is updated const timeoutId = setTimeout(updateIndicator, 10); return () => clearTimeout(timeoutId); - }, [previewMode, displayCount, isPreviewOpen]); + }, [previewMode, displayCount, isPreviewOpen, isCompact]); + + const renderButton = ( + mode: PreviewMode, + ref: React.RefObject, + icon: React.ReactNode, + text: string, + testId: string, + badge?: React.ReactNode, + ) => { + const buttonContent = ( + + ); + + if (isCompact) { + return ( + + {buttonContent} + +

{text}

+
+
+ ); + } + + return buttonContent; + }; return ( -
-
- - - - - - + {renderButton( + "problems", + problemsRef, + , + "Problems", + "problems-mode-button", + displayCount && ( + + {displayCount} + + ), + )} + {renderButton( + "code", + codeRef, + , + "Code", + "code-mode-button", + )} + {renderButton( + "configure", + configureRef, + , + "Configure", + "configure-mode-button", + )} +
+
+ + + + + + + +
+ Rebuild + + Re-installs node_modules and restarts + +
+
+ + +
+ Clear Cache + + Clears cookies and local storage and other app cache + +
+
+
+
+
-
- - - - - - - -
- Rebuild - - Re-installs node_modules and restarts - -
-
- - -
- Clear Cache - - Clears cookies and local storage and other app cache - -
-
-
-
-
-
+ ); };