10 files changed
+327
-75
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { animated, easings, useSpring } from "@react-spring/web";
|
||||
import useMeasure from "react-use-measure";
|
||||
|
||||
import { Corner, Degrees, Fraction } from "../../../../types/style";
|
||||
import { Corner, Degrees, Fraction, Px } from "../../../../types/style";
|
||||
import { Milliseconds } from "../../../../types/util";
|
||||
import { wipeCustomDegClip } from "../../../../utils/styling";
|
||||
|
||||
@@ -14,6 +14,10 @@ type WipeTransitionProps = {
|
||||
opacityStart?: Fraction,
|
||||
opacityDuration?: Milliseconds,
|
||||
opacityDelay?: Milliseconds,
|
||||
manualDimensions?: {
|
||||
height: Px,
|
||||
width: Px,
|
||||
},
|
||||
}
|
||||
|
||||
export function WipeTransition({
|
||||
@@ -25,6 +29,7 @@ export function WipeTransition({
|
||||
opacityStart = 1,
|
||||
opacityDuration = duration,
|
||||
opacityDelay = 0,
|
||||
manualDimensions,
|
||||
children,
|
||||
}: React.PropsWithChildren<WipeTransitionProps>) {
|
||||
const [childRef, {
|
||||
@@ -53,8 +58,8 @@ export function WipeTransition({
|
||||
opacity,
|
||||
clipPath: wipe.to(wipeProgress => {
|
||||
const coordinates = wipeCustomDegClip(
|
||||
childWidth,
|
||||
childHeight,
|
||||
(manualDimensions?.width ?? 0) || childWidth,
|
||||
(manualDimensions?.height ?? 0) || childHeight,
|
||||
wipeProgress,
|
||||
startingCorner,
|
||||
angle,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useSelector } from "react-redux";
|
||||
|
||||
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||
import { CarStatus } from "../../../../types/state";
|
||||
import { BGTimingTowerDisplayMode, CarStatus } from "../../../../types/state";
|
||||
import { Fraction } from "../../../../types/style";
|
||||
|
||||
import { RowsContainer } from "./styles";
|
||||
@@ -48,12 +48,17 @@ export function TimingTower({ debugDurationMultiplier: DDM }: TimingTowerProps)
|
||||
trackLength={trackLength}
|
||||
debugDurationMultiplier={DDM}
|
||||
/>));
|
||||
}, [lastUpdate, splitsMode]);
|
||||
}, [lastUpdate, splitsMode, displayMode]);
|
||||
|
||||
return (
|
||||
<RowsContainer
|
||||
carsToDisplay={startingCarsCount}
|
||||
retiredCarsPresent={retiredCarsCount > 0}
|
||||
open={displayMode !== BGTimingTowerDisplayMode.Hidden}
|
||||
transitionProps={[{
|
||||
property: "opacity",
|
||||
duration: 1000,
|
||||
}]}
|
||||
>
|
||||
{rows}
|
||||
</RowsContainer>
|
||||
|
||||
@@ -34,12 +34,16 @@ import {
|
||||
TimeDiff,
|
||||
RowLeftHalfPosFlagChangeContainer,
|
||||
AnimatedRowLeftHalfOutline,
|
||||
DriverNameContainer,
|
||||
DriverNameWipe,
|
||||
} from "./styles";
|
||||
import useMeasure from "react-use-measure";
|
||||
|
||||
const WIPE_DELAY: Milliseconds = 3500;
|
||||
const WIPE_DURATION: Milliseconds = 400;
|
||||
const TRAVEL_DURATION: Milliseconds = 750;
|
||||
const FULL_WIDTH_DURATION: Milliseconds = 750;
|
||||
const FULL_WIDTH_CLOSE_DELAY: Milliseconds = 333;
|
||||
|
||||
interface TimingTowerRowProps {
|
||||
car: Car;
|
||||
@@ -63,13 +67,15 @@ export function TimingTowerRow({
|
||||
}: TimingTowerRowProps) {
|
||||
const [pastPos, setPastPos] = useState(car.position);
|
||||
const [posChange, setPosChange] = useState(0);
|
||||
const [pastDisplayMode, setPastDisplayMode] = useState(displayMode);
|
||||
const [hugRight, setHugRight] = useState(true);
|
||||
|
||||
// Using timeouts and boolean states I can manipulate visiblity of the position
|
||||
// change effects. wipeVisible is true for only 1ms before being switched back off.
|
||||
const [showPosChange, setshowPosChange] = useState(false);
|
||||
const [showPosChange, setShowPosChange] = useState(false);
|
||||
const [showOutline, setShowOutline] = useState(false);
|
||||
const [wipeVisible, setWipeVisible] = useState(false);
|
||||
useTimeoutWhen(() => setshowPosChange(false), (WIPE_DELAY + WIPE_DURATION) * DDM, showPosChange);
|
||||
useTimeoutWhen(() => setShowPosChange(false), (WIPE_DELAY + WIPE_DURATION) * DDM, showPosChange);
|
||||
useTimeoutWhen(() => setShowOutline(false), TRAVEL_DURATION * DDM, showOutline);
|
||||
useTimeoutWhen(() => setWipeVisible(false), 1, wipeVisible);
|
||||
|
||||
@@ -77,12 +83,28 @@ export function TimingTowerRow({
|
||||
if (car.position !== pastPos) {
|
||||
setPastPos(car.position);
|
||||
setPosChange(pastPos - car.position);
|
||||
setshowPosChange(true);
|
||||
setShowPosChange(true);
|
||||
setShowOutline(true);
|
||||
setWipeVisible(true);
|
||||
}
|
||||
}, [car.position]);
|
||||
|
||||
useEffect(() => {
|
||||
if (pastDisplayMode !== displayMode) {
|
||||
if ((pastDisplayMode === BGTimingTowerDisplayMode.LeftAndRight
|
||||
&& displayMode === BGTimingTowerDisplayMode.FullLeft) || (
|
||||
pastDisplayMode === BGTimingTowerDisplayMode.FullLeft
|
||||
&& displayMode === BGTimingTowerDisplayMode.LeftAndRight
|
||||
)
|
||||
) {
|
||||
setHugRight(true);
|
||||
} else {
|
||||
setHugRight(false);
|
||||
}
|
||||
setPastDisplayMode(displayMode);
|
||||
}
|
||||
}, [displayMode]);
|
||||
|
||||
const { outlineClipPathProgress } = useSpring({
|
||||
outlineClipPathProgress: showPosChange ? 1 : 0,
|
||||
config: { duration: 333 * DDM },
|
||||
@@ -127,38 +149,67 @@ export function TimingTowerRow({
|
||||
yScale = rightHalfContent.includes("+") ? 1.1 : 1.0;
|
||||
}
|
||||
|
||||
const { design: { timingTower: timingTowerTheme } } = theme;
|
||||
|
||||
return (
|
||||
<AnimatedRowContainer
|
||||
key={car.driver.id}
|
||||
retired={car.status === CarStatus.Retired}
|
||||
wide={displayMode !== BGTimingTowerDisplayMode.LeftOnly}
|
||||
top={(car.position - 1) * theme.design.timingTower.rowHeightPx}
|
||||
top={(car.position - 1) * timingTowerTheme.rowHeightPx}
|
||||
transitionTime={TRAVEL_DURATION * DDM}
|
||||
>
|
||||
{car.notices.includes(CarNotice.FastestLap) && (
|
||||
<FastestLapGem />
|
||||
)}
|
||||
<RowLeftHalf
|
||||
roundedCornerTop={
|
||||
(displayMode === BGTimingTowerDisplayMode.FullLeft &&
|
||||
car.position === 1) ? 5 : 0
|
||||
}
|
||||
roundedCornerBottom={
|
||||
bottomRounded && orMatch(
|
||||
displayMode,
|
||||
BGTimingTowerDisplayMode.LeftOnly,
|
||||
BGTimingTowerDisplayMode.FullLeft,
|
||||
) ? 5 : undefined
|
||||
) ? 5 : 0
|
||||
}
|
||||
transitionTime={TRAVEL_DURATION * DDM}
|
||||
open={displayMode === BGTimingTowerDisplayMode.FullLeft}
|
||||
transitionOpeningProps={[{
|
||||
property: "width",
|
||||
duration: FULL_WIDTH_DURATION * DDM,
|
||||
}, {
|
||||
property: "border-top-right-radius",
|
||||
duration: TRAVEL_DURATION * DDM,
|
||||
}, {
|
||||
property: "border-bottom-right-radius",
|
||||
duration: TRAVEL_DURATION * DDM,
|
||||
}]}
|
||||
transitionClosingProps={[{
|
||||
property: "width",
|
||||
duration: FULL_WIDTH_DURATION * DDM,
|
||||
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
|
||||
}, {
|
||||
property: "border-top-right-radius",
|
||||
duration: TRAVEL_DURATION * DDM,
|
||||
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
|
||||
}, {
|
||||
property: "border-bottom-right-radius",
|
||||
duration: TRAVEL_DURATION * DDM,
|
||||
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
|
||||
}]}
|
||||
ref={leftHalfRef}
|
||||
>
|
||||
<RowLeftHalfLayout>
|
||||
{car.status !== CarStatus.Retired && (
|
||||
<RowLeftHalfPosFlagContainer size={32}>
|
||||
<RowLeftHalfPosFlagContainer size={timingTowerTheme.posFlagSize}>
|
||||
<PositionFlag
|
||||
size={32}
|
||||
size={timingTowerTheme.posFlagSize}
|
||||
number={car.position}
|
||||
numberSizeFraction={.6}
|
||||
/>
|
||||
<RowLeftHalfPosFlagChangeContainer
|
||||
size={32}
|
||||
size={timingTowerTheme.posFlagSize}
|
||||
visible={showPosChange}
|
||||
transitionTime={167 * DDM}
|
||||
>
|
||||
@@ -171,7 +222,7 @@ export function TimingTowerRow({
|
||||
startingCorner="topLeft"
|
||||
>
|
||||
<PositionFlag
|
||||
size={32}
|
||||
size={timingTowerTheme.posFlagSize}
|
||||
number={car.position}
|
||||
numberSizeFraction={.6}
|
||||
color={posChange > 0
|
||||
@@ -182,15 +233,53 @@ export function TimingTowerRow({
|
||||
|
||||
)}
|
||||
</RowLeftHalfPosFlagChangeContainer>
|
||||
|
||||
</RowLeftHalfPosFlagContainer>
|
||||
)}
|
||||
<DriverName>
|
||||
<DriverNameContainer>
|
||||
<DriverName
|
||||
open={displayMode !== BGTimingTowerDisplayMode.FullLeft}
|
||||
transitionOpeningProps={[{
|
||||
property: "opacity",
|
||||
duration: 333 * DDM,
|
||||
delay: (FULL_WIDTH_DURATION - 333) * DDM,
|
||||
}]}
|
||||
transitionClosingProps={[{
|
||||
property: "opacity",
|
||||
duration: 333 * DDM,
|
||||
delay: 0 * DDM,
|
||||
}]}
|
||||
>
|
||||
{car.driver.initials}
|
||||
</DriverName>
|
||||
<DriverNameWipe
|
||||
open={displayMode === BGTimingTowerDisplayMode.FullLeft}
|
||||
transitionOpeningProps={[{
|
||||
property: "width",
|
||||
duration: FULL_WIDTH_DURATION * 2 * DDM,
|
||||
delay: 0 * DDM,
|
||||
}, {
|
||||
property: "opacity",
|
||||
duration: 333 * DDM,
|
||||
delay: 0 * DDM,
|
||||
}]}
|
||||
transitionClosingProps={[{
|
||||
property: "width",
|
||||
duration: FULL_WIDTH_DURATION * DDM,
|
||||
delay: 0 * DDM,
|
||||
}, {
|
||||
property: "opacity",
|
||||
duration: 333 * DDM,
|
||||
delay: (FULL_WIDTH_DURATION - 333) * DDM,
|
||||
}]}
|
||||
>
|
||||
<DriverName open>
|
||||
{car.driver.lastName}
|
||||
</DriverName>
|
||||
</DriverNameWipe>
|
||||
</DriverNameContainer>
|
||||
</RowLeftHalfLayout>
|
||||
<RowLeftHalfGemContainer>
|
||||
<TeamGem team={car.driver.team.id} height={30} />
|
||||
<TeamGem team={car.driver.team.id} height={timingTowerTheme.teamGemSize} />
|
||||
</RowLeftHalfGemContainer>
|
||||
|
||||
<AnimatedRowLeftHalfOutline
|
||||
@@ -223,18 +312,48 @@ export function TimingTowerRow({
|
||||
</RowLeftHalf>
|
||||
|
||||
<RowRightHalf
|
||||
roundedCornerTop={car.position === 1 ? 5 : undefined}
|
||||
roundedCornerTop={car.position === 1 ? 5 : 0}
|
||||
roundedCornerBottom={
|
||||
bottomRounded && orMatch(
|
||||
splitsMode,
|
||||
BGTimingTowerSplitsMode.Leader,
|
||||
BGTimingTowerSplitsMode.Interval,
|
||||
) ? 5 : undefined
|
||||
) ? 5 : 0
|
||||
}
|
||||
transitionTime={TRAVEL_DURATION * DDM}
|
||||
open={displayMode === BGTimingTowerDisplayMode.LeftAndRight}
|
||||
transitionProps={[{
|
||||
property: "border-top-right-radius",
|
||||
duration: TRAVEL_DURATION * DDM,
|
||||
}, {
|
||||
property: "border-bottom-right-radius",
|
||||
duration: TRAVEL_DURATION * DDM,
|
||||
}]}
|
||||
transitionClosingProps={[{
|
||||
property: "width",
|
||||
duration: FULL_WIDTH_DURATION * DDM,
|
||||
}]}
|
||||
transitionOpeningProps={[{
|
||||
property: "width",
|
||||
duration: FULL_WIDTH_DURATION * DDM,
|
||||
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
|
||||
}]}
|
||||
hugRight={hugRight}
|
||||
>
|
||||
<RowRightHalfLayout>
|
||||
<TimeDiff xScale={xScale} yScale={yScale}>
|
||||
<TimeDiff
|
||||
xScale={xScale}
|
||||
yScale={yScale}
|
||||
open={displayMode === BGTimingTowerDisplayMode.LeftAndRight}
|
||||
transitionOpeningProps={[{
|
||||
property: "opacity",
|
||||
duration: FULL_WIDTH_DURATION * DDM,
|
||||
delay: FULL_WIDTH_CLOSE_DELAY * DDM,
|
||||
}]}
|
||||
transitionClosingProps={[{
|
||||
property: "opacity",
|
||||
duration: FULL_WIDTH_DURATION * DDM,
|
||||
}]}
|
||||
>
|
||||
{rightHalfContent}
|
||||
</TimeDiff>
|
||||
</RowRightHalfLayout>
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
import styled, { css } from "styled-components";
|
||||
import { animated } from "@react-spring/web";
|
||||
|
||||
import { Fraction, Px, TransitionArgs } from "../../../../types/style";
|
||||
import {
|
||||
Fraction,
|
||||
Px,
|
||||
DirectionalTransitionProps,
|
||||
} from "../../../../types/style";
|
||||
import { Milliseconds } from "../../../../types/util";
|
||||
import { commonTransition } from "../../../../utils/styling";
|
||||
import { commonDirectionalTransition } from "../../../../utils/styling";
|
||||
|
||||
import fastestLapIcon from "../../../../public/images/icons/fastest-lap.svg";
|
||||
|
||||
|
||||
type OpenProps = {
|
||||
open: boolean,
|
||||
};
|
||||
type TransitionProps = OpenProps & {
|
||||
transitionProps: TransitionArgs[],
|
||||
};
|
||||
|
||||
type RowsContainerProps = {
|
||||
type RowsContainerProps = DirectionalTransitionProps & {
|
||||
carsToDisplay: number,
|
||||
retiredCarsPresent: boolean,
|
||||
};
|
||||
@@ -29,6 +26,10 @@ export const RowsContainer = styled.div<RowsContainerProps>`
|
||||
theme.design.timingTower.rowHeightPx * carsToDisplay + (retiredCarsPresent ? 3 : 0)}px;
|
||||
|
||||
overflow-y: clip; // hidden doesn't work for some reason.
|
||||
|
||||
opacity: ${({ open }) => open ? 1 : 0};
|
||||
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
|
||||
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
|
||||
`;
|
||||
RowsContainer.displayName = "RowsContainer";
|
||||
|
||||
@@ -61,30 +62,31 @@ AnimatedRowContainer.displayName = "AnimatedRowContainer";
|
||||
type RoundedProp = {
|
||||
roundedCornerTop?: Px,
|
||||
roundedCornerBottom?: Px,
|
||||
transitionTime: Milliseconds,
|
||||
};
|
||||
const Rounded = styled.div<RoundedProp>`
|
||||
${({ roundedCornerTop }) =>
|
||||
roundedCornerTop && css`border-top-right-radius: ${roundedCornerTop}px;`}
|
||||
${({ roundedCornerBottom }) =>
|
||||
roundedCornerBottom && css`border-bottom-right-radius: ${roundedCornerBottom}px;`}
|
||||
transition: border-top-right-radius ${({ transitionTime }) => transitionTime}ms,
|
||||
border-bottom-right-radius ${({ transitionTime }) => transitionTime}ms;
|
||||
border-top-right-radius: ${({ roundedCornerTop = 0 }) => roundedCornerTop}px;
|
||||
border-bottom-right-radius: ${({ roundedCornerBottom = 0 }) => roundedCornerBottom}px;
|
||||
`;
|
||||
|
||||
export const RowLeftHalf = styled(Rounded)`
|
||||
export const RowLeftHalf = styled(Rounded)<DirectionalTransitionProps>`
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
overflow-x: clip;
|
||||
|
||||
width: ${p => p.theme.design.timingTower.rowLeftHalfWidthPx}px; // Future will be animated.
|
||||
width: ${({ theme: { design: { timingTower } }, open }) =>
|
||||
(open ? timingTower.rowRightHalfWidthPx : 0) + timingTower.rowLeftHalfWidthPx}px;
|
||||
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
||||
|
||||
background-color: #000000e5
|
||||
background-color: #000000e5;
|
||||
|
||||
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
|
||||
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
|
||||
`;
|
||||
RowLeftHalf.displayName = "RowLeftHalf";
|
||||
|
||||
type AnimatedRowLeftHalfOutlineProps = TransitionProps & {
|
||||
type AnimatedRowLeftHalfOutlineProps = DirectionalTransitionProps & {
|
||||
startThickness: Px,
|
||||
endThickness: Px,
|
||||
startColor: string,
|
||||
@@ -103,7 +105,8 @@ export const AnimatedRowLeftHalfOutline = animated(styled(Rounded) <AnimatedRowL
|
||||
: `${startThickness}px solid ${startColor}`};
|
||||
outline-offset: ${({ startThickness }) => -startThickness}px;
|
||||
|
||||
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
|
||||
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
|
||||
`);
|
||||
AnimatedRowLeftHalfOutline.displayName = "AnimatedRowLeftHalfOutline";
|
||||
|
||||
@@ -115,7 +118,6 @@ export const RowLeftHalfLayout = styled.div`
|
||||
display: flex;
|
||||
padding-left: 3px;
|
||||
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
`;
|
||||
RowLeftHalfLayout.displayName = "RowLeftHalfLayout";
|
||||
@@ -155,17 +157,29 @@ export const RowLeftHalfGemContainer = styled.div`
|
||||
`;
|
||||
RowLeftHalfGemContainer.displayName = "RowLeftHalfGemContainer";
|
||||
|
||||
export const RowRightHalf = styled(Rounded)`
|
||||
type RowRightHalfProps = DirectionalTransitionProps & {
|
||||
hugRight: boolean,
|
||||
};
|
||||
export const RowRightHalf = styled(Rounded)<RowRightHalfProps>`
|
||||
position: absolute;
|
||||
${({ hugRight }) => hugRight
|
||||
? css`
|
||||
right: 0;
|
||||
` : css`
|
||||
left: ${p => p.theme.design.timingTower.rowLeftHalfWidthPx}px;
|
||||
`}
|
||||
top: 0;
|
||||
|
||||
width: ${p => p.theme.design.timingTower.rowRightHalfWidthPx}px; // Future will be animated.
|
||||
width: ${({ theme: { design: { timingTower } }, open }) =>
|
||||
open ? timingTower.rowRightHalfWidthPx : 0}px;
|
||||
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
||||
|
||||
overflow-x: hidden;
|
||||
overflow-x: clip;
|
||||
|
||||
background-color: #0000007e
|
||||
background-color: #0000007e;
|
||||
|
||||
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
|
||||
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
|
||||
`;
|
||||
RowRightHalf.displayName = "RowRightHalf";
|
||||
|
||||
@@ -181,15 +195,44 @@ export const RowRightHalfLayout = styled.div`
|
||||
`;
|
||||
RowRightHalfLayout.displayName = "RowRightHalfLayout";
|
||||
|
||||
export const DriverName = styled.span`
|
||||
export const DriverNameContainer = styled.div`
|
||||
position: relative;
|
||||
margin-left: ${p => p.theme.design.timingTower.nameLeftMargin}px;
|
||||
`;
|
||||
DriverNameContainer.displayName = "DriverNameContainer";
|
||||
|
||||
export const DriverName = styled.span<DirectionalTransitionProps>`
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
color: white;
|
||||
font-family: ${p => p.theme.fonts.f1Bold};
|
||||
font-size: 20px;
|
||||
margin-left: 14px;
|
||||
text-transform: uppercase;
|
||||
|
||||
opacity: ${({ open }) => open ? 1 : 0};
|
||||
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
|
||||
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
|
||||
`;
|
||||
DriverName.displayName = "DriverName";
|
||||
|
||||
type TimeDiffProps = {
|
||||
export const DriverNameWipe = styled.div<DirectionalTransitionProps>`
|
||||
/* background: #deadbe; */
|
||||
|
||||
width: ${({ open }) => open ? 800 : 200}px;
|
||||
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
||||
|
||||
mask-image: linear-gradient(to right, black 0, black 20%, transparent 30%);
|
||||
mask-repeat: no-repeat;
|
||||
|
||||
opacity: ${({ open }) => open ? 1 : 0};
|
||||
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
|
||||
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
|
||||
`;
|
||||
DriverNameWipe.displayName = "DriverNameWipe";
|
||||
|
||||
type TimeDiffProps = DirectionalTransitionProps & {
|
||||
xScale: Fraction,
|
||||
yScale: Fraction,
|
||||
};
|
||||
@@ -203,6 +246,10 @@ export const TimeDiff = styled.span<TimeDiffProps>`
|
||||
font-feature-settings: 'tnum' 1;
|
||||
transform-origin: top right;
|
||||
transform: scale(${({ xScale, yScale }) => `${xScale}, ${yScale}`});
|
||||
|
||||
opacity: ${({ open }) => open ? 1 : 0};
|
||||
${({ open, transitionOpeningProps, transitionClosingProps, transitionProps }) =>
|
||||
commonDirectionalTransition(open, transitionOpeningProps, transitionClosingProps, transitionProps)}
|
||||
`;
|
||||
TimeDiff.displayName = "TimeDiff";
|
||||
|
||||
|
||||
+41
-18
@@ -1,14 +1,15 @@
|
||||
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||
import { PadBox } from "@bedrock-layout/padbox";
|
||||
import { Split } from "@bedrock-layout/split";
|
||||
import { Stack } from "@bedrock-layout/stack";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||
|
||||
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||
import { setTimingTowerSplitsMode } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||
import { setTimingTowerDisplayMode, setTimingTowerSplitsMode } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||
import { increaseDistance, refreshRunningOrder, setCarStatus } from "../../../../features/event/eventSlice";
|
||||
import { BGTimingTowerSplitsMode, CarStatus } from "../../../../types/state";
|
||||
import { BGTimingTowerDisplayMode, BGTimingTowerSplitsMode, CarStatus } from "../../../../types/state";
|
||||
import { GridSelection } from "../GridSelection";
|
||||
|
||||
import { ClickSpan } from "./styles";
|
||||
@@ -16,25 +17,17 @@ import { ClickSpan } from "./styles";
|
||||
export function TimingTowerPrototypeControls() {
|
||||
const dispatch = useDispatch();
|
||||
const { selectedCars } = useSelector(broadcastDirectorSelector);
|
||||
const { timingBoard: { timingTower: { splitsMode } } } = useSelector(broadcastGraphicsSelector);
|
||||
const { timingBoard: { timingTower: { splitsMode, displayMode } } } = useSelector(broadcastGraphicsSelector);
|
||||
const { grid } = useSelector(eventSelector);
|
||||
|
||||
return (
|
||||
<Split gutter="md">
|
||||
<InlineCluster as={PadBox} padding="md" gutter="md">
|
||||
<Stack gutter="md">
|
||||
|
||||
<PadBox padding="md">
|
||||
<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>
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
@@ -47,7 +40,7 @@ export function TimingTowerPrototypeControls() {
|
||||
dispatch(refreshRunningOrder());
|
||||
}}
|
||||
>
|
||||
+200m to cars
|
||||
+200m
|
||||
</ClickSpan>
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
@@ -71,7 +64,7 @@ export function TimingTowerPrototypeControls() {
|
||||
dispatch(refreshRunningOrder());
|
||||
}}
|
||||
>
|
||||
Retire cars
|
||||
Retire
|
||||
</ClickSpan>
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
@@ -82,9 +75,39 @@ export function TimingTowerPrototypeControls() {
|
||||
dispatch(refreshRunningOrder());
|
||||
}}
|
||||
>
|
||||
Un-retire cars
|
||||
Un-retire
|
||||
</ClickSpan>
|
||||
</InlineCluster>
|
||||
<hr />
|
||||
<InlineCluster gutter="md">
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
if (splitsMode === BGTimingTowerSplitsMode.Interval) {
|
||||
dispatch(setTimingTowerSplitsMode(BGTimingTowerSplitsMode.Leader));
|
||||
} else {
|
||||
dispatch(setTimingTowerSplitsMode(BGTimingTowerSplitsMode.Interval));
|
||||
}
|
||||
}}
|
||||
>
|
||||
Splits Mode = {BGTimingTowerSplitsMode[splitsMode]}
|
||||
</ClickSpan>
|
||||
<ClickSpan onClick={() => dispatch(setTimingTowerDisplayMode(BGTimingTowerDisplayMode.LeftAndRight))}>
|
||||
{(displayMode === BGTimingTowerDisplayMode.LeftAndRight ? "*" : "") + "LeftAndRight"}
|
||||
</ClickSpan>
|
||||
<ClickSpan onClick={() => dispatch(setTimingTowerDisplayMode(BGTimingTowerDisplayMode.LeftOnly))}>
|
||||
{(displayMode === BGTimingTowerDisplayMode.LeftOnly ? "*" : "") + "LeftOnly"}
|
||||
</ClickSpan>
|
||||
<ClickSpan onClick={() => dispatch(setTimingTowerDisplayMode(BGTimingTowerDisplayMode.FullLeft))}>
|
||||
{(displayMode === BGTimingTowerDisplayMode.FullLeft ? "*" : "") + "FullLeft"}
|
||||
</ClickSpan>
|
||||
<ClickSpan onClick={() => dispatch(setTimingTowerDisplayMode(BGTimingTowerDisplayMode.Hidden))}>
|
||||
{(displayMode === BGTimingTowerDisplayMode.Hidden ? "*" : "") + "Hidden"}
|
||||
</ClickSpan>
|
||||
|
||||
</InlineCluster>
|
||||
</PadBox>
|
||||
</Stack>
|
||||
|
||||
<PadBox padding="md">
|
||||
<GridSelection />
|
||||
</PadBox>
|
||||
|
||||
@@ -220,7 +220,8 @@ export const drivers: {[lastName: string]: Driver} = {
|
||||
perez: {
|
||||
id: "perez",
|
||||
firstName: "Sergio",
|
||||
lastName: "Pérez",
|
||||
// lastName: "Pérez",
|
||||
lastName: "Perez",
|
||||
number: 11,
|
||||
team: teams.redBull,
|
||||
yellowTCam: true,
|
||||
@@ -231,7 +232,8 @@ export const drivers: {[lastName: string]: Driver} = {
|
||||
raikkonen: {
|
||||
id: "raikkonen",
|
||||
firstName: "Kimi",
|
||||
lastName: "Räikkönen",
|
||||
// lastName: "Räikkönen",
|
||||
lastName: "Raikkonen",
|
||||
number: 7,
|
||||
team: teams.alfaRomeo,
|
||||
yellowTCam: false,
|
||||
|
||||
@@ -59,6 +59,9 @@ export const broadcastGraphicsSlice = createSlice({
|
||||
setTimingTowerSplitsMode: (state, action: PayloadAction<BGTimingTowerSplitsMode>) => {
|
||||
state.timingBoard.timingTower.splitsMode = action.payload;
|
||||
},
|
||||
setTimingTowerDisplayMode: (state, action: PayloadAction<BGTimingTowerDisplayMode>) => {
|
||||
state.timingBoard.timingTower.displayMode = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -68,5 +71,6 @@ export const {
|
||||
incrementChyronsOpenState,
|
||||
clearChyrons,
|
||||
setTimingTowerSplitsMode,
|
||||
setTimingTowerDisplayMode,
|
||||
} = broadcastGraphicsSlice.actions;
|
||||
export default broadcastGraphicsSlice.reducer;
|
||||
@@ -72,6 +72,9 @@ export const theme = {
|
||||
rowLeftHalfWidthPx: 147,
|
||||
rowRightHalfWidthPx: 108,
|
||||
retiredTopGapPx: 3,
|
||||
teamGemSize: 30,
|
||||
posFlagSize: 32,
|
||||
nameLeftMargin: 14,
|
||||
},
|
||||
button: {
|
||||
borderRadius: "0.25rem",
|
||||
|
||||
Vendored
+11
@@ -40,3 +40,14 @@ export interface TransitionArgs {
|
||||
timing?: string
|
||||
delay?: Milliseconds,
|
||||
}
|
||||
|
||||
export type OpenProps = {
|
||||
open: boolean,
|
||||
};
|
||||
export type TransitionProps = OpenProps & {
|
||||
transitionProps?: TransitionArgs[],
|
||||
};
|
||||
export type DirectionalTransitionProps = TransitionProps & {
|
||||
transitionOpeningProps?: TransitionArgs[],
|
||||
transitionClosingProps?: TransitionArgs[],
|
||||
}
|
||||
+36
-3
@@ -62,16 +62,49 @@ export function wipeCustomDegClip(
|
||||
}
|
||||
}
|
||||
|
||||
export function commonTransition(propsArray: TransitionArgs[]) {
|
||||
/**
|
||||
* Takes in an array of transition properties, durations, delays, and timings
|
||||
* in a special interface and returns them into a format understood by CSS.
|
||||
* Includes a semi-colon as well.
|
||||
* @param propsArray
|
||||
* @returns
|
||||
*/
|
||||
export function commonTransition(propsArray: TransitionArgs[] = []) {
|
||||
if (propsArray.length === 0){
|
||||
return "";
|
||||
}
|
||||
|
||||
return (
|
||||
"transition: "
|
||||
+ propsArray.map(p => `
|
||||
${p?.property ?? "all"} ${p?.duration ?? 1000}ms ${p?.timing ?? ""} ${p?.delay ?? 0}ms
|
||||
`).join(", ")
|
||||
${p?.property ?? "all"} ${p?.duration ?? 1000}ms ${p?.timing ?? ""} ${p?.delay ?? 0}ms`,
|
||||
).join(", ")
|
||||
+ ";"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* An extension and evolution of commonTransition() provides a way to define
|
||||
* transition configurations that can be differentiated by which direction
|
||||
* (opening or closing) that they're going and can even support additional
|
||||
* "shared" properties that are common in either direction.
|
||||
* @param open the (often visible) state of the element
|
||||
* @param openingPropsArray what transition props to use when "open" (opening)
|
||||
* @param closingPropsArray what transition props to use when "closed" (closing)
|
||||
* @param sharedPropsArray what transition props to use in either direction
|
||||
* @returns
|
||||
*/
|
||||
export function commonDirectionalTransition(
|
||||
open: boolean,
|
||||
openingPropsArray: TransitionArgs[] = [],
|
||||
closingPropsArray: TransitionArgs[] = [],
|
||||
sharedPropsArray: TransitionArgs[] = [],
|
||||
) {
|
||||
return open
|
||||
? commonTransition(openingPropsArray.concat(sharedPropsArray))
|
||||
: commonTransition(closingPropsArray.concat(sharedPropsArray));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the x, y coordinates of a six point polygon for use in a clip-path
|
||||
* mask. By taking a fraction to indicate the progress through the animation it
|
||||
|
||||
Reference in new issue
Block a user