Skip to content
2 changes: 1 addition & 1 deletion services/app/src/components/chessBoard/Tile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Tile = ({

/* eslint-disable-next-line */
const _onClick = useCallback(() => {
if (!attribute && (row !== 6 && column !== 0)) {
if (!attribute) {
onClick(row, column);
}
}, [onClick, row, column]);
Expand Down
90 changes: 72 additions & 18 deletions services/app/src/components/gameFooter/ChessBoardPiece.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import './chess-board-pieces.css';
import { Avatar, Tooltip } from 'antd';
import { useChessBoardContext } from '../../contexts/ChessBoardContext';
import PlanningChessTooltip from '../planningChessTooltip/PlanningChessTooltip';
import { PieceName } from '../../constants/board';
import { GameState } from '../../constants/gameConstants';
import UserAvatar from '../avatar/UserAvatar';

const ChessBoardPiece = ({ selectFigure, figureName, figureImg, figureStrength, disabled }) => {
const { selectedItem } = useChessBoardContext();
const { selectedItem, turns, gameState } = useChessBoardContext();

const skipTooltipTxt = "Mark my move as complete, without any story points";

Expand All @@ -18,31 +21,82 @@ const ChessBoardPiece = ({ selectFigure, figureName, figureImg, figureStrength,
}

return (
<PlanningChessTooltip
<PlanningChessTooltip
title={figureName === PieceName.SKIP ? skipTooltipTxt : null}
placement="top"
>
<button
type="button"
data-testid={`${figureName}-piece-btn`}
data-testid={`${figureName}-piece-btn`}
onClick={() => onSelect()}
className={classnames('piece-field padding-y-s padding-x-sm f-center rubik-font', {
'piece-field-selected': selectedItem === figureName,
// disabling with class, because antd appends unnecessary spam around the button when its disabled
'disabled': disabled,
})}
className={classnames(
'piece-field padding-y-s padding-x-sm f-center rubik-font',
{
'piece-field-selected':
selectedItem === figureName,
// disabling with class, because antd appends unnecessary spam around the button when its disabled
'disabled': disabled,
},
)}
>
<img
src={figureImg}
alt={figureName}
className='figure-img'
/>
<p className="figure-title font-size-s weight-500">
{figureName}
</p>
<div className="figure-strength-container border-r-20 padding-y-0 padding-x-xxs f-center">
<p className="figure-strength font-size-xxs weight-500">{figureStrength}</p>
<div className="piece-and-score">
<img src={figureImg} alt={figureName} className="figure-img" />
<p className="figure-title font-size-s weight-500">{figureName}</p>
<div className="figure-strength-container border-r-20 padding-y-0 padding-x-xxs f-center">
<p className="figure-strength font-size-xxs weight-500">
{figureStrength}
</p>
</div>
</div>
<Tooltip
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to create separate component for end game avatars?

title={(
<div>
<div>
{
turns.filter((element) => element.figure === figureName)
.length
}{' '}
voted for {figureStrength}
</div>
<div>
{turns
.filter((element) => element.figure === figureName)
.map((item) => item.player)
.join(', ')}
</div>
</div>
)}
placement="top"
>
<div className="figure-info">
{gameState === GameState.GAME_FINISHED && (
<Avatar.Group
maxCount={2}
maxStyle={{
color: 'var(--primary)',
border: '1px solid var(--primary)',
backgroundColor: 'var(--background)',
fontFamily: 'Poppins',
}}
overlayClassName="hide-group-popover"
size={24}
>
{turns
.filter((element) => element.figure === figureName)
.map((item, index) => (
<UserAvatar
size='xs'
playerId={item.playerId}
key={`bubble-${index}`}
playerInitials={item.player[0]}
dataTestId={`square-${item.playerId}`}
bordered
/>
))}
</Avatar.Group>
)}
</div>
</Tooltip>
</button>
</PlanningChessTooltip>
);
Expand Down
18 changes: 16 additions & 2 deletions services/app/src/components/gameFooter/chess-board-pieces.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
display: flex;
justify-content: space-evenly;
user-select: none;
height: auto;
position: relative;
}

.figure-info {
position: absolute;
top: calc(100%);
}

.piece-and-score {
display: flex;
flex-direction: column;
align-content: center;
align-items: center;
height: 85px;
}

.piece-field {
width: clamp(56px, 6vh, 70px);
aspect-ratio: 1 / 2;
flex-direction: column;
border: 2px solid transparent;
cursor: pointer;
Expand Down Expand Up @@ -50,4 +64,4 @@
.figure-strength-container p {
color: var(--white);
letter-spacing: -0.1px;
}
}
2 changes: 1 addition & 1 deletion services/app/src/static/style/spacing.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
.margin-y-0 { margin-top: 0px; margin-bottom: 0px }
.margin-y-xs { margin-top: 4px; margin-bottom: 4px }
.margin-y-s { margin-top: 8px; margin-bottom: 8px }
.margin-y-sm { margin-top: 12px; margin-bottom: 12px }
.margin-y-sm { margin-top: 10px; margin-bottom: 9px }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the values the same. .margin-y-sm { margin-top: 10px; margin-bottom: 10px }

.margin-y-m { margin-top: 16px; margin-bottom: 16px }
.margin-y-l { margin-top: 20px; margin-bottom: 20px }

Expand Down