diff --git a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx
index d3e23d9..18404a2 100644
--- a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx
+++ b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx
@@ -29,6 +29,9 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
: [0, 0];
const { car, flagMode, showPosFlag, showDriverNumber } = chyronData;
+ const flagProps = flagMode === "country"
+ ? { flagMode, flag: car.driver.nationality }
+ : flagMode === "team" ? { flagMode, flag: car.driver.team.id } : undefined;
return (
@@ -64,11 +67,12 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
width={baseHeight * 3}
right={-baseHeight * 0.6}
>
-
+ {flagProps != null && (
+
+ )}
);
diff --git a/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx b/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx
index 723a49a..21416af 100644
--- a/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx
+++ b/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx
@@ -1,16 +1,19 @@
-import { FlagMode } from "../../../../types/state";
+import { ReactNode } from "react";
+import { TeamId } from "../../../../types/state";
import { Px } from "../../../../types/style";
+import { getTeamFlagStyle } from "../../../../utils/dataLookup";
import {
Container,
Slant,
Sheen,
- CountryFlagEdge,
+ FlagEdge,
CountryFlagDiv,
FlagContainer,
+ TeamFlagDiv,
} from "./styles";
const countryFlags = require.context("../../../../public/images/countryFlags/angled", true);
-// const teamLogos = require.context("../../../../public/images/teamLogos", true);
+const teamLogos = require.context("../../../../public/images/logos/team", true);
/**
* To look right, country flags need to be 2:1. Additional editing will be
@@ -19,35 +22,67 @@ const countryFlags = require.context("../../../../public/images/countryFlags/ang
* center.
*/
type AngledFlagProps = {
- flagMode: FlagMode,
- flag: string,
flagHeight: Px,
+ flagProps: {
+ flagMode: "country",
+ flag: string,
+ } | {
+ flagMode: "team",
+ flag: TeamId,
+ },
};
-export function AngledFlag({ flagMode, flag, flagHeight }: AngledFlagProps) {
- const topFlag = flagMode === "country"
- ? (
+export function AngledFlag(props: AngledFlagProps) {
+ const { flagProps, flagHeight } = props;
+
+ let topFlag: ReactNode = null;
+ let bottomFlag: ReactNode = null;
+
+ if (flagProps.flagMode === "country") {
+ topFlag = (
-
- ) : null; // Team flag here
-
- const bottomFlag = flagMode === "country"
- ? (
+ );
+ bottomFlag = (
- ) : null; // Team flag here
+ );
+ } else if (flagProps.flagMode === "team") {
+ topFlag = (
+
+
+
+ );
+ bottomFlag = (
+
+ );
+ }
return (
diff --git a/src/components/BroadcastGraphics/Common/AngledFlag/styles.ts b/src/components/BroadcastGraphics/Common/AngledFlag/styles.ts
index 6ef1105..cb40672 100644
--- a/src/components/BroadcastGraphics/Common/AngledFlag/styles.ts
+++ b/src/components/BroadcastGraphics/Common/AngledFlag/styles.ts
@@ -1,4 +1,5 @@
import styled, { css } from "styled-components";
+import { TeamFlagStyle } from "../../../../domain/data/teams";
import { Px } from "../../../../types/style";
type ContainerProps = {
@@ -68,24 +69,48 @@ export const FlagContainer = styled.div`
`;
FlagContainer.displayName = "FlagContainer";
-type CountryFlagDivProps = {
+type FlagDivBaseProps = {
src: string,
height: Px,
width: Px,
- xOffset?: Px,
};
-export const CountryFlagDiv = styled.div`
+const FlagDivBase = styled.div`
height: ${({ height }) => `${height}px`};
width: ${({ width }) => `${width}px`};
background-image: url(${({ src }) => src});
- background-size: ${({ width, height }) => `${width}px ${height}px`};
background-repeat: no-repeat;
+`;
+
+type CountryFlagDivProps = {
+ xOffset?: Px,
+};
+export const CountryFlagDiv = styled(FlagDivBase)`
+ background-size: ${({ width, height }) => `${width}px ${height}px`};
${({ xOffset }) => xOffset == null
? css`background-position: center;`
: css`background-position-x: ${xOffset}px`}
`;
CountryFlagDiv.displayName = "CountryFlagDiv";
+type TeamFlagDivProps = {
+ style: TeamFlagStyle,
+};
+export const TeamFlagDiv = styled(FlagDivBase) `
+ height: ${({ height }) => `${height}px`};
+ width: ${({ width }) => `${width}px`};
+
+ background-image: url(${({ src }) => src})
+ ${({ style: { backgroundImage } }) => backgroundImage
+ && `, background-image: ${backgroundImage}`};
+ background-size: ${({ style: { imageSize } }) => `${imageSize}%`};
+ background-position: ${({ style: { imagePos: { x, y } } }) => `${x}% ${y}%`};
+
+ ${({ style: { backgroundColor } }) => backgroundColor &&
+ css`background-color: ${backgroundColor};`}
+ ${({ style: { backgroundImage } }) => backgroundImage &&
+ css`background-image: ${backgroundImage};`}
+`;
+
type SlashProps = {
x?: Px,
height: Px,
@@ -126,7 +151,7 @@ export const Slant = styled.div`
`;
Slant.displayName = "Slant";
-export const CountryFlagEdge = styled.div`
+export const FlagEdge = styled.div`
position: absolute;
height: ${({ height }) => `${height}px`};
width: ${({ girth }) => `${girth}px`};
@@ -142,4 +167,4 @@ export const CountryFlagEdge = styled.div`
black 100%
);
`;
-CountryFlagEdge.displayName = "CountryFlagEdge";
+FlagEdge.displayName = "FlagEdge";
diff --git a/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx b/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx
index 033fbb8..a9a2ae2 100644
--- a/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx
+++ b/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx
@@ -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 (
-
-
+ {flagMode === "country" ? (
+ <>
+
+
+ >
+ ) : flagMode === "team" ? (
+ <>
+
+
+ >
+
+ ) : null}
);
}
diff --git a/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx
index a1c826b..2610f3f 100644
--- a/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx
+++ b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx
@@ -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 (
diff --git a/src/domain/data/teams.ts b/src/domain/data/teams.ts
index 3e53fec..fb67e97 100644
--- a/src/domain/data/teams.ts
+++ b/src/domain/data/teams.ts
@@ -1,5 +1,6 @@
import { theme } from "../../shared/theme";
import { Driver, Team } from "../../types/state";
+import { Percent } from "../../types/style";
import { repeater } from "../../utils/strings";
/**
@@ -418,3 +419,66 @@ export const teamNumberStyles: { [teamId: string]: NumberStyle } = {
],
},
};
+
+
+export type TeamFlagStyle = {
+ backgroundColor?: string,
+ backgroundImage?: string,
+ imageSize: Percent,
+ imagePos: {
+ x: Percent,
+ y: Percent,
+ },
+};
+export const teamFlagStyles: { [teamId: string]: TeamFlagStyle } = {
+ alpine: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+ alfaRomeo: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+ alphaTauri: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+ astonMartin: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+ haas: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+ ferrari: {
+ backgroundColor: "#dc0000",
+ imageSize: 55,
+ imagePos: { x: 80, y: -40 },
+ },
+ mclaren: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+ mercedes: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+ redBull: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+ williams: {
+ backgroundColor: "black",
+ imageSize: 50,
+ imagePos: { x: 50, y: 50 },
+ },
+};
diff --git a/src/types/state.d.ts b/src/types/state.d.ts
index 157a83a..6842461 100644
--- a/src/types/state.d.ts
+++ b/src/types/state.d.ts
@@ -32,10 +32,14 @@ export interface WorkspaceProperties {
previewWindowDimensions: Dimensions;
}
export interface PrototypeState {
- angledFlag?: {
+ angledFlagCountry?: {
flagA: string;
flagB: string;
};
+ angledFlagTeam?: {
+ flagA: TeamId;
+ flagB: TeamId;
+ };
}
// Overlay Tool
diff --git a/src/types/style.d.ts b/src/types/style.d.ts
index da7c5af..40800d3 100644
--- a/src/types/style.d.ts
+++ b/src/types/style.d.ts
@@ -2,3 +2,8 @@
* Type to remind you that we're dealing with pixels.
*/
export type Px = number;
+
+/**
+ * Type to remind you that we're dealing with percentages.
+ */
+export type Percent = number;
diff --git a/src/utils/dataLookup.ts b/src/utils/dataLookup.ts
index dc48757..469ebeb 100644
--- a/src/utils/dataLookup.ts
+++ b/src/utils/dataLookup.ts
@@ -1,6 +1,6 @@
import { cloneDeep } from "lodash";
-import { drivers, teams, teamNumberStyles, NumberStyle } from "../domain/data/teams";
-import { Driver, DriverId, Team, TeamId } from "../types/state";
+import { drivers, teams, teamNumberStyles, teamFlagStyles } from "../domain/data/teams";
+import { DriverId, TeamId } from "../types/state";
/**
* Prefer getting data from teams.ts through these simple getter functions.
@@ -9,20 +9,23 @@ import { Driver, DriverId, Team, TeamId } from "../types/state";
* situation I wouldn't be able to normally
*/
-export function getDriver(driverId: DriverId): Driver {
+export function getDriver(driverId: DriverId) {
return drivers[driverId];
}
-export function cloneDriver(driverId: DriverId): Driver {
+export function cloneDriver(driverId: DriverId) {
return cloneDeep(drivers[driverId]);
}
-export function getTeam(teamId: TeamId): Team {
+export function getTeam(teamId: TeamId) {
return teams[teamId];
}
-export function cloneTeam(teamId: TeamId): Team {
+export function cloneTeam(teamId: TeamId) {
return cloneDeep(teams[teamId]);
}
-export function getTeamNumberStyle(teamId: TeamId): NumberStyle {
+export function getTeamNumberStyle(teamId: TeamId) {
return teamNumberStyles[teamId];
}
+export function getTeamFlagStyle(teamId: TeamId) {
+ return teamFlagStyles[teamId];
+}