ISSUE-054 - Added Team Gems to TimingTower.

Finer calibration to row sizing (not 37px or 36px high, but 36.5px!) and position flag font size.
This commit is contained in:
Kyle Geib committed 2022-02-17 17:25:50 -05:00
1 parent 39bddc4cf1
commit 2ad7fdd24c
12 files changed
+202 -21

No files matched your search

@@ -98,7 +98,7 @@ type TeamFlagDivProps = {
style: TeamFlagStyle,
bottomFlag?: boolean,
};
export const TeamFlagDiv = styled(FlagDivBase) <TeamFlagDivProps>`
export const TeamFlagDiv = styled(FlagDivBase)<TeamFlagDivProps>`
height: ${({ height }) => `${height}px`};
width: ${({ width }) => `${width}px`};
@@ -1,15 +1,16 @@
import { Px } from "../../../../types/style";
import { Fraction, Px } from "../../../../types/style";
import { PositionFlagBox, PositionNumber } from "./styles";
type PositionFlagProps = {
size: Px,
number: number,
numberSizeFraction?: Fraction,
};
export function PositionFlag({ size, number }: PositionFlagProps) {
export function PositionFlag({ size, number, numberSizeFraction = 0.64 }: PositionFlagProps) {
return (
<PositionFlagBox size={size}>
<PositionNumber size={size}>
<PositionNumber size={size * numberSizeFraction}>
{number}
</PositionNumber>
</PositionFlagBox>
@@ -23,7 +23,7 @@ type PositionNumberProps = {
};
export const PositionNumber = styled.span<PositionNumberProps>`
font-family: ${p => p.theme.fonts.f1Regular};
font-size: ${({ size }) => `${size * 0.64}px`};
font-size: ${({ size }) => size}px;
margin-top: 2px;
`;
PositionNumber.displayName = "PositionNumber";
@@ -0,0 +1,26 @@
import { TeamId } from "../../../../types/state";
import { Px } from "../../../../types/style";
import { getTeamGemStyle } from "../../../../utils/dataLookup";
import { GemColorDiv, GemContainer, GemLogoDiv } from "./styles";
const teamLogos = require.context("../../../../public/images/logos/team", true);
type TeamGemProps = {
height: Px,
team: TeamId,
};
export function TeamGem({ height, team }: TeamGemProps) {
return (
<GemContainer height={height}>
<GemColorDiv
height={height}
gemStyle={getTeamGemStyle(team)}
/>
<GemLogoDiv
height={height}
src={teamLogos(`./${team}.svg`)}
gemStyle={getTeamGemStyle(team)}
/>
</GemContainer>
);
}
@@ -0,0 +1 @@
export * from "./TeamGem";
@@ -0,0 +1,60 @@
import styled from "styled-components";
import { TeamGemStyle } from "../../../../domain/data/teams";
import { Px } from "../../../../types/style";
const GEM_WIDTH_RATIO = 1.21;
type GemContainerProps = {
height: Px,
};
export const GemContainer = styled.div<GemContainerProps>`
position: relative;
height: ${({ height }) => height}px;
width: ${({ height }) => height * GEM_WIDTH_RATIO}px;
overflow: hidden;
background-color: black;
border-bottom-right-radius: 3px;
mask-image: linear-gradient(to left, black 0%, black 80%, transparent 100%);
clip-path: polygon(40% 0, 100% 0, 100% 100%, 0 100%, 0 50%);
`;
GemContainer.displayName = "GemContainer";
type GemColorDivProps = {
height: Px,
gemStyle: TeamGemStyle,
};
export const GemColorDiv = styled.div<GemColorDivProps>`
position: absolute;
height: 100%;
width: 100%;
background-image: radial-gradient(
circle at 120% 160%,
${({ gemStyle: { backgroundColor } }) => backgroundColor} 50%,
black 100%
);
background-size: 100%;
background-repeat: no-repeat;
`;
type GemLogoDivProps = {
height: Px,
gemStyle: TeamGemStyle,
src: string,
};
export const GemLogoDiv = styled.div<GemLogoDivProps>`
position: absolute;
height: 100%;
width: 100%;
background-image: url(${({ src }) => src});
background-size: ${({ gemStyle: { imageSize } }) => imageSize}%;
background-position: ${({ height, gemStyle: { imagePos: { x, y } } }) => (
`${height * GEM_WIDTH_RATIO * x}px ${height * y}px`
)};
background-repeat: no-repeat;
`;
GemLogoDiv.displayName = "GemDiv";
@@ -8,12 +8,13 @@ import { orMatch } from "../../../../utils/common";
import { timeDiff } from "../../../../utils/event";
import { formatTime } from "../../../../utils/styling";
import { PositionFlag } from "../../Common/PositionFlag";
import { Spacer } from "../../Common/Spacer.styled";
import { TeamGem } from "../../Common/TeamGem";
import {
DriverName,
RowContainer,
RowLeftHalf,
RowLeftHalfGemContainer,
RowLeftHalfLayout,
RowRightHalf,
RowRightHalfLayout,
@@ -35,7 +36,7 @@ export function TimingTower({
const retiredCars: Car[] = [];
grid.forEach((car, index) => {
if (index >= carsToDisplay) return;
if (index >= carsToDisplay || car.status === CarStatus.DidNotStart) return;
if (car.status === CarStatus.Retired) {
retiredCars.push(car);
} else {
@@ -54,6 +55,7 @@ export function TimingTower({
const lastRow = index + 1 === count;
let rightHalfContent = "";
let xScale: Fraction = 1.0;
let yScale: Fraction = 1.0;
let leader = false;
if (forwardCarDistance === -1) {
@@ -72,6 +74,7 @@ export function TimingTower({
car.distance,
), 60)}`;
xScale = rightHalfContent.includes(".") && rightHalfContent.length > 7 ? 0.75 : 0.9;
yScale = rightHalfContent.includes(".") ? 1.1 : 1.0;
}
if (timingBoard.timingTower.mode === BGTimingTowerModes.Interval) {
@@ -95,18 +98,20 @@ export function TimingTower({
}
>
<RowLeftHalfLayout>
<Spacer width="3px" />
{car.status !== CarStatus.Retired && (
<PositionFlag
size={32}
number={index + 1} // Not using car.position...
numberSizeFraction={.6}
/>
)}
<Spacer width="14px" />
<DriverName>
{car.driver.initials}
</DriverName>
</RowLeftHalfLayout>
<RowLeftHalfGemContainer>
<TeamGem team={car.driver.team.id} height={30} />
</RowLeftHalfGemContainer>
</RowLeftHalf>
<RowRightHalf
roundedCornerTop={
@@ -122,7 +127,7 @@ export function TimingTower({
}
>
<RowRightHalfLayout>
<TimeDiff xScale={xScale}>
<TimeDiff xScale={xScale} yScale={yScale}>
{rightHalfContent}
</TimeDiff>
</RowRightHalfLayout>
@@ -2,6 +2,8 @@ import styled, { css } from "styled-components";
import { Fraction, Px } from "../../../../types/style";
const ROW_HEIGHT = 36.5;
export const RowsContainer = styled.div`
display: flex;
flex-direction: column;
@@ -11,7 +13,7 @@ flex-wrap: nowrap;
justify-content: flex-start;
align-items: stretch;
`;
RowsContainer.displayName = "RowsContainer";
type RowContainerProps = {
topGap?: boolean,
@@ -23,12 +25,13 @@ type RowContainerProps = {
export const RowContainer = styled.div<RowContainerProps>`
position: relative;
width: ${({ wide }) => wide ? 255 : 147}px;
height: 36px; // Future will be animated.
height: ${ROW_HEIGHT}px; // Future will be animated.
${({ topGap }) => topGap && css`margin-top: 3px;`}
${({ bottomGap }) => bottomGap && css`margin-bottom: 3px;`}
${({ retired }) => retired && css`opacity: 0.7;`}
`;
RowContainer.displayName = "RowContainer";
type RoundedProp = {
roundedCornerTop?: Px,
@@ -47,20 +50,32 @@ export const RowLeftHalf = styled(Rounded)`
top: 0;
width: 147px; // Future will be animated.
height: 36px;
height: ${ROW_HEIGHT}px;
background-color: #000000e5
`;
RowLeftHalf.displayName = "RowLeftHalf";
export const RowLeftHalfLayout = styled.div`
position: relative;
width: 100%;
height: 100%;
display: flex;
padding-left: 3px;
align-items: center;
justify-content: flex-start;
`;
RowLeftHalfLayout.displayName = "RowLeftHalfLayout";
export const RowLeftHalfGemContainer = styled.div`
position: absolute;
right: 0;
top: 0;
margin-top: 2px;
`;
RowLeftHalfGemContainer.displayName = "RowLeftHalfGemContainer";
export const RowRightHalf = styled(Rounded)`
position: absolute;
@@ -68,12 +83,13 @@ export const RowRightHalf = styled(Rounded)`
top: 0;
width: 108px; // Future will be animated.
height: 36px;
height: ${ROW_HEIGHT}px;
overflow-x: hidden;
background-color: #0000007e
`;
RowRightHalf.displayName = "RowRightHalf";
export const RowRightHalfLayout = styled.div`
width: 100%;
@@ -85,15 +101,19 @@ export const RowRightHalfLayout = styled.div`
justify-content: flex-end;
padding-right: 8px;
`;
RowRightHalfLayout.displayName = "RowRightHalfLayout";
export const DriverName = styled.span`
color: white;
font-family: ${p => p.theme.fonts.f1Bold};
font-size: 20px;
margin-left: 14px;
`;
DriverName.displayName = "DriverName";
type TimeDiffProps = {
xScale: Fraction,
yScale: Fraction,
};
export const TimeDiff = styled.span<TimeDiffProps>`
color: white;
@@ -103,6 +123,7 @@ export const TimeDiff = styled.span<TimeDiffProps>`
text-align: end;
font-feature-settings: 'tnum' 1;
transform-origin: right;
transform: scaleX(${({ xScale }) => xScale});
transform-origin: top right;
transform: scale(${({ xScale, yScale }) => `${xScale}, ${yScale}`});
`;
TimeDiff.displayName = "TimeDiff";
@@ -5,6 +5,8 @@ import useMeasure from "react-use-measure";
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
import { setPosition } from "../../../features/overlayTool/overlayToolSlice";
import { Px } from "../../../types/style";
import {
OverlayImage,
OverlayImageContainer,
@@ -16,10 +18,10 @@ const overlayImages = require.context("../../../public/images/overlays", true);
type OverlayDisplayProps = {
containerDimensions: {
width: number,
height: number,
width: Px,
height: Px,
},
bleedover?: number,
bleedover?: Px,
};
export function OverlayDisplay({
containerDimensions: { width: containerWidth, height: containerHeight },
@@ -103,6 +103,7 @@ export default function Workspaces() {
workspaceId="timingBoardShort"
previewContent={<TimingTower carsToDisplay={6} />}
prototypeControls={<div>Timing Tower Short</div>}
bleedover={250}
/>
} />
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
+61
View File
@@ -496,3 +496,64 @@ export const teamFlagStyles: { [teamId: string]: TeamFlagStyle } = {
subFlagModifier: { x: 1, y: 1, scale: .98 },
},
};
export type TeamGemStyle = {
backgroundColor: string,
imageSize: Percent,
imagePos: {
x: number,
y: number,
},
};
export const teamGemStyles: { [teamId: string]: TeamGemStyle } = {
alfaRomeo: {
backgroundColor: "#660000",
imageSize: 65,
imagePos: { x: .28, y: .15 },
},
alphaTauri: {
backgroundColor: "#232c3b",
imageSize: 75,
imagePos: { x: .26, y: .07 },
},
alpine: {
backgroundColor: "black",
imageSize: 82,
imagePos: { x: .13, y: 0 },
},
astonMartin: {
backgroundColor: "#037356",
imageSize: 130,
imagePos: { x: .05, y: -.22 },
},
ferrari: {
backgroundColor: "#dc0000",
imageSize: 65,
imagePos: { x: .3, y: .18 },
},
haas: {
backgroundColor: "#f0f0f0",
imageSize: 65,
imagePos: { x: .25, y: .12 },
},
mclaren: {
backgroundColor: "#545459",
imageSize: 67,
imagePos: { x: .25, y: .1 },
},
mercedes: {
backgroundColor: "#1ee0ad",
imageSize: 63,
imagePos: { x: .31, y: .16 },
},
redBull: {
backgroundColor: "#413ae2",
imageSize: 130,
imagePos: { x: .20, y: .05 },
},
williams: {
backgroundColor: "#12a0cb",
imageSize: 65,
imagePos: { x: .3, y: .12 },
},
};
+5 -2
View File
@@ -1,6 +1,6 @@
import { cloneDeep } from "lodash";
import { drivers, teams, teamNumberStyles, teamFlagStyles } from "../domain/data/teams";
import { DriverId, TeamId } from "../types/state";
import { drivers, teams, teamNumberStyles, teamFlagStyles, teamGemStyles } from "../domain/data/teams";
import { DriverId, Team, TeamId } from "../types/state";
/**
* Prefer getting data from teams.ts through these simple getter functions.
@@ -29,3 +29,6 @@ export function getTeamNumberStyle(teamId: TeamId) {
export function getTeamFlagStyle(teamId: TeamId) {
return teamFlagStyles[teamId];
}
export function getTeamGemStyle(teamId: TeamId) {
return teamGemStyles[teamId];
}