From 8144622407ecea7d6702d4e42c3108003aa35e3c Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Wed, 2 Feb 2022 15:24:58 -0500 Subject: [PATCH] ISSUE-041 - Portraits now working! Quite happy with the results. Was far less fiddly than I was expecting. One interesting thing I had to do was introduce a new BaseContainer div component so that I could let the portraits overflow the BaseBackground component (by being put in a parent component with no overflow rules). --- .../Chyrons/Driver/ChyronDriver.tsx | 95 +++++++++++-------- .../Chyrons/Driver/styles.ts | 33 ++++++- src/domain/data/workspaces.ts | 10 +- 3 files changed, 89 insertions(+), 49 deletions(-) diff --git a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx index 18404a2..61b94ba 100644 --- a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx +++ b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx @@ -17,8 +17,12 @@ import { TeamName, TextContainer, FlagContainer, + PortraitDiv, + BaseContainer, } from "./styles"; +const driverPortraits = require.context("../../../../public/images/drivers/front", true); + type ChyronDriverProps = { chyronData: BGChyronDriver, subMode: BGChyronSubMode, @@ -28,52 +32,61 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) { : subMode === "large" ? [638, 98] : [0, 0]; - const { car, flagMode, showPosFlag, showDriverNumber } = chyronData; + const { car, flagMode, showPosFlag, showDriverNumber, showPortrait } = chyronData; const flagProps = flagMode === "country" ? { flagMode, flag: car.driver.nationality } : flagMode === "team" ? { flagMode, flag: car.driver.team.id } : undefined; return ( - - - {showPosFlag && ( - - - {car.position} - - - )} - - - - - - {car.driver.firstName} - {car.driver.lastName} - {showDriverNumber && ( - - - - )} - - {car.driver.team.shortName} - - - {flagProps != null && ( - + + + + {showPosFlag && ( + + + {car.position} + + )} - - + + + + + + {car.driver.firstName} + {car.driver.lastName} + {showDriverNumber && ( + + + + )} + + {car.driver.team.shortName} + + + {flagProps != null && ( + + )} + + + {showPortrait && ( + + )} + ); } diff --git a/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts b/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts index 48b46c3..97ca527 100644 --- a/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts +++ b/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts @@ -1,14 +1,21 @@ import styled from "styled-components"; import { Px } from "../../../../types/style"; -type BaseBackgroundProps = { +type BaseContainerProps = { width: Px, height: Px, }; -export const BaseBackground = styled.div` +export const BaseContainer = styled.div` position: relative; width: ${({ width }) => `${width}px`}; height: ${({ height }) => `${height}px`}; +`; +BaseContainer.displayName = "BaseContainer"; + +export const BaseBackground = styled.div` + position: relative; + height: 100%; + width: 100%; display: flex; align-items: center; @@ -107,7 +114,6 @@ export const TeamName = styled.div` `; TeamName.displayName = "TeamName"; - type SpacerProps = { width?: string, height?: string; @@ -137,3 +143,24 @@ export const FlagContainer = styled.div` overflow: hidden; `; FlagContainer.displayName = "FlagContainer"; + +type PortraitDivProps = { + src: string, + height: Px, + rightMargin: Px, +}; +export const PortraitDiv = styled.div` + position: absolute; + + height: ${({ height }) => `${height}px`}; + width: ${({ height }) => `${height * 1.4}px`}; + + bottom: 0; + right: ${({ rightMargin }) => `${rightMargin}px`}; + + background-image: url(${({ src }) => src}); + background-size: contain; + background-repeat: no-repeat; + background-position: center ${({ height }) => `${height * .18}px`}; +`; +PortraitDiv.displayName = "PortraitDiv"; diff --git a/src/domain/data/workspaces.ts b/src/domain/data/workspaces.ts index 24bf3e3..603ae51 100644 --- a/src/domain/data/workspaces.ts +++ b/src/domain/data/workspaces.ts @@ -7,19 +7,19 @@ export const workspaces: WorkspaceObject = { chyron: { name: "Chyron", overlayIds: [ - "chyron-driver-portrait-maz.png", - "chyron-driver-medium-full-ham.png", "chyron-driver-medium-full-alo.png", "chyron-driver-medium-full-lec.png", "chyron-driver-medium-full-rai.png", "chyron-driver-medium-full-vet.png", "chyron-driver-medium-full-per.png", "chyron-driver-medium-full-msc.png", + "chyron-driver-medium-op1-ham.png", + "chyron-driver-medium-op2-ham.png", + "chyron-driver-medium-full-ham.png", + "chyron-driver-portrait-maz.png", "chyron-driver-medium-full-gas-weird.png", "chyron-driver-medium-full-nor-weird.png", "chyron-driver-medium-full-lat-no-pos.png", - "chyron-driver-medium-op1-ham.png", - "chyron-driver-medium-op2-ham.png", "chyron-driver-large-np-tsu.png", "chyron-driver-large-dnf-ver.png", ], @@ -35,7 +35,7 @@ export const workspaces: WorkspaceObject = { ], previewWindowDimensions: { width: 1200, - height: 150, + height: 250, }, }, angledFlagCountry: {