2022-07-14 08:53:26 +03:00
|
|
|
import * as React from "react";
|
|
|
|
|
import { FunctionComponent } from "react";
|
2022-07-14 13:38:00 +03:00
|
|
|
import { Context } from "../../context/context";
|
2022-07-14 08:53:26 +03:00
|
|
|
import { getColorByBrightness } from "../../util/ColorUtil";
|
|
|
|
|
import Util from "../../util/Util";
|
|
|
|
|
import PitViewModel from "../../viewmodel/PitViewModel";
|
|
|
|
|
import StoneView from "./StoneView";
|
|
|
|
|
|
|
|
|
|
const StoreView: FunctionComponent<{
|
2022-07-14 23:28:58 +03:00
|
|
|
context: Context;
|
|
|
|
|
pitViewModel: PitViewModel;
|
|
|
|
|
gridColumn: string;
|
|
|
|
|
gridRow: string;
|
|
|
|
|
}> = ({ context, pitViewModel, gridColumn, gridRow }) => {
|
|
|
|
|
const stones = [...Util.range(pitViewModel.stoneCount)].map((i, index) => (
|
|
|
|
|
<StoneView key={index} color={pitViewModel.stoneColor} />
|
|
|
|
|
));
|
|
|
|
|
const textColor = getColorByBrightness(
|
|
|
|
|
pitViewModel.pitColor,
|
|
|
|
|
context.themeManager.theme.textColor,
|
|
|
|
|
context.themeManager.theme.textLightColor
|
|
|
|
|
);
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className="store"
|
|
|
|
|
style={{
|
|
|
|
|
background: pitViewModel.pitColor,
|
|
|
|
|
gridColumn: gridColumn,
|
|
|
|
|
gridRow: gridRow
|
|
|
|
|
}}>
|
|
|
|
|
{stones}
|
|
|
|
|
<span className="store-stone-count-text" style={{ color: textColor }}>
|
|
|
|
|
{stones.length}
|
|
|
|
|
</span>
|
|
|
|
|
<style jsx>{`
|
|
|
|
|
.store {
|
|
|
|
|
margin: 5px;
|
|
|
|
|
border-radius: 10vw;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-content: center;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
.store-stone-count-text {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 2vw;
|
|
|
|
|
font-family: monospace;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
font-size: 2vw;
|
|
|
|
|
}
|
|
|
|
|
`}</style>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
2022-07-14 08:53:26 +03:00
|
|
|
|
2022-07-14 23:28:58 +03:00
|
|
|
export default StoreView;
|