front: PlayerComponent

- color
- name

TBD:
- setName
- nameList
This commit is contained in:
djmil 2023-10-26 13:46:09 +02:00
parent 4421ca5445
commit a658827cb3
5 changed files with 27 additions and 7 deletions

View File

@ -9,6 +9,8 @@
.selectable i { .selectable i {
font-size: 70%; font-size: 70%;
margin-left: 5px;
margin-right: 5px;
} }
/* .Games .li button.action { /* .Games .li button.action {

View File

@ -1,16 +1,21 @@
import './Selectable.css' import './Selectable.css'
import React from 'react'; import React from 'react';
import { Stone, oppositeColor } from '../Stone'; import { oppositeColor } from '../Stone';
import Player from '../Player';
export default function Selectable({game}) { export default function Selectable({game}) {
const myColor = game.myColor
const opponentColor = oppositeColor(myColor)
const opponentName = game.opponentName
return ( return (
<div className='selectable' key={game.uuid}> <div className='selectable' key={game.uuid}>
<div className='tiltle'> <div className='tiltle'>
{Stone(game.myColor)} <Player color={myColor}/>
<i>vs</i> <i>vs</i>
{Stone(oppositeColor(game.myColor))} <Player color={opponentColor} name={opponentName}/>
{game.opponentName}
</div> </div>
<q>{game.message}</q> <q>{game.message}</q>
</div> </div>

View File

View File

@ -0,0 +1,13 @@
import './Player.css'
import React from 'react'
import { Stone } from './Stone'
export default function Player({ color, name }) {
return (
<span className='player'>
<Stone color={color} />
{name}
</span>
)
}

View File

@ -1,7 +1,7 @@
import './Stone.css'; import './Stone.css'
import React from 'react'; import React from 'react'
export function Stone( color ) { export function Stone({ color }) {
switch (color) { switch (color) {
case WHITE(): case WHITE():
return WhiteStone() return WhiteStone()