Skip to content

Commit

Permalink
add dots for outs
Browse files Browse the repository at this point in the history
  • Loading branch information
arjanfrans committed Oct 24, 2023
1 parent a4070df commit c37f709
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 17 deletions.
Binary file added .github/mlb_tv.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
homeScore="0"
balls="2"
strikes="1"
outs="2"
outs="1"
awayScore="0"
inning="1.0"
awayGradient="180,#1653af,#063376,30,50"
Expand All @@ -36,6 +36,8 @@
homeLogoShadow="#000000"
activeInningColor="#e00000"
inactiveInningColor="#b3b3b3"
activeOutColor="#e00000"
inactiveOutColor="#b3b3b3"
activeBaseColor="#e5c72b"
inactiveBaseColor="#b3b3b3"
awayName="Away"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 19 additions & 7 deletions src/Counts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { generateGradient } from "./generateGradient.ts";
import { Gradient } from "./Gradient.ts";
import { html } from "lit";
import { OutsText } from "./OutsText.ts";
import { OutsDots } from "./OutsDots.ts";

interface Props {
type Props = {
balls: number;
strikes: number;
outs: number;
layoutGradient: Gradient;
}
export const Counts = ({ balls, strikes, outs, layoutGradient }: Props) => {
outsStyle: string;
activeOutColor: string;
inactiveOutColor: string;
};
export const Counts = ({
balls,
strikes,
outs,
layoutGradient,
outsStyle,
activeOutColor,
inactiveOutColor,
}: Props) => {
const style = `color: state.displaySettings.fontColorDark; background: ${generateGradient(
layoutGradient,
)}`;
Expand All @@ -20,10 +33,9 @@ export const Counts = ({ balls, strikes, outs, layoutGradient }: Props) => {
<span class="count-separator">-</span>
<span>${strikes}</span>
</div>
<div class="counts-bottom" style=${style}>
<span class="outs-count">${outs}</span>
<span class="outs-text">out</span>
</div>
${outsStyle === "text"
? OutsText({ outs, layoutGradient })
: OutsDots({ outs, layoutGradient, activeOutColor, inactiveOutColor })}
</div>
`;
};
38 changes: 38 additions & 0 deletions src/OutsDots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { generateGradient } from "./generateGradient.ts";
import { Gradient } from "./Gradient.ts";
import { html } from "lit";

interface Props {
outs: number;
layoutGradient: Gradient;
activeOutColor: string;
inactiveOutColor: string;
}

export const OutsDots = ({
outs,
layoutGradient,
activeOutColor,
inactiveOutColor,
}: Props) => {
const out1Color =
outs === 1 || outs === 2 ? activeOutColor : inactiveOutColor;
const out2Color = outs === 2 ? activeOutColor : inactiveOutColor;

const style = `color: state.displaySettings.fontColorDark; background: ${generateGradient(
layoutGradient,
)};`;

return html`
<div class="counts-bottom" style=${style}>
<div
class="outs-dot"
style="background-color: ${out1Color}; filter: drop-shadow(0px 0px 1px color-mix(in srgb, ${out1Color} 50%, black));"
></div>
<div
class="outs-dot"
style="background-color: ${out2Color}; filter: drop-shadow(0px 0px 1px color-mix(in srgb, ${out2Color} 50%, black))"
></div>
</div>
`;
};
21 changes: 21 additions & 0 deletions src/OutsText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { generateGradient } from "./generateGradient.ts";
import { Gradient } from "./Gradient.ts";
import { html } from "lit";

interface Props {
outs: number;
layoutGradient: Gradient;
}

export const OutsText = ({ outs, layoutGradient }: Props) => {
const style = `color: state.displaySettings.fontColorDark; background: ${generateGradient(
layoutGradient,
)}`;

return html`
<div class="counts-bottom" style=${style}>
<span class="outs-count">${outs}</span>
<span class="outs-text">out</span>
</div>
`;
};
26 changes: 19 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ export class BaseballScoreboard extends LitElement {
@property()
hideCounts = "false";

@property()
@property({ type: Number })
homeScore = 0;

@property()
@property({ type: Number })
balls = 0;

@property()
@property({ type: Number })
strikes = 0;

@property()
@property({ type: Number })
outs = 0;

@property()
@property({ type: Number })
awayScore = 0;

@property()
@property({ type: Number })
inning = 1.0;

@property()
Expand Down Expand Up @@ -75,6 +75,12 @@ export class BaseballScoreboard extends LitElement {
@property()
inactiveInningColor = "#b3b3b3";

@property()
activeOutColor = "#e00000";

@property()
inactiveOutColor = "#b3b3b3";

@property()
activeBaseColor = "#e00000";

Expand All @@ -90,7 +96,7 @@ export class BaseballScoreboard extends LitElement {
@property()
fontName = "Open Sans";

@property()
@property({ type: Number })
fontLineHeight = 1.15;

@property()
Expand All @@ -103,6 +109,9 @@ export class BaseballScoreboard extends LitElement {
backgroundImage =
"https://www.hardbulls.com/clubdesk/fileservlet?inline=true&type=image&id=253";

@property()
outsStyle = "dots";

private parseGradient(value: string): Gradient {
const awayGradientValues = value.split(",");

Expand Down Expand Up @@ -172,7 +181,10 @@ export class BaseballScoreboard extends LitElement {
balls: this.balls,
strikes: this.strikes,
outs: this.outs,
activeOutColor: this.activeOutColor,
inactiveOutColor: this.inactiveOutColor,
layoutGradient: layoutGradient,
outsStyle: this.outsStyle,
})
: ""
}
Expand Down
7 changes: 7 additions & 0 deletions src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export const Style = css`
perspective: 120px;
}
.outs-dot {
height: 25px;
width: 25px;
border-radius: 50%;
display: inline-block;
}
.base-3d-wrapper {
transform-style: preserve-3d;
transform: rotateX(20deg);
Expand Down

0 comments on commit c37f709

Please sign in to comment.