Skip to content

Commit 7e8110c

Browse files
authored
Add option to remove team numbers from multiqueue (#67)
* Add option to remove team numbers from multiqueue * linting
1 parent a658154 commit 7e8110c

File tree

7 files changed

+55
-42
lines changed

7 files changed

+55
-42
lines changed

src/Overlay/LowerThird.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ function LowerThird({
9292
!!displayedInfo
9393
&& cgConfig.showLowerThird
9494
&& (
95-
(!!displayedInfo.title && !!displayedInfo.title.match(/\S/))
95+
(!!displayedInfo.title && !!displayedInfo.title.match(/\S/))
9696
|| (!!displayedInfo.subtitle && !!displayedInfo.subtitle.match(/\S/))
97-
)
97+
),
9898
);
9999
}, [
100100
cgConfig?.showLowerThird,

src/components/MultiDisplay/EventRow/MessageRow/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Event } from '@shared/DbTypes';
44
import { Textfit } from '@gmurph91/react-textfit';
55
import styles from './styles.module.scss';
66

7-
const MessageRow = ({ event, showLine }: { event: Event; showLine: 0 | 1 }) => (
7+
const MessageRow = ({ event, showLine }: { event: Event; showLine: 0 | 1 | null }) => (
88
<div
99
className={styles.messageContainer}
1010
style={event.message ? { left: 0 } : {}}
@@ -19,7 +19,7 @@ const MessageRow = ({ event, showLine }: { event: Event; showLine: 0 | 1 }) => (
1919
{/* Logo/Event Name Short Fader */}
2020
<div className={styles.faderContainer}>
2121
{/* Logo */}
22-
<div style={{ opacity: !event.branding?.logo ? 0 : showLine }}>
22+
<div style={{ opacity: showLine !== null && !event.branding?.logo ? 0 : showLine }}>
2323
<img
2424
src={event.branding?.logo}
2525
alt={event.name}
@@ -30,7 +30,7 @@ const MessageRow = ({ event, showLine }: { event: Event; showLine: 0 | 1 }) => (
3030
<span
3131
className={`${styles.textCenter} ${styles.bold}`}
3232
// eslint-disable-next-line no-nested-ternary
33-
style={{ opacity: !event.branding?.logo ? 1 : showLine ? 0 : 1 }}
33+
style={{ opacity: (showLine === null || !event.branding?.logo) ? 1 : showLine ? 0 : 1 }}
3434
>
3535
<Textfit
3636
mode="single"

src/components/MultiDisplay/EventRow/PlayoffRow/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const PlayoffRow = ({
2929
token,
3030
}: {
3131
event: Event;
32-
showLine: 0 | 1;
32+
showLine: 0 | 1 | null;
3333
season: string;
3434
token: string;
3535
}) => {
@@ -114,7 +114,7 @@ const PlayoffRow = ({
114114
// Make a new array of max queuing matches to display
115115
const maxQ = typeof e.options?.maxQueueingToShow === 'number'
116116
? e.options?.maxQueueingToShow
117-
: 3;
117+
: 1;
118118

119119
const toFill = new Array(maxQ).fill(null);
120120
toFill.forEach((_, i) => {
@@ -237,7 +237,7 @@ const PlayoffRow = ({
237237
{getDisplayText(nextMatch)}
238238
</span>
239239
<span className={styles.nextMatchScroll}>
240-
{nextMatch?.match && (
240+
{nextMatch?.match && showLine !== null && (
241241
<AllianceFader
242242
red={getGenericText(nextMatch?.match?.participants?.red)}
243243
blue={getGenericText(nextMatch?.match?.participants?.blue)}
@@ -258,7 +258,7 @@ const PlayoffRow = ({
258258
<span className={styles.bold} style={{ fontSize: !x?.match ? '7vw' : undefined }}>
259259
{getDisplayText(x)}
260260
</span>
261-
{x?.match && (
261+
{x?.match && showLine !== null && (
262262
<AllianceFader
263263
red={getGenericText(x?.match?.participants?.red)}
264264
blue={getGenericText(x?.match?.participants?.blue)}
@@ -277,7 +277,7 @@ const PlayoffRow = ({
277277
{getDisplayText(queueingMatches[0])}
278278
</span>
279279
<span>
280-
{queueingMatches[0]?.match && (
280+
{queueingMatches[0]?.match && showLine !== null && (
281281
<AllianceFader
282282
red={getGenericText(queueingMatches[0]?.match?.participants?.red)}
283283
blue={getGenericText(queueingMatches[0]?.match?.participants?.blue)}

src/components/MultiDisplay/EventRow/QualRow/index.tsx

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const QualRow = ({
2424
token,
2525
}: {
2626
event: Event;
27-
showLine: 0 | 1;
27+
showLine: 0 | 1 | null;
2828
season: string;
2929
token: string;
3030
}) => {
@@ -90,7 +90,7 @@ const QualRow = ({
9090
// Make a new array of max queuing matches to display
9191
const maxQ = typeof e.options?.maxQueueingToShow === 'number'
9292
? e.options?.maxQueueingToShow
93-
: 3;
93+
: 1;
9494
const toFill = new Array(maxQ).fill(null);
9595
toFill.forEach((_, i) => {
9696
toFill[i] = i + 2;
@@ -250,13 +250,15 @@ const QualRow = ({
250250
<span className={styles.matchNumber}>
251251
{(nextMatch as QualMatch)?.number}
252252
</span>
253-
<span className={styles.nextMatchScroll}>
254-
<AllianceFader
255-
red={getRedStr(nextMatch as QualMatch)}
256-
blue={getBlueStr(nextMatch as QualMatch)}
257-
showLine={showLine}
258-
/>
259-
</span>
253+
{showLine !== null ? (
254+
<span className={styles.nextMatchScroll}>
255+
<AllianceFader
256+
red={getRedStr(nextMatch as QualMatch)}
257+
blue={getBlueStr(nextMatch as QualMatch)}
258+
showLine={showLine}
259+
/>
260+
</span>
261+
) : <></>}
260262
</Fragment>
261263
)}
262264

@@ -277,13 +279,15 @@ const QualRow = ({
277279
return (
278280
<div className={styles.flexRow}>
279281
<span className={styles.queueingMatchNumber}>{match.number} -</span>
280-
<div style={{ marginLeft: '16vw', position: 'relative', top: '4vh' }}>
281-
<AllianceFader
282-
red={getRedStr(match)}
283-
blue={getBlueStr(match)}
284-
showLine={showLine}
285-
/>
286-
</div>
282+
{showLine !== null && (
283+
<div style={{ marginLeft: '16vw', position: 'relative', top: '4vh' }}>
284+
<AllianceFader
285+
red={getRedStr(match)}
286+
blue={getBlueStr(match)}
287+
showLine={showLine}
288+
/>
289+
</div>
290+
)}
287291
</div>
288292
);
289293
}
@@ -305,13 +309,15 @@ const QualRow = ({
305309
<span className={styles.matchNumber}>
306310
{(queueingMatches[0] as QualMatch)?.number}
307311
</span>
308-
<span>
309-
<AllianceFader
310-
red={getRedStr(queueingMatches[0] as QualMatch)}
311-
blue={getBlueStr(queueingMatches[0] as QualMatch)}
312-
showLine={showLine}
313-
/>
314-
</span>
312+
{showLine !== null && (
313+
<span>
314+
<AllianceFader
315+
red={getRedStr(queueingMatches[0] as QualMatch)}
316+
blue={getBlueStr(queueingMatches[0] as QualMatch)}
317+
showLine={showLine}
318+
/>
319+
</span>
320+
)}
315321
</Fragment>
316322
)}
317323

src/components/MultiDisplay/EventRow/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const EventRow = ({
1919
}: {
2020
token: string;
2121
season: string;
22-
showLine: 0 | 1;
22+
showLine: 0 | 1 | null;
2323
}) => {
2424
// Ref to the event in the database
2525
const dbEventRef = useRef<DatabaseReference>();

src/components/MultiDisplay/EventRow/sharedStyles.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ $cell-vertical-negative: -3vh;
1818
line-height: 0.8;
1919
}
2020

21+
.noTeamNumbers .matchNumber {
22+
top: 0;
23+
font-size: calc($matchnumber-size * 0.9);
24+
}
25+
2126
.flexRow {
2227
display: flex;
2328
flex-direction: row;

src/components/MultiDisplay/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { h, Fragment } from 'preact';
22
import { useEffect, useState } from 'preact/hooks';
33
import EventRow from './EventRow';
44
import styles from './styles.module.scss';
5+
import sharedStyles from './EventRow/sharedStyles.module.scss';
56

67
const MultiQueueing = () => {
78
const searchParams = new URLSearchParams(window.location.search);
89
const events = searchParams.getAll('e');
910
const season = searchParams.get('s') ?? new Date().getFullYear().toString();
11+
const showTeamNumbers = searchParams.get('teamNumbers') !== 'false';
1012

1113
const calcClock = (): string => {
1214
const now = new Date();
@@ -18,29 +20,29 @@ const MultiQueueing = () => {
1820
return str;
1921
};
2022

21-
const [showLine, setShowLine] = useState<0 | 1>(0);
23+
const [showLine, setShowLine] = useState<0 | 1 | null>(showTeamNumbers ? 0 : null);
2224
const [clock, setClock] = useState<string>(calcClock());
2325

2426
useEffect(() => {
25-
const interval = setInterval(() => {
26-
setShowLine((sl: 0 | 1) => (sl === 0 ? 1 : 0));
27-
}, 5000);
27+
const interval = showTeamNumbers ? setInterval(() => {
28+
setShowLine((sl: 0 | 1 | null) => (sl === 0 ? 1 : 0));
29+
}, 5000) : null;
2830

2931
const clockInterval = setInterval(() => setClock(calcClock()), 10000);
3032
calcClock();
3133

3234
return () => {
33-
clearInterval(interval);
35+
if (interval) clearInterval(interval);
3436
clearInterval(clockInterval);
3537
};
36-
}, []);
38+
}, [showTeamNumbers]);
3739

3840
return (
39-
<div className={styles.container}>
41+
<div className={[styles.container, showLine === null ? sharedStyles.noTeamNumbers : null].filter((c) => c).join(' ')}>
4042
<table>
4143
<thead>
4244
<tr style={{ textAlign: 'center', fontSize: '7vh' }}>
43-
<th style={{ width: '18vw' }}>{clock}</th>
45+
<th style={{ width: '18vw', borderRight: '6px solid white' }}>{clock}</th>
4446
<th style={{ width: '18vw' }}>On Field</th>
4547
<th style={{ width: '32vw' }}>Up Next</th>
4648
<th style={{ width: '38vw' }}>Queueing</th>

0 commit comments

Comments
 (0)