first prototype

This commit is contained in:
2026-09-27 09:52:00 +02:00
parent 4635199a41
commit 6d011d474f
109 changed files with 6354 additions and 507 deletions
+48 -114
View File
@@ -1,121 +1,55 @@
import { useState } from 'react'
import heroImg from './assets/hero.png'
import reactLogo from './assets/react.svg'
import viteLogo from './assets/vite.svg'
import './App.css'
import { useEffect } from 'react'
import styles from './App.module.css'
import { useWizard } from './api/useWizard'
import { Toasts } from './components/Toasts/Toasts'
import { GameScreen } from './screens/GameScreen/GameScreen'
import { HomeScreen } from './screens/HomeScreen/HomeScreen'
import { LobbyScreen } from './screens/LobbyScreen/LobbyScreen'
const STATUS_MESSAGES = {
connecting: 'Connecting to the server…',
closed: 'Connection lost. Reconnecting…',
replaced: 'This game was opened in another window. Reload the page to continue here.',
} as const
function App() {
const [count, setCount] = useState(0)
const { status, playerId, lobby, game, completedTrick, completedRound, toasts, dismissToast, actions } =
useWizard()
const lobbyCode = lobby?.code
// Keep the lobby code in the address bar so the URL can be shared as an invite link.
useEffect(() => {
if (lobbyCode) {
window.history.replaceState(null, '', `?lobby=${lobbyCode}`)
} else if (status === 'open' && window.location.search) {
window.history.replaceState(null, '', window.location.pathname)
}
}, [lobbyCode, status])
let screen
if (!lobby || !playerId) {
screen = <HomeScreen connected={status === 'open'} actions={actions} />
} else if (lobby.status === 'waiting' || !game) {
screen = <LobbyScreen lobby={lobby} playerId={playerId} actions={actions} />
} else {
screen = (
<GameScreen
lobby={lobby}
game={game}
playerId={playerId}
completedTrick={completedTrick}
completedRound={completedRound}
actions={actions}
/>
)
}
return (
<>
<section id="center">
<div className="hero">
<img src={heroImg} className="base" width="170" height="179" alt="" />
<img src={reactLogo} className="framework" alt="React logo" />
<img src={viteLogo} className="vite" alt="Vite logo" />
</div>
<div>
<h1>Get started</h1>
<p>
Edit <code>src/App.tsx</code> and save to test <code>HMR</code>
</p>
</div>
<button
type="button"
className="counter"
onClick={() => setCount((count) => count + 1)}
>
Count is {count}
</button>
</section>
<div className="ticks"></div>
<section id="next-steps">
<div id="docs">
<svg className="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#documentation-icon"></use>
</svg>
<h2>Documentation</h2>
<p>Your questions, answered</p>
<ul>
<li>
<a href="https://vite.dev/" target="_blank">
<img className="logo" src={viteLogo} alt="" />
Explore Vite
</a>
</li>
<li>
<a href="https://react.dev/" target="_blank">
<img className="button-icon" src={reactLogo} alt="" />
Learn more
</a>
</li>
</ul>
</div>
<div id="social">
<svg className="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#social-icon"></use>
</svg>
<h2>Connect with us</h2>
<p>Join the Vite community</p>
<ul>
<li>
<a href="https://github.com/vitejs/vite" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#github-icon"></use>
</svg>
GitHub
</a>
</li>
<li>
<a href="https://chat.vite.dev/" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#discord-icon"></use>
</svg>
Discord
</a>
</li>
<li>
<a href="https://x.com/vite_js" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#x-icon"></use>
</svg>
X.com
</a>
</li>
<li>
<a href="https://bsky.app/profile/vite.dev" target="_blank">
<svg
className="button-icon"
role="presentation"
aria-hidden="true"
>
<use href="/icons.svg#bluesky-icon"></use>
</svg>
Bluesky
</a>
</li>
</ul>
</div>
</section>
<div className="ticks"></div>
<section id="spacer"></section>
</>
<div className={styles.app}>
{status !== 'open' && <div className={styles.banner}>{STATUS_MESSAGES[status]}</div>}
{screen}
<Toasts toasts={toasts} onDismiss={dismissToast} />
</div>
)
}