No files matched your search
@@ -21,7 +21,6 @@ import {
|
|||||||
LastName,
|
LastName,
|
||||||
NameContainer,
|
NameContainer,
|
||||||
NumberContainer,
|
NumberContainer,
|
||||||
Spacer,
|
|
||||||
TeamColorBar,
|
TeamColorBar,
|
||||||
TeamName,
|
TeamName,
|
||||||
TextContainer,
|
TextContainer,
|
||||||
@@ -29,6 +28,7 @@ import {
|
|||||||
DriverPortraitContainer,
|
DriverPortraitContainer,
|
||||||
} from "./styles";
|
} from "./styles";
|
||||||
import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition";
|
import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition";
|
||||||
|
import { Spacer } from "../../Common/Spacer.styled";
|
||||||
|
|
||||||
type ChyronDriverProps = {
|
type ChyronDriverProps = {
|
||||||
chyronData: BGChyronDriver,
|
chyronData: BGChyronDriver,
|
||||||
|
|||||||
@@ -171,16 +171,6 @@ export const TeamName = styled.div<TeamNameProps>`
|
|||||||
`;
|
`;
|
||||||
TeamName.displayName = "TeamName";
|
TeamName.displayName = "TeamName";
|
||||||
|
|
||||||
type SpacerProps = {
|
|
||||||
width?: string,
|
|
||||||
height?: string;
|
|
||||||
};
|
|
||||||
export const Spacer = styled.div<SpacerProps>`
|
|
||||||
width: ${({ width = "0" }) => width};
|
|
||||||
height: ${({ height = "0" }) => height};
|
|
||||||
`;
|
|
||||||
Spacer.displayName = "Spacer";
|
|
||||||
|
|
||||||
type FlagContainerProps = {
|
type FlagContainerProps = {
|
||||||
height: Px,
|
height: Px,
|
||||||
width: Px,
|
width: Px,
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import { Px } from "../../../../types/style";
|
import { Fraction, Px } from "../../../../types/style";
|
||||||
|
|
||||||
import { PositionFlagBox, PositionNumber } from "./styles";
|
import { PositionFlagBox, PositionNumber } from "./styles";
|
||||||
|
|
||||||
type PositionFlagProps = {
|
type PositionFlagProps = {
|
||||||
size: Px,
|
size: Px,
|
||||||
number: number,
|
number: number,
|
||||||
|
numberSizeFraction?: Fraction,
|
||||||
};
|
};
|
||||||
export function PositionFlag({ size, number }: PositionFlagProps) {
|
export function PositionFlag({ size, number, numberSizeFraction = 0.64 }: PositionFlagProps) {
|
||||||
return (
|
return (
|
||||||
<PositionFlagBox size={size}>
|
<PositionFlagBox size={size}>
|
||||||
<PositionNumber size={size}>
|
<PositionNumber size={size * numberSizeFraction}>
|
||||||
{number}
|
{number}
|
||||||
</PositionNumber>
|
</PositionNumber>
|
||||||
</PositionFlagBox>
|
</PositionFlagBox>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type PositionNumberProps = {
|
|||||||
};
|
};
|
||||||
export const PositionNumber = styled.span<PositionNumberProps>`
|
export const PositionNumber = styled.span<PositionNumberProps>`
|
||||||
font-family: ${p => p.theme.fonts.f1Regular};
|
font-family: ${p => p.theme.fonts.f1Regular};
|
||||||
font-size: ${({ size }) => `${size * 0.64}px`};
|
font-size: ${({ size }) => size}px;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
`;
|
`;
|
||||||
PositionNumber.displayName = "PositionNumber";
|
PositionNumber.displayName = "PositionNumber";
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
type SpacerProps = {
|
||||||
|
width?: string,
|
||||||
|
height?: string;
|
||||||
|
};
|
||||||
|
export const Spacer = styled.div<SpacerProps>`
|
||||||
|
width: ${({ width = "0" }) => width};
|
||||||
|
height: ${({ height = "0" }) => height};
|
||||||
|
`;
|
||||||
|
Spacer.displayName = "Spacer";
|
||||||
@@ -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";
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
|
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||||
|
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||||
|
import { theme } from "../../../../shared/theme";
|
||||||
|
import {
|
||||||
|
BGTimingTowerDisplayModes,
|
||||||
|
BGTimingTowerSplitsMode,
|
||||||
|
Car,
|
||||||
|
CarNotice,
|
||||||
|
CarStatus,
|
||||||
|
} from "../../../../types/state";
|
||||||
|
import { Fraction } from "../../../../types/style";
|
||||||
|
import { orMatch } from "../../../../utils/common";
|
||||||
|
import { getCarAtPos, timeDiff } from "../../../../utils/event";
|
||||||
|
import { formatTime } from "../../../../utils/styling";
|
||||||
|
|
||||||
|
import { PositionFlag } from "../../Common/PositionFlag";
|
||||||
|
import { TeamGem } from "../../Common/TeamGem";
|
||||||
|
|
||||||
|
import {
|
||||||
|
DriverName,
|
||||||
|
FastestLapGem,
|
||||||
|
AnimatedRowContainer,
|
||||||
|
RowLeftHalf,
|
||||||
|
RowLeftHalfGemContainer,
|
||||||
|
RowLeftHalfLayout,
|
||||||
|
RowRightHalf,
|
||||||
|
RowRightHalfLayout,
|
||||||
|
RowsContainer,
|
||||||
|
TimeDiff,
|
||||||
|
} from "./styles";
|
||||||
|
|
||||||
|
|
||||||
|
export function TimingTower() {
|
||||||
|
|
||||||
|
const { lastUpdate, grid, trackLength, leaderGridSpot } = useSelector(eventSelector);
|
||||||
|
const { timingBoard: { timingTower }, timingBoard: { timingTower: { splitsMode } } } = useSelector(
|
||||||
|
broadcastGraphicsSelector,
|
||||||
|
);
|
||||||
|
|
||||||
|
const [startingCarsCount, setStartingCarsCount] = useState(0);
|
||||||
|
const [retiredCarsCount, setRetiredCarsCount] = useState(0);
|
||||||
|
const [rows, setRows] = useState<JSX.Element[]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Filter away cars that are marked as not starting so they don't appear.
|
||||||
|
const startingGrid = grid.filter(car => car.status !== CarStatus.DidNotStart);
|
||||||
|
setStartingCarsCount(startingGrid.length);
|
||||||
|
|
||||||
|
let retiredCount = 0;
|
||||||
|
startingGrid.forEach(car => {
|
||||||
|
if (car.status === CarStatus.Retired) {
|
||||||
|
++retiredCount;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setRetiredCarsCount(retiredCount);
|
||||||
|
|
||||||
|
setRows(startingGrid.map(car => buildRow(car, startingGrid.length, retiredCount)));
|
||||||
|
}, [lastUpdate, splitsMode]);
|
||||||
|
|
||||||
|
|
||||||
|
const buildRow = (
|
||||||
|
car: Car,
|
||||||
|
startingCarsCount: number,
|
||||||
|
retiredCarsCount: number,
|
||||||
|
) => {
|
||||||
|
const bottomRounded = car.status === CarStatus.Retired ? (
|
||||||
|
car.position === startingCarsCount
|
||||||
|
) : (
|
||||||
|
car.position === startingCarsCount - retiredCarsCount
|
||||||
|
);
|
||||||
|
|
||||||
|
let rightHalfContent = "";
|
||||||
|
let xScale: Fraction = 1.0;
|
||||||
|
let yScale: Fraction = 1.0;
|
||||||
|
|
||||||
|
if (car.position === 1) {
|
||||||
|
rightHalfContent = splitsMode === BGTimingTowerSplitsMode.Leader
|
||||||
|
? "Leader" : splitsMode === BGTimingTowerSplitsMode.Interval
|
||||||
|
? "Interval" : "";
|
||||||
|
} else if (car.status === CarStatus.Retired) {
|
||||||
|
rightHalfContent = "OUT";
|
||||||
|
} else {
|
||||||
|
const deltaCar = getCarAtPos(
|
||||||
|
grid,
|
||||||
|
splitsMode === BGTimingTowerSplitsMode.Leader ? 1 : car.position - 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
const plusLaps = Math.floor((deltaCar.distance - car.distance) / trackLength);
|
||||||
|
|
||||||
|
rightHalfContent =
|
||||||
|
splitsMode === BGTimingTowerSplitsMode.Leader && plusLaps > 0
|
||||||
|
? `+${plusLaps} LAP${plusLaps > 1 ? "S" : ""}`
|
||||||
|
: `+${formatTime(timeDiff(deltaCar.distance, car.distance), 60)}`;
|
||||||
|
|
||||||
|
xScale = rightHalfContent.includes(":") ? 0.75 : 0.9;
|
||||||
|
yScale = rightHalfContent.includes("+") ? 1.1 : 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AnimatedRowContainer
|
||||||
|
key={car.driver.id}
|
||||||
|
retired={car.status === CarStatus.Retired}
|
||||||
|
wide={timingTower.displayMode !== BGTimingTowerDisplayModes.LeftOnly}
|
||||||
|
top={(car.position - 1) * theme.design.timingTower.rowHeightPx}
|
||||||
|
>
|
||||||
|
{car.notices.includes(CarNotice.FastestLap) && (
|
||||||
|
<FastestLapGem />
|
||||||
|
)}
|
||||||
|
<RowLeftHalf
|
||||||
|
roundedCornerBottom={
|
||||||
|
bottomRounded && orMatch(
|
||||||
|
timingTower.displayMode,
|
||||||
|
BGTimingTowerDisplayModes.LeftOnly,
|
||||||
|
BGTimingTowerDisplayModes.FullLeft,
|
||||||
|
) ? 5 : undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<RowLeftHalfLayout>
|
||||||
|
{car.status !== CarStatus.Retired && (
|
||||||
|
<PositionFlag
|
||||||
|
size={32}
|
||||||
|
number={car.position}
|
||||||
|
numberSizeFraction={.6}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<DriverName>
|
||||||
|
{car.driver.initials}
|
||||||
|
</DriverName>
|
||||||
|
</RowLeftHalfLayout>
|
||||||
|
<RowLeftHalfGemContainer>
|
||||||
|
<TeamGem team={car.driver.team.id} height={30} />
|
||||||
|
</RowLeftHalfGemContainer>
|
||||||
|
</RowLeftHalf>
|
||||||
|
<RowRightHalf
|
||||||
|
roundedCornerTop={car.position === 1 ? 5 : undefined}
|
||||||
|
roundedCornerBottom={
|
||||||
|
bottomRounded && orMatch(
|
||||||
|
timingTower.splitsMode,
|
||||||
|
BGTimingTowerSplitsMode.Leader,
|
||||||
|
BGTimingTowerSplitsMode.Interval,
|
||||||
|
) ? 5 : undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<RowRightHalfLayout>
|
||||||
|
<TimeDiff xScale={xScale} yScale={yScale}>
|
||||||
|
{rightHalfContent}
|
||||||
|
</TimeDiff>
|
||||||
|
</RowRightHalfLayout>
|
||||||
|
</RowRightHalf>
|
||||||
|
</AnimatedRowContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RowsContainer
|
||||||
|
carsToDisplay={startingCarsCount}
|
||||||
|
retiredCarsPresent={retiredCarsCount > 0}
|
||||||
|
>
|
||||||
|
{rows}
|
||||||
|
</RowsContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./TimingTower";
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
import styled, { css } from "styled-components";
|
||||||
|
import { animated } from "@react-spring/web";
|
||||||
|
|
||||||
|
import { Fraction, Px } from "../../../../types/style";
|
||||||
|
|
||||||
|
import fastestLapIcon from "../../../../public/images/icons/fastest-lap.svg";
|
||||||
|
|
||||||
|
type RowsContainerProps = {
|
||||||
|
carsToDisplay: number,
|
||||||
|
retiredCarsPresent: boolean,
|
||||||
|
};
|
||||||
|
export const RowsContainer = styled.div<RowsContainerProps>`
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
width: ${p =>
|
||||||
|
p.theme.design.timingTower.rowLeftHalfWidthPx
|
||||||
|
+ p.theme.design.timingTower.rowRightHalfWidthPx}px;
|
||||||
|
height: ${({ theme, carsToDisplay, retiredCarsPresent }) =>
|
||||||
|
theme.design.timingTower.rowHeightPx * carsToDisplay + (retiredCarsPresent ? 3 : 0)}px;
|
||||||
|
|
||||||
|
overflow-y: clip; // hidden doesn't work for some reason.
|
||||||
|
`;
|
||||||
|
RowsContainer.displayName = "RowsContainer";
|
||||||
|
|
||||||
|
type AnimatedRowContainerProps = {
|
||||||
|
retired?: boolean,
|
||||||
|
wide?: boolean,
|
||||||
|
top: Px,
|
||||||
|
};
|
||||||
|
// All the elements in a row should go in here.
|
||||||
|
export const AnimatedRowContainer = animated(styled.div.attrs<AnimatedRowContainerProps>(({
|
||||||
|
top,
|
||||||
|
retired,
|
||||||
|
}) => ({
|
||||||
|
style: {
|
||||||
|
top: `${top + (retired ? 3 : 0)}px`,
|
||||||
|
},
|
||||||
|
}))<AnimatedRowContainerProps>`
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
transition: top 500ms;
|
||||||
|
|
||||||
|
width: ${({ wide }) => wide ? 255 : 147}px;
|
||||||
|
height: ${p => p.theme.design.timingTower.rowHeightPx}px; // Future will be animated.
|
||||||
|
|
||||||
|
${({ retired }) => retired && css`opacity: 0.7;`}
|
||||||
|
`);
|
||||||
|
AnimatedRowContainer.displayName = "AnimatedRowContainer";
|
||||||
|
|
||||||
|
type RoundedProp = {
|
||||||
|
roundedCornerTop?: Px,
|
||||||
|
roundedCornerBottom?: Px,
|
||||||
|
};
|
||||||
|
const Rounded = styled.div<RoundedProp>`
|
||||||
|
${({ roundedCornerTop }) =>
|
||||||
|
roundedCornerTop && css`border-top-right-radius: ${roundedCornerTop}px;`}
|
||||||
|
${({ roundedCornerBottom }) =>
|
||||||
|
roundedCornerBottom && css`border-bottom-right-radius: ${roundedCornerBottom}px;`}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const RowLeftHalf = styled(Rounded)`
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
width: ${p => p.theme.design.timingTower.rowLeftHalfWidthPx}px; // Future will be animated.
|
||||||
|
height: ${p => p.theme.design.timingTower.rowHeightPx}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;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
width: ${p => p.theme.design.timingTower.rowRightHalfWidthPx}px; // Future will be animated.
|
||||||
|
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
||||||
|
|
||||||
|
overflow-x: hidden;
|
||||||
|
|
||||||
|
background-color: #0000007e
|
||||||
|
`;
|
||||||
|
RowRightHalf.displayName = "RowRightHalf";
|
||||||
|
|
||||||
|
export const RowRightHalfLayout = styled.div`
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
align-items: center;
|
||||||
|
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;
|
||||||
|
font-family: ${p => p.theme.fonts.f1Regular};
|
||||||
|
font-size: 20px;
|
||||||
|
|
||||||
|
text-align: end;
|
||||||
|
|
||||||
|
font-feature-settings: 'tnum' 1;
|
||||||
|
transform-origin: top right;
|
||||||
|
transform: scale(${({ xScale, yScale }) => `${xScale}, ${yScale}`});
|
||||||
|
`;
|
||||||
|
TimeDiff.displayName = "TimeDiff";
|
||||||
|
|
||||||
|
export const FastestLapGem = styled.div`
|
||||||
|
position: absolute;
|
||||||
|
|
||||||
|
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
||||||
|
width: ${p => p.theme.design.timingTower.rowHeightPx - 2}px;
|
||||||
|
|
||||||
|
left: ${p => -p.theme.design.timingTower.rowHeightPx + 2}px;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
background-color: ${p => p.theme.colors.laps.purple};
|
||||||
|
background-image: url(${fastestLapIcon});
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 89%;
|
||||||
|
background-position: center 40%;
|
||||||
|
`;
|
||||||
|
FastestLapGem.displayName = "FastestLapGem";
|
||||||
@@ -5,6 +5,8 @@ import useMeasure from "react-use-measure";
|
|||||||
|
|
||||||
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
|
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
|
||||||
import { setPosition } from "../../../features/overlayTool/overlayToolSlice";
|
import { setPosition } from "../../../features/overlayTool/overlayToolSlice";
|
||||||
|
import { Px } from "../../../types/style";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
OverlayImage,
|
OverlayImage,
|
||||||
OverlayImageContainer,
|
OverlayImageContainer,
|
||||||
@@ -16,10 +18,10 @@ const overlayImages = require.context("../../../public/images/overlays", true);
|
|||||||
|
|
||||||
type OverlayDisplayProps = {
|
type OverlayDisplayProps = {
|
||||||
containerDimensions: {
|
containerDimensions: {
|
||||||
width: number,
|
width: Px,
|
||||||
height: number,
|
height: Px,
|
||||||
},
|
},
|
||||||
bleedover?: number,
|
bleedover?: Px,
|
||||||
};
|
};
|
||||||
export function OverlayDisplay({
|
export function OverlayDisplay({
|
||||||
containerDimensions: { width: containerWidth, height: containerHeight },
|
containerDimensions: { width: containerWidth, height: containerHeight },
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||||
|
import { setTimingTowerSplitsMode } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||||
|
|
||||||
|
import { refreshRunningOrder } from "../../../../features/event/eventSlice";
|
||||||
|
import { BGTimingTowerSplitsMode } from "../../../../types/state";
|
||||||
|
|
||||||
|
import { ClickSpan } from "./styles";
|
||||||
|
|
||||||
|
export function TimingTowerPrototypeControls() {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { timingBoard: { timingTower: { splitsMode } } } = useSelector(broadcastGraphicsSelector);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<InlineCluster gutter="md">
|
||||||
|
<ClickSpan onClick={() => dispatch(refreshRunningOrder())}>
|
||||||
|
Refresh Running Order
|
||||||
|
</ClickSpan>
|
||||||
|
<ClickSpan
|
||||||
|
onClick={() => {
|
||||||
|
if (splitsMode === BGTimingTowerSplitsMode.Interval) {
|
||||||
|
dispatch(setTimingTowerSplitsMode(BGTimingTowerSplitsMode.Leader));
|
||||||
|
} else {
|
||||||
|
dispatch(setTimingTowerSplitsMode(BGTimingTowerSplitsMode.Interval));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Splits Mode = {BGTimingTowerSplitsMode[splitsMode]}
|
||||||
|
</ClickSpan>
|
||||||
|
</InlineCluster>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./TimingTowerPrototypeControls";
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
export const ClickSpan = styled.span`
|
||||||
|
font-family: ${p => p.theme.fonts.f1Bold};
|
||||||
|
font-size: 0.9em;
|
||||||
|
cursor: pointer;
|
||||||
|
`;
|
||||||
@@ -8,24 +8,27 @@ import { updateWorkspace } from "../../../features/workspace/workspaceSlice";
|
|||||||
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
|
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
|
||||||
import { newWorkspace } from "../../../features/overlayTool/overlayToolSlice";
|
import { newWorkspace } from "../../../features/overlayTool/overlayToolSlice";
|
||||||
|
|
||||||
|
import { Px } from "../../../types/style";
|
||||||
|
import { workspaces } from "../../../domain/data/workspaces";
|
||||||
|
import { WorkspaceId } from "../../../types/state";
|
||||||
|
|
||||||
import { PreviewWindow, H2, ControlsContainer } from "./styles";
|
import { PreviewWindow, H2, ControlsContainer } from "./styles";
|
||||||
import { WorkspaceControls } from "../WorkspaceControls";
|
import { WorkspaceControls } from "../WorkspaceControls";
|
||||||
import { OverlayDisplay } from "../../OverlayTool";
|
import { OverlayDisplay } from "../../OverlayTool";
|
||||||
|
|
||||||
import { workspaces } from "../../../domain/data/workspaces";
|
|
||||||
import { WorkspaceId } from "../../../types/state";
|
|
||||||
|
|
||||||
type WorkspaceProps = {
|
type WorkspaceProps = {
|
||||||
workspaceId: WorkspaceId,
|
workspaceId: WorkspaceId,
|
||||||
previewContent: ReactNode,
|
previewContent: ReactNode,
|
||||||
prototypeControls: ReactNode,
|
prototypeControls: ReactNode,
|
||||||
showAnimationSpeedSelector?: boolean,
|
showAnimationSpeedSelector?: boolean,
|
||||||
|
bleedover?: Px,
|
||||||
};
|
};
|
||||||
export const Workspace = ({
|
export const Workspace = ({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
previewContent,
|
previewContent,
|
||||||
prototypeControls,
|
prototypeControls,
|
||||||
showAnimationSpeedSelector = false,
|
showAnimationSpeedSelector = false,
|
||||||
|
bleedover,
|
||||||
}: WorkspaceProps) => {
|
}: WorkspaceProps) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { animatedBG, darkBG, workspaceProperties } = useSelector(workspaceSelector);
|
const { animatedBG, darkBG, workspaceProperties } = useSelector(workspaceSelector);
|
||||||
@@ -63,6 +66,7 @@ export const Workspace = ({
|
|||||||
{previewContent}
|
{previewContent}
|
||||||
<OverlayDisplay
|
<OverlayDisplay
|
||||||
containerDimensions={workspaceProperties.previewWindowDimensions}
|
containerDimensions={workspaceProperties.previewWindowDimensions}
|
||||||
|
bleedover={bleedover}
|
||||||
/>
|
/>
|
||||||
</PreviewWindow>
|
</PreviewWindow>
|
||||||
<ControlsContainer>
|
<ControlsContainer>
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPro
|
|||||||
import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
||||||
import { VenetianBlindsWorkspace } from "./CustomWorkSpaces/VenetianBlindsWorkspace";
|
import { VenetianBlindsWorkspace } from "./CustomWorkSpaces/VenetianBlindsWorkspace";
|
||||||
import { VenetianBlindsPrototypeControls } from "./PrototypingControls/VenetianBlindsPrototype";
|
import { VenetianBlindsPrototypeControls } from "./PrototypingControls/VenetianBlindsPrototype";
|
||||||
|
import { TimingTower } from "../BroadcastGraphics/TimingBoard/TimingTower";
|
||||||
|
import { TimingTowerPrototypeControls } from "./PrototypingControls/TimingTowerPrototype";
|
||||||
|
|
||||||
const WORKSPACE_LIST_WIDTH = 180;
|
const WORKSPACE_LIST_WIDTH = 180;
|
||||||
|
|
||||||
@@ -89,6 +91,14 @@ export default function Workspaces() {
|
|||||||
prototypeControls={<VenetianBlindsPrototypeControls />}
|
prototypeControls={<VenetianBlindsPrototypeControls />}
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
|
<Route path="timingBoard" element={
|
||||||
|
<Workspace
|
||||||
|
workspaceId="timingBoard"
|
||||||
|
previewContent={<TimingTower />}
|
||||||
|
prototypeControls={<TimingTowerPrototypeControls />}
|
||||||
|
bleedover={500}
|
||||||
|
/>
|
||||||
|
} />
|
||||||
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
|
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</FullScreenContainer>
|
</FullScreenContainer>
|
||||||
|
|||||||
@@ -496,3 +496,64 @@ export const teamFlagStyles: { [teamId: string]: TeamFlagStyle } = {
|
|||||||
subFlagModifier: { x: 1, y: 1, scale: .98 },
|
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 },
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -84,4 +84,17 @@ export const workspaces: WorkspaceObject = {
|
|||||||
height: 500,
|
height: 500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
timingBoard: {
|
||||||
|
name: "Timing Board",
|
||||||
|
overlayIds: [
|
||||||
|
"timing-board-leader-19.png",
|
||||||
|
"timing-board-leader-20-out-1.png",
|
||||||
|
"timing-board-intervals-yellow-flag.png",
|
||||||
|
"timing-board-portrait-gap.png",
|
||||||
|
],
|
||||||
|
previewWindowDimensions: {
|
||||||
|
width: 700,
|
||||||
|
height: 900,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
@@ -1,9 +1,31 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
import { BGChyrons, OpenState, RootState } from "../../../types/state";
|
import {
|
||||||
|
BGChyrons,
|
||||||
|
BGStatusIndicatorModes,
|
||||||
|
BGTimingTowerDisplayModes,
|
||||||
|
BGTimingTowerFocusedCarsMode,
|
||||||
|
BGTimingTowerSplitsMode,
|
||||||
|
OpenState,
|
||||||
|
RootState,
|
||||||
|
} from "../../../types/state";
|
||||||
|
|
||||||
const initialState: RootState["broadcastGraphics"] = {
|
const initialState: RootState["broadcastGraphics"] = {
|
||||||
chyrons: null,
|
chyrons: null,
|
||||||
|
timingBoard: {
|
||||||
|
relativePos: {},
|
||||||
|
openState: 0,
|
||||||
|
statusIndicator: {
|
||||||
|
mode: BGStatusIndicatorModes.NormalNarrow,
|
||||||
|
},
|
||||||
|
timingTower: {
|
||||||
|
open: 1,
|
||||||
|
displayMode: BGTimingTowerDisplayModes.LeftAndRight,
|
||||||
|
splitsMode: BGTimingTowerSplitsMode.Leader,
|
||||||
|
focusedCars: [],
|
||||||
|
focusedCarsMode: BGTimingTowerFocusedCarsMode.None,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const broadcastGraphicsSlice = createSlice({
|
export const broadcastGraphicsSlice = createSlice({
|
||||||
@@ -32,6 +54,11 @@ export const broadcastGraphicsSlice = createSlice({
|
|||||||
clearChyrons: (state) => {
|
clearChyrons: (state) => {
|
||||||
state.chyrons = null;
|
state.chyrons = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Timing Board
|
||||||
|
setTimingTowerSplitsMode: (state, action: PayloadAction<BGTimingTowerSplitsMode>) => {
|
||||||
|
state.timingBoard.timingTower.splitsMode = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -40,5 +67,6 @@ export const {
|
|||||||
setChyronsOpenState,
|
setChyronsOpenState,
|
||||||
incrementChyronsOpenState,
|
incrementChyronsOpenState,
|
||||||
clearChyrons,
|
clearChyrons,
|
||||||
|
setTimingTowerSplitsMode,
|
||||||
} = broadcastGraphicsSlice.actions;
|
} = broadcastGraphicsSlice.actions;
|
||||||
export default broadcastGraphicsSlice.reducer;
|
export default broadcastGraphicsSlice.reducer;
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
import { CourseFlag, RootState } from "../../types/state";
|
import { CourseFlag, CarStatus, RootState, Tyre, TyreCompound, CarNotice } from "../../types/state";
|
||||||
import { cloneDriver } from "../../utils/dataLookup";
|
import { cloneDriver } from "../../utils/dataLookup";
|
||||||
|
|
||||||
|
const DEFAULT_TYRE: Tyre = {
|
||||||
|
compound: TyreCompound.Medium,
|
||||||
|
age: 0,
|
||||||
|
new: true,
|
||||||
|
};
|
||||||
|
|
||||||
const initialState: RootState["event"] = {
|
const initialState: RootState["event"] = {
|
||||||
trackName: "Melbourne",
|
trackName: "Circuit de Spa-Franchorchamps",
|
||||||
|
trackLength: 7004,
|
||||||
courseStatus: {
|
courseStatus: {
|
||||||
courseFlag: "green",
|
courseFlag: "green",
|
||||||
sectorFlags: ["green", "green", "green"],
|
sectorFlags: ["green", "green", "green"],
|
||||||
@@ -18,28 +25,170 @@ const initialState: RootState["event"] = {
|
|||||||
currentLap: 1,
|
currentLap: 1,
|
||||||
lapCount: 10,
|
lapCount: 10,
|
||||||
},
|
},
|
||||||
|
leaderGridSpot: 0,
|
||||||
grid: [
|
grid: [
|
||||||
{ position: 1, driver: cloneDriver("verstappen") },
|
{
|
||||||
{ position: 2, driver: cloneDriver("hamilton") },
|
position: 1,
|
||||||
{ position: 3, driver: cloneDriver("bottas") },
|
status: CarStatus.Normal,
|
||||||
{ position: 4, driver: cloneDriver("perez") },
|
tyre: DEFAULT_TYRE,
|
||||||
{ position: 5, driver: cloneDriver("sainz") },
|
notices: [CarNotice.FastestLap],
|
||||||
{ position: 6, driver: cloneDriver("norris") },
|
distance: 2000 * 4,
|
||||||
{ position: 7, driver: cloneDriver("leclerc") },
|
driver: cloneDriver("verstappen"),
|
||||||
{ position: 8, driver: cloneDriver("ricciardo") },
|
},
|
||||||
{ position: 9, driver: cloneDriver("gasly") },
|
{
|
||||||
{ position: 10, driver: cloneDriver("alonso") },
|
position: 2,
|
||||||
{ position: 11, driver: cloneDriver("ocon") },
|
status: CarStatus.Normal,
|
||||||
{ position: 12, driver: cloneDriver("vettel") },
|
tyre: DEFAULT_TYRE,
|
||||||
{ position: 13, driver: cloneDriver("stroll") },
|
notices: [],
|
||||||
{ position: 14, driver: cloneDriver("tsunoda") },
|
distance: 1900 * 4,
|
||||||
{ position: 15, driver: cloneDriver("russell") },
|
driver: cloneDriver("hamilton"),
|
||||||
{ position: 16, driver: cloneDriver("raikkonen") },
|
},
|
||||||
{ position: 17, driver: cloneDriver("latifi") },
|
{
|
||||||
{ position: 18, driver: cloneDriver("giovinazzi") },
|
position: 3,
|
||||||
{ position: 19, driver: cloneDriver("schumacher") },
|
status: CarStatus.Normal,
|
||||||
{ position: 20, driver: cloneDriver("mazepin") },
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1800 * 4,
|
||||||
|
driver: cloneDriver("bottas"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 4,
|
||||||
|
status: CarStatus.Retired,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1700 * 4,
|
||||||
|
driver: cloneDriver("perez"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 5,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1600 * 4,
|
||||||
|
driver: cloneDriver("sainz"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 6,
|
||||||
|
status: CarStatus.Retired,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1500 * 4,
|
||||||
|
driver: cloneDriver("norris"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 7,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1400 * 4,
|
||||||
|
driver: cloneDriver("leclerc"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 8,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1300 * 4,
|
||||||
|
driver: cloneDriver("ricciardo"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 9,
|
||||||
|
status: CarStatus.DidNotStart,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1200 * 4,
|
||||||
|
driver: cloneDriver("gasly"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 10,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1100 * 4,
|
||||||
|
driver: cloneDriver("alonso"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 11,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 1000 * 4,
|
||||||
|
driver: cloneDriver("ocon"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 12,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 900 * 4,
|
||||||
|
driver: cloneDriver("vettel"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 13,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 800 * 4,
|
||||||
|
driver: cloneDriver("stroll"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 14,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 700 * 4,
|
||||||
|
driver: cloneDriver("tsunoda"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 15,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 600 * 4,
|
||||||
|
driver: cloneDriver("russell"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 16,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 500 * 4,
|
||||||
|
driver: cloneDriver("raikkonen"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 17,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 400 * 4,
|
||||||
|
driver: cloneDriver("latifi"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 18,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 300 * 4,
|
||||||
|
driver: cloneDriver("giovinazzi"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 19,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 200 * 4,
|
||||||
|
driver: cloneDriver("schumacher"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: 20,
|
||||||
|
status: CarStatus.Normal,
|
||||||
|
tyre: DEFAULT_TYRE,
|
||||||
|
notices: [],
|
||||||
|
distance: 100 * 4,
|
||||||
|
driver: cloneDriver("mazepin"),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
lastUpdate: Date.now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const eventSlice = createSlice({
|
export const eventSlice = createSlice({
|
||||||
@@ -48,11 +197,40 @@ export const eventSlice = createSlice({
|
|||||||
reducers: {
|
reducers: {
|
||||||
setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
|
setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
|
||||||
state.courseStatus.courseFlag = action.payload;
|
state.courseStatus.courseFlag = action.payload;
|
||||||
|
state.lastUpdate = Date.now();
|
||||||
|
},
|
||||||
|
refreshRunningOrder: (state) => {
|
||||||
|
const sortingGrid = state.grid.map((car, index) => ({
|
||||||
|
gridSpot: index,
|
||||||
|
distance: car.distance,
|
||||||
|
status: car.status,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const add = (status: CarStatus) => {
|
||||||
|
if (status === CarStatus.Retired) {
|
||||||
|
return 1000000;
|
||||||
|
} else if (status === CarStatus.DidNotStart) {
|
||||||
|
return 2000000;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
sortingGrid.sort((a, b) =>
|
||||||
|
// Retired cars go to the end but still maintain their own order.
|
||||||
|
(b.distance - add(b.status)) - (a.distance - add(a.status)),
|
||||||
|
);
|
||||||
|
|
||||||
|
sortingGrid.forEach((entry, sortedPosition) => {
|
||||||
|
state.grid[entry.gridSpot].position = sortedPosition + 1;
|
||||||
|
});
|
||||||
|
state.leaderGridSpot = sortingGrid[0].gridSpot;
|
||||||
|
state.lastUpdate = Date.now();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
setCourseFlag,
|
setCourseFlag,
|
||||||
|
refreshRunningOrder,
|
||||||
} = eventSlice.actions;
|
} = eventSlice.actions;
|
||||||
export default eventSlice.reducer;
|
export default eventSlice.reducer;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 46 43" clip-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><path fill="#fff" d="M23.022 5.476c-10.31 0-18.691 8.38-18.691 18.691 0 10.31 8.38 18.648 18.691 18.648 10.31 0 18.647-8.337 18.647-18.648 0-10.31-8.336-18.691-18.647-18.691zm0 4.684c7.718 0 13.963 6.29 13.963 14.007 0 7.718-6.245 13.964-13.963 13.964-7.717 0-13.963-6.246-13.963-13.964 0-7.717 6.246-14.007 13.963-14.007z"/><path fill="#fff" d="M19.599 24.145a3.401 3.401 0 014.105-3.328c.554.117 4.578-4.75 6.739-5.193.372-.076.597.037.832.27.197.198.357.394.325.687-.225 2.077-5.453 6.164-5.314 6.684A3.405 3.405 0 0123 27.546a3.401 3.401 0 01-3.401-3.4zM38.538 5.998l2.587 2.542a1.821 1.821 0 01-2.553 2.598l-2.586-2.542a1.821 1.821 0 112.553-2.598zM20.788.186c1.97 0 2.522.024 4.45.024 1.926 0 2.228.99 2.221 2.196-.007 1.206-.167 2.171-2.247 2.171s-2.374-.024-4.45-.024c-2.075 0-2.228-.99-2.221-2.196.007-1.206.276-2.171 2.247-2.171z"/></svg>
|
||||||
|
After Width: | Height: | Size: 975 B |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:vectornator="http://vectornator.io" viewBox="0 0 510.3 510.3" clip-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><defs><linearGradient y1="-.036" id="prefix__a" x1="222.792" y2="-20.972" x2="243.728" gradientUnits="userSpaceOnUse" gradientTransform="matrix(4.11037 0 0 -4.11037 -703.579 188.953)"><stop stop-color="#396" offset="0"/><stop stop-color="#004f32" offset="1"/><stop stop-color="#004f32" offset="1"/></linearGradient></defs><g vectornator:layerName="Layer 1"><path d="M255.22 291.823c-.93 0-1.614.696-1.622.712-.04.033-16.515 15.753-16.515 15.753-6.075 5.864-14.14 3.41-15.002 3.123 0 0-70.419-19.209-70.429-19.216-13.438-4.054-16.108-8.427-18.165-13.738 0 0-1.195-3.302-4.119-4.167 0 0-86.082-25.271-86.09-25.271-3.513-1.084-5.446-2.075-6.827-4.75 0 0-4.725-8.319-4.74-8.343-1.048-1.994-2.947-2.205-3.057-2.221-6.51-.879-8.419-4.509-9.226-6.054l-3.84-6.744c-1.201-2.09-2.918-2.267-2.972-2.273-3.702-.234-5.463-1.168-6.994-3.682 0 0-3.754-6.243-3.77-6.275-1.845-3.409-1.207-5.849-.356-7.298 1.795-2.97 5.077-3.195 6.394-3.242h205.837c5.828 0 10.537 1.766 14.019 5.258 2.501 2.492 4.223 5.744 5.114 9.66.016.092.258.91 2.02.91h40.684c1.763 0 2.004-.816 2.019-.91.892-3.916 2.614-7.168 5.115-9.66 3.481-3.492 8.189-5.258 14.02-5.258h205.837c1.317.045 4.597.272 6.391 3.241.853 1.448 1.489 3.888-.356 7.298-.016.031-3.77 6.275-3.77 6.275-1.531 2.513-3.291 3.447-6.994 3.682-.052.006-1.772.183-2.972 2.272l-3.84 6.744c-.807 1.546-2.715 5.176-9.225 6.055-.109.016-2.008.227-3.058 2.221-.015.023-4.739 8.343-4.739 8.343-1.381 2.674-3.314 3.667-6.825 4.75-.006 0-86.09 25.27-86.09 25.27-2.924.865-4.119 4.167-4.119 4.167-2.055 5.312-4.725 9.685-18.165 13.739-.008.006-70.429 19.216-70.429 19.216-.861.286-8.927 2.74-15.002-3.124 0 0-16.473-15.722-16.517-15.753-.006-.016-.689-.712-1.62-.712h-.005v.002z"/><path d="M281.323 213.89c.721-3.189 2.097-5.804 4.074-7.782 2.737-2.742 6.551-4.137 11.312-4.137h94.558c-3.25 2.432-4.956 5.508-5.07 5.713a154.197 154.197 0 01-4.09 7.143H280.99c.209-.367.334-.937.333-.937zm223.896-7.047l-3.691 6.139c-.69 1.138-1.117 1.653-3.954 1.833l-111.984.015a160.626 160.626 0 003.228-5.721c.031-.058 3.998-7.127 11.041-7.127l102.587-.01c1.076.045 2.474.166 3.214 1.387.089.165.3.506.3 1.12 0 .545-.173 1.319-.741 2.364zm-13.695 12.17l-3.91 6.864c-.534 1.015-1.356 2.584-3.968 3.487-2.184.545-6.529.198-8.033.015l-95.25-6.328a172.443 172.443 0 003.412-5.249h108.572a9.578 9.578 0 00-.823 1.211zm-16.193 15.123c.025-.03-3.746 6.609-4.529 7.987-.193.258-1.266 1.424-4.754.961l-91.272-12.244a165.471 165.471 0 003.549-4.828l96.956 6.433c.142.017.551.062 1.134.114a8.117 8.117 0 00-1.084 1.577zm-31.391 17.716c-3.436.91-10.157-.121-12.49-.606l-62.718-12.891a167.207 167.207 0 003.94-4.793l91.661 12.303-20.393 5.987zm-31.089 9.123c-4.41 1.181-10.166-.729-10.221-.745l-.069-.021s-.007-.008-.015-.008l-41.978-12.949a165.125 165.125 0 005.92-6.319l64.361 13.229c.141.022 1.459.294 3.31.554l-21.308 6.259zm-32.792 9.631c-2.979.811-7.373-.91-8.83-1.645 0 0-11.234-5.258-22.769-10.654a153.32 153.32 0 009.715-8.675l43.532 13.434c.085.031.876.289 2.089.562l-23.737 6.978zm-6.719 6.57c-1.268 3.25-2.593 6.598-11.522 9.953-3.687 1.145-8.071-2.114-8.109-2.15-.015-.016-9.956-7.131-21.277-15.231a147.183 147.183 0 0013.438-9.372l24.054 11.26c.133.067 2.614 1.32 5.618 1.88-1.436 1.636-2.086 3.326-2.202 3.66zm-33.646 16.261l-3.352.909c-2.823.676-6.267-2.121-7.368-3.283 0 0-5.41-5.629-12.363-12.888a140.233 140.233 0 0013.035-6.751l22.294 15.951c.091.075 1.364 1.029 3.235 1.841a26228.92 26228.92 0 00-15.481 4.221zm-29.475 8.039c-2.354.371-5.085-3.492-5.876-4.933l-6.724-11.38a138.062 138.062 0 0016.08-5.713l13.115 13.685c.115.114 1.567 1.621 3.672 2.811l-20.267 5.53zm-22.321 6.083c-1.584.365-2.921.205-4.071-.489-2.467-1.51-3.288-4.98-3.333-5.184l-3.43-12.375a148.085 148.085 0 0017.58-3.522l7.113 12.042c.244.43 1.688 2.947 3.851 4.705l-17.71 4.823zm-14.466-4.49s-9.537-9.102-12.772-12.18c4.539-.158 9.018-.491 13.417-1.007l3.506 12.653c.1.44.801 3.214 2.748 5.42-2.687-.765-3.502-1.561-6.899-4.886zm-16.72-15.075v-38.551h6.153l10.405 37.538c-5.415.621-10.933.962-16.558 1.013zm-19.544-1.013l10.41-37.538h6.155v38.547a158.517 158.517 0 01-16.565-1.009zm-2.733 18.534a9.754 9.754 0 01-4.331 2.441c1.962-2.213 2.644-4.994 2.747-5.425l3.508-12.632c4.398.507 8.878.84 13.415.992-3.633 3.453-15.339 14.624-15.339 14.624zm-4.492-3.652c0 .037-.808 3.66-3.339 5.207-1.148.694-2.481.855-4.065.489l-17.711-4.825c2.163-1.767 3.622-4.282 3.872-4.744-.008.008 3-5.077 7.081-11.995a146.225 146.225 0 0017.591 3.515l-3.429 12.353zm-29.726-.387l-20.266-5.532c2.102-1.196 3.56-2.704 3.671-2.817 0 0 5.793-6.049 13.113-13.679a139.106 139.106 0 0016.076 5.721l-6.696 11.345c-.815 1.468-3.546 5.333-5.898 4.962zm-26.128-7.13l-18.83-5.13a16.711 16.711 0 003.266-1.865c-.016.016 10.52-7.524 22.263-15.925a141.832 141.832 0 0013.043 6.749l-12.371 12.888c-1.099 1.162-4.545 3.959-7.371 3.283zm-25.493-7.215c-8.893-3.357-10.226-6.696-11.489Line truncated
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 510.3 510.3" xmlns:vectornator="http://vectornator.io" clip-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><defs><linearGradient x1="222.792" y1="-.036" gradientTransform="matrix(4.11037 0 0 -4.11037 -703.579 188.953)" id="prefix__a" y2="-20.972" x2="243.728" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#396"/><stop offset="1" stop-color="#004f32"/><stop stop-color="#004f32" offset="1"/></linearGradient></defs><g vectornator:layerName="Layer 1" fill-rule="evenodd"><path d="M255.22 291.823c-.93 0-1.614.696-1.622.712-.04.033-16.515 15.753-16.515 15.753-6.075 5.864-14.14 3.41-15.002 3.123 0 0-70.419-19.209-70.429-19.216-13.438-4.054-16.108-8.427-18.165-13.738 0 0-1.195-3.302-4.119-4.167 0 0-86.082-25.271-86.09-25.271-3.513-1.084-5.446-2.075-6.827-4.75 0 0-4.725-8.319-4.74-8.343-1.048-1.994-2.947-2.205-3.057-2.221-6.51-.879-8.419-4.509-9.226-6.054l-3.84-6.744c-1.201-2.09-2.918-2.267-2.972-2.273-3.702-.234-5.463-1.168-6.994-3.682 0 0-3.754-6.243-3.77-6.275-1.845-3.409-1.207-5.849-.356-7.298 1.795-2.97 5.077-3.195 6.394-3.242h205.837c5.828 0 10.537 1.766 14.019 5.258 2.501 2.492 4.223 5.744 5.114 9.66.016.092.258.91 2.02.91h40.684c1.763 0 2.004-.816 2.019-.91.892-3.916 2.614-7.168 5.115-9.66 3.481-3.492 8.189-5.258 14.02-5.258h205.837c1.317.045 4.597.272 6.391 3.241.853 1.448 1.489 3.888-.356 7.298-.016.031-3.77 6.275-3.77 6.275-1.531 2.513-3.291 3.447-6.994 3.682-.052.006-1.772.183-2.972 2.272l-3.84 6.744c-.807 1.546-2.715 5.176-9.225 6.055-.109.016-2.008.227-3.058 2.221-.015.023-4.739 8.343-4.739 8.343-1.381 2.674-3.314 3.667-6.825 4.75-.006 0-86.09 25.27-86.09 25.27-2.924.865-4.119 4.167-4.119 4.167-2.055 5.312-4.725 9.685-18.165 13.739-.008.006-70.429 19.216-70.429 19.216-.861.286-8.927 2.74-15.002-3.124 0 0-16.473-15.722-16.517-15.753-.006-.016-.689-.712-1.62-.712h-.005v.002z"/><path fill="url(#prefix__a)" d="M153.29 246.465l-.044-.045v-28.605h203.931v28.619c-.006.015-.016.015-.022.023l-203.865.008z"/><path d="M166.796 222.383h-.851l-8.715 19.496h2.36l.038-.112c.705-2.373 1.614-4.646 2.496-6.826l.183-.463h6.739a102.476 102.476 0 012.842 7.295l.039.106h3.258l-8.389-19.496zm-3.829 10.608c.178-.43 2.465-5.789 2.737-6.424.269.635 2.601 5.994 2.784 6.424h-5.521zm13.157 7.501l.072.075c1.029 1.123 3.35 1.647 4.598 1.647 4.089 0 6.952-2.639 6.952-6.424 0-3.139-2.375-4.063-4.671-4.972-2.04-.812-3.979-1.561-3.979-3.879 0-1.759 1.387-3.031 3.289-3.031 1.52 0 2.668.803 3.25 2.271l.039.105h.519l.815-2.46-.091-.085c-1.11-1.001-2.82-1.356-4.036-1.356-3.812 0-6.271 2.129-6.271 5.434 0 3.364 2.509 4.34 4.717 5.221 1.998.772 3.872 1.515 3.872 3.827 0 2.144-1.599 3.833-3.635 3.833-1.866 0-3.103-.804-4.309-2.773l-.047-.075h-.52l-.564 2.642zm27.01-17.707h-14.337v2.008l.185-.015a51.352 51.352 0 015.828-.335v17.497h2.754v-17.488c1.947 0 3.807.112 5.546.326l.194.022v-2.015h-.17zm9.877-.402c-6.081 0-10.336 4.1-10.336 9.957 0 5.909 4.137 9.872 10.283 9.872 6.353 0 10.629-4.138 10.629-10.29.002-6.592-5.315-9.539-10.576-9.539zm5.091 16.428c-1.353 1.431-3.05 2.16-5.069 2.16-4.452 0-7.331-3.257-7.331-8.296 0-5.584 2.909-9.048 7.581-9.048 2.204 0 4.284.969 5.57 2.59 1.412 1.803 1.7 3.683 1.7 5.934.008.122.015.258.015.388 0 1.831-.746 4.431-2.466 6.272zm24.581-16.026h-1.708v14.132h-.032c-.098-.115-13.044-14.132-13.044-14.132h-1.317v19.094h1.879v-14.775h.039c.1.114 11.799 13.064 11.799 13.064l1.467 1.713h1.087v-19.096h-.17zm30.852 0h-.675l-4.625 8.387s-2.927 5.335-3.192 5.813c-2.853-4.759-5.423-9.767-7.61-14.109l-.045-.091h-.971l-.016.16c-.272 2.82-1.914 14.312-2.632 18.745l-.038.189h2.315v-.164c0-2.69.477-6.7.984-10.952l.305-2.629c.324.62 3.916 7.442 5.288 10.253l1.553 3.198h.519l.044-.106c1.597-3.669 3.852-7.858 6.938-13.374.437 3.289 1.015 9.858 1.336 13.623l.017.153h2.925l-.025-.189c-.66-4.632-1.381-10.761-2.224-18.746l-.017-.159h-.154v-.002zm13.095-.402h-.857l-8.718 19.496h2.374l.031-.112c.709-2.395 1.622-4.675 2.509-6.874 0 0 .109-.273.163-.416h6.744a103.37 103.37 0 012.837 7.294l.038.107h3.261l-8.382-19.495zm-3.834 10.608c.179-.43 2.467-5.789 2.74-6.424l2.785 6.424h-5.525zm20.601-.545c3.445-.696 5.507-2.659 5.507-5.311 0-2.916-2.048-4.348-6.266-4.348h-5.984v19.094h2.748v-9.153h.802c.711.842 1.424 1.683 2.138 2.523-.009-.01 3.237 4.19 3.237 4.19l1.776 2.44h3.599c0-.002-7.23-9.033-7.557-9.435zm-3.995-1.09v-7.213c1.132-.053 2.889-.128 3.841.025 1.907.308 2.875 1.422 2.875 3.292 0 1.919-1.259 3.319-3.381 3.746-1.194.239-2.636.196-3.335.15zm25.397-8.571h-14.342v2.008l.187-.015a51.26 51.26 0 015.822-.335v17.497h2.768v-17.488c1.94 0 3.804.112 5.545.326l.192.022v-2.015h-.172zm2.435 19.094h2.598v-19.094h-2.598v19.094zm21.042-19.094v14.132h-.024c-.101-.115-13.044-14.132-13.044-14.132h-1.32v19.094h1.88v-14.775h.033c.1.114 11.815 13.064 11.815 13.064l1.467 1.713h1.071v-19.096h-1.878z" fill="#fff"/></g><g vectornator:layerName="Layer 2" fill="#fff"><path d="M237.168 286.981l10.41-37.538h6.155v38.547l-16.565-1.009zM150.264 231.885v4.712l-5.221 1.077-3.824-4.569 9.0Line truncated
|
||||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 187 KiB |
|
After Width: | Height: | Size: 229 KiB |
|
After Width: | Height: | Size: 276 KiB |
|
After Width: | Height: | Size: 86 KiB |
@@ -23,24 +23,53 @@ export const theme = {
|
|||||||
faintGrey: "#eee",
|
faintGrey: "#eee",
|
||||||
darkGrey: "#303030",
|
darkGrey: "#303030",
|
||||||
videoFrameBG: "#333",
|
videoFrameBG: "#333",
|
||||||
teams: {
|
teams: { // 2021 Season
|
||||||
alfaRomeo: "#900000",
|
alfaRomeo: "#900000",
|
||||||
alphaTauri: "#2b4562",
|
alphaTauri: "#2b4562",
|
||||||
alpine: "#0090ff",
|
alpine: "#0090ff",
|
||||||
astonMartin: "#006f62",
|
astonMartin: "#006f62",
|
||||||
ferrari: "#dc0000",
|
ferrari: "#dc0000",
|
||||||
haas: "#fff",
|
haas: "#ffffff",
|
||||||
mclaren: "#ff9800",
|
mclaren: "#ff9800",
|
||||||
mercedes: "#00d2be",
|
mercedes: "#00d2be",
|
||||||
redBull: "#0600ef",
|
redBull: "#0600ef",
|
||||||
williams: "#005aff",
|
williams: "#005aff",
|
||||||
},
|
},
|
||||||
|
logos: { // Colors provided by https://www.f1.daavs.org/credits
|
||||||
|
f1Red: "#ff1801",
|
||||||
|
dhlYellow: "#ffcc00",
|
||||||
|
dhlRed: "#d40511",
|
||||||
|
rolexGreen: "#006039",
|
||||||
|
rolexGold: "#a37e2c",
|
||||||
|
emiratesRed: "#d71a21",
|
||||||
|
pirelliRed: "#d52b1e",
|
||||||
|
pirelliYellow: "#fed100",
|
||||||
|
},
|
||||||
|
laps: { // Colors provided by https://www.f1.daavs.org/credits
|
||||||
|
purple: "#a700ff",
|
||||||
|
green: "#44d745",
|
||||||
|
yellow: "#f8d500",
|
||||||
|
red: "#be2c30",
|
||||||
|
},
|
||||||
|
tyres: { // Colors provided by https://www.f1.daavs.org/credits
|
||||||
|
soft: "#e93324",
|
||||||
|
medium: "#f3fd54",
|
||||||
|
hard: "#ffffff",
|
||||||
|
wet: "#518ed4",
|
||||||
|
intermediate: "#6ebe4f",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
fontSizes: {
|
fontSizes: {
|
||||||
label: "0.9em",
|
label: "0.9em",
|
||||||
selector: "0.9em",
|
selector: "0.9em",
|
||||||
},
|
},
|
||||||
design: {
|
design: {
|
||||||
|
timingTower: {
|
||||||
|
rowHeightPx: 36.5,
|
||||||
|
rowLeftHalfWidthPx: 147,
|
||||||
|
rowRightHalfWidthPx: 108,
|
||||||
|
retiredTopGapPx: 3,
|
||||||
|
},
|
||||||
button: {
|
button: {
|
||||||
borderRadius: "0.25rem",
|
borderRadius: "0.25rem",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Milliseconds, Optional } from "./util";
|
import { Meters, Milliseconds, Optional } from "./util";
|
||||||
import { Corner, Fraction } from "./style";
|
import { Corner, Fraction } from "./style";
|
||||||
|
|
||||||
export interface RootState {
|
export interface RootState {
|
||||||
@@ -60,7 +60,7 @@ export interface OverlayTool {
|
|||||||
visible: boolean;
|
visible: boolean;
|
||||||
}
|
}
|
||||||
export type OverlayId = string;
|
export type OverlayId = string;
|
||||||
export type OverlayIds = Array<OverlayId>;
|
export type OverlayIds = OverlayId[];
|
||||||
export interface OverlayPosition { x: number; y: number; }
|
export interface OverlayPosition { x: number; y: number; }
|
||||||
export interface OverlayItem {
|
export interface OverlayItem {
|
||||||
position: OverlayPosition;
|
position: OverlayPosition;
|
||||||
@@ -70,10 +70,14 @@ export interface OverlayItem {
|
|||||||
// Event State
|
// Event State
|
||||||
export interface Event {
|
export interface Event {
|
||||||
trackName: string;
|
trackName: string;
|
||||||
|
trackLength: Meters;
|
||||||
courseStatus: CourseStatus;
|
courseStatus: CourseStatus;
|
||||||
mode: EventMode;
|
mode: EventMode;
|
||||||
progress: EventProgress;
|
progress: EventProgress;
|
||||||
|
leaderGridSpot: GridSpot;
|
||||||
grid: Grid;
|
grid: Grid;
|
||||||
|
// gridPositions: GridSpot[];
|
||||||
|
lastUpdate: number;
|
||||||
}
|
}
|
||||||
export interface EventProgress {
|
export interface EventProgress {
|
||||||
startTime: Milliseconds;
|
startTime: Milliseconds;
|
||||||
@@ -91,8 +95,8 @@ export type EventMode =
|
|||||||
| "q2"
|
| "q2"
|
||||||
| "q3";
|
| "q3";
|
||||||
export interface CourseStatus {
|
export interface CourseStatus {
|
||||||
courseFlag: CourseFlags;
|
courseFlag: CourseFlag;
|
||||||
sectorFlags: Array<CourseFlag>;
|
sectorFlags: CourseFlag[];
|
||||||
safetyCar: SafetyCarStatus;
|
safetyCar: SafetyCarStatus;
|
||||||
virtualSafetyCar: VirtualSafetyCarStatus;
|
virtualSafetyCar: VirtualSafetyCarStatus;
|
||||||
}
|
}
|
||||||
@@ -106,14 +110,16 @@ export type CourseFlag =
|
|||||||
| "redYellow";
|
| "redYellow";
|
||||||
export type SafetyCarStatus = "clear" | "starting" | "out" | "ending";
|
export type SafetyCarStatus = "clear" | "starting" | "out" | "ending";
|
||||||
export type VirtualSafetyCarStatus = "clear" | "out" | "ending";
|
export type VirtualSafetyCarStatus = "clear" | "out" | "ending";
|
||||||
export type Grid = Array<Car>; // Grid order does not change.
|
export type Grid = Car[]; // Grid order does not change.
|
||||||
|
export type GridSpot = number;
|
||||||
export interface Car {
|
export interface Car {
|
||||||
position: number;
|
position: number;
|
||||||
driver: Driver;
|
driver: Driver;
|
||||||
// status: ???; // retired
|
status: CarStatus;
|
||||||
|
tyre: Tyre;
|
||||||
// flags: ???, // blue, red, meatball, black/white, black
|
// flags: ???, // blue, red, meatball, black/white, black
|
||||||
// notices: ???; // Penalties, warnings, investigations, blue flags, etc
|
notices: CarNotice[];
|
||||||
// distance: number;
|
distance: Meters;
|
||||||
}
|
}
|
||||||
export interface Driver {
|
export interface Driver {
|
||||||
id: DriverId;
|
id: DriverId;
|
||||||
@@ -150,6 +156,44 @@ export type DriverId =
|
|||||||
| "vettel"
|
| "vettel"
|
||||||
| "zhou";
|
| "zhou";
|
||||||
|
|
||||||
|
export enum CarStatus {
|
||||||
|
Normal,
|
||||||
|
OnGrid,
|
||||||
|
Finished,
|
||||||
|
Retired,
|
||||||
|
InPit,
|
||||||
|
OutLap,
|
||||||
|
InLap,
|
||||||
|
DidNotStart,
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum CarNotice {
|
||||||
|
FastestLap,
|
||||||
|
BlueFlag,
|
||||||
|
BlackAndWhiteFlag,
|
||||||
|
BlackFlag,
|
||||||
|
BlackWithOrangeCircleFlag,
|
||||||
|
UnderInvestigation,
|
||||||
|
PenaltyDriveThrough,
|
||||||
|
Penalty5Seconds,
|
||||||
|
Penalty10Seconds,
|
||||||
|
Penalty10SecondsStopGo,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Tyre {
|
||||||
|
compound: TyreCompound,
|
||||||
|
age: number,
|
||||||
|
new: boolean,
|
||||||
|
}
|
||||||
|
export enum TyreCompound {
|
||||||
|
Soft,
|
||||||
|
Medium,
|
||||||
|
Hard,
|
||||||
|
Wet,
|
||||||
|
Intermediate,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface Team {
|
export interface Team {
|
||||||
id: TeamId;
|
id: TeamId;
|
||||||
shortName: TeamShortName;
|
shortName: TeamShortName;
|
||||||
@@ -193,7 +237,7 @@ export type TeamFullName =
|
|||||||
|
|
||||||
// Broadcast Director
|
// Broadcast Director
|
||||||
export interface BroadcastDirector {
|
export interface BroadcastDirector {
|
||||||
selectedCars: Array<Car>;
|
selectedCars: Car[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast Graphics
|
// Broadcast Graphics
|
||||||
@@ -213,14 +257,52 @@ export interface BGBaseState {
|
|||||||
export type OpenState = number;
|
export type OpenState = number;
|
||||||
|
|
||||||
export interface BroadcastGraphics {
|
export interface BroadcastGraphics {
|
||||||
// timingBoard: BGTimingBoard;
|
timingBoard: BGTimingBoard;
|
||||||
// statusIndicator: BGStatusIndicator;
|
|
||||||
// indicators: BGIndicators
|
// indicators: BGIndicators
|
||||||
chyrons: Optional<BGChyrons>;
|
chyrons: Optional<BGChyrons>;
|
||||||
// gems: BGGems
|
// gems: BGGems
|
||||||
// toasts: BGToasts;
|
// toasts: BGToasts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Timing Board
|
||||||
|
export interface BGTimingBoard extends BGBaseState {
|
||||||
|
statusIndicator: BGStatusIndicator;
|
||||||
|
timingTower: BGTimingTower;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status Indicator
|
||||||
|
export interface BGStatusIndicator {
|
||||||
|
mode: BGStatusIndicatorModes;
|
||||||
|
}
|
||||||
|
export enum BGStatusIndicatorModes {
|
||||||
|
NormalNarrow, // "LAP" above "##/##" lap count.
|
||||||
|
NormalWide, // "LAP" to the left of "##/##" lap count.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timing Tower
|
||||||
|
export interface BGTimingTower {
|
||||||
|
open: OpenState;
|
||||||
|
displayMode: BGTimingTowerDisplayModes;
|
||||||
|
splitsMode: BGTimingTowerSplitsMode,
|
||||||
|
focusedCars: Car[],
|
||||||
|
focusedCarsMode: BGTimingTowerFocusedCarsMode,
|
||||||
|
}
|
||||||
|
export enum BGTimingTowerDisplayModes {
|
||||||
|
Hidden,
|
||||||
|
LeftOnly,
|
||||||
|
LeftAndRight,
|
||||||
|
FullLeft,
|
||||||
|
}
|
||||||
|
export enum BGTimingTowerSplitsMode {
|
||||||
|
Leader, // Leader timing.
|
||||||
|
Interval, // Interval timing.
|
||||||
|
}
|
||||||
|
export enum BGTimingTowerFocusedCarsMode {
|
||||||
|
None, // When no special treatments are made.
|
||||||
|
Portrait, // When it shows the portrait of the driver.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Chyrons
|
// Chyrons
|
||||||
export type BGChyronMode = string;
|
export type BGChyronMode = string;
|
||||||
export type BGChyronSubMode = string;
|
export type BGChyronSubMode = string;
|
||||||
@@ -234,7 +316,7 @@ export interface BGChyrons extends BGBaseState {
|
|||||||
// sponsorGem: BGSponsorGem;
|
// sponsorGem: BGSponsorGem;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BGChyronDriver extends BGChyron {
|
export interface BGChyronDriver {
|
||||||
car: Car;
|
car: Car;
|
||||||
flagMode: FlagMode;
|
flagMode: FlagMode;
|
||||||
showPosFlag: boolean;
|
showPosFlag: boolean;
|
||||||
@@ -9,3 +9,9 @@ export type Milliseconds = number;
|
|||||||
* Type to remind you that we're dealing with seconds.
|
* Type to remind you that we're dealing with seconds.
|
||||||
*/
|
*/
|
||||||
export type Seconds = number;
|
export type Seconds = number;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type to remind you that we're dealing with meters.
|
||||||
|
*/
|
||||||
|
export type Meters = number;
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import { andMatch, andWith, orMatch, orWith } from "./common";
|
||||||
|
|
||||||
|
describe("common", () => {
|
||||||
|
describe("andMatch", () => {
|
||||||
|
describe("detects correct matches", () => {
|
||||||
|
it("works with number", () => {
|
||||||
|
expect(andMatch(5, 2 + 3, 5 + 0, 6 - 1)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("works with boolean", () => {
|
||||||
|
expect(andMatch(true, 1 == 1, !false, !!1)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("detects incorrect matches", () => {
|
||||||
|
it("works with number", () => {
|
||||||
|
expect(andMatch(5, 4 + 1, 3 + 0)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("works with boolean", () => {
|
||||||
|
expect(andMatch(true, !true, !!0)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("sensibly handles odd situations", () => {
|
||||||
|
it("returns truthiness of self when no rights given", () => {
|
||||||
|
expect(andMatch(5)).toBe(true);
|
||||||
|
expect(andMatch(0)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("orMatch", () => {
|
||||||
|
describe("detects correct matches", () => {
|
||||||
|
it("works with number", () => {
|
||||||
|
expect(orMatch(5, 0, 0, 6 - 1)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("works with boolean", () => {
|
||||||
|
expect(orMatch(true, false, !false)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("detects incorrect matches", () => {
|
||||||
|
it("works with number", () => {
|
||||||
|
expect(orMatch(5, 2, 3)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("works with boolean", () => {
|
||||||
|
expect(orMatch(false, true, !!1)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("sensibly handles odd situations", () => {
|
||||||
|
it("returns truthiness of self when no rights given", () => {
|
||||||
|
expect(orMatch(5)).toBe(true);
|
||||||
|
expect(orMatch(0)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const greaterCompare = (l: number, r: number) => l > r;
|
||||||
|
describe("andWith", () => {
|
||||||
|
describe("detects correct matches", () => {
|
||||||
|
it("works with number", () => {
|
||||||
|
expect(andWith(10, greaterCompare, 5, 3, 9)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("detects incorrect matches", () => {
|
||||||
|
it("works with number", () => {
|
||||||
|
expect(andWith(5, greaterCompare, 4, 10)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("sensibly handles odd situations", () => {
|
||||||
|
it("returns truthiness of self when no rights given", () => {
|
||||||
|
expect(andWith(5, greaterCompare)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("orWith", () => {
|
||||||
|
describe("detects correct matches", () => {
|
||||||
|
it("works with number", () => {
|
||||||
|
expect(orWith(5, greaterCompare, 10, 15, 3)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("detects incorrect matches", () => {
|
||||||
|
it("works with number", () => {
|
||||||
|
expect(orWith(5, greaterCompare, 10, 20)).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("sensibly handles odd situations", () => {
|
||||||
|
it("returns truthiness of self when no rights given", () => {
|
||||||
|
expect(orWith(5, greaterCompare)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Helpful utility function to save on ugly looking chains of && checks.
|
||||||
|
* Before: (myObj.modeA === MyModes.On && myObj.modeB === MyModes.On)
|
||||||
|
* After: andMatch(MyModes.On, myObj.modeA, myObj.modeB)
|
||||||
|
* Uses strict equals.
|
||||||
|
* @param left The argument you're checking.
|
||||||
|
* @param rights n arguments you're checking against.
|
||||||
|
* @returns True if all match. If no rights given returns truthiness of left.
|
||||||
|
*/
|
||||||
|
export function andMatch<T>(left: T, ...rights: T[]): boolean {
|
||||||
|
if (rights.length === 0) {
|
||||||
|
return !!left;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const right of rights) {
|
||||||
|
if (left !== right) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helpful utility function to save on ugly looking chains of || checks.
|
||||||
|
* @param left The argument you're checking.
|
||||||
|
* @param rights n arguments you're checking against.
|
||||||
|
* @returns True if any match. If no rights given returns truthiness of left.
|
||||||
|
*/
|
||||||
|
export function orMatch<T>(left: T, ...rights: T[]): boolean {
|
||||||
|
if (rights.length === 0) {
|
||||||
|
return !!left;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const right of rights) {
|
||||||
|
if (left === right) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helpful function that essentially repackages the functionality of Array.every()
|
||||||
|
* into a slightly more sensible form.
|
||||||
|
* @param left The argument you're checking.
|
||||||
|
* @param func Predicate that returns a boolean.
|
||||||
|
* @param rights n arguments you're checking against.
|
||||||
|
* @returns True if all match. If no rights given returns truthiness of left.
|
||||||
|
*/
|
||||||
|
export function andWith<T>(
|
||||||
|
left: T,
|
||||||
|
func: (l: T, r: T) => boolean,
|
||||||
|
...rights: T[]
|
||||||
|
): boolean {
|
||||||
|
if (rights.length === 0) {
|
||||||
|
return !!left;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const right of rights) {
|
||||||
|
if (!func(left, right)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helpful function that essentially repackages the functionality of Array.some()
|
||||||
|
* into a slightly more sensible form.
|
||||||
|
* @param left The argument you're checking.
|
||||||
|
* @param func Predicate that returns a boolean.
|
||||||
|
* @param rights n arguments you're checking against.
|
||||||
|
* @returns True if any match. If no rights given returns truthiness of left.
|
||||||
|
*/
|
||||||
|
export function orWith<T>(
|
||||||
|
left: T,
|
||||||
|
func: (l: T, r: T) => boolean,
|
||||||
|
...rights: T[]
|
||||||
|
): boolean {
|
||||||
|
if (rights.length === 0) {
|
||||||
|
return !!left;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const right of rights) {
|
||||||
|
if (func(left, right)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { drivers, teams, teamNumberStyles, teamFlagStyles } from "../domain/data/teams";
|
import { drivers, teams, teamNumberStyles, teamFlagStyles, teamGemStyles } from "../domain/data/teams";
|
||||||
import { DriverId, TeamId } from "../types/state";
|
import { DriverId, Team, TeamId } from "../types/state";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefer getting data from teams.ts through these simple getter functions.
|
* 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) {
|
export function getTeamFlagStyle(teamId: TeamId) {
|
||||||
return teamFlagStyles[teamId];
|
return teamFlagStyles[teamId];
|
||||||
}
|
}
|
||||||
|
export function getTeamGemStyle(teamId: TeamId) {
|
||||||
|
return teamGemStyles[teamId];
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { random } from "lodash";
|
||||||
|
import { Car, Grid } from "../types/state";
|
||||||
|
|
||||||
|
import { Meters } from "../types/util";
|
||||||
|
|
||||||
|
export function timeDiff(
|
||||||
|
front: Meters,
|
||||||
|
back: Meters,
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* Spa length in 2020 was 308,052m. Hamilton won it in 1:24:08.761.
|
||||||
|
* That's 3600 + 1440 + 8.761 = 5,048.761 seconds.
|
||||||
|
* 61.015 m/s average. So, let's do that.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return random(0.95, 1.05) * ((front - back) / 61.015);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function getCarAtPos(
|
||||||
|
grid: Grid,
|
||||||
|
targetPosition: number,
|
||||||
|
): Car {
|
||||||
|
const foundCar = grid.find(car => car.position === targetPosition);
|
||||||
|
if (!foundCar) {
|
||||||
|
return grid[0];
|
||||||
|
}
|
||||||
|
return foundCar;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { formatTime } from "./styling";
|
||||||
|
|
||||||
|
describe("styling", () => {
|
||||||
|
describe("formatTime", () => {
|
||||||
|
describe("works correctly with 60 limit", () => {
|
||||||
|
it("should format 65.32210101 to 1:05.322", () => {
|
||||||
|
expect(formatTime(65.32210101, 60)).toBe("1:05.322");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format 3.2009101 to 3.201", () => {
|
||||||
|
expect(formatTime(3.2009101, 60)).toBe("3.201");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format 50 to 50.000", () => {
|
||||||
|
expect(formatTime(50, 60)).toBe("50.000");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format 60 to 1:00.00", () => {
|
||||||
|
expect(formatTime(60, 60)).toBe("1:00.000");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("works correctly with 70 limit", () => {
|
||||||
|
it("should format 65.32210101 to 65.322", () => {
|
||||||
|
expect(formatTime(65.32210101, 70)).toBe("65.322");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format 73.2009101 to 1:13.201", () => {
|
||||||
|
expect(formatTime(73.2009101, 70)).toBe("1:13.201");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format 50 to 50.000", () => {
|
||||||
|
expect(formatTime(50, 70)).toBe("50.000");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format 70 to 1:10.00", () => {
|
||||||
|
expect(formatTime(70, 70)).toBe("1:10.000");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("works correctly with 50 limit", () => {
|
||||||
|
it("should format 65.32210101 to 1:05.322", () => {
|
||||||
|
expect(formatTime(65.32210101, 50)).toBe("1:05.322");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format 73.2009101 to 1:13.201", () => {
|
||||||
|
expect(formatTime(73.2009101, 50)).toBe("1:13.201");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should format 50 to 0:50.00", () => {
|
||||||
|
expect(formatTime(50, 50)).toBe("0:50.000");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -2,6 +2,7 @@ import { css }from "styled-components";
|
|||||||
import { clamp } from "lodash";
|
import { clamp } from "lodash";
|
||||||
|
|
||||||
import { Corner, Fraction, Placement, Px, TransitionArgs } from "../types/style";
|
import { Corner, Fraction, Placement, Px, TransitionArgs } from "../types/style";
|
||||||
|
import { Seconds } from "../types/util";
|
||||||
|
|
||||||
export function placementStyleRules(pos: Placement) {
|
export function placementStyleRules(pos: Placement) {
|
||||||
return css`
|
return css`
|
||||||
@@ -127,9 +128,22 @@ export function outlineClipPath(
|
|||||||
[0, height + outlineThickness],
|
[0, height + outlineThickness],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
// return [
|
* Converts amount of seconds that are over the limit to become a new format:
|
||||||
|
* If limit is 60, then 65.322 will become "1:05.322".
|
||||||
// ]
|
* You can set the limit to other than 60 to change the time when the new format
|
||||||
|
* is used.
|
||||||
|
* @param time Time to format given in seconds
|
||||||
|
* @param limit Bounds (exclusive) that will keep the format in seconds.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function formatTime(time: Seconds, limit: Seconds) {
|
||||||
|
if (time < limit) {
|
||||||
|
return String(time.toFixed(3));
|
||||||
|
}
|
||||||
|
const minutes = Math.floor(time / 60);
|
||||||
|
const seconds = time % 60;
|
||||||
|
return `${minutes}:${seconds.toFixed(3).padStart(6, "0")}`;
|
||||||
}
|
}
|
||||||