From c4c00449855607db02a70a913ca3bd9fa9a5cb96 Mon Sep 17 00:00:00 2001 From: jhalitaksoy Date: Wed, 30 Jun 2021 16:11:22 +0300 Subject: [PATCH] changed theme --- src/Home.tsx | 27 +++++++++++++---- src/components/BoardView.tsx | 58 +++++++++++++++++++++++------------- src/index.html | 19 ++++++++++-- 3 files changed, 76 insertions(+), 28 deletions(-) diff --git a/src/Home.tsx b/src/Home.tsx index 07b0263..73c642f 100644 --- a/src/Home.tsx +++ b/src/Home.tsx @@ -76,13 +76,30 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => { return
-

Mancala

+
+

Mancala

+ {game && } +
{!game && } - {game && } - {game && } - {game &&
{game.checkGameTurn(userKey) ? "Your Turn" : "Opponent Turn"}
} + + {game && ( + <> +

{game.checkGameTurn(userKey) ? "Your Turn" : "Opponent Turn"}

+ + + )}
} diff --git a/src/components/BoardView.tsx b/src/components/BoardView.tsx index b7addf3..1f2abf4 100644 --- a/src/components/BoardView.tsx +++ b/src/components/BoardView.tsx @@ -2,14 +2,30 @@ import * as React from 'react'; import { FunctionComponent, useState } from 'react'; import { Hole, Store, Game } from '../mancala'; -const BallView: FunctionComponent = () => { +type Theme = { + background : string, + boardColor: string + storeColor: string + holeColor: string + ballColor: string +} + +const theme: Theme = { + background : "#EEEEEE", + boardColor: "#4D606E", + storeColor: "#3FBAC2", + holeColor: "#D3D4D8", + ballColor: "#393E46", +} + +const BallView: FunctionComponent<{color : string}> = ({color}) => { return (
) } @@ -23,7 +39,7 @@ function range(size: number) { } const HoleView: FunctionComponent<{ hole: Hole, color: string, onClick: () => void }> = ({ hole, color, onClick }) => { - const balls = [...range(hole.ballCount)].map((i) => ) + const balls = [...range(hole.ballCount)].map((i) => ) return (
vo background: color, margin: "5px", padding: "5px", - borderRadius: "100px", + borderRadius: "10vw", display: 'flex', alignItems: 'center', alignContent: 'center', @@ -45,17 +61,17 @@ const HoleView: FunctionComponent<{ hole: Hole, color: string, onClick: () => vo const StoreView: FunctionComponent< { store: Store, color: string, gridColumn: string, gridRow: string }> = ({ store, color, gridColumn, gridRow }) => { - const balls = [...range(store.ballCount)].map((i) => ) + const balls = [...range(store.ballCount)].map((i) => ) return (
{balls} @@ -66,13 +82,13 @@ const BoardView: FunctionComponent<{ game?: Game, userKey: string, onHoleSelect: game, userKey, onHoleSelect }) => { const player1Holes = game?.board.player1Holes.map((hole) => ( - { + { if (game.turn == "player1") onHoleSelect(game.board.player1Holes.indexOf(hole), hole) }} /> )) const player2Holes = game!!.board.player2Holes.map((hole) => ( - { + { if (game.turn == "player2") onHoleSelect(game.board.player2Holes.indexOf(hole), hole) }} /> )) @@ -82,23 +98,23 @@ const BoardView: FunctionComponent<{ game?: Game, userKey: string, onHoleSelect: margin: '10px', padding: '10px', display: 'grid', - gridTemplateColumns: 'repeat(8, 150px)', - gridTemplateRows: '150px 150px', - border: "2px solid black", - borderRadius: "30px", + gridTemplateColumns: 'repeat(8, 11vw)', + gridTemplateRows: 'repeat(2, 11vw)', + borderRadius: "3vw", + background: theme.boardColor }}> { game.getPlayerNameByKey(userKey) == "player2" ? ( <> - - + + {player1Holes.reverse()} {player2Holes} ) : ( <> - - + + {player2Holes.reverse()} {player1Holes} diff --git a/src/index.html b/src/index.html index 2618db2..cf30955 100644 --- a/src/index.html +++ b/src/index.html @@ -6,8 +6,23 @@ Mancala - -
+ +
+ + + \ No newline at end of file