Skip to content

Commit

Permalink
Add icons to player list
Browse files Browse the repository at this point in the history
  • Loading branch information
samanthathompson52 committed Dec 13, 2023
1 parent 2570a03 commit 477d0d8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
5 changes: 0 additions & 5 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ html, body {
background-color: var(--orange);
}

.name-plate {
border-radius: 0rem 1.25rem 1.25rem 0rem;
background: #FFF;
}

@media only screen and (max-width: 640px) {
h1 {
font-size: 2.2rem;
Expand Down
12 changes: 8 additions & 4 deletions client/src/components/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ const Game = ({sendJsonMessage, lastMessageJson}: {sendJsonMessage: any, lastMes
<div className='bg-light-purple pb-4 pr-4'>
<h3 className='p-4'>Players</h3>
{players.map((player:Player) => (
<h4 key={player.id}>
<div className="bg-white rounded-r-lg mt-2 p-1">{player.name} : {player.points}</div>
<PlayerIcon iconName={player.icon}/>
</h4>
<div className="flex bg-white rounded-r-lg mt-2 p-1 h-12 justify-between items-center">
<h4 key={player.id}>
{player.name} : {player.points}
</h4>
<div className="test">
<PlayerIcon iconName={player.icon} customClass="h-12"/>
</div>
</div>
))}
</div>
<div className='col-span-3'>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Lobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ function Lobby({sendJsonMessage, isHost, remainingIcons}: {sendJsonMessage: any,
{Object.keys(iconMap).map((iconName: string, idx:number) => {
if (remainingIcons.includes(iconName)) {
return (
<div key={iconName+idx} className='hover:scale-110 duration-500' onClick={() => selectIcon(iconName)}>
<div key={iconName+idx} className='hover:scale-110 duration-500 p-2 md:p-4' onClick={() => selectIcon(iconName)}>
<PlayerIcon iconName={iconName}/>
</div>
)
} else {
return (
<div key={iconName+idx} className='filter grayscale'>
<div key={iconName+idx} className='filter grayscale p-2 md:p-4'>
<PlayerIcon iconName={iconName}/>
</div>
)}
Expand Down
6 changes: 2 additions & 4 deletions client/src/components/PlayerIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ export const iconMap:any = {
cow: "cow.svg"
}

const PlayerIcon = ({iconName}: {iconName: string}) => {
const PlayerIcon = ({iconName, customClass}: {iconName: string, customClass?: string}) => {
if (!iconMap[iconName]) {
return <></>
}

const icon = iconMap[iconName];

return (
<div className="p-2 lg:p-4">
<img src={`./icons/${icon}`} alt={iconName}/>
</div>
<img src={`./icons/${icon}`} alt={iconName} className={customClass}/>
)
}

Expand Down

0 comments on commit 477d0d8

Please sign in to comment.