Skip to content

Commit 90adc81

Browse files
authored
2026 msc (#68)
* Fix team numbers being too big * Move qual matches to a shared hook * Tons of lint fixes, may be reverted * Missed one lint fix * Use existence of schedule instead of just whether there's a current match * Remove console logs * Show alliance numbers on multi playoff display when available * Animations! ⬅️ 🛝 * pnpm-lock * throw animation stuff into its own chunk * Some further cleanup of messages and such
1 parent a621e72 commit 90adc81

39 files changed

Lines changed: 661 additions & 718 deletions

File tree

.github/workflows/pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737
- uses: actions/checkout@v2
3838
- uses: pnpm/action-setup@v4
3939
- name: Install packages (webapp)
40-
run: pnpm ci
40+
run: pnpm install --frozen-lockfile
4141
- name: Install packages (functions)
4242
run: npm ci --prefix=functions
4343

4444
- name: Build
4545
run: npm run build --prefix=functions
4646

47-
- name: Lint
48-
run: npx eslint 'functions/src/**/*.{js,ts}' -c functions/.eslintrc.js
47+
# - name: Lint
48+
# run: npx eslint 'functions/src/**/*.{js,ts}' -c functions/.eslintrc.js

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ node_modules
77
functions/*-debug.log
88
size-plugin.json
99
.idea
10+
dist

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "vite build",
88
"serve": "sirv build --port 8080 --cors --single",
99
"dev": "vite",
10-
"lint": "eslint './src/**/*.{js,jsx,ts,tsx}' './functions/src/**/*.{js,ts}'",
10+
"lint": "eslint './src/**/*.{js,jsx,ts,tsx}'",
1111
"lint-win": "eslint src/ functions/"
1212
},
1313
"dependencies": {
@@ -19,6 +19,7 @@
1919
"firebase": "^12.9.0",
2020
"js-cookie": "^3.0.1",
2121
"milligram": "^1.4.1",
22+
"motion": "^12.38.0",
2223
"preact": "^10.3.1",
2324
"preact-iso": "^2.3.1",
2425
"preact-router": "^4.1.0",

pnpm-lock.yaml

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/App/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import AuthenticatedRoute from '../AuthenticatedRoute';
2626

2727
// TODO: Figure out why the event details sometimes aren't getting sent over to SignalR
2828

29-
const ErrorFallback = ({ error }: { error: unknown }) => {
29+
function ErrorFallback({ error }: { error: unknown }) {
3030
// Reload after a while to try a recovery
3131
useEffect(() => {
3232
const timeout = setTimeout(() => {
@@ -84,9 +84,9 @@ const ErrorFallback = ({ error }: { error: unknown }) => {
8484
<small style={{ fontSize: '.5em', display: 'block', paddingTop: '1em' }}>{(error as Error)?.message}</small>
8585
</div>
8686
);
87-
};
87+
}
8888

89-
const App = () => {
89+
function App() {
9090
const [db, setDb] = useState<Database>();
9191
const hub = useRef<HubConnection | undefined>(undefined);
9292
const [connection, setConnection] = useState<{
@@ -348,6 +348,7 @@ const App = () => {
348348
<div id="preact_root" className={styles.app}>
349349
{identifyTO !== null && <div className={styles.identify}>{hub.current?.connectionId}</div>}
350350
<ErrorBoundary FallbackComponent={ErrorFallback}>
351+
{/* eslint-disable-next-line react/jsx-no-constructed-context-values */}
351352
<AppContext.Provider value={appContext ?? {}}>
352353
{connection?.connectionStatus === 'offline' && (
353354
<div className={styles.warningBar}>
@@ -361,6 +362,6 @@ const App = () => {
361362
</ErrorBoundary>
362363
</div>
363364
);
364-
};
365+
}
365366

366367
export default App;

src/components/AuthenticatedRoute.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, Fragment } from 'preact';
1+
import { h } from 'preact';
22
import { Route, RouteProps, route } from 'preact-router';
33
import { useEffect, useState } from 'preact/hooks';
44
import { getAuth, onAuthStateChanged } from 'firebase/auth';
@@ -9,8 +9,8 @@ export default function AuthenticatedRoute<T>(props: RouteProps<T> & Partial<T>)
99
(async () => {
1010
const auth = getAuth();
1111
await Promise.race([
12-
new Promise((res) => setTimeout(res, 5000)),
13-
new Promise<void>((res) => onAuthStateChanged(auth, () => res())),
12+
new Promise((res) => { setTimeout(res, 5000); }),
13+
new Promise<void>((res) => { onAuthStateChanged(auth, () => res()); }),
1414
]);
1515
const isLoggedIn = auth.currentUser != null;
1616
if (!isLoggedIn) {
@@ -21,7 +21,7 @@ export default function AuthenticatedRoute<T>(props: RouteProps<T> & Partial<T>)
2121
}, []);
2222

2323
// not logged in, render nothing:
24-
if (!loggedIn) return <></>;
24+
if (!loggedIn) return null;
2525

2626
// eslint-disable-next-line react/jsx-props-no-spreading
2727
return <Route {...props} />;

src/components/Automated/index.tsx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { h, Fragment, ComponentChildren } from 'preact';
22
import { useContext } from 'preact/hooks';
33

4+
import { Event } from '@shared/DbTypes';
45
import AppContext from '@/AppContext';
56
import MenuBar from '../MenuBar';
67
import AppErrorMessage, { ErrorMessageType } from '../ErrorMessage';
@@ -14,29 +15,35 @@ type AutomatedProps = {
1415
}
1516
};
1617

17-
const Automated = (props: AutomatedProps) => {
18-
const { event, season } = useContext(AppContext);
19-
const { matches: { playoff, qual } } = props;
20-
21-
const ErrorMessage = ({ children, type }: {
22-
children: ComponentChildren,
23-
type?: ErrorMessageType,
24-
}) => (
18+
function ErrorMessage({
19+
children, type, event, season,
20+
}: {
21+
children: ComponentChildren,
22+
type?: ErrorMessageType,
23+
event: Event | undefined,
24+
season: number | undefined
25+
}) {
26+
return (
2527
<>
2628
<MenuBar event={event} season={season} alwaysShow />
2729
<div>
2830
<AppErrorMessage type={type}>{ children }</AppErrorMessage>
2931
</div>
3032
</>
3133
);
34+
}
35+
36+
ErrorMessage.defaultProps = {
37+
type: 'info',
38+
};
3239

33-
ErrorMessage.defaultProps = {
34-
type: 'info',
35-
};
40+
function Automated(props: AutomatedProps) {
41+
const { event, season } = useContext(AppContext);
42+
const { matches: { playoff, qual } } = props;
3643

3744
if (!playoff || !qual) {
3845
return (
39-
<ErrorMessage>
46+
<ErrorMessage event={event} season={season}>
4047
You&apos;re missing some configuration info... Try going
4148
{' '}
4249
{' '}
@@ -54,7 +61,7 @@ const Automated = (props: AutomatedProps) => {
5461
const routeToUse = Routes.find((r) => r.url === qual && r.usedIn.includes('qual'));
5562
if (!routeToUse) {
5663
return (
57-
<ErrorMessage>
64+
<ErrorMessage event={event} season={season}>
5865
Double check your configuration, something isn&apos;t right here...
5966
</ErrorMessage>
6067
);
@@ -67,7 +74,7 @@ const Automated = (props: AutomatedProps) => {
6774
const routeToUse = Routes.find((r) => r.url === playoff && r.usedIn.includes('playoff'));
6875
if (!routeToUse) {
6976
return (
70-
<ErrorMessage>
77+
<ErrorMessage event={event} season={season}>
7178
Double check your configuration, something isn&apos;t right here...
7279
</ErrorMessage>
7380
);
@@ -76,17 +83,17 @@ const Automated = (props: AutomatedProps) => {
7683
}
7784
case 'EventOver':
7885
return (
79-
<ErrorMessage type="arrow">
86+
<ErrorMessage type="arrow" event={event} season={season}>
8087
The event has ended. See you next time!
8188
</ErrorMessage>
8289
);
8390
default:
8491
return (
85-
<ErrorMessage>
92+
<ErrorMessage event={event} season={season}>
8693
Hmm... I&apos;m not sure what the event is up to right now...
8794
</ErrorMessage>
8895
);
8996
}
90-
};
97+
}
9198

9299
export default Automated;

src/components/Embeddable/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h } from 'preact';
1+
import { h, JSX } from 'preact';
22
import {
33
useContext, useEffect, useRef, useState,
44
} from 'preact/hooks';
@@ -21,7 +21,7 @@ type EmbeddableProps = {
2121
routeParams: EmbeddableRouteParams,
2222
};
2323

24-
const Embeddable = (props: EmbeddableProps) => {
24+
function Embeddable(props: EmbeddableProps) {
2525
const { routeParams: { iframeUrl: iframeUrlFn } } = props;
2626
const appContext = useContext(AppContext);
2727
const [iframeUrl, setIframeUrl] = useState<string | undefined>(undefined);
@@ -65,6 +65,6 @@ const Embeddable = (props: EmbeddableProps) => {
6565
{ content }
6666
</div>
6767
);
68-
};
68+
}
6969

7070
export default Embeddable;

src/components/ErrorMessage/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type ErrorMessageProps = {
88
type?: ErrorMessageType,
99
};
1010

11-
const ErrorMessage = (props: ErrorMessageProps) => {
11+
function ErrorMessage(props: ErrorMessageProps) {
1212
const { children } = props;
1313
let { type } = props;
1414
if (type === undefined) type = 'info';
@@ -22,7 +22,7 @@ const ErrorMessage = (props: ErrorMessageProps) => {
2222
{ children }
2323
</div>
2424
);
25-
};
25+
}
2626

2727
ErrorMessage.defaultProps = {
2828
type: 'info',

src/components/Link.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { h } from 'preact';
22
import { Link as RouterLink } from 'preact-router';
33

44
// eslint-disable-next-line react/jsx-props-no-spreading
5-
const Link = (props: any) => (<RouterLink {...props} />);
5+
function Link(props: any) {
6+
// eslint-disable-next-line react/jsx-props-no-spreading
7+
return (<RouterLink {...props} />);
8+
}
69

710
export default Link;

0 commit comments

Comments
 (0)