ISSUE-035 - Took some work but have proper type checking for AngledFlag props and have updated everything necessary.

Styling is still to come. Only have Ferrari working.
I've discovered that the team flags are wider than the country flags. So I'll be tackling that necessary change in the next commit before dealing with styling.
This commit is contained in:
Kyle Geib committed 2022-02-01 12:57:40 -05:00
1 parent 57647f6488
commit bd1892ab17
9 files changed
+231 -53

No files matched your search

@@ -1,7 +1,7 @@
import { useSelector } from "react-redux";
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
import { FlagMode } from "../../../types/state";
import { FlagMode, TeamId } from "../../../types/state";
import { AngledFlag } from "../../BroadcastGraphics/Common/AngledFlag";
import { BasicBlock } from "./styles";
@@ -11,20 +11,48 @@ type AngledFlagWorkSpaceProps = {
};
export function AngledFlagWorkSpace({ flagMode }: AngledFlagWorkSpaceProps) {
const { prototypeState } = useSelector(workspaceSelector);
const defaultFlag = flagMode === "country" ? "GBR" : flagMode === "team" ? "alpine" : "";
if (flagMode === "none") return null;
const defaultTeam: TeamId = "alpine";
return (
<BasicBlock width={750} height={450} color="rgba(30, 30, 30, .7)">
<AngledFlag
flagMode={flagMode}
flag={prototypeState?.angledFlag?.flagA ?? defaultFlag}
flagHeight={64}
/>
<AngledFlag
flagMode={flagMode}
flag={prototypeState?.angledFlag?.flagB ?? defaultFlag}
flagHeight={128}
/>
{flagMode === "country" ? (
<>
<AngledFlag
flagProps={{
flagMode,
flag: prototypeState?.angledFlagCountry?.flagA ?? "GBR",
}}
flagHeight={64}
/>
<AngledFlag
flagProps={{
flagMode,
flag: prototypeState?.angledFlagCountry?.flagB ?? "GBR",
}}
flagHeight={128}
/>
</>
) : flagMode === "team" ? (
<>
<AngledFlag
flagProps={{
flagMode,
flag: prototypeState?.angledFlagTeam?.flagA ?? defaultTeam,
}}
flagHeight={64}
/>
<AngledFlag
flagProps={{
flagMode,
flag: prototypeState?.angledFlagTeam?.flagB ?? defaultTeam,
}}
flagHeight={128}
/>
</>
) : null}
</BasicBlock>
);
}
@@ -26,12 +26,22 @@ export function AngledFlagPrototypeControls({ flagMode }: AngledFlagPrototypeCon
const flagList = flagMode === "country" ? countries : flagMode === "team" ? teams : [];
const onChange = (flag: "flagA" | "flagB") => (index: number) => {
dispatch(setPrototypeState({
angledFlag: {
flagA: flag === "flagA" ? flagList[index] : prototypeState?.angledFlag?.flagA ?? "GBR",
flagB: flag === "flagB" ? flagList[index] : prototypeState?.angledFlag?.flagB ?? "GBR",
},
}));
if (flagMode === "country") {
dispatch(setPrototypeState({
angledFlagCountry: {
flagA: flag === "flagA" ? countries[index] : prototypeState?.angledFlagCountry?.flagA ?? "GBR",
flagB: flag === "flagB" ? countries[index] : prototypeState?.angledFlagCountry?.flagB ?? "GBR",
},
}));
} else if (flagMode === "team") {
dispatch(setPrototypeState({
angledFlagTeam: {
flagA: flag === "flagA" ? teams[index] : prototypeState?.angledFlagTeam?.flagA ?? "alpine",
flagB: flag === "flagB" ? teams[index] : prototypeState?.angledFlagTeam?.flagB ?? "alpine",
},
}));
}
};
return (
<Split as={PadBox} gutter="md" padding="md">