diff --git a/src/components/EditorPanel.jsx b/src/components/EditorPanel.jsx index fadcc5d..d96b02e 100644 --- a/src/components/EditorPanel.jsx +++ b/src/components/EditorPanel.jsx @@ -4,12 +4,13 @@ import Editor from '@monaco-editor/react'; export default function EditorPanel({ code, onChange }) { return (
onChange(v || '')} theme="vs-dark" options={{ - fontSize: 16, + fontSize: 20, padding: { top: 10, bottom: 10 }, minimap: { enabled: false }, scrollbar: { - verticalScrollbarSize: 8, - horizontalScrollbarSize: 8, + verticalScrollbarSize: 12, + horizontalScrollbarSize: 12 }, lineNumbers: 'on', - scrollBeyondLastLine: false, + scrollBeyondLastLine: false }} />
diff --git a/src/components/PreviewPanel.jsx b/src/components/PreviewPanel.jsx index f94a471..3e66bd7 100644 --- a/src/components/PreviewPanel.jsx +++ b/src/components/PreviewPanel.jsx @@ -2,140 +2,120 @@ import React, { useState } from 'react'; export default function PreviewPanel({ code }) { const [gameUrl, setGameUrl] = useState(''); - const [snakeApiUrl, setSnakeApiUrl] = useState(''); const [settings, setSettings] = useState(null); - const [moveRes, setMoveRes] = useState(null); const [loadingSetup, setLoadingSetup] = useState(false); - const [loadingMove, setLoadingMove] = useState(false); - - const fetchSetup = async (e) => { - e.preventDefault(); - setLoadingSetup(true); - try { - const res = await fetch( - `/api/fetch-board?url=${encodeURIComponent(gameUrl.trim())}` - ); - setSettings(await res.json()); - setMoveRes(null); - } catch (err) { - console.error(err); - } - setLoadingSetup(false); - }; - - const testMove = async (e) => { - e.preventDefault(); - if (!settings) return; - setLoadingMove(true); + const fetchBoard = async () => { + if (!gameUrl.trim()) return; + setLoadingSetup(true); try { - const res = await fetch('/api/move', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ code, boardState: settings }) - }); - setMoveRes(await res.json()); + const res = await fetch( + `/api/fetch-board?url=${encodeURIComponent(gameUrl.trim())}` + ); + if (!res.ok) throw new Error('Fetch board failed'); + setSettings(await res.json()); } catch (err) { console.error(err); + } finally { + setLoadingSetup(false); } - setLoadingMove(false); }; const gameId = gameUrl.trim().split('/').pop(); return ( -
-

Battlesnake Preview

+
+
+

+ 🎯 Live Arena Output +

- {/* game board URL */} -
+
setGameUrl(e.target.value)} - style={{ flex: 1 }} + onChange={e => setGameUrl(e.target.value)} + style={{ + width: '100%', + padding: '0.5rem', + marginBottom: '0.75rem', + border: 'none', + borderRadius: 4, + background: 'transparent', + color: '#fff', + outline: 'none' + }} /> - - - - {/* API server URL */} -
- setSnakeApiUrl(e.target.value)} - style={{ flex: 1 }} - /> - -
- - {/* Test Move */} -
-
- {settings && gameId && ( -
+ {/*
+
*/} + +
+ {settings && gameId && (