diff --git a/tank-frontend/src/App.css b/tank-frontend/src/App.css new file mode 100644 index 0000000..8845dee --- /dev/null +++ b/tank-frontend/src/App.css @@ -0,0 +1,4 @@ +.GadgetRows { + justify-content: space-evenly; + margin-top: 24px; +} diff --git a/tank-frontend/src/App.tsx b/tank-frontend/src/App.tsx new file mode 100644 index 0000000..312d5c6 --- /dev/null +++ b/tank-frontend/src/App.tsx @@ -0,0 +1,47 @@ +import {useCallback, useState} from 'react'; +import ClientScreen from './ClientScreen'; +import Controls from './Controls.tsx'; +import JoinForm from './JoinForm.tsx'; +import PlayerInfo from './PlayerInfo.tsx'; +import {useStoredObjectState} from './useStoredState.ts'; +import {NameId, postPlayer} from './serverCalls.tsx'; +import Column from "./components/Column.tsx"; +import Row from "./components/Row.tsx"; +import Scoreboard from "./Scoreboard.tsx"; +import Button from "./components/Button.tsx"; +import './App.css'; + +const getNewNameId = () => ({ + id: crypto.randomUUID(), + name: '' +}); + +export default function App() { + const [nameId, setNameId] = useStoredObjectState('access', getNewNameId); + + const [isLoggedIn, setLoggedIn] = useState(false); + const logout = () => setLoggedIn(false); + + useCallback(async () => { + if (isLoggedIn) + return; + const result = await postPlayer(nameId); + setLoggedIn(result !== null); + }, [nameId, isLoggedIn])(); + + return + +

Tanks!

+ {nameId.name !== '' && + + text='INSERT COIN'/>
; } diff --git a/tank-frontend/src/PlayerInfo.css b/tank-frontend/src/PlayerInfo.css index c3a8623..14ae318 100644 --- a/tank-frontend/src/PlayerInfo.css +++ b/tank-frontend/src/PlayerInfo.css @@ -1,9 +1,5 @@ - .Elems { +.Elems { padding: 8px 8px; margin: 8px 8px; } -.PlayerInfo-Reset { - height: 4em; - width: 4em; -} diff --git a/tank-frontend/src/components/Button.css b/tank-frontend/src/components/Button.css index 8efe497..b0b9c76 100644 --- a/tank-frontend/src/components/Button.css +++ b/tank-frontend/src/components/Button.css @@ -1,7 +1,14 @@ .Button { - border: solid 1px green; - border-radius: 12px; + border: solid 4px green; + padding: 8px; color: green; background: transparent; } + +.Button:hover, .Button:active { + background-color: green; + color: black; + cursor: pointer; +} + diff --git a/tank-frontend/src/components/Button.tsx b/tank-frontend/src/components/Button.tsx index c3be029..609245c 100644 --- a/tank-frontend/src/components/Button.tsx +++ b/tank-frontend/src/components/Button.tsx @@ -1,14 +1,16 @@ import './Button.css'; import {MouseEventHandler} from "react"; -export default function Button({text, onClick, className}: { +export default function Button({text, onClick, className, disabled}: { text: string, onClick?: MouseEventHandler, - className?: string + className?: string, + disabled?: boolean }) { return diff --git a/tank-frontend/src/components/TextInput.css b/tank-frontend/src/components/TextInput.css new file mode 100644 index 0000000..06e873a --- /dev/null +++ b/tank-frontend/src/components/TextInput.css @@ -0,0 +1,3 @@ +.TextInput { + padding: 8px; +} diff --git a/tank-frontend/src/components/TextInput.tsx b/tank-frontend/src/components/TextInput.tsx new file mode 100644 index 0000000..b806045 --- /dev/null +++ b/tank-frontend/src/components/TextInput.tsx @@ -0,0 +1,21 @@ +import {ChangeEventHandler} from "react"; +import './TextInput.css'; + +export default function TextInput(props: { + onChange?: ChangeEventHandler | undefined; + className?: string; + value: string; + placeholder: string; + onEnter?: () => void; +}) { + return { + if (props.onEnter && event.key === 'Enter') + props.onEnter(); + }} + />; +} diff --git a/tank-frontend/src/index.css b/tank-frontend/src/index.css index dcd795f..b60815d 100644 --- a/tank-frontend/src/index.css +++ b/tank-frontend/src/index.css @@ -1,7 +1,3 @@ -* { - box-sizing: border-box; -} - @font-face { font-family: 'CCCBFont'; font-style: normal; @@ -10,10 +6,15 @@ src: url('/CCCBFont.ttf') format('ttf'), url('/CCCBFont.woff') format('woff'); } +* { + box-sizing: border-box; + font-family: CCCBFont, monospace; + text-transform: uppercase; +} + html, body { height: 100%; - font-family: CCCBFont, monospace; margin: 0; display: flex; align-items: center; @@ -34,8 +35,3 @@ html, body { .grow { flex-grow: 1; } - -.GadgetRows { - justify-content: space-evenly; - margin-top: 24px; -} diff --git a/tank-frontend/src/index.tsx b/tank-frontend/src/index.tsx index 67c3cc7..07bbf93 100644 --- a/tank-frontend/src/index.tsx +++ b/tank-frontend/src/index.tsx @@ -1,51 +1,8 @@ -import React, {useCallback, useState} from 'react'; -import './index.css'; -import ClientScreen from './ClientScreen'; -import Controls from './Controls.tsx'; -import JoinForm from './JoinForm.tsx'; +import React from 'react'; import {createRoot} from 'react-dom/client'; -import PlayerInfo from './PlayerInfo.tsx'; -import {useStoredObjectState} from './useStoredState.ts'; -import {NameId, postPlayer} from './serverCalls.tsx'; -import Column from "./components/Column.tsx"; -import Row from "./components/Row.tsx"; -import Scoreboard from "./Scoreboard.tsx"; -import Button from "./components/Button.tsx"; +import './index.css'; +import App from "./App.tsx"; -const getNewNameId = () => ({ - id: crypto.randomUUID(), - name: '' -}); - -function App() { - const [nameId, setNameId] = useStoredObjectState('access', getNewNameId); - - const [isLoggedIn, setLoggedIn] = useState(false); - const logout = () => setLoggedIn(false); - - useCallback(async () => { - if (isLoggedIn) - return; - const result = await postPlayer(nameId); - setLoggedIn(result !== null); - }, [nameId, isLoggedIn])(); - - return - -

Tanks!

- {nameId.name !== '' && -