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).
This commit is contained in:
Kyle Geib committed 2022-02-02 15:24:58 -05:00
1 parent 72b6fc60ef
commit 8144622407
3 files changed
+89 -49

No files matched your search

@@ -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 (
<BaseBackground width={baseWidth} height={baseHeight}>
<Spacer width="6px" />
{showPosFlag && (
<PositionFlag containerHeight={baseHeight}>
<PositionNumber containerHeight={baseHeight}>
{car.position}
</PositionNumber>
</PositionFlag>
)}
<Spacer width="8px" />
<TeamColorBar color={theme.colors.teams[car.driver.team.id]} />
<Spacer width="8px" />
<TextContainer>
<NameContainer>
<FirstName>{car.driver.firstName}</FirstName>
<LastName>{car.driver.lastName}</LastName>
{showDriverNumber && (
<NumberContainer>
<DriverNumber
teamId={car.driver.team.id}
fontSize="29px"
number={car.driver.number}
/>
</NumberContainer>
)}
</NameContainer>
<TeamName>{car.driver.team.shortName}</TeamName>
</TextContainer>
<FlagContainer
height={baseHeight * 0.9}
width={baseHeight * 3}
right={-baseHeight * 0.6}
>
{flagProps != null && (
<AngledFlag
flagHeight={baseHeight * 0.9}
flagProps={flagProps}
/>
<BaseContainer width={baseWidth} height={baseHeight}>
<BaseBackground >
<Spacer width="6px" />
{showPosFlag && (
<PositionFlag containerHeight={baseHeight}>
<PositionNumber containerHeight={baseHeight}>
{car.position}
</PositionNumber>
</PositionFlag>
)}
</FlagContainer>
</BaseBackground>
<Spacer width="8px" />
<TeamColorBar color={theme.colors.teams[car.driver.team.id]} />
<Spacer width="8px" />
<TextContainer>
<NameContainer>
<FirstName>{car.driver.firstName}</FirstName>
<LastName>{car.driver.lastName}</LastName>
{showDriverNumber && (
<NumberContainer>
<DriverNumber
teamId={car.driver.team.id}
fontSize="29px"
number={car.driver.number}
/>
</NumberContainer>
)}
</NameContainer>
<TeamName>{car.driver.team.shortName}</TeamName>
</TextContainer>
<FlagContainer
height={baseHeight * 0.9}
width={baseHeight * 3}
right={-baseHeight * 0.6}
>
{flagProps != null && (
<AngledFlag
flagHeight={baseHeight * 0.9}
flagProps={flagProps}
/>
)}
</FlagContainer>
</BaseBackground>
{showPortrait && (
<PortraitDiv
src={driverPortraits(`./${car.driver.id}.png`)}
height={baseHeight * 2.5}
rightMargin={-5}
/>
)}
</BaseContainer>
);
}