No files matched your search
@@ -3,14 +3,14 @@ import { useEffect, useState } from "react";
|
|||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Stack } from "@bedrock-layout/stack";
|
import { Stack } from "@bedrock-layout/stack";
|
||||||
import { Inline } from "@bedrock-layout/inline";
|
import { Inline } from "@bedrock-layout/inline";
|
||||||
import { FaPlay, FaStepForward, FaStop } from "react-icons/fa";
|
import { FaCheck, FaStepForward, FaTimes } from "react-icons/fa";
|
||||||
|
|
||||||
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||||
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||||
import {
|
import {
|
||||||
chyronsClear,
|
incrementChyronsOpenState,
|
||||||
chyronsOpenStateIncrement,
|
setChyrons,
|
||||||
chyronsSet,
|
setChyronsOpenState,
|
||||||
} from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
} from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||||
import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics";
|
import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics";
|
||||||
import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode } from "../../../../types/state";
|
import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode } from "../../../../types/state";
|
||||||
@@ -37,12 +37,28 @@ export function ChyronsDirectorControls() {
|
|||||||
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
||||||
const { selectedCars } = useSelector(broadcastDirectorSelector);
|
const { selectedCars } = useSelector(broadcastDirectorSelector);
|
||||||
|
|
||||||
|
// Handle changes to the chyron mode so submodes can be changed accordingly.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setChyronSubModes(getChyronSubModesList(chyronMode));
|
setChyronSubModes(getChyronSubModesList(chyronMode));
|
||||||
}, [chyronMode]);
|
}, [chyronMode]);
|
||||||
|
|
||||||
const onOpen = () => {
|
const onOpen = () => {
|
||||||
if (chyronMode === "driver") {
|
buildDriver();
|
||||||
|
setTimeout(() => {
|
||||||
|
// Delay a short time and increment the open state so the animation can happen.
|
||||||
|
dispatch(incrementChyronsOpenState());
|
||||||
|
}, 50);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onNext = () => {
|
||||||
|
dispatch(incrementChyronsOpenState());
|
||||||
|
};
|
||||||
|
|
||||||
|
const onClose = () => {
|
||||||
|
dispatch(setChyronsOpenState(-1));
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildDriver = () => {
|
||||||
if (selectedCars.length === 0) return;
|
if (selectedCars.length === 0) return;
|
||||||
let primaryCar = selectedCars[0];
|
let primaryCar = selectedCars[0];
|
||||||
let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
|
let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
|
||||||
@@ -54,7 +70,7 @@ export function ChyronsDirectorControls() {
|
|||||||
primaryCar = selectedCars[1];
|
primaryCar = selectedCars[1];
|
||||||
}
|
}
|
||||||
const newChyrons: BGChyrons = {
|
const newChyrons: BGChyrons = {
|
||||||
openState: 1,
|
openState: 0,
|
||||||
relativePos: { top: "0", right: "0", bottom: "0", left: "0" },
|
relativePos: { top: "0", right: "0", bottom: "0", left: "0" },
|
||||||
mode: chyronMode,
|
mode: chyronMode,
|
||||||
subMode: chyronSubMode,
|
subMode: chyronSubMode,
|
||||||
@@ -63,16 +79,7 @@ export function ChyronsDirectorControls() {
|
|||||||
secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null,
|
secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
dispatch(chyronsSet(newChyrons));
|
dispatch(setChyrons(newChyrons));
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const onNext = () => {
|
|
||||||
dispatch(chyronsOpenStateIncrement());
|
|
||||||
};
|
|
||||||
|
|
||||||
const onClose = () => {
|
|
||||||
dispatch(chyronsClear());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildDriverChyron = (car: Car): BGChyronDriver => ({
|
const buildDriverChyron = (car: Car): BGChyronDriver => ({
|
||||||
@@ -136,19 +143,19 @@ export function ChyronsDirectorControls() {
|
|||||||
onClick={onOpen}
|
onClick={onOpen}
|
||||||
disabled={chyrons != null}
|
disabled={chyrons != null}
|
||||||
>
|
>
|
||||||
<FaPlay size="0.8em" />
|
<FaCheck size="0.8em" />
|
||||||
</OpenButton>
|
</OpenButton>
|
||||||
<Button
|
<Button
|
||||||
onClick={onNext}
|
onClick={onNext}
|
||||||
disabled={chyrons == null}
|
disabled={chyrons == null || chyrons.openState === -1}
|
||||||
>
|
>
|
||||||
<FaStepForward size="0.8em" />
|
<FaStepForward size="0.8em" />
|
||||||
</Button>
|
</Button>
|
||||||
<CloseButton
|
<CloseButton
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
disabled={chyrons == null}
|
disabled={chyrons == null || chyrons.openState <= 0}
|
||||||
>
|
>
|
||||||
<FaStop size="0.8em" />
|
<FaTimes size="0.8em" />
|
||||||
</CloseButton>
|
</CloseButton>
|
||||||
</Inline>
|
</Inline>
|
||||||
</Inline>
|
</Inline>
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||||
|
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||||
|
|
||||||
import { ChyronDriver } from "../Driver";
|
import { ChyronDriver } from "../Driver";
|
||||||
import { DoubleChyronContainer } from "./styles";
|
import { DoubleChyronContainer } from "./styles";
|
||||||
|
|
||||||
export function ChyronContainer() {
|
type ChyronContainerProps = {
|
||||||
|
debug?: boolean,
|
||||||
|
};
|
||||||
|
export function ChyronContainer({ debug = false }: ChyronContainerProps) {
|
||||||
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
||||||
|
const { debugDurationMultiplier } = useSelector(workspaceSelector);
|
||||||
|
|
||||||
if (chyrons == null || chyrons.driver == null) return null;
|
if (chyrons == null || chyrons.driver == null) return null;
|
||||||
|
|
||||||
@@ -14,6 +19,8 @@ export function ChyronContainer() {
|
|||||||
<ChyronDriver
|
<ChyronDriver
|
||||||
chyronData={chyrons.driver.primary}
|
chyronData={chyrons.driver.primary}
|
||||||
subMode={chyrons.subMode}
|
subMode={chyrons.subMode}
|
||||||
|
openState={chyrons.openState}
|
||||||
|
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
if (chyrons.subMode === "medium" && chyrons.driver.secondary) {
|
if (chyrons.subMode === "medium" && chyrons.driver.secondary) {
|
||||||
@@ -23,6 +30,8 @@ export function ChyronContainer() {
|
|||||||
<ChyronDriver
|
<ChyronDriver
|
||||||
chyronData={chyrons.driver.secondary}
|
chyronData={chyrons.driver.secondary}
|
||||||
subMode={chyrons.subMode}
|
subMode={chyrons.subMode}
|
||||||
|
openState={chyrons.openState}
|
||||||
|
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
|
||||||
/>
|
/>
|
||||||
</DoubleChyronContainer>
|
</DoubleChyronContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,55 +1,172 @@
|
|||||||
import { BGChyronDriver, BGChyronSubMode } from "../../../../types/state";
|
import { useSpring } from "@react-spring/web";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
|
||||||
|
import { BGChyronDriver, BGChyronSubMode, OpenState } from "../../../../types/state";
|
||||||
|
import { Fraction } from "../../../../types/style";
|
||||||
|
import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||||
import { theme } from "../../../../shared/theme";
|
import { theme } from "../../../../shared/theme";
|
||||||
|
import { outlineClipPath } from "../../../../utils/styling";
|
||||||
|
|
||||||
import { DriverNumber } from "../../Common/DriverNumber";
|
import { DriverNumber } from "../../Common/DriverNumber";
|
||||||
import { AngledFlag } from "../../Common/AngledFlag";
|
import { AngledFlag } from "../../Common/AngledFlag";
|
||||||
|
import { PositionFlag } from "../../Common/PositionFlag";
|
||||||
|
import { DriverPortrait } from "../../Common/DriverPortrait";
|
||||||
import {
|
import {
|
||||||
BaseBackground,
|
AnimatedBaseContainer,
|
||||||
|
BaseLayout,
|
||||||
|
AnimatedBaseOutline,
|
||||||
|
BaseBlack,
|
||||||
|
BaseBackgroundColor,
|
||||||
FirstName,
|
FirstName,
|
||||||
PositionNumber,
|
|
||||||
LastName,
|
LastName,
|
||||||
NameContainer,
|
NameContainer,
|
||||||
NumberContainer,
|
NumberContainer,
|
||||||
PositionFlag,
|
|
||||||
Spacer,
|
Spacer,
|
||||||
TeamColorBar,
|
TeamColorBar,
|
||||||
TeamName,
|
TeamName,
|
||||||
TextContainer,
|
TextContainer,
|
||||||
FlagContainer,
|
FlagContainer,
|
||||||
PortraitDiv,
|
DriverPortraitContainer,
|
||||||
BaseContainer,
|
|
||||||
} from "./styles";
|
} from "./styles";
|
||||||
|
import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition";
|
||||||
const driverPortraits = require.context("../../../../public/images/drivers/front", true);
|
|
||||||
|
|
||||||
type ChyronDriverProps = {
|
type ChyronDriverProps = {
|
||||||
chyronData: BGChyronDriver,
|
chyronData: BGChyronDriver,
|
||||||
subMode: BGChyronSubMode,
|
subMode: BGChyronSubMode,
|
||||||
|
openState: OpenState,
|
||||||
|
debugDurationMultiplier?: Fraction,
|
||||||
};
|
};
|
||||||
export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
export function ChyronDriver({
|
||||||
|
chyronData,
|
||||||
|
subMode,
|
||||||
|
openState,
|
||||||
|
debugDurationMultiplier: DDM = 1.0,
|
||||||
|
}: ChyronDriverProps) {
|
||||||
const [baseWidth, baseHeight] = subMode === "medium" ? [582, 72]
|
const [baseWidth, baseHeight] = subMode === "medium" ? [582, 72]
|
||||||
: subMode === "large" ? [638, 98]
|
: subMode === "large" ? [638, 98]
|
||||||
: [0, 0];
|
: [0, 0];
|
||||||
|
|
||||||
const { car, flagMode, showPosFlag, showDriverNumber, showPortrait } = chyronData;
|
const { car, flagMode, showPosFlag, showDriverNumber, showPortrait } = chyronData;
|
||||||
|
|
||||||
const flagProps = flagMode === "country"
|
const flagProps = flagMode === "country"
|
||||||
? { flagMode, flag: car.driver.nationality }
|
? { flagMode, flag: car.driver.nationality }
|
||||||
: flagMode === "team" ? { flagMode, flag: car.driver.team.id } : undefined;
|
: flagMode === "team"
|
||||||
|
? { flagMode, flag: car.driver.team.id }
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
|
const containerFadeAwaySpring = useSpring({
|
||||||
|
opacity: openState == -1 ? 0 : 1,
|
||||||
|
config: { duration: 300 * DDM },
|
||||||
|
delay: 0,
|
||||||
|
onRest: () => {
|
||||||
|
if (openState === -1) {
|
||||||
|
dispatch(clearChyrons());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { outlineClipPathProgress } = useSpring({
|
||||||
|
outlineClipPathProgress: openState !== 0 ? 1 : 0,
|
||||||
|
config: { duration: 500 * DDM },
|
||||||
|
delay: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
const teamColor = theme.colors.teams[car.driver.team.id];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseContainer width={baseWidth} height={baseHeight}>
|
<AnimatedBaseContainer
|
||||||
<BaseBackground >
|
width={baseWidth}
|
||||||
|
height={baseHeight}
|
||||||
|
style={containerFadeAwaySpring}
|
||||||
|
>
|
||||||
|
<AnimatedBaseOutline
|
||||||
|
open={openState !== 0}
|
||||||
|
startThickness={5}
|
||||||
|
endThickness={1}
|
||||||
|
startColor="#ffffffff"
|
||||||
|
endColor="#ffffff00"
|
||||||
|
transitionProps={[{
|
||||||
|
property: "outline",
|
||||||
|
duration: 1167 * DDM,
|
||||||
|
}]}
|
||||||
|
style={{
|
||||||
|
clipPath: outlineClipPathProgress.to(progress => {
|
||||||
|
const coordinates = outlineClipPath(
|
||||||
|
baseWidth,
|
||||||
|
baseHeight,
|
||||||
|
progress,
|
||||||
|
5,
|
||||||
|
);
|
||||||
|
return `polygon(${coordinates.map(([x, y]) => `${x}px ${y}px`).join(", ")})`;
|
||||||
|
}),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<BaseBlack
|
||||||
|
open={openState !== 0}
|
||||||
|
transitionProps={[{
|
||||||
|
property: "opacity",
|
||||||
|
duration: 800 * DDM,
|
||||||
|
timing: "ease-in",
|
||||||
|
}, {
|
||||||
|
property: "width",
|
||||||
|
duration: 667 * DDM,
|
||||||
|
timing: "ease-out",
|
||||||
|
}]}
|
||||||
|
/>
|
||||||
|
<BaseLayout
|
||||||
|
open={openState !== 0}
|
||||||
|
transitionProps={[{
|
||||||
|
property: "clip-path",
|
||||||
|
duration: 400 * DDM,
|
||||||
|
timing: "ease-in",
|
||||||
|
delay: 333 * DDM,
|
||||||
|
}]}
|
||||||
|
>
|
||||||
|
<BaseBackgroundColor
|
||||||
|
open={openState !== 0}
|
||||||
|
transitionProps={[{
|
||||||
|
property: "opacity",
|
||||||
|
duration: 566 * DDM,
|
||||||
|
delay: 600 * DDM,
|
||||||
|
}]}
|
||||||
|
teamColor={teamColor}
|
||||||
|
/>
|
||||||
<Spacer width="6px" />
|
<Spacer width="6px" />
|
||||||
{showPosFlag && (
|
{showPosFlag && (
|
||||||
<PositionFlag containerHeight={baseHeight}>
|
<VenetianBlindsTransition
|
||||||
<PositionNumber containerHeight={baseHeight}>
|
visible={openState !== 0}
|
||||||
{car.position}
|
delay={500 * DDM}
|
||||||
</PositionNumber>
|
blindsColor="#f60d0d"
|
||||||
</PositionFlag>
|
blindsColorFadeDuration={300 * DDM}
|
||||||
|
blindsColorFadeDelay={200 * DDM}
|
||||||
|
blindsAngle={-45}
|
||||||
|
blindsOpenDuration={100 * DDM}
|
||||||
|
blindsOpenDelay={150 * DDM}
|
||||||
|
blindsSize={{ transparent: 3, opaque: 6 }}
|
||||||
|
wipeAngle={40}
|
||||||
|
wipeDuration={333 * DDM}
|
||||||
|
wipeStartingCorner="bottomRight"
|
||||||
|
opacityStart={0.1}
|
||||||
|
opacityDuration={200 * DDM}
|
||||||
|
opacityDelay={100 * DDM}
|
||||||
|
spanBlinkDuration={500 * DDM}
|
||||||
|
>
|
||||||
|
<PositionFlag size={baseHeight * 0.85} number={car.position} />
|
||||||
|
</VenetianBlindsTransition>
|
||||||
)}
|
)}
|
||||||
<Spacer width="8px" />
|
<Spacer width="8px" />
|
||||||
<TeamColorBar color={theme.colors.teams[car.driver.team.id]} />
|
<TeamColorBar
|
||||||
|
open={openState !== 0}
|
||||||
|
transitionProps={[{
|
||||||
|
property: "clip-path",
|
||||||
|
duration: 667 * DDM,
|
||||||
|
timing: "ease-in-out",
|
||||||
|
delay: 733 * DDM,
|
||||||
|
}]}
|
||||||
|
color={teamColor}
|
||||||
|
/>
|
||||||
<Spacer width="8px" />
|
<Spacer width="8px" />
|
||||||
<TextContainer>
|
<TextContainer>
|
||||||
<NameContainer>
|
<NameContainer>
|
||||||
@@ -65,9 +182,25 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
|||||||
</NumberContainer>
|
</NumberContainer>
|
||||||
)}
|
)}
|
||||||
</NameContainer>
|
</NameContainer>
|
||||||
<TeamName>{car.driver.team.shortName}</TeamName>
|
<TeamName
|
||||||
|
open={openState !== 0}
|
||||||
|
duration={233 * DDM}
|
||||||
|
delay={500 * DDM}
|
||||||
|
>
|
||||||
|
{car.driver.team.shortName}
|
||||||
|
</TeamName>
|
||||||
</TextContainer>
|
</TextContainer>
|
||||||
<FlagContainer
|
<FlagContainer
|
||||||
|
open={openState !== 0}
|
||||||
|
transitionProps={[{
|
||||||
|
property: "opacity",
|
||||||
|
duration: 1200 * DDM,
|
||||||
|
delay: 1000 * DDM,
|
||||||
|
}, {
|
||||||
|
property: "right",
|
||||||
|
duration: 2000 * DDM,
|
||||||
|
delay: 1000 * DDM,
|
||||||
|
}]}
|
||||||
height={baseHeight * 0.9}
|
height={baseHeight * 0.9}
|
||||||
width={baseHeight * 3}
|
width={baseHeight * 3}
|
||||||
right={-baseHeight * 0.6}
|
right={-baseHeight * 0.6}
|
||||||
@@ -79,14 +212,39 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</FlagContainer>
|
</FlagContainer>
|
||||||
</BaseBackground>
|
</BaseLayout>
|
||||||
{showPortrait && (
|
{showPortrait && (
|
||||||
<PortraitDiv
|
<DriverPortraitContainer
|
||||||
src={driverPortraits(`./${car.driver.id}.png`)}
|
open={openState !== 0}
|
||||||
|
transitionProps={[{
|
||||||
|
property: "opacity",
|
||||||
|
duration: 500 * DDM,
|
||||||
|
delay: 2000 * DDM,
|
||||||
|
}]}
|
||||||
|
placement={{ right: "-5px", bottom: "0" }}
|
||||||
|
>
|
||||||
|
<VenetianBlindsTransition
|
||||||
|
visible={openState !== 0}
|
||||||
|
delay={1700 * DDM}
|
||||||
|
blindsColor={teamColor}
|
||||||
|
blindsColorFadeDuration={600 * DDM}
|
||||||
|
blindsColorFadeDelay={0 * DDM}
|
||||||
|
blindsAngle={-45}
|
||||||
|
blindsOpenDuration={300 * DDM}
|
||||||
|
blindsOpenDelay={0 * DDM}
|
||||||
|
blindsSize={{ transparent: 2, opaque: 5 }}
|
||||||
|
wipeAngle={45}
|
||||||
|
wipeDuration={700 * DDM}
|
||||||
|
wipeStartingCorner="bottomRight"
|
||||||
|
>
|
||||||
|
<DriverPortrait
|
||||||
|
driverId={car.driver.id}
|
||||||
height={baseHeight * 2.5}
|
height={baseHeight * 2.5}
|
||||||
rightMargin={-5}
|
verticalOffsetPercentage={18}
|
||||||
/>
|
/>
|
||||||
|
</VenetianBlindsTransition>
|
||||||
|
</DriverPortraitContainer>
|
||||||
)}
|
)}
|
||||||
</BaseContainer>
|
</AnimatedBaseContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,68 +1,109 @@
|
|||||||
import styled from "styled-components";
|
import { animated } from "@react-spring/web";
|
||||||
import { Px } from "../../../../types/style";
|
import styled, { css, keyframes } from "styled-components";
|
||||||
|
|
||||||
type BaseContainerProps = {
|
import { Placement, Px, TransitionArgs } from "../../../../types/style";
|
||||||
|
import { Milliseconds } from "../../../../types/util";
|
||||||
|
import { commonTransition, placementStyleRules } from "../../../../utils/styling";
|
||||||
|
|
||||||
|
type OpenProps = {
|
||||||
|
open: boolean,
|
||||||
|
};
|
||||||
|
type TransitionProps = OpenProps & {
|
||||||
|
transitionProps: TransitionArgs[],
|
||||||
|
};
|
||||||
|
|
||||||
|
type AnimatedBaseContainerProps = {
|
||||||
width: Px,
|
width: Px,
|
||||||
height: Px,
|
height: Px,
|
||||||
};
|
};
|
||||||
export const BaseContainer = styled.div<BaseContainerProps>`
|
export const AnimatedBaseContainer = animated(styled.div<AnimatedBaseContainerProps>`
|
||||||
position: relative;
|
position: relative;
|
||||||
width: ${({ width }) => `${width}px`};
|
width: ${({ width }) => `${width}px`};
|
||||||
height: ${({ height }) => `${height}px`};
|
height: ${({ height }) => `${height}px`};
|
||||||
`;
|
`);
|
||||||
BaseContainer.displayName = "BaseContainer";
|
AnimatedBaseContainer.displayName = "AnimatedBaseContainer";
|
||||||
|
|
||||||
export const BaseBackground = styled.div`
|
const BaseShape = styled.div`
|
||||||
position: relative;
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
border-bottom-right-radius: 11px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
type AnimatedBaseOutlineProps = TransitionProps & {
|
||||||
|
startThickness: Px,
|
||||||
|
endThickness: Px,
|
||||||
|
startColor: string,
|
||||||
|
endColor: string,
|
||||||
|
};
|
||||||
|
export const AnimatedBaseOutline = animated(styled(BaseShape)<AnimatedBaseOutlineProps>`
|
||||||
|
width: 100%;
|
||||||
|
opacity: ${({ open }) => open ? 1 : 0};
|
||||||
|
outline: ${({ open, startThickness, endThickness, startColor, endColor }) => open
|
||||||
|
? `${endThickness}px solid ${endColor}`
|
||||||
|
: `${startThickness}px solid ${startColor}`};
|
||||||
|
|
||||||
|
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||||
|
`);
|
||||||
|
AnimatedBaseOutline.displayName = "AnimatedBaseOutline";
|
||||||
|
|
||||||
|
export const BaseBlack = styled(BaseShape)<TransitionProps>`
|
||||||
|
opacity: ${({ open }) => open ? 1 : 0.1};
|
||||||
|
width: ${({ open }) => open ? 100 : 0}%;
|
||||||
|
|
||||||
|
background-color: black;
|
||||||
|
|
||||||
|
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||||
|
`;
|
||||||
|
BaseBlack.displayName = "BaseBlack";
|
||||||
|
|
||||||
|
type BaseBackgroundColorProps = {
|
||||||
|
teamColor: string,
|
||||||
|
};
|
||||||
|
export const BaseBackgroundColor = styled(BaseShape)<BaseBackgroundColorProps & TransitionProps>`
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
background-color: ${({ teamColor }) => teamColor};
|
||||||
|
opacity: ${({ open }) => open ? 0 : 1};
|
||||||
|
|
||||||
|
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||||
|
`;
|
||||||
|
BaseBackgroundColor.displayName = "BaseBackgroundColor";
|
||||||
|
|
||||||
|
export const BaseLayout = styled(BaseShape)<TransitionProps>`
|
||||||
|
position: absolute;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
border-bottom-right-radius: 11px;
|
|
||||||
background-color: #000;
|
|
||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
clip-path: ${({ open }) => open
|
||||||
|
? "polygon(0 0, 100% 0, 100% 100%, 0 100%)"
|
||||||
|
: "polygon(0 0, 0 0, -40% 100%, -40% 100%)"};
|
||||||
|
|
||||||
|
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||||
`;
|
`;
|
||||||
BaseBackground.displayName = "BaseBackground";
|
BaseLayout.displayName = "BaseLayout";
|
||||||
|
|
||||||
type PositionFlagProps = {
|
|
||||||
containerHeight: Px,
|
|
||||||
};
|
|
||||||
export const PositionFlag = styled.div<PositionFlagProps>`
|
|
||||||
position: relative;
|
|
||||||
height: ${({ containerHeight }) => `${containerHeight * 0.85}px`};
|
|
||||||
width: ${({ containerHeight }) => `${containerHeight * 0.85}px`};
|
|
||||||
|
|
||||||
border-bottom-right-radius: 9px;
|
|
||||||
background-color: #f4f3ee;
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
`;
|
|
||||||
PositionFlag.displayName = "PositionFlag";
|
|
||||||
|
|
||||||
type PositionNumberProps = {
|
|
||||||
containerHeight: Px,
|
|
||||||
};
|
|
||||||
export const PositionNumber = styled.span<PositionNumberProps>`
|
|
||||||
font-family: ${p => p.theme.fonts.f1Regular};
|
|
||||||
font-size: ${({ containerHeight }) => `${containerHeight * 0.85 * 0.64}px`};
|
|
||||||
margin-top: 2px;
|
|
||||||
`;
|
|
||||||
PositionNumber.displayName = "PositionNumber";
|
|
||||||
|
|
||||||
type TeamColorBarProps = {
|
type TeamColorBarProps = {
|
||||||
color: string,
|
color: string,
|
||||||
};
|
};
|
||||||
export const TeamColorBar = styled.div<TeamColorBarProps>`
|
export const TeamColorBar = styled.div<TeamColorBarProps & TransitionProps>`
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 1%; // 6px;
|
width: 1%; // 6px;
|
||||||
height: 63%;
|
height: 63%;
|
||||||
|
|
||||||
background-color: ${({ color }) => color};
|
background-color: ${({ color }) => color};
|
||||||
|
|
||||||
|
clip-path: ${({ open }) => open
|
||||||
|
? "polygon(0 0, 100% 0, 100% 100%, 0 100%)"
|
||||||
|
: "polygon(-100% 0, 200% 0, 200% 0, -100% 0)"};
|
||||||
|
|
||||||
|
outline: ${({ color }) => color} solid 1px;
|
||||||
|
|
||||||
|
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||||
`;
|
`;
|
||||||
TeamColorBar.displayName = "TeamColorBar";
|
TeamColorBar.displayName = "TeamColorBar";
|
||||||
|
|
||||||
@@ -106,11 +147,27 @@ export const NumberContainer = styled.div`
|
|||||||
`;
|
`;
|
||||||
NumberContainer.displayName = "NumberContainer";
|
NumberContainer.displayName = "NumberContainer";
|
||||||
|
|
||||||
export const TeamName = styled.div`
|
const blinkingAnimation = keyframes`
|
||||||
|
0% { opacity: 0.4 }
|
||||||
|
14% { opacity: 0 }
|
||||||
|
42% { opacity: 0.4 }
|
||||||
|
56% { opacity: 0 }
|
||||||
|
86% { opacity: 1 }
|
||||||
|
`;
|
||||||
|
|
||||||
|
type TeamNameProps = OpenProps & {
|
||||||
|
duration: Milliseconds,
|
||||||
|
delay: Milliseconds,
|
||||||
|
}
|
||||||
|
export const TeamName = styled.div<TeamNameProps>`
|
||||||
position: relative;
|
position: relative;
|
||||||
font-family: ${p => p.theme.fonts.f1Regular};
|
font-family: ${p => p.theme.fonts.f1Regular};
|
||||||
color: #d1d1d1;
|
color: #d1d1d1;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
|
||||||
|
${({ open, duration, delay }) => open && css`
|
||||||
|
animation: ${blinkingAnimation} ${duration}ms step-end ${delay}ms;
|
||||||
|
`}
|
||||||
`;
|
`;
|
||||||
TeamName.displayName = "TeamName";
|
TeamName.displayName = "TeamName";
|
||||||
|
|
||||||
@@ -129,9 +186,10 @@ type FlagContainerProps = {
|
|||||||
width: Px,
|
width: Px,
|
||||||
right: Px,
|
right: Px,
|
||||||
};
|
};
|
||||||
export const FlagContainer = styled.div<FlagContainerProps>`
|
export const FlagContainer = styled.div<FlagContainerProps & TransitionProps>`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: ${({ right }) => `${right}px`};
|
right: ${({ right, open }) => open ? right : right * -3}px;
|
||||||
|
z-index: -1;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -141,26 +199,22 @@ export const FlagContainer = styled.div<FlagContainerProps>`
|
|||||||
width: ${({ width }) => `${width}px`};
|
width: ${({ width }) => `${width}px`};
|
||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
opacity: ${({ open }) => open ? 1 : 0};
|
||||||
|
|
||||||
|
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||||
`;
|
`;
|
||||||
FlagContainer.displayName = "FlagContainer";
|
FlagContainer.displayName = "FlagContainer";
|
||||||
|
|
||||||
type PortraitDivProps = {
|
type DriverPortraitContainerProps = TransitionProps & {
|
||||||
src: string,
|
placement: Placement,
|
||||||
height: Px,
|
|
||||||
rightMargin: Px,
|
|
||||||
};
|
};
|
||||||
export const PortraitDiv = styled.div<PortraitDivProps>`
|
export const DriverPortraitContainer = styled.div<DriverPortraitContainerProps>`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
height: ${({ height }) => `${height}px`};
|
${({ placement }) => placementStyleRules(placement)}
|
||||||
width: ${({ height }) => `${height * 1.4}px`};
|
|
||||||
|
|
||||||
bottom: 0;
|
opacity: ${({ open }) => open ? 1 : 0};
|
||||||
right: ${({ rightMargin }) => `${rightMargin}px`};
|
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||||
|
|
||||||
background-image: url(${({ src }) => src});
|
|
||||||
background-size: contain;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center ${({ height }) => `${height * .18}px`};
|
|
||||||
`;
|
`;
|
||||||
PortraitDiv.displayName = "PortraitDiv";
|
DriverPortraitContainer.displayName = "DriverPortraitContainer";
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { DriverId } from "../../../../types/state";
|
||||||
|
import { Percent, Px } from "../../../../types/style";
|
||||||
|
|
||||||
|
import { PortraitDiv } from "./styles";
|
||||||
|
|
||||||
|
const driverPortraits = require.context("../../../../public/images/drivers/front", true);
|
||||||
|
|
||||||
|
type DriverPortraitProps = {
|
||||||
|
driverId: DriverId,
|
||||||
|
height: Px,
|
||||||
|
verticalOffsetPercentage?: Percent,
|
||||||
|
};
|
||||||
|
export function DriverPortrait({
|
||||||
|
driverId,
|
||||||
|
height,
|
||||||
|
verticalOffsetPercentage = 0,
|
||||||
|
}: DriverPortraitProps) {
|
||||||
|
return (
|
||||||
|
<PortraitDiv
|
||||||
|
src={driverPortraits(`./${driverId}.png`)}
|
||||||
|
height={height}
|
||||||
|
verticalOffsetPercentage={verticalOffsetPercentage}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./DriverPortrait";
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
import { Percent, Px } from "../../../../types/style";
|
||||||
|
|
||||||
|
type PortraitDivProps = {
|
||||||
|
src: string,
|
||||||
|
height: Px,
|
||||||
|
verticalOffsetPercentage: Percent,
|
||||||
|
};
|
||||||
|
export const PortraitDiv = styled.div<PortraitDivProps>`
|
||||||
|
height: ${({ height }) => `${height}px`};
|
||||||
|
width: ${({ height }) => `${height * 1.4}px`};
|
||||||
|
|
||||||
|
--image: url(${({ src }) => src});
|
||||||
|
--position: center ${({ height, verticalOffsetPercentage }) =>
|
||||||
|
`${height * (verticalOffsetPercentage / 100)}px`};
|
||||||
|
|
||||||
|
background-image: var(--image);
|
||||||
|
background-size: contain;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: var(--position);
|
||||||
|
|
||||||
|
/* Redundant masking to allow special filters to work. */
|
||||||
|
mask-image: var(--image);
|
||||||
|
mask-size: contain;
|
||||||
|
mask-repeat: no-repeat;
|
||||||
|
mask-position: var(--position);
|
||||||
|
`;
|
||||||
|
PortraitDiv.displayName = "PortraitDiv";
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Px } from "../../../../types/style";
|
||||||
|
|
||||||
|
import { PositionFlagBox, PositionNumber } from "./styles";
|
||||||
|
|
||||||
|
type PositionFlagProps = {
|
||||||
|
size: Px,
|
||||||
|
number: number,
|
||||||
|
};
|
||||||
|
export function PositionFlag({ size, number }: PositionFlagProps) {
|
||||||
|
return (
|
||||||
|
<PositionFlagBox size={size}>
|
||||||
|
<PositionNumber size={size}>
|
||||||
|
{number}
|
||||||
|
</PositionNumber>
|
||||||
|
</PositionFlagBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./PositionFlag";
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import styled from "styled-components";
|
||||||
|
import { Px } from "../../../../types/style";
|
||||||
|
|
||||||
|
type PositionFlagBoxProps = {
|
||||||
|
size: Px,
|
||||||
|
};
|
||||||
|
export const PositionFlagBox = styled.div<PositionFlagBoxProps>`
|
||||||
|
position: relative;
|
||||||
|
height: ${({ size }) => `${size}px`};
|
||||||
|
width: ${({ size }) => `${size}px`};
|
||||||
|
|
||||||
|
border-bottom-right-radius: 15%;
|
||||||
|
background-color: #f4f3ee;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
`;
|
||||||
|
PositionFlagBox.displayName = "PositionFlagBox";
|
||||||
|
|
||||||
|
type PositionNumberProps = {
|
||||||
|
size: Px,
|
||||||
|
};
|
||||||
|
export const PositionNumber = styled.span<PositionNumberProps>`
|
||||||
|
font-family: ${p => p.theme.fonts.f1Regular};
|
||||||
|
font-size: ${({ size }) => `${size * 0.64}px`};
|
||||||
|
margin-top: 2px;
|
||||||
|
`;
|
||||||
|
PositionNumber.displayName = "PositionNumber";
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
import { useSpring, animated, easings } from "@react-spring/web";
|
||||||
|
import useMeasure from "react-use-measure";
|
||||||
|
|
||||||
|
import { AnimatedVenetianBlindsFilter, VenetianBlindsFilter } from "./styles";
|
||||||
|
import { wipeCustomDegClip } from "../../../../utils/styling";
|
||||||
|
import { Corner, Degrees, Fraction, Px } from "../../../../types/style";
|
||||||
|
import { Milliseconds } from "../../../../types/util";
|
||||||
|
|
||||||
|
type VenetianBlindsTransitionProps = {
|
||||||
|
visible: boolean,
|
||||||
|
delay?: Milliseconds,
|
||||||
|
blindsColor: string,
|
||||||
|
blindsColorFadeDuration: Milliseconds,
|
||||||
|
blindsColorFadeDelay?: Milliseconds,
|
||||||
|
blindsAngle: Degrees,
|
||||||
|
blindsOpenDuration: Milliseconds,
|
||||||
|
blindsOpenDelay?: Milliseconds,
|
||||||
|
blindsSize: { opaque: Px, transparent: Px },
|
||||||
|
wipeAngle: Degrees,
|
||||||
|
wipeDuration: Milliseconds,
|
||||||
|
wipeStartingCorner: Corner,
|
||||||
|
opacityStart?: Fraction,
|
||||||
|
opacityDuration?: Milliseconds,
|
||||||
|
opacityDelay?: Milliseconds,
|
||||||
|
spanBlinkDuration?: Milliseconds,
|
||||||
|
};
|
||||||
|
export const VenetianBlindsTransition = (
|
||||||
|
{
|
||||||
|
visible,
|
||||||
|
delay = 0,
|
||||||
|
blindsColor,
|
||||||
|
blindsColorFadeDuration,
|
||||||
|
blindsColorFadeDelay = 0,
|
||||||
|
blindsAngle,
|
||||||
|
blindsOpenDuration,
|
||||||
|
blindsOpenDelay = 0,
|
||||||
|
blindsSize,
|
||||||
|
wipeAngle,
|
||||||
|
wipeDuration,
|
||||||
|
wipeStartingCorner,
|
||||||
|
opacityStart = 1,
|
||||||
|
opacityDuration = wipeDuration,
|
||||||
|
opacityDelay = 0,
|
||||||
|
spanBlinkDuration,
|
||||||
|
children,
|
||||||
|
}: React.PropsWithChildren<VenetianBlindsTransitionProps>,
|
||||||
|
) => {
|
||||||
|
const [childRef, {
|
||||||
|
height: childHeight,
|
||||||
|
width: childWidth,
|
||||||
|
}] = useMeasure();
|
||||||
|
|
||||||
|
const { wipe } = useSpring({
|
||||||
|
wipe: visible ? 1 : 0,
|
||||||
|
config: {
|
||||||
|
duration: wipeDuration,
|
||||||
|
easing: easings.easeInOutQuint,
|
||||||
|
},
|
||||||
|
delay: 0 + delay,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { opacity } = useSpring({
|
||||||
|
opacity: visible ? 1 : opacityStart,
|
||||||
|
config: { duration: opacityDuration },
|
||||||
|
delay: opacityDelay + delay,
|
||||||
|
});
|
||||||
|
|
||||||
|
const blindsSpring = useSpring({
|
||||||
|
opacity: visible ? 1 : 0,
|
||||||
|
config: { duration: blindsOpenDuration },
|
||||||
|
delay: blindsOpenDelay + delay,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<animated.div
|
||||||
|
style={{
|
||||||
|
opacity,
|
||||||
|
clipPath: wipe.to(wipeProgress => {
|
||||||
|
const coordinates = wipeCustomDegClip(
|
||||||
|
childWidth,
|
||||||
|
childHeight,
|
||||||
|
wipeProgress,
|
||||||
|
wipeStartingCorner,
|
||||||
|
wipeAngle,
|
||||||
|
);
|
||||||
|
return `polygon(${coordinates.map(([x, y]) => `${x}px ${y}px`).join(", ")})`;
|
||||||
|
}),
|
||||||
|
}}
|
||||||
|
ref={childRef}
|
||||||
|
>
|
||||||
|
<AnimatedVenetianBlindsFilter
|
||||||
|
style={blindsSpring}
|
||||||
|
blindsAngle={blindsAngle}
|
||||||
|
transparentWidth={blindsSize.transparent}
|
||||||
|
opaqueWidth={blindsSize.opaque}
|
||||||
|
blindsColor={blindsColor}
|
||||||
|
blindsColorFadeDuration={blindsColorFadeDuration}
|
||||||
|
blindsColorFadeDelay={blindsColorFadeDelay + delay}
|
||||||
|
blindsClosing={visible}
|
||||||
|
spanBlinkDuration={spanBlinkDuration}
|
||||||
|
spanBlinkDelay={delay}
|
||||||
|
mirror={true} // Mirror version provides the opposite blinds.
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</AnimatedVenetianBlindsFilter>
|
||||||
|
<VenetianBlindsFilter
|
||||||
|
blindsAngle={blindsAngle}
|
||||||
|
transparentWidth={blindsSize.transparent}
|
||||||
|
opaqueWidth={blindsSize.opaque}
|
||||||
|
blindsColor={blindsColor}
|
||||||
|
blindsColorFadeDuration={blindsColorFadeDuration}
|
||||||
|
blindsColorFadeDelay={blindsColorFadeDelay + delay}
|
||||||
|
blindsClosing={visible}
|
||||||
|
spanBlinkDuration={spanBlinkDuration}
|
||||||
|
spanBlinkDelay={delay}
|
||||||
|
mirror={false}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</VenetianBlindsFilter>
|
||||||
|
</animated.div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./VenetianBlindsTransition";
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { animated } from "@react-spring/web";
|
||||||
|
import styled, { css, keyframes } from "styled-components";
|
||||||
|
|
||||||
|
import { Degrees, Px } from "../../../../types/style";
|
||||||
|
import { Milliseconds } from "../../../../types/util";
|
||||||
|
|
||||||
|
const spanBlinkAnimation = keyframes`
|
||||||
|
0% { opacity: 0 }
|
||||||
|
62% { opacity: 1 }
|
||||||
|
72% { opacity: 0 }
|
||||||
|
81% { opacity: 1 }
|
||||||
|
91% { opacity: 0 }
|
||||||
|
100% { opacity: 1 }
|
||||||
|
`;
|
||||||
|
|
||||||
|
type VenetianBlindsFilterProps = {
|
||||||
|
blindsAngle: Degrees,
|
||||||
|
transparentWidth: Px,
|
||||||
|
opaqueWidth: Px,
|
||||||
|
blindsColor: string,
|
||||||
|
blindsColorFadeDuration: Milliseconds,
|
||||||
|
blindsColorFadeDelay?: Milliseconds,
|
||||||
|
blindsClosing: boolean,
|
||||||
|
mirror?: boolean,
|
||||||
|
spanBlinkDuration?: Milliseconds,
|
||||||
|
spanBlinkDelay?: Milliseconds,
|
||||||
|
};
|
||||||
|
export const VenetianBlindsFilter = styled.div<VenetianBlindsFilterProps>`
|
||||||
|
position: ${({ mirror }) => mirror ? "absolute" : null};
|
||||||
|
|
||||||
|
--A: ${({ mirror }) => mirror ? "transparent" : "black"};
|
||||||
|
--B: ${({ mirror }) => mirror ? "black" : "transparent"};
|
||||||
|
|
||||||
|
mask-image: repeating-linear-gradient(
|
||||||
|
${({ blindsAngle }) => blindsAngle}deg,
|
||||||
|
var(--A),
|
||||||
|
var(--A) ${({ opaqueWidth }) => opaqueWidth}px,
|
||||||
|
var(--B) ${({ opaqueWidth }) => opaqueWidth}px,
|
||||||
|
var(--B) ${({ transparentWidth, opaqueWidth }) => transparentWidth + opaqueWidth}px
|
||||||
|
);
|
||||||
|
|
||||||
|
> * {
|
||||||
|
box-shadow: inset 0 0 0 99999px ${({ blindsColor, blindsClosing }) =>
|
||||||
|
`${blindsColor}${blindsClosing ? "00" : "cc"}`};
|
||||||
|
transition: box-shadow
|
||||||
|
${({ blindsColorFadeDuration }) => blindsColorFadeDuration}ms
|
||||||
|
cubic-bezier(0.88, 0.18, 0.96, 0.75)
|
||||||
|
${({ blindsColorFadeDelay = 0 }) => blindsColorFadeDelay}ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
${({ blindsClosing, spanBlinkDuration, spanBlinkDelay = 0 }) => (
|
||||||
|
blindsClosing && spanBlinkDuration
|
||||||
|
? css`
|
||||||
|
span {
|
||||||
|
animation: ${spanBlinkAnimation} ${spanBlinkDuration}ms step-end ${spanBlinkDelay}ms;
|
||||||
|
};
|
||||||
|
`
|
||||||
|
: null)
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
VenetianBlindsFilter.displayName = "VenetianBlindsFilter";
|
||||||
|
|
||||||
|
export const AnimatedVenetianBlindsFilter = animated(VenetianBlindsFilter);
|
||||||
|
AnimatedVenetianBlindsFilter.displayName = "AnimatedVenetianBlindsFilter";
|
||||||
@@ -3,6 +3,8 @@ import { useDrag } from "@use-gesture/react";
|
|||||||
import useMeasure from "react-use-measure";
|
import useMeasure from "react-use-measure";
|
||||||
import { clamp } from "lodash";
|
import { clamp } from "lodash";
|
||||||
|
|
||||||
|
import { Fraction } from "../../../../types/style";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnimatedProgressSliderBar,
|
AnimatedProgressSliderBar,
|
||||||
ProgressSliderBarHandle,
|
ProgressSliderBarHandle,
|
||||||
@@ -19,7 +21,7 @@ const MARGIN_WIDTH = 15;
|
|||||||
const percentage = (value: number) => `${Math.floor(value * 100)}%`;
|
const percentage = (value: number) => `${Math.floor(value * 100)}%`;
|
||||||
|
|
||||||
type ProgressSliderProps = {
|
type ProgressSliderProps = {
|
||||||
value: number, // Fraction of 1 (0.0 to 1.0)
|
value: Fraction,
|
||||||
onChange: (value: number) => void,
|
onChange: (value: number) => void,
|
||||||
disabled?: boolean,
|
disabled?: boolean,
|
||||||
formatter?: (value: number) => string,
|
formatter?: (value: number) => string,
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||||
import { FlagMode, TeamId } from "../../../types/state";
|
import { FlagMode, TeamId } from "../../../../types/state";
|
||||||
|
|
||||||
import { AngledFlag } from "../../BroadcastGraphics/Common/AngledFlag";
|
import { AngledFlag } from "../../../BroadcastGraphics/Common/AngledFlag";
|
||||||
import { BasicBlock } from "./styles";
|
import { BasicBlock } from "../styles";
|
||||||
|
|
||||||
type AngledFlagWorkSpaceProps = {
|
type AngledFlagWorkspaceProps = {
|
||||||
flagMode: FlagMode,
|
flagMode: FlagMode,
|
||||||
};
|
};
|
||||||
export function AngledFlagWorkSpace({ flagMode }: AngledFlagWorkSpaceProps) {
|
export function AngledFlagWorkspace({ flagMode }: AngledFlagWorkspaceProps) {
|
||||||
const { prototypeState } = useSelector(workspaceSelector);
|
const { prototypeState } = useSelector(workspaceSelector);
|
||||||
if (flagMode === "none") return null;
|
if (flagMode === "none") return null;
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./AngledFlagWorkspace";
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
|
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||||
|
import { theme } from "../../../../shared/theme";
|
||||||
|
import { BasicBlock } from "../styles";
|
||||||
|
import { DriverId } from "../../../../types/state";
|
||||||
|
import { getDriver } from "../../../../utils/dataLookup";
|
||||||
|
|
||||||
|
import { DriverPortrait } from "../../../BroadcastGraphics/Common/DriverPortrait";
|
||||||
|
import { PositionFlag } from "../../../BroadcastGraphics/Common/PositionFlag";
|
||||||
|
import { VenetianBlindsTransition } from "../../../BroadcastGraphics/Common/VenetianBlindsTransition";
|
||||||
|
|
||||||
|
export function VenetianBlindsWorkspace() {
|
||||||
|
const { prototypeState } = useSelector(workspaceSelector);
|
||||||
|
|
||||||
|
const bgColor = prototypeState?.venetianTransition?.showBG ?? true
|
||||||
|
? "black" : "transparent";
|
||||||
|
|
||||||
|
const [visible, setVisible] = useState(true);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BasicBlock width={450} height={450} color={bgColor} onClick={() => setVisible(!visible)} >
|
||||||
|
{prototypeState?.venetianTransition?.mode === "driverPortrait" ? (
|
||||||
|
<VenetianBlindsTransition
|
||||||
|
visible={visible}
|
||||||
|
blindsColor={theme.colors.teams[
|
||||||
|
getDriver( // This is very sus. This would not fly in production.
|
||||||
|
prototypeState?.venetianTransition?.subMode as DriverId ?? "hamilton",
|
||||||
|
).team.id
|
||||||
|
]}
|
||||||
|
blindsColorFadeDuration={600}
|
||||||
|
blindsColorFadeDelay={300}
|
||||||
|
blindsAngle={-45}
|
||||||
|
blindsOpenDuration={600}
|
||||||
|
blindsOpenDelay={600}
|
||||||
|
blindsSize={{ transparent: 2, opaque: 5 }}
|
||||||
|
wipeAngle={45}
|
||||||
|
wipeDuration={600}
|
||||||
|
wipeStartingCorner={
|
||||||
|
prototypeState?.venetianTransition?.wipeStartingCorner ?? "bottomRight"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<DriverPortrait
|
||||||
|
driverId={prototypeState?.venetianTransition?.subMode as DriverId ?? "hamilton"}
|
||||||
|
height={250}
|
||||||
|
/>
|
||||||
|
</VenetianBlindsTransition>
|
||||||
|
) : (
|
||||||
|
<VenetianBlindsTransition
|
||||||
|
visible={visible}
|
||||||
|
blindsColor="#f60d0d"
|
||||||
|
blindsColorFadeDuration={300}
|
||||||
|
blindsColorFadeDelay={200}
|
||||||
|
blindsAngle={-45}
|
||||||
|
blindsOpenDuration={100}
|
||||||
|
blindsOpenDelay={150}
|
||||||
|
blindsSize={{ transparent: 3, opaque: 6 }}
|
||||||
|
wipeAngle={40}
|
||||||
|
wipeDuration={300}
|
||||||
|
wipeStartingCorner={
|
||||||
|
prototypeState?.venetianTransition?.wipeStartingCorner ?? "bottomRight"
|
||||||
|
}
|
||||||
|
opacityStart={0.1}
|
||||||
|
opacityDuration={200}
|
||||||
|
opacityDelay={100}
|
||||||
|
spanBlinkDuration={500}
|
||||||
|
>
|
||||||
|
<PositionFlag size={122} number={parseInt(prototypeState?.venetianTransition?.subMode ?? "1")} />
|
||||||
|
</VenetianBlindsTransition>
|
||||||
|
)}
|
||||||
|
</BasicBlock>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./VenetianBlindsWorkspace";
|
||||||
@@ -19,3 +19,4 @@ export const BasicBlock = styled.div<BasicBlockProps>`
|
|||||||
|
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
`;
|
`;
|
||||||
|
BasicBlock.displayName = "BasicBlock";
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
import { PadBox } from "@bedrock-layout/padbox";
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
import { Split } from "@bedrock-layout/split";
|
import { Split } from "@bedrock-layout/split";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
|
||||||
|
|
||||||
import { setPrototypeState } from "../../../../features/workspace/workspaceSlice";
|
import { updateAngledFlagCountry, updateAngledFlagTeam } from "../../../../features/workspace/workspaceSlice";
|
||||||
import { FlagMode, TeamId } from "../../../../types/state";
|
import { FlagMode, TeamId } from "../../../../types/state";
|
||||||
|
|
||||||
import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
|
import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
|
||||||
@@ -17,41 +16,22 @@ const teams: Array<TeamId> = [
|
|||||||
"mclaren", "mercedes", "redBull", "williams",
|
"mclaren", "mercedes", "redBull", "williams",
|
||||||
];
|
];
|
||||||
|
|
||||||
const DEFAULT_COUNTRY = "GBR";
|
|
||||||
const DEFAULT_TEAM: TeamId = "alfaRomeo";
|
|
||||||
|
|
||||||
type AngledFlagPrototypeControlsProps = {
|
type AngledFlagPrototypeControlsProps = {
|
||||||
flagMode: FlagMode,
|
flagMode: FlagMode,
|
||||||
};
|
};
|
||||||
export function AngledFlagPrototypeControls({ flagMode }: AngledFlagPrototypeControlsProps) {
|
export function AngledFlagPrototypeControls({ flagMode }: AngledFlagPrototypeControlsProps) {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { prototypeState } = useSelector(workspaceSelector);
|
|
||||||
const flagList = flagMode === "country" ? countries : flagMode === "team" ? teams : [];
|
const flagList = flagMode === "country" ? countries : flagMode === "team" ? teams : [];
|
||||||
|
|
||||||
const onChange = (flag: "flagA" | "flagB") => (index: number) => {
|
const onChange = (flag: "flagA" | "flagB") => (index: number) => {
|
||||||
if (flagMode === "country") {
|
if (flagMode === "country") {
|
||||||
dispatch(setPrototypeState({
|
dispatch(updateAngledFlagCountry({
|
||||||
angledFlagCountry: {
|
[flag]: countries[index],
|
||||||
flagA: flag === "flagA"
|
|
||||||
? countries[index]
|
|
||||||
: prototypeState?.angledFlagCountry?.flagA ?? DEFAULT_COUNTRY,
|
|
||||||
flagB: flag === "flagB"
|
|
||||||
? countries[index]
|
|
||||||
: prototypeState?.angledFlagCountry?.flagB ?? DEFAULT_COUNTRY,
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
} else if (flagMode === "team") {
|
} else if (flagMode === "team") {
|
||||||
dispatch(setPrototypeState({
|
dispatch(updateAngledFlagTeam({
|
||||||
angledFlagTeam: {
|
[flag]: teams[index],
|
||||||
flagA: flag === "flagA"
|
|
||||||
? teams[index]
|
|
||||||
: prototypeState?.angledFlagTeam?.flagA ?? DEFAULT_TEAM,
|
|
||||||
flagB: flag === "flagB"
|
|
||||||
? teams[index]
|
|
||||||
: prototypeState?.angledFlagTeam?.flagB ?? DEFAULT_TEAM,
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { findIndex } from "lodash";
|
|||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||||
import { selectedCarsAdd, selectedCarsClear, selectedCarsRemove } from "../../../../features/broadcast/director/broadcastDirectorSlice";
|
import { pushSelectedCars, clearSelectedCars, removeSelectedCars } from "../../../../features/broadcast/director/broadcastDirectorSlice";
|
||||||
import { eventSelector } from "../../../../features/event/eventSelector";
|
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||||
import { Car } from "../../../../types/state";
|
import { Car } from "../../../../types/state";
|
||||||
import { carMatch } from "../../../../utils/comparators";
|
import { carMatch } from "../../../../utils/comparators";
|
||||||
@@ -21,13 +21,13 @@ export function GridSelection() {
|
|||||||
|
|
||||||
const carClick = (car: Car, selected: boolean) => () => {
|
const carClick = (car: Car, selected: boolean) => () => {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
dispatch(selectedCarsRemove(car));
|
dispatch(removeSelectedCars(car));
|
||||||
} else {
|
} else {
|
||||||
dispatch(selectedCarsAdd(car));
|
dispatch(pushSelectedCars(car));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const carDoubleClick = (car: Car) => () => {
|
const carDoubleClick = (car: Car) => () => {
|
||||||
dispatch(selectedCarsClear(car));
|
dispatch(clearSelectedCars(car));
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
|
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||||
|
import { updateVenetianTransition } from "../../../../features/workspace/workspaceSlice";
|
||||||
|
import { DriverId } from "../../../../types/state";
|
||||||
|
import { Corner } from "../../../../types/style";
|
||||||
|
|
||||||
|
import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
|
||||||
|
import { Toggle } from "../../../Common/Inputs/Toggle";
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: This is all hacky and 100% wouldn't fly in production code.
|
||||||
|
const modes = ["positionFlag", "driverPortrait"];
|
||||||
|
const subModes: [string[], DriverId[]] = [
|
||||||
|
["1", "3", "5", "10", "20"],
|
||||||
|
["hamilton", "verstappen", "schumacher", "alonso", "leclerc"],
|
||||||
|
];
|
||||||
|
const corners: Corner[] = ["bottomRight", "bottomLeft", "topLeft", "topRight"];
|
||||||
|
|
||||||
|
export function VenetianBlindsPrototypeControls() {
|
||||||
|
const [modeIndex, setModeIndex] = useState(0);
|
||||||
|
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { prototypeState } = useSelector(workspaceSelector);
|
||||||
|
|
||||||
|
const changeMode = (index: number) => {
|
||||||
|
setModeIndex(index);
|
||||||
|
|
||||||
|
dispatch(updateVenetianTransition({
|
||||||
|
mode: modes[index],
|
||||||
|
subMode: subModes[index][0],
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
const changeSubMode = (index: number) => {
|
||||||
|
dispatch(updateVenetianTransition({
|
||||||
|
subMode: subModes[modeIndex][index],
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
const onChangeStartingCorner = (index: number) => {
|
||||||
|
dispatch(updateVenetianTransition({
|
||||||
|
wipeStartingCorner: corners[index],
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const onToggle = (value: boolean) => {
|
||||||
|
dispatch(updateVenetianTransition({
|
||||||
|
showBG: value,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<InlineCluster as={PadBox} gutter="md" padding="md">
|
||||||
|
<SlotSelector
|
||||||
|
items={modes}
|
||||||
|
onChange={changeMode}
|
||||||
|
label="Mode"
|
||||||
|
slotWidth="200px"
|
||||||
|
/>
|
||||||
|
<SlotSelector
|
||||||
|
items={subModes[modeIndex]}
|
||||||
|
onChange={changeSubMode}
|
||||||
|
label="SubMode"
|
||||||
|
slotWidth="200px"
|
||||||
|
/>
|
||||||
|
<SlotSelector
|
||||||
|
items={corners}
|
||||||
|
onChange={onChangeStartingCorner}
|
||||||
|
label="Starting Corner"
|
||||||
|
slotWidth="200px"
|
||||||
|
/>
|
||||||
|
<Toggle
|
||||||
|
toggled={prototypeState?.venetianTransition?.showBG ?? true}
|
||||||
|
onToggle={onToggle}
|
||||||
|
label="Show BG"
|
||||||
|
/>
|
||||||
|
</InlineCluster>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./VenetianBlindsPrototypeControls";
|
||||||
@@ -19,14 +19,16 @@ type WorkspaceProps = {
|
|||||||
workspaceId: WorkspaceId,
|
workspaceId: WorkspaceId,
|
||||||
previewContent: ReactNode,
|
previewContent: ReactNode,
|
||||||
prototypeControls: ReactNode,
|
prototypeControls: ReactNode,
|
||||||
|
showAnimationSpeedSelector?: boolean,
|
||||||
};
|
};
|
||||||
export const Workspace = ({
|
export const Workspace = ({
|
||||||
workspaceId,
|
workspaceId,
|
||||||
previewContent,
|
previewContent,
|
||||||
prototypeControls,
|
prototypeControls,
|
||||||
|
showAnimationSpeedSelector = false,
|
||||||
}: WorkspaceProps) => {
|
}: WorkspaceProps) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { animatedBG, workspaceProperties } = useSelector(workspaceSelector);
|
const { animatedBG, darkBG, workspaceProperties } = useSelector(workspaceSelector);
|
||||||
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -56,6 +58,7 @@ export const Workspace = ({
|
|||||||
<PreviewWindow
|
<PreviewWindow
|
||||||
dimensions={workspaceProperties.previewWindowDimensions}
|
dimensions={workspaceProperties.previewWindowDimensions}
|
||||||
animatedBG={animatedBG}
|
animatedBG={animatedBG}
|
||||||
|
darkBG={darkBG}
|
||||||
>
|
>
|
||||||
{previewContent}
|
{previewContent}
|
||||||
<OverlayDisplay
|
<OverlayDisplay
|
||||||
@@ -63,7 +66,9 @@ export const Workspace = ({
|
|||||||
/>
|
/>
|
||||||
</PreviewWindow>
|
</PreviewWindow>
|
||||||
<ControlsContainer>
|
<ControlsContainer>
|
||||||
<WorkspaceControls />
|
<WorkspaceControls
|
||||||
|
showAnimationSpeedSelector={showAnimationSpeedSelector}
|
||||||
|
/>
|
||||||
{prototypeControls}
|
{prototypeControls}
|
||||||
</ControlsContainer>
|
</ControlsContainer>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import styled, { css, keyframes } from "styled-components";
|
import styled, { css, keyframes } from "styled-components";
|
||||||
import { PadBox } from "@bedrock-layout/padbox";
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
|
||||||
import bg from "../../../public/images/misc/checker-40x40.png";
|
|
||||||
import { Dimensions } from "../../../types/state";
|
import { Dimensions } from "../../../types/state";
|
||||||
|
|
||||||
|
import bgLight from "../../../public/images/misc/checker-40x40-light.png";
|
||||||
|
import bgDark from "../../../public/images/misc/checker-40x40-dark.png";
|
||||||
|
|
||||||
const scrollAnimation = keyframes`
|
const scrollAnimation = keyframes`
|
||||||
from { background-position: 0 0; }
|
from { background-position: 0 0; }
|
||||||
to { background-position: 80px -40px; }
|
to { background-position: 80px -40px; }
|
||||||
@@ -12,6 +14,7 @@ const scrollAnimation = keyframes`
|
|||||||
export type PreviewWindowProps = {
|
export type PreviewWindowProps = {
|
||||||
dimensions: Dimensions,
|
dimensions: Dimensions,
|
||||||
animatedBG?: boolean,
|
animatedBG?: boolean,
|
||||||
|
darkBG?: boolean,
|
||||||
};
|
};
|
||||||
export const PreviewWindow = styled.div<PreviewWindowProps>`
|
export const PreviewWindow = styled.div<PreviewWindowProps>`
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -24,7 +27,7 @@ export const PreviewWindow = styled.div<PreviewWindowProps>`
|
|||||||
|
|
||||||
border-radius: 1em;
|
border-radius: 1em;
|
||||||
|
|
||||||
background-image: url("${bg}");
|
background-image: url("${({ darkBG }) => darkBG ? bgDark : bgLight}");
|
||||||
background-position: 0px 0px;
|
background-position: 0px 0px;
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,56 @@
|
|||||||
import { Grid } from "@bedrock-layout/grid";
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
import { PadBox } from "@bedrock-layout/padbox";
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
import { Split } from "@bedrock-layout/split";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
||||||
import { setAnimatedBG } from "../../../features/workspace/workspaceSlice";
|
import { setAnimatedBG, setDarkBG, setDebugDurationMultiplier } from "../../../features/workspace/workspaceSlice";
|
||||||
|
import { SlotSelector } from "../../Common/Inputs/SlotSelector";
|
||||||
|
|
||||||
import { Toggle } from "../../Common/Inputs/Toggle";
|
import { Toggle } from "../../Common/Inputs/Toggle";
|
||||||
import { OverlayControl } from "../../OverlayTool";
|
import { OverlayControl } from "../../OverlayTool";
|
||||||
|
|
||||||
export const WorkspaceControls = () => {
|
const debugMultipliers = ["1", "1.5", "2", "3", "5", "10"];
|
||||||
|
|
||||||
|
|
||||||
|
type WorkspaceControlsProps = {
|
||||||
|
showAnimationSpeedSelector?: boolean,
|
||||||
|
};
|
||||||
|
export const WorkspaceControls = (
|
||||||
|
{ showAnimationSpeedSelector = false }: WorkspaceControlsProps,
|
||||||
|
) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { animatedBG } = useSelector(workspaceSelector);
|
const { animatedBG, darkBG } = useSelector(workspaceSelector);
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<Grid gutter="sm" minItemWidth="100px">
|
<Split gutter="md">
|
||||||
<PadBox padding="sm">
|
<InlineCluster as={PadBox} padding="sm" gutter="md">
|
||||||
<Toggle
|
<Toggle
|
||||||
label="Animate BG"
|
label="Animate BG"
|
||||||
toggled={animatedBG}
|
toggled={animatedBG}
|
||||||
onToggle={(value: boolean) => {
|
onToggle={(value: boolean) => {
|
||||||
dispatch(setAnimatedBG(value));
|
dispatch(setAnimatedBG(value));
|
||||||
}} />
|
}}
|
||||||
</PadBox>
|
/>
|
||||||
|
<Toggle
|
||||||
|
label="Dark BG"
|
||||||
|
toggled={darkBG}
|
||||||
|
onToggle={(value: boolean) => {
|
||||||
|
dispatch(setDarkBG(value));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{showAnimationSpeedSelector && (
|
||||||
|
<SlotSelector
|
||||||
|
label="Animation Duration"
|
||||||
|
items={debugMultipliers}
|
||||||
|
formatter={value => `x${value}`}
|
||||||
|
onChange={index =>
|
||||||
|
dispatch(setDebugDurationMultiplier(parseFloat(debugMultipliers[index])))}
|
||||||
|
slotWidth="4ch"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</InlineCluster>
|
||||||
<OverlayControl />
|
<OverlayControl />
|
||||||
</Grid>
|
</Split>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -7,15 +7,17 @@ import { mainMenuDimensionsSelector } from "../../features/pageDimensions/pageDi
|
|||||||
import { setDimensions } from "../../features/pageDimensions/pageDimensionsSlice";
|
import { setDimensions } from "../../features/pageDimensions/pageDimensionsSlice";
|
||||||
|
|
||||||
import { FullScreenContainer } from "../Common/FullScreenContainer.styled";
|
import { FullScreenContainer } from "../Common/FullScreenContainer.styled";
|
||||||
|
import { IndexHeading } from "../Common/IndexHeading.styled";
|
||||||
import { WorkspaceList } from "./WorkspaceList";
|
import { WorkspaceList } from "./WorkspaceList";
|
||||||
import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
|
import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
|
||||||
|
|
||||||
import { Workspace } from "./Workspace";
|
import { Workspace } from "./Workspace";
|
||||||
import { ChyronPrototypeControls } from "./PrototypingControls/ChyronPrototype";
|
import { ChyronPrototypeControls } from "./PrototypingControls/ChyronPrototype";
|
||||||
import { AngledFlagWorkSpace } from "./CustomWorkSpaces/AngledFlagWorkSpace";
|
import { AngledFlagWorkspace } from "./CustomWorkSpaces/AngledFlagWorkspace";
|
||||||
import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPrototype";
|
import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPrototype";
|
||||||
import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
||||||
import { IndexHeading } from "../Common/IndexHeading.styled";
|
import { VenetianBlindsWorkspace } from "./CustomWorkSpaces/VenetianBlindsWorkspace";
|
||||||
|
import { VenetianBlindsPrototypeControls } from "./PrototypingControls/VenetianBlindsPrototype";
|
||||||
|
|
||||||
const WORKSPACE_LIST_WIDTH = 180;
|
const WORKSPACE_LIST_WIDTH = 180;
|
||||||
|
|
||||||
@@ -53,32 +55,41 @@ export default function Workspaces() {
|
|||||||
<Route path="chyron" element={
|
<Route path="chyron" element={
|
||||||
<Workspace
|
<Workspace
|
||||||
workspaceId="chyron"
|
workspaceId="chyron"
|
||||||
previewContent={<ChyronContainer />}
|
previewContent={<ChyronContainer debug />}
|
||||||
prototypeControls={<ChyronPrototypeControls />}
|
prototypeControls={<ChyronPrototypeControls />}
|
||||||
|
showAnimationSpeedSelector
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
<Route path="chyronWide" element={
|
<Route path="chyronWide" element={
|
||||||
<Workspace
|
<Workspace
|
||||||
workspaceId="chyronWide"
|
workspaceId="chyronWide"
|
||||||
previewContent={<ChyronContainer />}
|
previewContent={<ChyronContainer debug />}
|
||||||
prototypeControls={<ChyronPrototypeControls />}
|
prototypeControls={<ChyronPrototypeControls />}
|
||||||
|
showAnimationSpeedSelector
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
<Route path="angledFlagCountry" element={
|
<Route path="angledFlagCountry" element={
|
||||||
<Workspace
|
<Workspace
|
||||||
workspaceId="angledFlagCountry"
|
workspaceId="angledFlagCountry"
|
||||||
previewContent={<AngledFlagWorkSpace flagMode="country"/>}
|
previewContent={<AngledFlagWorkspace flagMode="country"/>}
|
||||||
prototypeControls={<AngledFlagPrototypeControls flagMode="country" />}
|
prototypeControls={<AngledFlagPrototypeControls flagMode="country" />}
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
<Route path="angledFlagTeam" element={
|
<Route path="angledFlagTeam" element={
|
||||||
<Workspace
|
<Workspace
|
||||||
workspaceId="angledFlagTeam"
|
workspaceId="angledFlagTeam"
|
||||||
previewContent={<AngledFlagWorkSpace flagMode="team"/>}
|
previewContent={<AngledFlagWorkspace flagMode="team"/>}
|
||||||
prototypeControls={<AngledFlagPrototypeControls flagMode="team"/>}
|
prototypeControls={<AngledFlagPrototypeControls flagMode="team"/>}
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
<Route path="*" element={<h1>Unknown Workspace</h1>} />
|
<Route path="venetianTransition" element={
|
||||||
|
<Workspace
|
||||||
|
workspaceId="venetianTransition"
|
||||||
|
previewContent={<VenetianBlindsWorkspace />}
|
||||||
|
prototypeControls={<VenetianBlindsPrototypeControls />}
|
||||||
|
/>
|
||||||
|
} />
|
||||||
|
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</FullScreenContainer>
|
</FullScreenContainer>
|
||||||
</LayoutGridItem>
|
</LayoutGridItem>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export const workspaces: WorkspaceObject = {
|
|||||||
"chyron-driver-medium-full-vet.png",
|
"chyron-driver-medium-full-vet.png",
|
||||||
"chyron-driver-medium-full-per.png",
|
"chyron-driver-medium-full-per.png",
|
||||||
"chyron-driver-medium-full-msc.png",
|
"chyron-driver-medium-full-msc.png",
|
||||||
|
"chyron-driver-medium-op0-ham.png",
|
||||||
"chyron-driver-medium-op1-ham.png",
|
"chyron-driver-medium-op1-ham.png",
|
||||||
"chyron-driver-medium-op2-ham.png",
|
"chyron-driver-medium-op2-ham.png",
|
||||||
"chyron-driver-medium-full-ham.png",
|
"chyron-driver-medium-full-ham.png",
|
||||||
@@ -67,4 +68,20 @@ export const workspaces: WorkspaceObject = {
|
|||||||
height: 500,
|
height: 500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
venetianTransition: {
|
||||||
|
name: "Venetian Transition",
|
||||||
|
overlayIds: [
|
||||||
|
"venetian-pos-1.png",
|
||||||
|
"venetian-pos-2.png",
|
||||||
|
"venetian-pos-3.png",
|
||||||
|
"venetian-pos-4.png",
|
||||||
|
"venetian-pos-5.png",
|
||||||
|
"venetian-pos-6.png",
|
||||||
|
"venetian-pos-7.png",
|
||||||
|
],
|
||||||
|
previewWindowDimensions: {
|
||||||
|
width: 700,
|
||||||
|
height: 500,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
@@ -13,16 +13,16 @@ export const broadcastDirectorSlice = createSlice({
|
|||||||
name: "broadcastDirector",
|
name: "broadcastDirector",
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
selectedCarsAdd: (state, action: PayloadAction<Car>) => {
|
pushSelectedCars: (state, action: PayloadAction<Car>) => {
|
||||||
const index = findIndex(state.selectedCars, carMatch(action.payload));
|
const index = findIndex(state.selectedCars, carMatch(action.payload));
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
state.selectedCars = state.selectedCars.concat(action.payload);
|
state.selectedCars = state.selectedCars.concat(action.payload);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectedCarsSet: (state, action: PayloadAction<Car>) => { // Might be removed.
|
setSelectedCars: (state, action: PayloadAction<Car>) => { // Might be removed.
|
||||||
state.selectedCars = [action.payload];
|
state.selectedCars = [action.payload];
|
||||||
},
|
},
|
||||||
selectedCarsRemove: (state, action: PayloadAction<Car | number>) => {
|
removeSelectedCars: (state, action: PayloadAction<Car | number>) => {
|
||||||
const index = typeof action.payload === "number"
|
const index = typeof action.payload === "number"
|
||||||
? action.payload
|
? action.payload
|
||||||
: findIndex(state.selectedCars, carMatch(action.payload));
|
: findIndex(state.selectedCars, carMatch(action.payload));
|
||||||
@@ -36,7 +36,7 @@ export const broadcastDirectorSlice = createSlice({
|
|||||||
* car.
|
* car.
|
||||||
* @param action Car (optional)
|
* @param action Car (optional)
|
||||||
*/
|
*/
|
||||||
selectedCarsClear: (state, action: PayloadAction<Optional<Car>>) => {
|
clearSelectedCars: (state, action: PayloadAction<Optional<Car>>) => {
|
||||||
if (action.payload == null) {
|
if (action.payload == null) {
|
||||||
state.selectedCars = [];
|
state.selectedCars = [];
|
||||||
} else {
|
} else {
|
||||||
@@ -47,9 +47,9 @@ export const broadcastDirectorSlice = createSlice({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
selectedCarsAdd,
|
pushSelectedCars,
|
||||||
selectedCarsSet,
|
setSelectedCars,
|
||||||
selectedCarsRemove,
|
removeSelectedCars,
|
||||||
selectedCarsClear,
|
clearSelectedCars,
|
||||||
} = broadcastDirectorSlice.actions;
|
} = broadcastDirectorSlice.actions;
|
||||||
export default broadcastDirectorSlice.reducer;
|
export default broadcastDirectorSlice.reducer;
|
||||||
@@ -10,10 +10,10 @@ export const broadcastGraphicsSlice = createSlice({
|
|||||||
name: "broadcastGraphics",
|
name: "broadcastGraphics",
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
chyronsSet: (state, action: PayloadAction<BGChyrons>) => {
|
setChyrons: (state, action: PayloadAction<BGChyrons>) => {
|
||||||
state.chyrons = action.payload;
|
state.chyrons = action.payload;
|
||||||
},
|
},
|
||||||
chyronsOpenStateSet: (state, action: PayloadAction<OpenState>) => {
|
setChyronsOpenState: (state, action: PayloadAction<OpenState>) => {
|
||||||
if (state.chyrons == null) return;
|
if (state.chyrons == null) return;
|
||||||
state.chyrons.openState = action.payload;
|
state.chyrons.openState = action.payload;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ export const broadcastGraphicsSlice = createSlice({
|
|||||||
state.chyrons.openState = action.payload;
|
state.chyrons.openState = action.payload;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
chyronsOpenStateIncrement: (state) => {
|
incrementChyronsOpenState: (state) => {
|
||||||
if (state.chyrons == null) return;
|
if (state.chyrons == null) return;
|
||||||
++state.chyrons.openState;
|
++state.chyrons.openState;
|
||||||
|
|
||||||
@@ -29,16 +29,16 @@ export const broadcastGraphicsSlice = createSlice({
|
|||||||
++state.chyrons.openState;
|
++state.chyrons.openState;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
chyronsClear: (state) => {
|
clearChyrons: (state) => {
|
||||||
state.chyrons = null;
|
state.chyrons = null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
chyronsSet,
|
setChyrons,
|
||||||
chyronsOpenStateSet,
|
setChyronsOpenState,
|
||||||
chyronsOpenStateIncrement,
|
incrementChyronsOpenState,
|
||||||
chyronsClear,
|
clearChyrons,
|
||||||
} = broadcastGraphicsSlice.actions;
|
} = broadcastGraphicsSlice.actions;
|
||||||
export default broadcastGraphicsSlice.reducer;
|
export default broadcastGraphicsSlice.reducer;
|
||||||
@@ -46,13 +46,13 @@ export const eventSlice = createSlice({
|
|||||||
name: "event",
|
name: "event",
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
courseFlagSet: (state, action: PayloadAction<CourseFlag>) => {
|
setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
|
||||||
state.courseStatus.courseFlag = action.payload;
|
state.courseStatus.courseFlag = action.payload;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
courseFlagSet,
|
setCourseFlag,
|
||||||
} = eventSlice.actions;
|
} = eventSlice.actions;
|
||||||
export default eventSlice.reducer;
|
export default eventSlice.reducer;
|
||||||
@@ -1,15 +1,18 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
import { PrototypeState, RootState, WorkspaceId, WorkspaceProperties } from "../../types/state";
|
import { PrototypeState, RootState, WorkspaceId, WorkspaceProperties } from "../../types/state";
|
||||||
|
import { Fraction } from "../../types/style";
|
||||||
|
|
||||||
const initialState: RootState["workspace"] = {
|
const initialState: RootState["workspace"] = {
|
||||||
workspaceId: "",
|
workspaceId: "",
|
||||||
animatedBG: true,
|
animatedBG: true,
|
||||||
|
darkBG: false,
|
||||||
|
debugDurationMultiplier: 1.0,
|
||||||
workspaceProperties: {
|
workspaceProperties: {
|
||||||
name: "undefined",
|
name: "undefined",
|
||||||
overlayIds: [],
|
overlayIds: [],
|
||||||
previewWindowDimensions: { width: 0, height: 0 },
|
previewWindowDimensions: { width: 0, height: 0 },
|
||||||
},
|
},
|
||||||
prototypeState: null,
|
prototypeState: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateWorkspaceAction = {
|
export type UpdateWorkspaceAction = {
|
||||||
@@ -27,12 +30,64 @@ export const workspaceSlice = createSlice({
|
|||||||
setAnimatedBG: (state, action: PayloadAction<boolean>) => {
|
setAnimatedBG: (state, action: PayloadAction<boolean>) => {
|
||||||
state.animatedBG = action.payload;
|
state.animatedBG = action.payload;
|
||||||
},
|
},
|
||||||
|
setDarkBG: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.darkBG = action.payload;
|
||||||
|
},
|
||||||
|
setDebugDurationMultiplier: (state, action: PayloadAction<Fraction>) => {
|
||||||
|
state.debugDurationMultiplier = action.payload;
|
||||||
|
},
|
||||||
updateWorkspace: (state, action: PayloadAction<UpdateWorkspaceAction>) => {
|
updateWorkspace: (state, action: PayloadAction<UpdateWorkspaceAction>) => {
|
||||||
state.workspaceId = action.payload.workspaceId;
|
state.workspaceId = action.payload.workspaceId;
|
||||||
state.workspaceProperties = action.payload.workspaceProperties;
|
state.workspaceProperties = action.payload.workspaceProperties;
|
||||||
},
|
},
|
||||||
setPrototypeState: (state, action: PayloadAction<PrototypeState>) => {
|
|
||||||
state.prototypeState = action.payload;
|
// Prototype States
|
||||||
|
updateAngledFlagCountry: (
|
||||||
|
state,
|
||||||
|
action: PayloadAction<Partial<PrototypeState["angledFlagCountry"]>>,
|
||||||
|
) => {
|
||||||
|
if (state.prototypeState.angledFlagCountry == null) {
|
||||||
|
state.prototypeState.angledFlagCountry = {
|
||||||
|
flagA: "GBR",
|
||||||
|
flagB: "GBR",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
state.prototypeState.angledFlagCountry = Object.assign(
|
||||||
|
state.prototypeState.angledFlagCountry,
|
||||||
|
action.payload,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
updateAngledFlagTeam: (
|
||||||
|
state,
|
||||||
|
action: PayloadAction<Partial<PrototypeState["angledFlagTeam"]>>,
|
||||||
|
) => {
|
||||||
|
if (state.prototypeState.angledFlagTeam == null) {
|
||||||
|
state.prototypeState.angledFlagTeam = {
|
||||||
|
flagA: "alfaRomeo",
|
||||||
|
flagB: "alfaRomeo",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
state.prototypeState.angledFlagTeam = Object.assign(
|
||||||
|
state.prototypeState.angledFlagTeam,
|
||||||
|
action.payload,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
updateVenetianTransition: (
|
||||||
|
state,
|
||||||
|
action: PayloadAction<Partial<PrototypeState["venetianTransition"]>>,
|
||||||
|
) => {
|
||||||
|
if (state.prototypeState.venetianTransition == null) {
|
||||||
|
state.prototypeState.venetianTransition = {
|
||||||
|
mode: "portraitFlag",
|
||||||
|
subMode: "1",
|
||||||
|
showBG: true,
|
||||||
|
wipeStartingCorner: "bottomRight",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
state.prototypeState.venetianTransition = Object.assign(
|
||||||
|
state.prototypeState?.venetianTransition,
|
||||||
|
action.payload,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -40,7 +95,11 @@ export const workspaceSlice = createSlice({
|
|||||||
export const {
|
export const {
|
||||||
setWorkspaceId,
|
setWorkspaceId,
|
||||||
setAnimatedBG,
|
setAnimatedBG,
|
||||||
|
setDarkBG,
|
||||||
|
setDebugDurationMultiplier,
|
||||||
updateWorkspace,
|
updateWorkspace,
|
||||||
setPrototypeState,
|
updateAngledFlagCountry,
|
||||||
|
updateAngledFlagTeam,
|
||||||
|
updateVenetianTransition,
|
||||||
} = workspaceSlice.actions;
|
} = workspaceSlice.actions;
|
||||||
export default workspaceSlice.reducer;
|
export default workspaceSlice.reducer;
|
||||||
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 17 KiB |
@@ -1,4 +1,5 @@
|
|||||||
import { Milliseconds, Optional } from "./util";
|
import { Milliseconds, Optional } from "./util";
|
||||||
|
import { Corner, Fraction } from "./style";
|
||||||
|
|
||||||
export interface RootState {
|
export interface RootState {
|
||||||
pageDimensions: PageDimensions;
|
pageDimensions: PageDimensions;
|
||||||
@@ -21,8 +22,10 @@ export interface Dimensions { width: number; height: number; }
|
|||||||
export interface Workspace {
|
export interface Workspace {
|
||||||
workspaceId: WorkspaceId;
|
workspaceId: WorkspaceId;
|
||||||
animatedBG: boolean;
|
animatedBG: boolean;
|
||||||
|
darkBG: boolean;
|
||||||
|
debugDurationMultiplier: Fraction,
|
||||||
workspaceProperties: WorkspaceProperties;
|
workspaceProperties: WorkspaceProperties;
|
||||||
prototypeState: Optional<PrototypeState>;
|
prototypeState: PrototypeState;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WorkspaceId = string;
|
export type WorkspaceId = string;
|
||||||
@@ -40,6 +43,12 @@ export interface PrototypeState {
|
|||||||
flagA: TeamId;
|
flagA: TeamId;
|
||||||
flagB: TeamId;
|
flagB: TeamId;
|
||||||
};
|
};
|
||||||
|
venetianTransition?: {
|
||||||
|
mode: string,
|
||||||
|
subMode: string,
|
||||||
|
showBG: boolean;
|
||||||
|
wipeStartingCorner: Corner,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overlay Tool
|
// Overlay Tool
|
||||||
|
|||||||
@@ -4,6 +4,39 @@
|
|||||||
export type Px = number;
|
export type Px = number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type to remind you that we're dealing with percentages.
|
* Type to remind you that we're dealing with percentages (100 = 100%).
|
||||||
*/
|
*/
|
||||||
export type Percent = number;
|
export type Percent = number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type to remind you that we're dealing with fraction (0-1).
|
||||||
|
*/
|
||||||
|
export type Fraction = number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type to remind you that we're dealing with degrees (0-360, etc).
|
||||||
|
*/
|
||||||
|
export type Degrees = number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object to cleanly define relative/absolute placement for a styled component.
|
||||||
|
*/
|
||||||
|
export interface Placement {
|
||||||
|
top?: string;
|
||||||
|
right?: string;
|
||||||
|
bottom?: string;
|
||||||
|
left?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Useful to initialize movements from.
|
||||||
|
*/
|
||||||
|
export type Corner = "topLeft" | "topRight" | "bottomRight" | "bottomLeft";
|
||||||
|
|
||||||
|
|
||||||
|
export interface TransitionArgs {
|
||||||
|
property?: string,
|
||||||
|
duration?: Milliseconds,
|
||||||
|
timing?: string
|
||||||
|
delay?: Milliseconds,
|
||||||
|
}
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
export type Optional<TEntity> = TEntity | null;
|
export type Optional<T> = T | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type to remind you that we're dealing with milliseconds.
|
||||||
|
*/
|
||||||
export type Milliseconds = number;
|
export type Milliseconds = number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type to remind you that we're dealing with seconds.
|
||||||
|
*/
|
||||||
export type Seconds = number;
|
export type Seconds = number;
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
import { css }from "styled-components";
|
||||||
|
import { clamp } from "lodash";
|
||||||
|
|
||||||
|
import { Corner, Fraction, Placement, Px, TransitionArgs } from "../types/style";
|
||||||
|
|
||||||
|
export function placementStyleRules(pos: Placement) {
|
||||||
|
return css`
|
||||||
|
${pos.top ? `top: ${pos.top};` : ""}
|
||||||
|
${pos.right ? `right: ${pos.right};` : ""}
|
||||||
|
${pos.bottom ? `bottom: ${pos.bottom};` : ""}
|
||||||
|
${pos.left ? `left: ${pos.left};` : ""}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the x, y coordinates of a three point polygon for use in a clip-path
|
||||||
|
* mask. By taking a fraction to indicate the progress through the animation it
|
||||||
|
* will return the six coordinates that will generate a wipe effect.
|
||||||
|
* @param width element width in pixels
|
||||||
|
* @param height element height in pixels
|
||||||
|
* @param progress fraction from 0 to 1
|
||||||
|
* @param startingCorner Which corner the wipe originates from
|
||||||
|
* @param degrees The angle in degrees of the wipe
|
||||||
|
* @returns Array of six numbers representing pixel values of the clip-path
|
||||||
|
*/
|
||||||
|
export function wipeCustomDegClip(
|
||||||
|
width: Px,
|
||||||
|
height: Px,
|
||||||
|
progress: Fraction,
|
||||||
|
startingCorner: Corner,
|
||||||
|
degrees: number,
|
||||||
|
): [[Px, Px], [Px, Px], [Px, Px]] {
|
||||||
|
const tangent = Math.tan(clamp(degrees, 0.01, 90) * Math.PI / 180);
|
||||||
|
|
||||||
|
switch (startingCorner) {
|
||||||
|
case "topLeft":
|
||||||
|
return [
|
||||||
|
[0, 0],
|
||||||
|
[(width + height / tangent) * progress, 0],
|
||||||
|
[0, (height + width * tangent) * progress ],
|
||||||
|
];
|
||||||
|
case "topRight":
|
||||||
|
return [
|
||||||
|
[width, 0],
|
||||||
|
[width, (height + width * tangent) * progress],
|
||||||
|
[width - (width + height / tangent) * progress, 0],
|
||||||
|
];
|
||||||
|
case "bottomRight":
|
||||||
|
return [
|
||||||
|
[width, height],
|
||||||
|
[width, height - (height + width * tangent) * progress],
|
||||||
|
[width - (width + height / tangent) * progress, height],
|
||||||
|
];
|
||||||
|
case "bottomLeft":
|
||||||
|
return [
|
||||||
|
[0, height],
|
||||||
|
[0, height - (height + width * tangent) * progress],
|
||||||
|
[(width + height / tangent) * progress, height],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function commonTransition(propsArray: TransitionArgs[]) {
|
||||||
|
return (
|
||||||
|
"transition: "
|
||||||
|
+ propsArray.map(p => `
|
||||||
|
${p?.property ?? "all"} ${p?.duration ?? 1000}ms ${p?.timing ?? ""} ${p?.delay ?? 0}ms
|
||||||
|
`).join(", ")
|
||||||
|
+ ";"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* will return the six coordinates that will generate a wipe effect.
|
||||||
|
* @param width element width in pixels
|
||||||
|
* @param height element height in pixels
|
||||||
|
* @param progress fraction from 0 to 1
|
||||||
|
* @param outlineThickness the expected max width of the outline
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function outlineClipPath(
|
||||||
|
width: Px,
|
||||||
|
height: Px,
|
||||||
|
progress: Fraction,
|
||||||
|
outlineThickness: Px,
|
||||||
|
): [[Px, Px], [Px, Px], [Px, Px], [Px, Px], [Px, Px], [Px, Px]] {
|
||||||
|
const travelDistance = width * 2 + height;
|
||||||
|
const pt1End = width / travelDistance;
|
||||||
|
const pt2End = (width + height) / travelDistance;
|
||||||
|
|
||||||
|
// Part 1: Reveal the bottom line.
|
||||||
|
if (progress <= pt1End) {
|
||||||
|
const x = width * progress / pt1End;
|
||||||
|
return [
|
||||||
|
[0, height],
|
||||||
|
[0, height],
|
||||||
|
[0, height],
|
||||||
|
[x, height],
|
||||||
|
[x, height + outlineThickness],
|
||||||
|
[0, height + outlineThickness],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Part 2: Reveal the right line.
|
||||||
|
} else if (progress > pt1End && progress <= pt2End) {
|
||||||
|
const y = height - (height + outlineThickness) * ((progress - pt1End) / (pt2End - pt1End));
|
||||||
|
return [
|
||||||
|
[0, height],
|
||||||
|
[width - 10, height],
|
||||||
|
[width, y],
|
||||||
|
[width + outlineThickness, y],
|
||||||
|
[width + outlineThickness, height + outlineThickness],
|
||||||
|
[0, height + outlineThickness],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Part 3: Reveal the top line.
|
||||||
|
} else {
|
||||||
|
const x = width - width * ((progress - pt2End) / (1 - pt2End));
|
||||||
|
return [
|
||||||
|
[0, height],
|
||||||
|
[x - 10, height],
|
||||||
|
[x, -outlineThickness],
|
||||||
|
[width + outlineThickness, -outlineThickness],
|
||||||
|
[width + outlineThickness, height + outlineThickness],
|
||||||
|
[0, height + outlineThickness],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return [
|
||||||
|
|
||||||
|
// ]
|
||||||
|
}
|
||||||