Skip to content

Commit

Permalink
Split score board into lazy loaded bundle to avoid having to have mot…
Browse files Browse the repository at this point in the history
…ion js in the default bundle
  • Loading branch information
J12934 committed Nov 28, 2024
1 parent d9e58c3 commit c0e249c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions balancer/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { BrowserRouter, Routes, Route } from "react-router-dom";
import { IntlProvider } from "react-intl";

import { JoinPage } from "./pages/JoinPage";
import { ScoreOverviewPage } from "./pages/ScoreOverview";
import { JoiningPage } from "./pages/JoiningPage";
import { TeamStatusPage } from "./pages/TeamStatusPage";
import { IndividualScorePage } from "./pages/IndividualScorePage";

import { Layout } from "./Layout";
import { Spinner } from "./components/Spinner";
import { MessageLoader } from "./translations/index";
import { Toaster } from "react-hot-toast";

const AdminPage = lazy(() => import("./pages/AdminPage"));
const ScoreOverviewPage = lazy(() => import("./pages/ScoreOverview"));
const IndividualScorePage = lazy(() => import("./pages/IndividualScorePage"));

interface SimplifiedTeamStatusResponse {
name: string;
Expand Down
29 changes: 29 additions & 0 deletions balancer/ui/src/components/PositionDisplay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function FirstPlace({ ...props }) {
return <img src="/balancer/icons/first-place.svg" {...props} />;
}

function SecondPlace({ ...props }) {
return <img src="/balancer/icons/second-place.svg" {...props} />;
}

function ThirdPlace({ ...props }) {
return <img src="/balancer/icons/third-place.svg" {...props} />;
}

export function PositionDisplay({ place }: { place: number }) {
switch (place) {
case 1:
return <FirstPlace className="h-10" />;
case 2:
return <SecondPlace className="h-10" />;
case 3:
return <ThirdPlace className="h-10" />;
default:
return (
<>
<small>#</small>
{place}
</>
);
}
}
2 changes: 1 addition & 1 deletion balancer/ui/src/pages/IndividualScorePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function fetchScore(
};
}

export function IndividualScorePage() {
export default function IndividualScorePage() {
const { team } = useParams();
const intl = useIntl();

Expand Down
33 changes: 2 additions & 31 deletions balancer/ui/src/pages/ScoreOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
import { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import { MagicMotion } from "react-magic-motion";

function FirstPlace({ ...props }) {
return <img src="/balancer/icons/first-place.svg" {...props} />;
}

function SecondPlace({ ...props }) {
return <img src="/balancer/icons/second-place.svg" {...props} />;
}

function ThirdPlace({ ...props }) {
return <img src="/balancer/icons/third-place.svg" {...props} />;
}

export function PositionDisplay({ place }: { place: number }) {
switch (place) {
case 1:
return <FirstPlace className="h-10" />;
case 2:
return <SecondPlace className="h-10" />;
case 3:
return <ThirdPlace className="h-10" />;
default:
return (
<>
<small>#</small>
{place}
</>
);
}
}
import { PositionDisplay } from "../components/PositionDisplay";

interface Team {
name: string;
Expand All @@ -53,7 +24,7 @@ async function fetchTeams(lastSeen: Date | null): Promise<null | Team[]> {
return teams;
}

export function ScoreOverviewPage({
export default function ScoreOverviewPage({
activeTeam,
}: {
activeTeam: string | null;
Expand Down
2 changes: 1 addition & 1 deletion balancer/ui/src/pages/TeamStatusPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { useEffect, useState } from "react";
import { Link, useLocation, useNavigate, useParams } from "react-router-dom";
import { Card } from "../components/Card";
import { FormattedMessage, useIntl } from "react-intl";
import { PositionDisplay } from "./ScoreOverview";
import { PasscodeDisplayCard } from "../cards/PassCodeDisplayCard";
import { Button } from "../components/Button";
import toast from "react-hot-toast";
import { PositionDisplay } from "../components/PositionDisplay";

interface TeamStatusResponse {
name: string;
Expand Down

0 comments on commit c0e249c

Please sign in to comment.