chs/src-web/index.tsx

24 lines
643 B
TypeScript
Raw Normal View History

2022-10-31 13:25:32 +00:00
/* @refresh reload */
import { render } from 'solid-js/web';
import 'solid-devtools';
import App from './App';
import './main.css';
import '@fontsource/ubuntu';
2022-10-31 13:25:32 +00:00
import "@fontsource/noto-sans-symbols-2";
import { v4 as uuidv4 } from 'uuid';
import Button from './components/Button';
2022-10-31 13:25:32 +00:00
const search = new URLSearchParams(window.location.search);
const root = document.getElementById('root')!;
function newGame() {
window.location.search = '?game_id=' + uuidv4();
}
2022-10-31 13:25:32 +00:00
if (search.has('game_id')) {
render(() => <App gameId={search.get('game_id')!} />, root);
2022-10-31 13:25:32 +00:00
} else {
render(() => <Button onClick={newGame}>New game</Button>, root);
2022-10-31 13:25:32 +00:00
}