diff --git a/app/components/tournament/ActionSectionWrapper.tsx b/app/components/tournament/ActionSectionWrapper.tsx index 061c99cec..bfb1a0f22 100644 --- a/app/components/tournament/ActionSectionWrapper.tsx +++ b/app/components/tournament/ActionSectionWrapper.tsx @@ -1,3 +1,5 @@ +import { MyCSSProperties } from "~/utils"; + export function ActionSectionWrapper({ children, icon, @@ -6,11 +8,11 @@ export function ActionSectionWrapper({ icon: "warning" | "info" | "success" | "error"; }) { // todo: flex-dir: column on mobile + const style: MyCSSProperties = { + "--action-section-icon-color": `var(--theme-${icon})`, + }; return ( -
+
{children}
); diff --git a/app/components/tournament/EliminationBracket.tsx b/app/components/tournament/EliminationBracket.tsx index accea2ca4..7f3f2bca7 100644 --- a/app/components/tournament/EliminationBracket.tsx +++ b/app/components/tournament/EliminationBracket.tsx @@ -1,7 +1,7 @@ import classNames from "classnames"; import invariant from "tiny-invariant"; import type { BracketModified } from "~/services/tournament"; -import { Unpacked } from "~/utils"; +import { MyCSSProperties, Unpacked } from "~/utils"; export function EliminationBracket({ bracketSide, @@ -10,16 +10,12 @@ export function EliminationBracket({ bracketSide: BracketModified["winners"]; ownTeamName?: string; }) { + const style: MyCSSProperties = { + "--brackets-columns": bracketSide.length, + "--brackets-max-matches": bracketSide[0].matches.length, + }; return ( -
+
{bracketSide.map((round, i) => (
{round.matches.map((match) => { diff --git a/app/routes/to/$organization.$tournament.tsx b/app/routes/to/$organization.$tournament.tsx index 1e5e741c8..fd4b72c00 100644 --- a/app/routes/to/$organization.$tournament.tsx +++ b/app/routes/to/$organization.$tournament.tsx @@ -19,6 +19,7 @@ import { FindTournamentByNameForUrlI, } from "~/services/tournament"; import { makeTitle } from "~/utils"; +import type { MyCSSProperties } from "~/utils"; import { useUser } from "~/utils/hooks"; import tournamentStylesUrl from "../../styles/tournament.css"; @@ -86,24 +87,25 @@ export default function TournamentPage() { return result; })(); + const tournamentContainerStyle: MyCSSProperties = { + "--tournaments-bg": data.bannerBackground, + "--tournaments-text": data.CSSProperties.text, + "--tournaments-text-transparent": data.CSSProperties.textTransparent, + // todo: could make a TS helper type for this that checks for leading -- + }; + + const linksContainerStyle: MyCSSProperties = { + "--tabs-count": navLinks.length, + }; + return ( -
- } - > +
{navLinks.map(({ code, text, icon }) => ( diff --git a/app/utils/index.ts b/app/utils/index.ts index 8087560cd..c7cf34438 100644 --- a/app/utils/index.ts +++ b/app/utils/index.ts @@ -1,6 +1,7 @@ import { json } from "remix"; import invariant from "tiny-invariant"; import { useLocation } from "remix"; +import type { CSSProperties } from "react"; export function makeTitle(endOfTitle?: string) { return endOfTitle ? `sendou.ink | ${endOfTitle}` : "sendou.ink"; @@ -89,5 +90,14 @@ export type MyReducerAction< } : { type: K }; -// TODO: -// export type InferredSerializedAPI = Serialized>; +export interface MyCSSProperties extends CSSProperties { + "--tournaments-bg"?: string; + "--tournaments-text"?: string; + "--tournaments-text-transparent"?: string; + "--action-section-icon-color"?: string; + "--brackets-columns"?: number; + "--brackets-max-matches"?: number; + "--brackets-bottom-border-length"?: number; + "--brackets-column-matches"?: number; + "--tabs-count"?: number; +}