From b39d005e23ae1a7cfe65b976cd08c3fb5de9015c Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Tue, 1 Feb 2022 18:24:48 -0500 Subject: [PATCH] ISSUE-035 - Styled the Team flags individually. Went through a lot of trouble to style the team flags to be wider than the country flags. This called for a troubling amount of ternary statements in the angled flag components. I'm content with the results. --- .../Common/AngledFlag/AngledFlag.tsx | 26 +++-- .../Common/AngledFlag/styles.ts | 53 +++++---- .../CustomWorkSpaces/AngledFlagWorkSpace.tsx | 2 +- .../AngledFlagPrototypeControls.tsx | 21 +++- src/domain/data/teams.ts | 102 ++++++++++-------- src/domain/data/workspaces.ts | 9 ++ src/public/images/logos/team/alfaRomeo.svg | 2 +- src/public/images/logos/team/ferrari.svg | 32 +++++- 8 files changed, 168 insertions(+), 79 deletions(-) diff --git a/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx b/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx index 21416af..fe062e2 100644 --- a/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx +++ b/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx @@ -15,6 +15,9 @@ import { const countryFlags = require.context("../../../../public/images/countryFlags/angled", true); const teamLogos = require.context("../../../../public/images/logos/team", true); +const FLAG_WIDTH_TEAM = 2.4; +const FLAG_WIDTH_COUNTRY = 2; + /** * To look right, country flags need to be 2:1. Additional editing will be * necessary for some flags to not cut off prominent elements. Ex: China's flag @@ -42,7 +45,7 @@ export function AngledFlag(props: AngledFlagProps) { ); @@ -64,13 +67,13 @@ export function AngledFlag(props: AngledFlagProps) { ); @@ -78,26 +81,31 @@ export function AngledFlag(props: AngledFlagProps) { ); } + const flagModeWidth = flagProps.flagMode === "team" ? FLAG_WIDTH_TEAM : FLAG_WIDTH_COUNTRY; + return ( {topFlag} diff --git a/src/components/BroadcastGraphics/Common/AngledFlag/styles.ts b/src/components/BroadcastGraphics/Common/AngledFlag/styles.ts index cb40672..763873a 100644 --- a/src/components/BroadcastGraphics/Common/AngledFlag/styles.ts +++ b/src/components/BroadcastGraphics/Common/AngledFlag/styles.ts @@ -33,6 +33,7 @@ type FlagContainerProps = { collapsedWidth: Px, topFlag?: boolean, masked?: boolean, + teamFlag?: boolean, }; export const FlagContainer = styled.div` position: absolute; @@ -40,28 +41,28 @@ export const FlagContainer = styled.div` width: ${({ width }) => `${width}px`}; ${({ masked = false }) => masked && css` mask-image: linear-gradient( - 60deg, + to right, transparent 0%, black 15%, - black 85%, - transparent 100% + black 70%, + transparent 95% ); `} - ${({ width, collapsedWidth, topFlag = false }) => topFlag + ${({ width, collapsedWidth, topFlag = false, teamFlag = false }) => topFlag ? css` clip-path: polygon( - ${((collapsedWidth * .5) / width) * 100}% 0, - 95% 0, + ${((collapsedWidth * (teamFlag ? .415 : .5)) / width) * 100}% 0, + ${teamFlag ? 87.7 : 95}% 0, ${((1 - ((collapsedWidth * .55) / width)) * 100)}% 100%, 0 100% ); ` : css` clip-path: polygon( - ${((collapsedWidth * .5) / width) * 100}% 0, - 100% 0, - 100% 30%, + ${((collapsedWidth * (teamFlag ? .415 : .5)) / width) * 100}% 0, + ${teamFlag ? 90 : 95}% 0, + ${teamFlag ? 90 : 95}% 40%, ${((1 - ((collapsedWidth * .34) / width)) * 100)}% 100%, 0 100% ); @@ -77,6 +78,7 @@ type FlagDivBaseProps = { const FlagDivBase = styled.div` height: ${({ height }) => `${height}px`}; width: ${({ width }) => `${width}px`}; + background-color: white; background-image: url(${({ src }) => src}); background-repeat: no-repeat; `; @@ -94,21 +96,36 @@ CountryFlagDiv.displayName = "CountryFlagDiv"; type TeamFlagDivProps = { style: TeamFlagStyle, + bottomFlag?: boolean, }; 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}%`}; + background-image: url(${({ src }) => src}); + ${({ style: { backgroundColor } }) => css`background-color: ${backgroundColor};`} - ${({ style: { backgroundColor } }) => backgroundColor && - css`background-color: ${backgroundColor};`} - ${({ style: { backgroundImage } }) => backgroundImage && - css`background-image: ${backgroundImage};`} + ${({ + bottomFlag, + height, + width, + style: { + imageSize, + imagePos: { x, y }, + subFlagModifier: { x: subX, y: subY, scale: subScale }, + }, + }) => bottomFlag + ? css` + background-size: ${imageSize * subScale}%; + background-position: + ${`${width * (x === 0 ? .1 : x) * subX}px + ${height * (y === 0 ? .1 : y) * subY}px`}; + ` + : css` + background-size: ${imageSize}%; + background-position: + ${`${width * x}px ${height * y}px`}; + `} `; type SlashProps = { diff --git a/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx b/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx index a9a2ae2..cf9244e 100644 --- a/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx +++ b/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx @@ -13,7 +13,7 @@ export function AngledFlagWorkSpace({ flagMode }: AngledFlagWorkSpaceProps) { const { prototypeState } = useSelector(workspaceSelector); if (flagMode === "none") return null; - const defaultTeam: TeamId = "alpine"; + const defaultTeam: TeamId = "alfaRomeo"; return ( diff --git a/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx index 2610f3f..82c0baf 100644 --- a/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx +++ b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx @@ -13,10 +13,13 @@ const countries = [ "CAN", "RUS", "RAF", "AUS", "ESP", "ITA", ]; const teams: Array = [ - "alpine", "alfaRomeo", "alphaTauri", "astonMartin", "haas", "ferrari", + "alfaRomeo", "alphaTauri", "alpine", "astonMartin", "ferrari", "haas", "mclaren", "mercedes", "redBull", "williams", ]; +const DEFAULT_COUNTRY = "GBR"; +const DEFAULT_TEAM: TeamId = "alfaRomeo"; + type AngledFlagPrototypeControlsProps = { flagMode: FlagMode, }; @@ -29,15 +32,23 @@ export function AngledFlagPrototypeControls({ flagMode }: AngledFlagPrototypeCon if (flagMode === "country") { dispatch(setPrototypeState({ angledFlagCountry: { - flagA: flag === "flagA" ? countries[index] : prototypeState?.angledFlagCountry?.flagA ?? "GBR", - flagB: flag === "flagB" ? countries[index] : prototypeState?.angledFlagCountry?.flagB ?? "GBR", + flagA: flag === "flagA" + ? countries[index] + : prototypeState?.angledFlagCountry?.flagA ?? DEFAULT_COUNTRY, + flagB: flag === "flagB" + ? countries[index] + : prototypeState?.angledFlagCountry?.flagB ?? DEFAULT_COUNTRY, }, })); } 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", + flagA: flag === "flagA" + ? teams[index] + : prototypeState?.angledFlagTeam?.flagA ?? DEFAULT_TEAM, + flagB: flag === "flagB" + ? teams[index] + : prototypeState?.angledFlagTeam?.flagB ?? DEFAULT_TEAM, }, })); diff --git a/src/domain/data/teams.ts b/src/domain/data/teams.ts index fb67e97..53ae5db 100644 --- a/src/domain/data/teams.ts +++ b/src/domain/data/teams.ts @@ -324,15 +324,6 @@ export type NumberStyle = { * Do not grab directly! */ export const teamNumberStyles: { [teamId: string]: NumberStyle } = { - alpine: { - numberColor: "#ddffff", - fontFamily: theme.fonts.f1Italic, - rules: [ - { type: "shadow", property: repeater("0 0 0.2em #4B7B9E", 4) }, - { type: "stroke", color: "#000", width: 0.13 }, - { type: "shadow", property: repeater("0 0 0.07em #65A6D6", 2) }, - ], - }, alfaRomeo: { numberColor: "#ffe9f4", fontFamily: theme.fonts.f1Italic, @@ -350,6 +341,15 @@ export const teamNumberStyles: { [teamId: string]: NumberStyle } = { { type: "stroke", color: "#2b4562", width: 0.03 }, ], }, + alpine: { + numberColor: "#ddffff", + fontFamily: theme.fonts.f1Italic, + rules: [ + { type: "shadow", property: repeater("0 0 0.2em #4B7B9E", 4) }, + { type: "stroke", color: "#000", width: 0.13 }, + { type: "shadow", property: repeater("0 0 0.07em #65A6D6", 2) }, + ], + }, astonMartin: { numberColor: "#f9ffff", fontFamily: theme.fonts.f1Italic, @@ -422,63 +422,77 @@ export const teamNumberStyles: { [teamId: string]: NumberStyle } = { export type TeamFlagStyle = { - backgroundColor?: string, - backgroundImage?: string, + backgroundColor: string, imageSize: Percent, imagePos: { - x: Percent, - y: Percent, + x: number, + y: number, + }, + subFlagModifier: { + x: number, + y: number, + scale: number, }, }; 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 }, + backgroundColor: "#660000", + imageSize: 41, + imagePos: { x: .32, y: .08 }, + subFlagModifier: { x: .99, y: .97, scale: .99 }, }, alphaTauri: { + backgroundColor: "#232c3b", + imageSize: 58, + imagePos: { x: .25, y: -.15 }, + subFlagModifier: { x: 1, y: .9, scale: .99 }, + }, + alpine: { backgroundColor: "black", - imageSize: 50, - imagePos: { x: 50, y: 50 }, + imageSize: 51, + imagePos: { x: .23, y: -.12 }, + subFlagModifier: { x: 1.02, y: .98, scale: .98 }, }, astonMartin: { - backgroundColor: "black", - imageSize: 50, - imagePos: { x: 50, y: 50 }, - }, - haas: { - backgroundColor: "black", - imageSize: 50, - imagePos: { x: 50, y: 50 }, + backgroundColor: "#037356", + imageSize: 109, + imagePos: { x: .05, y: -.75 }, + subFlagModifier: { x: 1.05, y: .9, scale: .95 }, }, ferrari: { backgroundColor: "#dc0000", - imageSize: 55, - imagePos: { x: 80, y: -40 }, + imageSize: 50, + imagePos: { x: .3, y: .04 }, + subFlagModifier: { x: 1, y: 1, scale: .98 }, + }, + haas: { + backgroundColor: "#f0f0f0", + imageSize: 46, + imagePos: { x: .3, y: -.04 }, + subFlagModifier: { x: 1, y: .98, scale: .98 }, }, mclaren: { - backgroundColor: "black", + backgroundColor: "#545459", imageSize: 50, - imagePos: { x: 50, y: 50 }, + imagePos: { x: .25, y: -.1 }, + subFlagModifier: { x: .98, y: 1.03, scale: 1.03 }, }, mercedes: { - backgroundColor: "black", - imageSize: 50, - imagePos: { x: 50, y: 50 }, + backgroundColor: "#1ee0ad", + imageSize: 40, + imagePos: { x: .33, y: .05 }, + subFlagModifier: { x: 1, y: 1, scale: .98 }, }, redBull: { - backgroundColor: "black", - imageSize: 50, - imagePos: { x: 50, y: 50 }, + backgroundColor: "#413ae2", + imageSize: 88, + imagePos: { x: .33, y: 0 }, + subFlagModifier: { x: 1.04, y: .2, scale: .92 }, }, williams: { - backgroundColor: "black", - imageSize: 50, - imagePos: { x: 50, y: 50 }, + backgroundColor: "#12a0cb", + imageSize: 40, + imagePos: { x: .35, y: .1 }, + subFlagModifier: { x: 1, y: 1, scale: .98 }, }, }; diff --git a/src/domain/data/workspaces.ts b/src/domain/data/workspaces.ts index a0319a1..5839e35 100644 --- a/src/domain/data/workspaces.ts +++ b/src/domain/data/workspaces.ts @@ -50,7 +50,16 @@ export const workspaces: WorkspaceObject = { angledFlagTeam: { name: "Angled Flag (Team)", overlayIds: [ + "angled-flag-alfaRomeo.png", + "angled-flag-alphaTauri.png", + "angled-flag-alpine.png", + "angled-flag-astonMartin.png", "angled-flag-ferrari.png", + "angled-flag-haas.png", + "angled-flag-mclaren.png", + "angled-flag-mercedes.png", + "angled-flag-redBull.png", + "angled-flag-williams.png", ], previewWindowDimensions: { width: 800, diff --git a/src/public/images/logos/team/alfaRomeo.svg b/src/public/images/logos/team/alfaRomeo.svg index 2cf5a1d..55ac7b3 100644 --- a/src/public/images/logos/team/alfaRomeo.svg +++ b/src/public/images/logos/team/alfaRomeo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/public/images/logos/team/ferrari.svg b/src/public/images/logos/team/ferrari.svg index 6415210..43e2712 100644 --- a/src/public/images/logos/team/ferrari.svg +++ b/src/public/images/logos/team/ferrari.svg @@ -1 +1,31 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +