diff --git a/visions/server/src/core.rs b/visions/server/src/core.rs index d566f9b..944bc82 100644 --- a/visions/server/src/core.rs +++ b/visions/server/src/core.rs @@ -30,7 +30,7 @@ impl Core { Self(Arc::new(RwLock::new(AppState { image_base: PathBuf::from("/home/savanni/Pictures"), tabletop: Tabletop { - background_color: RGB{ red: 15, green: 0, blue: 0 }, + background_color: RGB{ red: 0xca, green: 0xb9, blue: 0xbb }, background_image: None, }, clients: HashMap::new(), diff --git a/visions/server/src/main.rs b/visions/server/src/main.rs index c93d8e1..b783d29 100644 --- a/visions/server/src/main.rs +++ b/visions/server/src/main.rs @@ -139,7 +139,7 @@ pub async fn main() { let core = core.clone(); move |body| { println!("background_image: {}", body); - core.set_background_image(body); + let _ = core.set_background_image(body); warp::reply() } }); diff --git a/visions/ui/src/App.tsx b/visions/ui/src/App.tsx index b3ad3af..ff5d709 100644 --- a/visions/ui/src/App.tsx +++ b/visions/ui/src/App.tsx @@ -1,10 +1,10 @@ import React, { useEffect, useState } from 'react'; import './App.css'; -import { TabletopElement } from './components/Tabletop/Tabletop'; import { Client } from './client'; import { createBrowserRouter, RouterProvider } from 'react-router-dom'; import { GmPlayingFieldComponent } from './components/GmPlayingField/GmPlayingField'; import { WebsocketProvider } from './components/WebsocketProvider'; +import { PlayerView } from './views/PlayerView/PlayerView'; interface AppProps { client: Client; @@ -26,7 +26,7 @@ const App = ({ client }: AppProps) => { }, { path: "/", - element: websocketUrl ? :
+ element: websocketUrl ? :
} ]); return ( diff --git a/visions/ui/src/components/Tabletop/Tabletop.css b/visions/ui/src/components/Tabletop/Tabletop.css index 05514de..19f7799 100644 --- a/visions/ui/src/components/Tabletop/Tabletop.css +++ b/visions/ui/src/components/Tabletop/Tabletop.css @@ -1,9 +1,5 @@ -.playing-field { - display: flex; -} - .playing-field__background { - max-width: 50%; + flex-grow: 1; } .playing-field__background > img { diff --git a/visions/ui/src/components/Tabletop/Tabletop.tsx b/visions/ui/src/components/Tabletop/Tabletop.tsx index 50c7375..ae105e2 100644 --- a/visions/ui/src/components/Tabletop/Tabletop.tsx +++ b/visions/ui/src/components/Tabletop/Tabletop.tsx @@ -1,23 +1,14 @@ import React, { useContext } from 'react'; import './Tabletop.css'; -import { WebsocketContext } from '../WebsocketProvider'; -import { Client } from '../../client'; +import { RGB } from 'visions'; interface TabletopElementProps { - client: Client; + backgroundColor: RGB; + backgroundUrl: URL | undefined; } -export const TabletopElement = ({ client }: TabletopElementProps) => { - const { tabletop } = useContext(WebsocketContext); - console.log("backgroundImage", tabletop.backgroundImage); - if (tabletop.backgroundImage) { - return (
-
{tabletop.backgroundImage && playing field}
-
) - } else { - return (
-
-
- ); - } +export const TabletopElement = ({ backgroundColor, backgroundUrl }: TabletopElementProps) => { + const tabletopColorStyle = `rgb(${backgroundColor.red}, ${backgroundColor.green}, ${backgroundColor.blue})`; + + return
{backgroundUrl && playing field}
} diff --git a/visions/ui/src/views/PlayerView/PlayerView.css b/visions/ui/src/views/PlayerView/PlayerView.css new file mode 100644 index 0000000..d0394d2 --- /dev/null +++ b/visions/ui/src/views/PlayerView/PlayerView.css @@ -0,0 +1,16 @@ +.player-view { + display: flex; + width: 100%; +} + +.player-view__left-panel { + flex-grow: 0; + min-width: 100px; +} + +.player-view__right-panel { + flex-grow: 0; + min-width: 100px; +} + + diff --git a/visions/ui/src/views/PlayerView/PlayerView.tsx b/visions/ui/src/views/PlayerView/PlayerView.tsx new file mode 100644 index 0000000..c4c351e --- /dev/null +++ b/visions/ui/src/views/PlayerView/PlayerView.tsx @@ -0,0 +1,24 @@ +import React, { useContext } from 'react'; +import './PlayerView.css'; +import { WebsocketContext } from '../../components/WebsocketProvider'; +import { Client } from '../../client'; +import { TabletopElement } from '../../components/Tabletop/Tabletop'; + +interface PlayerViewProps { + client: Client; +} + +export const PlayerView = ({ client }: PlayerViewProps) => { + const { tabletop } = useContext(WebsocketContext); + + const backgroundColor = tabletop.backgroundColor; + const tabletopColorStyle = `rgb(${backgroundColor.red}, ${backgroundColor.green}, ${backgroundColor.blue})`; + const backgroundUrl = tabletop.backgroundImage ? client.imageUrl(tabletop.backgroundImage) : undefined; + + return (
+
Left Side
+ +
Right Side
+
) +} +