ISSUE-054 - Have static timing display mostly figured out.
Some subtle scaling was necessary to accomplish the proper spacing.
This commit is contained in:
1 parent
22ebab1101
commit
7507868dce
8 files changed
+134
-45
No files matched your search
@@ -4,6 +4,8 @@ import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphi
|
||||
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||
import { BGTimingTowerModes, Car, CarStatus } from "../../../../types/state";
|
||||
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";
|
||||
|
||||
@@ -15,6 +17,7 @@ import {
|
||||
RowRightHalf,
|
||||
RowRightHalfLayout,
|
||||
RowsContainer,
|
||||
TimeDiff,
|
||||
} from "./styles";
|
||||
|
||||
type TimingTowerProps = {
|
||||
@@ -39,6 +42,8 @@ export function TimingTower({
|
||||
}
|
||||
});
|
||||
|
||||
let forwardCarDistance = -1;
|
||||
|
||||
const buildRow = (
|
||||
car: Car,
|
||||
index: number,
|
||||
@@ -46,6 +51,32 @@ export function TimingTower({
|
||||
) => {
|
||||
const lastRow = index + 1 === count;
|
||||
|
||||
let leader = false;
|
||||
if (forwardCarDistance === -1) {
|
||||
leader = true;
|
||||
forwardCarDistance = car.distance;
|
||||
}
|
||||
|
||||
let rightHalfContent = "";
|
||||
let xScale = 1.0;
|
||||
if (leader) {
|
||||
rightHalfContent = timingBoard.timingTower.mode === BGTimingTowerModes.Leader
|
||||
? "Leader" : timingBoard.timingTower.mode === BGTimingTowerModes.Interval
|
||||
? "Interval" : "";
|
||||
} else if (car.status === CarStatus.Retired) {
|
||||
rightHalfContent = "OUT";
|
||||
} else {
|
||||
rightHalfContent = `+${formatTime(timeDiff(
|
||||
forwardCarDistance,
|
||||
car.distance,
|
||||
))}`;
|
||||
xScale = rightHalfContent.includes(".") && rightHalfContent.length > 7 ? 0.75 : 0.9;
|
||||
}
|
||||
|
||||
if (timingBoard.timingTower.mode === BGTimingTowerModes.Interval) {
|
||||
forwardCarDistance = car.distance;
|
||||
}
|
||||
|
||||
return (
|
||||
<RowContainer
|
||||
key={car.driver.id}
|
||||
@@ -54,11 +85,13 @@ export function TimingTower({
|
||||
wide={timingBoard.timingTower.mode !== BGTimingTowerModes.Minimum}
|
||||
>
|
||||
<RowLeftHalf
|
||||
roundedCorner={lastRow && orMatch(
|
||||
timingBoard.timingTower.mode,
|
||||
BGTimingTowerModes.Minimum,
|
||||
BGTimingTowerModes.FullName,
|
||||
)}
|
||||
roundedCornerBottom={
|
||||
lastRow && orMatch(
|
||||
timingBoard.timingTower.mode,
|
||||
BGTimingTowerModes.Minimum,
|
||||
BGTimingTowerModes.FullName,
|
||||
) ? 5 : undefined
|
||||
}
|
||||
>
|
||||
<RowLeftHalfLayout>
|
||||
<Spacer width="3px" />
|
||||
@@ -75,14 +108,22 @@ export function TimingTower({
|
||||
</RowLeftHalfLayout>
|
||||
</RowLeftHalf>
|
||||
<RowRightHalf
|
||||
roundedCorner={lastRow && orMatch(
|
||||
timingBoard.timingTower.mode,
|
||||
BGTimingTowerModes.Leader,
|
||||
BGTimingTowerModes.Interval,
|
||||
)}
|
||||
roundedCornerTop={
|
||||
index === 0 && car.status !== CarStatus.Retired
|
||||
? 5 : undefined
|
||||
}
|
||||
roundedCornerBottom={
|
||||
lastRow && orMatch(
|
||||
timingBoard.timingTower.mode,
|
||||
BGTimingTowerModes.Leader,
|
||||
BGTimingTowerModes.Interval,
|
||||
) ? 5 : undefined
|
||||
}
|
||||
>
|
||||
<RowRightHalfLayout>
|
||||
|
||||
<TimeDiff xScale={xScale}>
|
||||
{rightHalfContent}
|
||||
</TimeDiff>
|
||||
</RowRightHalfLayout>
|
||||
</RowRightHalf>
|
||||
</RowContainer>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import styled, { css } from "styled-components";
|
||||
|
||||
import { Fraction, Px } from "../../../../types/style";
|
||||
|
||||
export const RowsContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -25,14 +27,18 @@ export const RowContainer = styled.div<RowContainerProps>`
|
||||
|
||||
${({ topGap }) => topGap && css`margin-top: 3px;`}
|
||||
${({ bottomGap }) => bottomGap && css`margin-bottom: 3px;`}
|
||||
${({ retired }) => retired && css`opacity: 0.4;`}
|
||||
${({ retired }) => retired && css`opacity: 0.7;`}
|
||||
`;
|
||||
|
||||
type RoundedProp = {
|
||||
roundedCorner?: boolean;
|
||||
roundedCornerTop?: Px,
|
||||
roundedCornerBottom?: Px,
|
||||
};
|
||||
const Rounded = styled.div<RoundedProp>`
|
||||
${({ roundedCorner }) => roundedCorner && css`border-bottom-right-radius: 5px;`}
|
||||
${({ roundedCornerTop }) =>
|
||||
roundedCornerTop && css`border-top-right-radius: ${roundedCornerTop}px;`}
|
||||
${({ roundedCornerBottom }) =>
|
||||
roundedCornerBottom && css`border-bottom-right-radius: ${roundedCornerBottom}px;`}
|
||||
`;
|
||||
|
||||
export const RowLeftHalf = styled(Rounded)`
|
||||
@@ -43,7 +49,7 @@ export const RowLeftHalf = styled(Rounded)`
|
||||
width: 147px; // Future will be animated.
|
||||
height: 36px;
|
||||
|
||||
background-color: #000000cb
|
||||
background-color: #000000e5
|
||||
`;
|
||||
|
||||
export const RowLeftHalfLayout = styled.div`
|
||||
@@ -77,6 +83,7 @@ export const RowRightHalfLayout = styled.div`
|
||||
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding-right: 8px;
|
||||
`;
|
||||
|
||||
export const DriverName = styled.span`
|
||||
@@ -84,3 +91,18 @@ export const DriverName = styled.span`
|
||||
font-family: ${p => p.theme.fonts.f1Bold};
|
||||
font-size: 20px;
|
||||
`;
|
||||
|
||||
type TimeDiffProps = {
|
||||
xScale: 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: right;
|
||||
transform: scaleX(${({ xScale }) => xScale});
|
||||
`;
|
||||
Reference in new issue
Block a user