light styling

This commit is contained in:
Mikayla Dobson
2022-07-21 15:20:50 -05:00
parent cfae1ddfbb
commit 21bf7a2eb0
11 changed files with 104 additions and 10 deletions

View File

@@ -12,12 +12,12 @@ export default function Card({ data }: CardProps) {
<p>Counts as: {data.gemValue}</p> <p>Counts as: {data.gemValue}</p>
<p>Point value: {data.points || 0}</p> <p>Point value: {data.points || 0}</p>
<p>Cost:</p> <p>Cost:</p>
{ Object.keys(data.resourceCost).map((key, value) => { {
return ( Object.keys(data.resourceCost).map((key, value) => {
// @ts-ignore // @ts-ignore
<p key={v4()}>{key}: {data.resourceCost[key]}</p> return (data.resourceCost[key] > 0) && <p key={v4()}>{key}: {data.resourceCost[key]}</p>
) })
}) } }
</div> </div>
</div> </div>
) )

View File

View File

@@ -2,8 +2,11 @@ import { useContext, useEffect, useState } from 'react';
import { Context } from '../../context/Context'; import { Context } from '../../context/Context';
import GameConstructor from '../../util/GameConstructor'; import GameConstructor from '../../util/GameConstructor';
import { NobleData } from '../../util/types'; import { NobleData } from '../../util/types';
import AllPlayers from '../Player/AllPlayers';
import AvailableChips from '../Resources/AvailableChips'; import AvailableChips from '../Resources/AvailableChips';
import CardRow from './CardRow'; import CardRow from './CardRow';
import Nobles from './Nobles';
import NobleStore from '../../data/nobles.json';
export default function Gameboard() { export default function Gameboard() {
let AppContext = useContext(Context); let AppContext = useContext(Context);
@@ -16,14 +19,21 @@ export default function Gameboard() {
useEffect(() => { useEffect(() => {
if (!players.length) { if (!players.length) {
setView(<GameConstructor />); setView(
<div className="error-page">
<h1>Sorry! It appears we've lost track of your game data.</h1>
<p>Please head back to the <a href="/">home page</a> to start a fresh game.</p>
</div>
);
} else { } else {
setView( setView(
<div className="gameboard-rows"> <div className="gameboard-rows">
<Nobles />
<CardRow tier={3} cards={gameboard.cardRows.tierThree} /> <CardRow tier={3} cards={gameboard.cardRows.tierThree} />
<CardRow tier={2} cards={gameboard.cardRows.tierTwo} /> <CardRow tier={2} cards={gameboard.cardRows.tierTwo} />
<CardRow tier={1} cards={gameboard.cardRows.tierOne} /> <CardRow tier={1} cards={gameboard.cardRows.tierOne} />
<AvailableChips /> <AvailableChips />
<AllPlayers />
</div> </div>
) )
} }
@@ -47,7 +57,7 @@ export default function Gameboard() {
} }
const setNobles = () => { const setNobles = () => {
let newNobles = gameboard.nobles; let newNobles = NobleStore.nobles;
let shuffledNobles = new Array<NobleData>; let shuffledNobles = new Array<NobleData>;
while (shuffledNobles.length < 4) { while (shuffledNobles.length < 4) {
@@ -56,6 +66,9 @@ export default function Gameboard() {
shuffledNobles.push(randNoble); shuffledNobles.push(randNoble);
} }
console.log(newNobles);
console.log(shuffledNobles);
// setState({ ...gameboard, nobles: shuffledNobles }); // setState({ ...gameboard, nobles: shuffledNobles });
gameboard.nobles = shuffledNobles; gameboard.nobles = shuffledNobles;
} }

View File

@@ -0,0 +1,18 @@
.nobles-panel {
display: flex;
flex-flow: column nowrap;
background-color: rgb(240, 236, 225);
padding: 1.5rem;
color: black;
}
.all-nobles {
display: flex;
flex-flow: row nowrap;
justify-content: space-around;
}
.noble-card {
display: inline-flex;
flex-flow: column nowrap;
}

View File

@@ -0,0 +1,36 @@
import { useContext, useEffect } from "react";
import { v4 } from "uuid";
import { Context } from "../../context/Context";
import "./Nobles.css"
export default function Nobles() {
const { gameboard } = useContext(Context);
useEffect(() => {
console.log(gameboard);
}, [gameboard])
return (
<div className="nobles-panel">
<strong>NOBLES</strong>
<div className="all-nobles">
{
gameboard.nobles.map((noble) => {
return (
<div className="noble-card" key={v4()}>
<p>Points: {noble.points}</p>
<p>Cost:</p>
{
Object.keys(noble.resourceCost).map((each) => {
// @ts-ignore
return (noble.resourceCost[each] > 0) && <p>{each}: {noble.resourceCost[each]}</p>
})
}
</div>
)
}) || <p>Nobles not found. Please wait...</p>
}
</div>
</div>
)
}

View File

@@ -0,0 +1,9 @@
.all-players {
display: flex;
background-color: rgb(237, 213, 156);
color: black;
}
.all-players p {
margin: 1rem;
}

View File

@@ -1,11 +1,16 @@
import { useContext } from "react" import { useContext } from "react"
import { Context } from "../../context/Context" import { Context } from "../../context/Context"
import Player from "./Player";
import "./AllPlayers.css"
export default function AllPlayers() { export default function AllPlayers() {
const AppContext = useContext(Context); const { players } = useContext(Context);
return ( return (
<> <div className="all-players">
</> {
players.map((player) => <Player data={player} />)
}
</div>
) )
} }

View File

View File

@@ -39,6 +39,8 @@ export default function Player({ data }: PlayerProps) {
<div className="player-ui"> <div className="player-ui">
<p>Name: {data.name}</p> <p>Name: {data.name}</p>
<p>Score: {data.points}</p> <p>Score: {data.points}</p>
<div className="player-cards"></div>
<div className="player-resources"></div>
</div> </div>
) )
} }

View File

@@ -0,0 +1,10 @@
.available-chips {
display: flex;
flex-flow: row nowrap;
background-color: rgb(236, 238, 186);
color: black;
}
.available-chips p {
margin: 1rem;
}

View File

@@ -1,6 +1,7 @@
import { useContext } from "react" import { useContext } from "react"
import { Context } from "../../context/Context" import { Context } from "../../context/Context"
import { v4 } from "uuid"; import { v4 } from "uuid";
import "./AvailableChips.css"
export default function AvailableChips() { export default function AvailableChips() {
const { gameboard } = useContext(Context); const { gameboard } = useContext(Context);