diff --git a/ptcs/ptcs_ui/src/components/Railway.tsx b/ptcs/ptcs_ui/src/components/Railway.tsx index df4b325..ee3834f 100644 --- a/ptcs/ptcs_ui/src/components/Railway.tsx +++ b/ptcs/ptcs_ui/src/components/Railway.tsx @@ -5,15 +5,21 @@ import { Train } from "./Train"; import { Junction } from "./Junction"; import { useContext } from "react"; import { Stop } from "./Stop"; +import { useMantineTheme } from "@mantine/core"; export const Railway: React.FC = ({ children }) => { + const theme = useMantineTheme(); const railwayUI = useContext(RailwayUIContext); if (!railwayUI) return null; return ( - + {Object.entries(railwayUI.platforms).map(([id, platform]) => ( ))} diff --git a/ptcs/ptcs_ui/src/main.tsx b/ptcs/ptcs_ui/src/main.tsx index b5d8946..df04cd3 100644 --- a/ptcs/ptcs_ui/src/main.tsx +++ b/ptcs/ptcs_ui/src/main.tsx @@ -13,7 +13,11 @@ const router = createHashRouter([ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - + diff --git a/ptcs/ptcs_ui/src/pages/Home.tsx b/ptcs/ptcs_ui/src/pages/Home.tsx index 79ecbc9..cc5a07c 100644 --- a/ptcs/ptcs_ui/src/pages/Home.tsx +++ b/ptcs/ptcs_ui/src/pages/Home.tsx @@ -1,4 +1,10 @@ -import { Code, Container, DEFAULT_THEME, Grid, Stack } from "@mantine/core"; +import { + Code, + Container, + DEFAULT_THEME, + Stack, + useMantineTheme, +} from "@mantine/core"; import { DefaultService, RailwayState } from "ptcs_client"; import { Layout } from "../components/Layout"; import { useEffect, useState } from "react"; @@ -103,19 +109,21 @@ const ui: RailwayUI = { }; export const Home: React.FC = () => { + const theme = useMantineTheme(); const [railwayState, setRailwayState] = useState(null); - const [time, setTime] = useState(); + const [time, setTime] = useState(() => new Date()); useEffect(() => { DefaultService.getState().then((state) => { + setTime(new Date()); setRailwayState(state); }); }, []); useEffect(() => { const interval = setInterval(() => { - setTime(new Date()); DefaultService.getState().then((state) => { + setTime(new Date()); setRailwayState(state); }); }, 500); @@ -129,16 +137,20 @@ export const Home: React.FC = () => { - - {time?.toLocaleString()} - + + + + {time.toLocaleString()} + + - - - {JSON.stringify(railwayState, null, 4)} - - - + {JSON.stringify(railwayState, null, 4)}