Create dice view to present all available dice to place in the board
parent
af133bae8b
commit
163ca86734
|
|
@ -1,6 +1,3 @@
|
||||||
@use "node_modules/@picocss/pico/scss/pico" with (
|
@use "node_modules/@picocss/pico/scss/pico" with (
|
||||||
$theme-color: "pumpkin"
|
$theme-color: "pumpkin"
|
||||||
);
|
);
|
||||||
|
|
||||||
@import "./pages/game/GamePage.scss";
|
|
||||||
@import "./pages/game/components/GameBoard.scss";
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { io } from "socket.io-client";
|
import { io } from "socket.io-client";
|
||||||
import GamePage from "./pages/game/GamePage";
|
import GamePage from "./pages/game/GamePage";
|
||||||
|
import "./App.scss";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const socket = io("http://localhost:3010");
|
const socket = io("http://localhost:3010");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import "./App.scss";
|
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(
|
const root = ReactDOM.createRoot(
|
||||||
document.getElementById("root") as HTMLElement,
|
document.getElementById("root") as HTMLElement,
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,14 @@ h1 {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.game-panel {
|
||||||
|
user-select: none; /* Standard syntax */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
.right-panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import GameBoard from "./components/GameBoard";
|
import GameBoard from "./components/GameBoard";
|
||||||
|
import DiceSet from "./components/DiceSet";
|
||||||
|
import "./GamePage.scss";
|
||||||
|
|
||||||
const GamePage = () => {
|
const GamePage = () => {
|
||||||
return (
|
return (
|
||||||
|
|
@ -7,6 +9,9 @@ const GamePage = () => {
|
||||||
<h1>Game Page Title</h1>
|
<h1>Game Page Title</h1>
|
||||||
<div className="game-panel">
|
<div className="game-panel">
|
||||||
<GameBoard />
|
<GameBoard />
|
||||||
|
<div className="rigth-panel">
|
||||||
|
<DiceSet />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
.dice-set {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, auto);
|
||||||
|
gap: 20px;
|
||||||
|
padding: 50px;
|
||||||
|
|
||||||
|
.dice {
|
||||||
|
height: 150px;
|
||||||
|
width: 150px;
|
||||||
|
border: 2px solid black;
|
||||||
|
border-radius: 10%;
|
||||||
|
|
||||||
|
img{
|
||||||
|
border-radius: 10%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import "./DiceSet.scss";
|
||||||
|
|
||||||
|
const DiceSet = () => {
|
||||||
|
const diceImages = [1, 2, 3, 4]
|
||||||
|
.map(() => Math.floor(Math.random() * 22 + 1))
|
||||||
|
.map((index) => ("0" + index).slice(-2))
|
||||||
|
.map((index) => `${process.env.PUBLIC_URL}/pieces/P${index}.jpeg`);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="dice-set">
|
||||||
|
{diceImages.map((file) => (
|
||||||
|
<div className="dice">
|
||||||
|
<img src={file}></img>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DiceSet;
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
.game-board {
|
.game-board {
|
||||||
height: 850px;
|
height: 850px;
|
||||||
width: 850px;
|
width: 850px;
|
||||||
|
min-height: 850px;
|
||||||
|
min-width: 850px;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, auto);
|
grid-template-columns: repeat(7, auto);
|
||||||
gap: auto;
|
gap: auto;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { buildBoard, Cell, directions, Exit } from "interface";
|
import { buildBoard, Cell, directions, Exit } from "interface";
|
||||||
|
import "./GameBoard.scss";
|
||||||
|
|
||||||
const GameBoard = () => {
|
const GameBoard = () => {
|
||||||
const board: Cell[][] = buildBoard();
|
const board: Cell[][] = buildBoard();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue