Merge pull request #7 from jhalitaksoy/feature/store-stone-count-label

add stone count label to store view
This commit is contained in:
Halit Aksoy 2022-05-24 22:26:47 +03:00 committed by GitHub
commit 47b39a268b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,10 +59,11 @@ const HoleView: FunctionComponent<{
};
const StoreView: FunctionComponent<{
context: Context;
pitViewModel: PitViewModel;
gridColumn: string;
gridRow: string;
}> = ({ pitViewModel, gridColumn, gridRow }) => {
}> = ({ context, pitViewModel, gridColumn, gridRow }) => {
const balls = [...range(pitViewModel.stoneCount)].map((i) => (
<BallView color={pitViewModel.stoneColor} />
));
@ -79,9 +80,22 @@ const StoreView: FunctionComponent<{
justifyContent: "center",
alignContent: "center",
flexWrap: "wrap",
position: "relative",
}}
>
{balls}
<span
style={{
position: "absolute",
bottom: "2vw",
fontFamily: "monospace",
fontWeight: "bold",
fontSize: "2vw",
color: context.themeManager.theme.ballColor,
}}
>
{balls.length}
</span>
</div>
);
};
@ -119,6 +133,7 @@ const BoardView: FunctionComponent<{
boardViewModel.pits[game.board.player2BankIndex()];
const player1Bank = (
<StoreView
context={context}
pitViewModel={player1BankViewModel}
gridColumn="1 / 2"
gridRow="1 / 3"
@ -126,6 +141,7 @@ const BoardView: FunctionComponent<{
);
const player2Bank = (
<StoreView
context={context}
pitViewModel={player2BankViewModel}
gridColumn="8 / 9"
gridRow="1 / 3"
@ -149,11 +165,13 @@ const BoardView: FunctionComponent<{
{userKey === game.player2Id ? (
<>
<StoreView
context={context}
pitViewModel={player1BankViewModel}
gridColumn="1 / 2"
gridRow="1 / 3"
/>
<StoreView
context={context}
pitViewModel={player2BankViewModel}
gridColumn="8 / 9"
gridRow="1 / 3"
@ -164,11 +182,13 @@ const BoardView: FunctionComponent<{
) : (
<>
<StoreView
context={context}
pitViewModel={player1BankViewModel}
gridColumn="8 / 9"
gridRow="1 / 3"
/>
<StoreView
context={context}
pitViewModel={player2BankViewModel}
gridColumn="1 / 2"
gridRow="1 / 3"