diff --git a/src/components/Shakespeare/PreviewPane.tsx b/src/components/Shakespeare/PreviewPane.tsx index 538cefc3..1b529e59 100644 --- a/src/components/Shakespeare/PreviewPane.tsx +++ b/src/components/Shakespeare/PreviewPane.tsx @@ -16,11 +16,8 @@ import { GitStatusIndicator } from '@/components/GitStatusIndicator'; import { BranchSwitcher } from '@/components/BranchSwitcher'; import { BrowserAddressBar } from '@/components/ui/browser-address-bar'; import { type DeviceMode } from '@/components/ui/device-toggle'; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from '@/components/ui/popover'; +import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '@/components/ui/resizable'; +import type { ImperativePanelHandle } from 'react-resizable-panels'; import { cn } from '@/lib/utils'; import { FileTree } from './FileTree'; import { FileEditor } from './FileEditor'; @@ -83,8 +80,11 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable const [isFullscreen, setIsFullscreen] = useState(false); const [deviceMode, setDeviceMode] = useState('laptop'); + const [isLogsOpen, setIsLogsOpen] = useState(false); const previewContainerRef = useRef(null); const iframeRef = useRef(null); + const iframePanelRef = useRef(null); + const logsPanelRef = useRef(null); const { fs } = useFS(); const { projectsPath } = useFSPaths(); const projectsManager = useProjectsManager(); @@ -500,141 +500,47 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable } }; - const ConsoleDropdown = () => { - const [isOpen, setIsOpen] = useState(false); - const [copiedMessageIndex, setCopiedMessageIndex] = useState(null); - const [copiedAll, setCopiedAll] = useState(false); + const [copiedMessageIndex, setCopiedMessageIndex] = useState(null); + const [copiedAll, setCopiedAll] = useState(false); - const messages = isOpen ? getConsoleMessages() : []; + const messages = isLogsOpen ? getConsoleMessages() : []; - const copyMessageToClipboard = async (msg: ConsoleMessage, index: number) => { - try { - await navigator.clipboard.writeText(msg.message); - setCopiedMessageIndex(index); - setTimeout(() => setCopiedMessageIndex(null), 2000); - } catch (error) { - console.error('Failed to copy message to clipboard:', error); - } - }; - - const copyAllMessagesToClipboard = async () => { - try { - const allMessages = messages.map(msg => msg.message).join('\n'); - await navigator.clipboard.writeText(allMessages); - setCopiedAll(true); - setTimeout(() => setCopiedAll(false), 2000); - } catch (error) { - console.error('Failed to copy all messages to clipboard:', error); - } - }; - - const messageCount = messages.length; - - return ( - - - - - - - {/* Messages */} -
-
- {messageCount === 0 ? ( -
-

No console messages

-

Messages from your project will appear here

-
- ) : ( - messages.map((msg, index) => ( -
{ - e.stopPropagation(); - copyMessageToClipboard(msg, index); - }} - > -
- {msg.message} -
- -
- )) - )} -
-
- - {/* Action buttons */} -
- {messageCount > 0 && ( - - )} - -
-
-
- ); + const copyMessageToClipboard = async (msg: ConsoleMessage, index: number) => { + try { + await navigator.clipboard.writeText(msg.message); + setCopiedMessageIndex(index); + setTimeout(() => setCopiedMessageIndex(null), 2000); + } catch (error) { + console.error('Failed to copy message to clipboard:', error); + } }; + const copyAllMessagesToClipboard = async () => { + try { + const allMessages = messages.map(msg => msg.message).join('\n'); + await navigator.clipboard.writeText(allMessages); + setCopiedAll(true); + setTimeout(() => setCopiedAll(false), 2000); + } catch (error) { + console.error('Failed to copy all messages to clipboard:', error); + } + }; + + const messageCount = messages.length; + + // Programmatically resize panels when isLogsOpen changes + useEffect(() => { + if (isLogsOpen) { + // Open logs panel to 40% and resize iframe to 60% + logsPanelRef.current?.resize(40); + iframePanelRef.current?.resize(60); + } else { + // Close logs panel and expand iframe to 100% + logsPanelRef.current?.resize(0); + iframePanelRef.current?.resize(100); + } + }, [isLogsOpen]); + return (
@@ -712,40 +618,168 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable Code )} - +
{/* Content area */} -
- {hasBuiltProject ? ( -
+ + -