remove homepage board
This commit is contained in:
parent
9777084ca8
commit
299f3eff87
40
src/App.tsx
40
src/App.tsx
|
|
@ -1,19 +1,13 @@
|
||||||
import { inject } from '@vercel/analytics';
|
import { inject } from '@vercel/analytics';
|
||||||
import "tldraw/tldraw.css";
|
import "tldraw/tldraw.css";
|
||||||
import "@/css/style.css"
|
import "@/css/style.css"
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
import { Default } from "@/components/Default";
|
import { Default } from "@/components/Default";
|
||||||
import { Canvas } from "@/components/Canvas";
|
|
||||||
import { Toggle } from "@/components/Toggle";
|
|
||||||
import { useCanvas } from "@/hooks/useCanvas"
|
|
||||||
import { createShapes } from "@/utils/utils";
|
|
||||||
import { BrowserRouter, Route, Routes } from 'react-router-dom';
|
import { BrowserRouter, Route, Routes } from 'react-router-dom';
|
||||||
import { Contact } from "@/components/Contact";
|
import { Contact } from "@/components/Contact";
|
||||||
import { Post } from '@/components/Post';
|
import { Post } from '@/components/Post';
|
||||||
import { Board } from './components/Board';
|
import { Board } from './components/Board';
|
||||||
import { Inbox } from './components/Inbox';
|
import { Inbox } from './components/Inbox';
|
||||||
import { Books } from './components/Books';
|
|
||||||
import {
|
import {
|
||||||
Editor,
|
Editor,
|
||||||
Tldraw,
|
Tldraw,
|
||||||
|
|
@ -32,7 +26,6 @@ inject();
|
||||||
const customShapeUtils = [ChatBoxShape, VideoChatShape, EmbedShape];
|
const customShapeUtils = [ChatBoxShape, VideoChatShape, EmbedShape];
|
||||||
const customTools = [ChatBoxTool, VideoChatTool, EmbedTool];
|
const customTools = [ChatBoxTool, VideoChatTool, EmbedTool];
|
||||||
|
|
||||||
// [2]
|
|
||||||
export default function InteractiveShapeExample() {
|
export default function InteractiveShapeExample() {
|
||||||
return (
|
return (
|
||||||
<div className="tldraw__editor">
|
<div className="tldraw__editor">
|
||||||
|
|
@ -50,7 +43,6 @@ export default function InteractiveShapeExample() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add this function before or after InteractiveShapeExample
|
|
||||||
const handleInitialShapeLoad = (editor: Editor) => {
|
const handleInitialShapeLoad = (editor: Editor) => {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
const shapeId = url.searchParams.get('shapeId') || url.searchParams.get('frameId');
|
const shapeId = url.searchParams.get('shapeId') || url.searchParams.get('frameId');
|
||||||
|
|
@ -75,7 +67,6 @@ const handleInitialShapeLoad = (editor: Editor) => {
|
||||||
console.log('Zooming to shape bounds');
|
console.log('Zooming to shape bounds');
|
||||||
editor.zoomToBounds(editor.getShapeGeometry(shape).bounds, {
|
editor.zoomToBounds(editor.getShapeGeometry(shape).bounds, {
|
||||||
targetZoom: 1,
|
targetZoom: 1,
|
||||||
//padding: 32
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -94,42 +85,13 @@ function App() {
|
||||||
// <React.StrictMode>
|
// <React.StrictMode>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Home />} />
|
<Route path="/" element={<Default />} />
|
||||||
<Route path="/card/contact" element={<Contact />} />
|
<Route path="/card/contact" element={<Contact />} />
|
||||||
<Route path="/posts/:slug" element={<Post />} />
|
<Route path="/posts/:slug" element={<Post />} />
|
||||||
<Route path="/board/:slug" element={<Board />} />
|
<Route path="/board/:slug" element={<Board />} />
|
||||||
<Route path="/inbox" element={<Inbox />} />
|
<Route path="/inbox" element={<Inbox />} />
|
||||||
<Route path="/books" element={<Books />} />
|
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
// </React.StrictMode>
|
// </React.StrictMode>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function Home() {
|
|
||||||
const { isCanvasEnabled, elementsInfo } = useCanvas();
|
|
||||||
const shapes = createShapes(elementsInfo)
|
|
||||||
const [isEditorMounted, setIsEditorMounted] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleEditorDidMount = () => {
|
|
||||||
setIsEditorMounted(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('editorDidMountEvent', handleEditorDidMount);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener('editorDidMountEvent', handleEditorDidMount);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Toggle />
|
|
||||||
<div style={{ zIndex: 999999 }} className={`${isCanvasEnabled && isEditorMounted ? 'transparent' : ''}`}>
|
|
||||||
{<Default />}
|
|
||||||
</div>
|
|
||||||
{isCanvasEnabled && elementsInfo.length > 0 ? <Canvas shapes={shapes} /> : null}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
49322
src/canvas01.ts
49322
src/canvas01.ts
File diff suppressed because it is too large
Load Diff
|
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
import { Editor, Tldraw } from "tldraw";
|
|
||||||
import { canvas } from "@/canvas01";
|
|
||||||
|
|
||||||
export function Books() {
|
|
||||||
return (
|
|
||||||
<div className="tldraw__editor">
|
|
||||||
<Tldraw
|
|
||||||
onMount={(editor: Editor) => {
|
|
||||||
editor.putContentOntoCurrentPage(canvas as any)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
import { Editor, Tldraw, TLShape, TLUiComponents } from "tldraw";
|
|
||||||
import { SimController } from "@/physics/PhysicsControls";
|
|
||||||
import { HTMLShapeUtil } from "@/utils/HTMLShapeUtil";
|
|
||||||
|
|
||||||
const components: TLUiComponents = {
|
|
||||||
HelpMenu: null,
|
|
||||||
StylePanel: null,
|
|
||||||
PageMenu: null,
|
|
||||||
NavigationPanel: null,
|
|
||||||
DebugMenu: null,
|
|
||||||
//ContextMenu: null,
|
|
||||||
ActionsMenu: null,
|
|
||||||
QuickActions: null,
|
|
||||||
MainMenu: null,
|
|
||||||
MenuPanel: null,
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Canvas({ shapes }: { shapes: TLShape[]; }) {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="tldraw__editor">
|
|
||||||
<Tldraw
|
|
||||||
components={components}
|
|
||||||
shapeUtils={[HTMLShapeUtil]}
|
|
||||||
onMount={(_: Editor) => {
|
|
||||||
window.dispatchEvent(new CustomEvent('editorDidMountEvent'));
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SimController shapes={shapes} />
|
|
||||||
</Tldraw>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue