Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add box shadow to MAXIMUM BLASEBALL update rows #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions reblase/src/components/game/UpdateRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ interface UpdateRowProps extends WrappedUpdateProps {
highlight: boolean;
}

function isMaximumBlaseball(evt: BlaseballGame): boolean {
const outs = evt.halfInningOuts;
const outsNeeded = (evt.topOfInning ? evt.awayOuts : evt.homeOuts) ?? 3;
const balls = evt.atBatBalls;
const ballsNeeded = (evt.topOfInning ? evt.awayBalls : evt.homeBalls) ?? 4;
const strikes = evt.atBatStrikes;
const strikesNeeded = (evt.topOfInning ? evt.awayStrikes : evt.homeStrikes) ?? 3;
const bases = (evt.topOfInning ? evt.awayBases : evt.homeBases) ?? 4;
const basesLoaded = Array.from({ length: bases - 1 }).every((_, i) => evt.basesOccupied.includes(i));

return basesLoaded &&
ballsNeeded - 1 === balls &&
outsNeeded - 1 === outs &&
strikesNeeded - 1 === strikes;
}

export const UpdateRow = React.memo(
function UpdateRow({ update, highlight }: UpdateRowProps) {
const evt = update.data;
Expand All @@ -114,8 +130,9 @@ export const UpdateRow = React.memo(
<div
ref={highlight ? scrollRef : undefined}
className={
"grid grid-flow-row-dense gap-2 items-center px-2 py-2 border-b border-gray-300 dark:border-gray-700" +
(highlight ? " bg-yellow-200 dark:bg-gray-900" : "")
"grid grid-flow-row-dense gap-2 items-center px-2 py-2 border-gray-300 dark:border-gray-700" +
(highlight ? " bg-yellow-200 dark:bg-gray-900" : "") +
(isMaximumBlaseball(evt) ? " maximum-blaseball" : " border-b")
}
style={{ gridTemplateColumns: "auto auto 1fr" }}
>
Expand Down
5 changes: 5 additions & 0 deletions reblase/src/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
margin: 0 .05em 0 .1em;
vertical-align: -0.15em;
}

.maximum-blaseball {
@apply rounded;
box-shadow: 0 0 8px 2px var(--theme-black);
}
}

@layer components {
Expand Down