2025-03-19 06:04:06 +00:00
|
|
|
"use client";
|
2025-11-10 09:25:56 +09:00
|
|
|
import React, { useState, useEffect } from "react";
|
2025-03-26 00:30:00 +00:00
|
|
|
import { DrawIoEmbed } from "react-drawio";
|
2025-03-25 02:24:12 +00:00
|
|
|
import ChatPanel from "@/components/chat-panel";
|
2025-03-27 08:24:17 +00:00
|
|
|
import { useDiagram } from "@/contexts/diagram-context";
|
2025-03-19 06:04:06 +00:00
|
|
|
|
2025-03-27 08:17:54 +00:00
|
|
|
export default function Home() {
|
2025-03-26 00:30:00 +00:00
|
|
|
const { drawioRef, handleDiagramExport } = useDiagram();
|
2025-11-10 09:25:56 +09:00
|
|
|
const [isMobile, setIsMobile] = useState(false);
|
2025-11-15 12:09:32 +09:00
|
|
|
const [isChatVisible, setIsChatVisible] = useState(true);
|
2025-11-10 09:25:56 +09:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const checkMobile = () => {
|
|
|
|
|
setIsMobile(window.innerWidth < 768);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Check on mount
|
|
|
|
|
checkMobile();
|
|
|
|
|
|
|
|
|
|
// Add event listener for resize
|
|
|
|
|
window.addEventListener("resize", checkMobile);
|
|
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
|
return () => window.removeEventListener("resize", checkMobile);
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-11-15 12:09:32 +09:00
|
|
|
// Add keyboard shortcut for toggling chat panel (Ctrl+B)
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
|
|
|
if ((event.ctrlKey || event.metaKey) && event.key === 'b') {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
setIsChatVisible((prev) => !prev);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('keydown', handleKeyDown);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener('keydown', handleKeyDown);
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-11-17 15:18:29 +09:00
|
|
|
return (
|
|
|
|
|
<div className="flex h-screen bg-gray-100 relative">
|
|
|
|
|
{/* Mobile warning overlay - keeps components mounted */}
|
|
|
|
|
{isMobile && (
|
|
|
|
|
<div className="absolute inset-0 z-50 flex items-center justify-center bg-gray-100">
|
|
|
|
|
<div className="text-center p-8">
|
|
|
|
|
<h1 className="text-2xl font-semibold text-gray-800">
|
|
|
|
|
Please open this application on a desktop or laptop
|
|
|
|
|
</h1>
|
|
|
|
|
</div>
|
2025-11-10 09:25:56 +09:00
|
|
|
</div>
|
2025-11-17 15:18:29 +09:00
|
|
|
)}
|
2025-03-19 08:16:44 +00:00
|
|
|
|
2025-11-15 12:09:32 +09:00
|
|
|
<div className={`${isChatVisible ? 'w-2/3' : 'w-full'} p-1 h-full relative transition-all duration-300 ease-in-out`}>
|
2025-03-27 08:24:17 +00:00
|
|
|
<DrawIoEmbed
|
|
|
|
|
ref={drawioRef}
|
|
|
|
|
onExport={handleDiagramExport}
|
|
|
|
|
urlParameters={{
|
|
|
|
|
spin: true,
|
|
|
|
|
libraries: false,
|
|
|
|
|
saveAndExit: false,
|
|
|
|
|
noExitBtn: true,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2025-03-27 08:17:54 +00:00
|
|
|
</div>
|
2025-11-15 12:09:32 +09:00
|
|
|
<div className={`${isChatVisible ? 'w-1/3' : 'w-12'} h-full p-1 transition-all duration-300 ease-in-out`}>
|
|
|
|
|
<ChatPanel
|
|
|
|
|
isVisible={isChatVisible}
|
|
|
|
|
onToggleVisibility={() => setIsChatVisible(!isChatVisible)}
|
|
|
|
|
/>
|
2025-03-27 08:24:17 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-03-26 00:30:00 +00:00
|
|
|
);
|
|
|
|
|
}
|