No files matched your search
@@ -3,14 +3,14 @@ import { useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { Stack } from "@bedrock-layout/stack";
|
||||
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 { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||
import {
|
||||
chyronsClear,
|
||||
chyronsOpenStateIncrement,
|
||||
chyronsSet,
|
||||
incrementChyronsOpenState,
|
||||
setChyrons,
|
||||
setChyronsOpenState,
|
||||
} from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||
import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics";
|
||||
import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode } from "../../../../types/state";
|
||||
@@ -37,42 +37,49 @@ export function ChyronsDirectorControls() {
|
||||
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
||||
const { selectedCars } = useSelector(broadcastDirectorSelector);
|
||||
|
||||
// Handle changes to the chyron mode so submodes can be changed accordingly.
|
||||
useEffect(() => {
|
||||
setChyronSubModes(getChyronSubModesList(chyronMode));
|
||||
}, [chyronMode]);
|
||||
|
||||
const onOpen = () => {
|
||||
if (chyronMode === "driver") {
|
||||
if (selectedCars.length === 0) return;
|
||||
let primaryCar = selectedCars[0];
|
||||
let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
|
||||
|
||||
// Auto-sort drivers by position so trailing car always appears second.
|
||||
if (chyronSubMode === "medium" && secondaryCar != null
|
||||
&& secondaryCar.position < primaryCar.position) {
|
||||
secondaryCar = selectedCars[0];
|
||||
primaryCar = selectedCars[1];
|
||||
}
|
||||
const newChyrons: BGChyrons = {
|
||||
openState: 1,
|
||||
relativePos: { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
mode: chyronMode,
|
||||
subMode: chyronSubMode,
|
||||
driver: {
|
||||
primary: buildDriverChyron(primaryCar),
|
||||
secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null,
|
||||
},
|
||||
};
|
||||
dispatch(chyronsSet(newChyrons));
|
||||
}
|
||||
buildDriver();
|
||||
setTimeout(() => {
|
||||
// Delay a short time and increment the open state so the animation can happen.
|
||||
dispatch(incrementChyronsOpenState());
|
||||
}, 50);
|
||||
};
|
||||
|
||||
const onNext = () => {
|
||||
dispatch(chyronsOpenStateIncrement());
|
||||
dispatch(incrementChyronsOpenState());
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
dispatch(chyronsClear());
|
||||
dispatch(setChyronsOpenState(-1));
|
||||
};
|
||||
|
||||
const buildDriver = () => {
|
||||
if (selectedCars.length === 0) return;
|
||||
let primaryCar = selectedCars[0];
|
||||
let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
|
||||
|
||||
// Auto-sort drivers by position so trailing car always appears second.
|
||||
if (chyronSubMode === "medium" && secondaryCar != null
|
||||
&& secondaryCar.position < primaryCar.position) {
|
||||
secondaryCar = selectedCars[0];
|
||||
primaryCar = selectedCars[1];
|
||||
}
|
||||
const newChyrons: BGChyrons = {
|
||||
openState: 0,
|
||||
relativePos: { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
mode: chyronMode,
|
||||
subMode: chyronSubMode,
|
||||
driver: {
|
||||
primary: buildDriverChyron(primaryCar),
|
||||
secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null,
|
||||
},
|
||||
};
|
||||
dispatch(setChyrons(newChyrons));
|
||||
};
|
||||
|
||||
const buildDriverChyron = (car: Car): BGChyronDriver => ({
|
||||
@@ -136,19 +143,19 @@ export function ChyronsDirectorControls() {
|
||||
onClick={onOpen}
|
||||
disabled={chyrons != null}
|
||||
>
|
||||
<FaPlay size="0.8em" />
|
||||
<FaCheck size="0.8em" />
|
||||
</OpenButton>
|
||||
<Button
|
||||
onClick={onNext}
|
||||
disabled={chyrons == null}
|
||||
disabled={chyrons == null || chyrons.openState === -1}
|
||||
>
|
||||
<FaStepForward size="0.8em" />
|
||||
</Button>
|
||||
<CloseButton
|
||||
onClick={onClose}
|
||||
disabled={chyrons == null}
|
||||
disabled={chyrons == null || chyrons.openState <= 0}
|
||||
>
|
||||
<FaStop size="0.8em" />
|
||||
<FaTimes size="0.8em" />
|
||||
</CloseButton>
|
||||
</Inline>
|
||||
</Inline>
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||
|
||||
import { ChyronDriver } from "../Driver";
|
||||
import { DoubleChyronContainer } from "./styles";
|
||||
|
||||
export function ChyronContainer() {
|
||||
type ChyronContainerProps = {
|
||||
debug?: boolean,
|
||||
};
|
||||
export function ChyronContainer({ debug = false }: ChyronContainerProps) {
|
||||
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
||||
const { debugDurationMultiplier } = useSelector(workspaceSelector);
|
||||
|
||||
if (chyrons == null || chyrons.driver == null) return null;
|
||||
|
||||
@@ -14,6 +19,8 @@ export function ChyronContainer() {
|
||||
<ChyronDriver
|
||||
chyronData={chyrons.driver.primary}
|
||||
subMode={chyrons.subMode}
|
||||
openState={chyrons.openState}
|
||||
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
|
||||
/>
|
||||
);
|
||||
if (chyrons.subMode === "medium" && chyrons.driver.secondary) {
|
||||
@@ -23,6 +30,8 @@ export function ChyronContainer() {
|
||||
<ChyronDriver
|
||||
chyronData={chyrons.driver.secondary}
|
||||
subMode={chyrons.subMode}
|
||||
openState={chyrons.openState}
|
||||
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
|
||||
/>
|
||||
</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 { outlineClipPath } from "../../../../utils/styling";
|
||||
|
||||
import { DriverNumber } from "../../Common/DriverNumber";
|
||||
import { AngledFlag } from "../../Common/AngledFlag";
|
||||
import { PositionFlag } from "../../Common/PositionFlag";
|
||||
import { DriverPortrait } from "../../Common/DriverPortrait";
|
||||
import {
|
||||
BaseBackground,
|
||||
AnimatedBaseContainer,
|
||||
BaseLayout,
|
||||
AnimatedBaseOutline,
|
||||
BaseBlack,
|
||||
BaseBackgroundColor,
|
||||
FirstName,
|
||||
PositionNumber,
|
||||
LastName,
|
||||
NameContainer,
|
||||
NumberContainer,
|
||||
PositionFlag,
|
||||
Spacer,
|
||||
TeamColorBar,
|
||||
TeamName,
|
||||
TextContainer,
|
||||
FlagContainer,
|
||||
PortraitDiv,
|
||||
BaseContainer,
|
||||
DriverPortraitContainer,
|
||||
} from "./styles";
|
||||
|
||||
const driverPortraits = require.context("../../../../public/images/drivers/front", true);
|
||||
import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition";
|
||||
|
||||
type ChyronDriverProps = {
|
||||
chyronData: BGChyronDriver,
|
||||
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]
|
||||
: subMode === "large" ? [638, 98]
|
||||
: [0, 0];
|
||||
|
||||
const { car, flagMode, showPosFlag, showDriverNumber, showPortrait } = chyronData;
|
||||
|
||||
const flagProps = flagMode === "country"
|
||||
? { 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 (
|
||||
<BaseContainer width={baseWidth} height={baseHeight}>
|
||||
<BaseBackground >
|
||||
<AnimatedBaseContainer
|
||||
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" />
|
||||
{showPosFlag && (
|
||||
<PositionFlag containerHeight={baseHeight}>
|
||||
<PositionNumber containerHeight={baseHeight}>
|
||||
{car.position}
|
||||
</PositionNumber>
|
||||
</PositionFlag>
|
||||
<VenetianBlindsTransition
|
||||
visible={openState !== 0}
|
||||
delay={500 * DDM}
|
||||
blindsColor="#f60d0d"
|
||||
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" />
|
||||
<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" />
|
||||
<TextContainer>
|
||||
<NameContainer>
|
||||
@@ -65,9 +182,25 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
</NumberContainer>
|
||||
)}
|
||||
</NameContainer>
|
||||
<TeamName>{car.driver.team.shortName}</TeamName>
|
||||
<TeamName
|
||||
open={openState !== 0}
|
||||
duration={233 * DDM}
|
||||
delay={500 * DDM}
|
||||
>
|
||||
{car.driver.team.shortName}
|
||||
</TeamName>
|
||||
</TextContainer>
|
||||
<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}
|
||||
width={baseHeight * 3}
|
||||
right={-baseHeight * 0.6}
|
||||
@@ -79,14 +212,39 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
/>
|
||||
)}
|
||||
</FlagContainer>
|
||||
</BaseBackground>
|
||||
</BaseLayout>
|
||||
{showPortrait && (
|
||||
<PortraitDiv
|
||||
src={driverPortraits(`./${car.driver.id}.png`)}
|
||||
height={baseHeight * 2.5}
|
||||
rightMargin={-5}
|
||||
/>
|
||||
<DriverPortraitContainer
|
||||
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}
|
||||
verticalOffsetPercentage={18}
|
||||
/>
|
||||
</VenetianBlindsTransition>
|
||||
</DriverPortraitContainer>
|
||||
)}
|
||||
</BaseContainer>
|
||||
</AnimatedBaseContainer>
|
||||
);
|
||||
}
|
||||
@@ -1,68 +1,109 @@
|
||||
import styled from "styled-components";
|
||||
import { Px } from "../../../../types/style";
|
||||
import { animated } from "@react-spring/web";
|
||||
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,
|
||||
height: Px,
|
||||
};
|
||||
export const BaseContainer = styled.div<BaseContainerProps>`
|
||||
export const AnimatedBaseContainer = animated(styled.div<AnimatedBaseContainerProps>`
|
||||
position: relative;
|
||||
width: ${({ width }) => `${width}px`};
|
||||
height: ${({ height }) => `${height}px`};
|
||||
`;
|
||||
BaseContainer.displayName = "BaseContainer";
|
||||
`);
|
||||
AnimatedBaseContainer.displayName = "AnimatedBaseContainer";
|
||||
|
||||
export const BaseBackground = styled.div`
|
||||
position: relative;
|
||||
const BaseShape = styled.div`
|
||||
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%;
|
||||
width: 100%;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
border-bottom-right-radius: 11px;
|
||||
background-color: #000;
|
||||
|
||||
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";
|
||||
|
||||
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";
|
||||
BaseLayout.displayName = "BaseLayout";
|
||||
|
||||
type TeamColorBarProps = {
|
||||
color: string,
|
||||
};
|
||||
export const TeamColorBar = styled.div<TeamColorBarProps>`
|
||||
export const TeamColorBar = styled.div<TeamColorBarProps & TransitionProps>`
|
||||
position: relative;
|
||||
width: 1%; // 6px;
|
||||
height: 63%;
|
||||
|
||||
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";
|
||||
|
||||
@@ -106,11 +147,27 @@ export const NumberContainer = styled.div`
|
||||
`;
|
||||
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;
|
||||
font-family: ${p => p.theme.fonts.f1Regular};
|
||||
color: #d1d1d1;
|
||||
font-size: 20px;
|
||||
|
||||
${({ open, duration, delay }) => open && css`
|
||||
animation: ${blinkingAnimation} ${duration}ms step-end ${delay}ms;
|
||||
`}
|
||||
`;
|
||||
TeamName.displayName = "TeamName";
|
||||
|
||||
@@ -129,9 +186,10 @@ type FlagContainerProps = {
|
||||
width: Px,
|
||||
right: Px,
|
||||
};
|
||||
export const FlagContainer = styled.div<FlagContainerProps>`
|
||||
export const FlagContainer = styled.div<FlagContainerProps & TransitionProps>`
|
||||
position: absolute;
|
||||
right: ${({ right }) => `${right}px`};
|
||||
right: ${({ right, open }) => open ? right : right * -3}px;
|
||||
z-index: -1;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -141,26 +199,22 @@ export const FlagContainer = styled.div<FlagContainerProps>`
|
||||
width: ${({ width }) => `${width}px`};
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
opacity: ${({ open }) => open ? 1 : 0};
|
||||
|
||||
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||
`;
|
||||
FlagContainer.displayName = "FlagContainer";
|
||||
|
||||
type PortraitDivProps = {
|
||||
src: string,
|
||||
height: Px,
|
||||
rightMargin: Px,
|
||||
type DriverPortraitContainerProps = TransitionProps & {
|
||||
placement: Placement,
|
||||
};
|
||||
export const PortraitDiv = styled.div<PortraitDivProps>`
|
||||
export const DriverPortraitContainer = styled.div<DriverPortraitContainerProps>`
|
||||
position: absolute;
|
||||
|
||||
height: ${({ height }) => `${height}px`};
|
||||
width: ${({ height }) => `${height * 1.4}px`};
|
||||
${({ placement }) => placementStyleRules(placement)}
|
||||
|
||||
bottom: 0;
|
||||
right: ${({ rightMargin }) => `${rightMargin}px`};
|
||||
|
||||
background-image: url(${({ src }) => src});
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center ${({ height }) => `${height * .18}px`};
|
||||
opacity: ${({ open }) => open ? 1 : 0};
|
||||
${({ transitionProps }) => commonTransition(transitionProps)}
|
||||
`;
|
||||
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 { clamp } from "lodash";
|
||||
|
||||
import { Fraction } from "../../../../types/style";
|
||||
|
||||
import {
|
||||
AnimatedProgressSliderBar,
|
||||
ProgressSliderBarHandle,
|
||||
@@ -19,7 +21,7 @@ const MARGIN_WIDTH = 15;
|
||||
const percentage = (value: number) => `${Math.floor(value * 100)}%`;
|
||||
|
||||
type ProgressSliderProps = {
|
||||
value: number, // Fraction of 1 (0.0 to 1.0)
|
||||
value: Fraction,
|
||||
onChange: (value: number) => void,
|
||||
disabled?: boolean,
|
||||
formatter?: (value: number) => string,
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
||||
import { FlagMode, TeamId } from "../../../types/state";
|
||||
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||
import { FlagMode, TeamId } from "../../../../types/state";
|
||||
|
||||
import { AngledFlag } from "../../BroadcastGraphics/Common/AngledFlag";
|
||||
import { BasicBlock } from "./styles";
|
||||
import { AngledFlag } from "../../../BroadcastGraphics/Common/AngledFlag";
|
||||
import { BasicBlock } from "../styles";
|
||||
|
||||
type AngledFlagWorkSpaceProps = {
|
||||
type AngledFlagWorkspaceProps = {
|
||||
flagMode: FlagMode,
|
||||
};
|
||||
export function AngledFlagWorkSpace({ flagMode }: AngledFlagWorkSpaceProps) {
|
||||
export function AngledFlagWorkspace({ flagMode }: AngledFlagWorkspaceProps) {
|
||||
const { prototypeState } = useSelector(workspaceSelector);
|
||||
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;
|
||||
`;
|
||||
BasicBlock.displayName = "BasicBlock";
|
||||
@@ -1,9 +1,8 @@
|
||||
import { PadBox } from "@bedrock-layout/padbox";
|
||||
import { Split } from "@bedrock-layout/split";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
import { setPrototypeState } from "../../../../features/workspace/workspaceSlice";
|
||||
import { updateAngledFlagCountry, updateAngledFlagTeam } from "../../../../features/workspace/workspaceSlice";
|
||||
import { FlagMode, TeamId } from "../../../../types/state";
|
||||
|
||||
import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
|
||||
@@ -17,41 +16,22 @@ const teams: Array<TeamId> = [
|
||||
"mclaren", "mercedes", "redBull", "williams",
|
||||
];
|
||||
|
||||
const DEFAULT_COUNTRY = "GBR";
|
||||
const DEFAULT_TEAM: TeamId = "alfaRomeo";
|
||||
|
||||
type AngledFlagPrototypeControlsProps = {
|
||||
flagMode: FlagMode,
|
||||
};
|
||||
export function AngledFlagPrototypeControls({ flagMode }: AngledFlagPrototypeControlsProps) {
|
||||
const dispatch = useDispatch();
|
||||
const { prototypeState } = useSelector(workspaceSelector);
|
||||
const flagList = flagMode === "country" ? countries : flagMode === "team" ? teams : [];
|
||||
|
||||
const onChange = (flag: "flagA" | "flagB") => (index: number) => {
|
||||
if (flagMode === "country") {
|
||||
dispatch(setPrototypeState({
|
||||
angledFlagCountry: {
|
||||
flagA: flag === "flagA"
|
||||
? countries[index]
|
||||
: prototypeState?.angledFlagCountry?.flagA ?? DEFAULT_COUNTRY,
|
||||
flagB: flag === "flagB"
|
||||
? countries[index]
|
||||
: prototypeState?.angledFlagCountry?.flagB ?? DEFAULT_COUNTRY,
|
||||
},
|
||||
dispatch(updateAngledFlagCountry({
|
||||
[flag]: countries[index],
|
||||
}));
|
||||
} else if (flagMode === "team") {
|
||||
dispatch(setPrototypeState({
|
||||
angledFlagTeam: {
|
||||
flagA: flag === "flagA"
|
||||
? teams[index]
|
||||
: prototypeState?.angledFlagTeam?.flagA ?? DEFAULT_TEAM,
|
||||
flagB: flag === "flagB"
|
||||
? teams[index]
|
||||
: prototypeState?.angledFlagTeam?.flagB ?? DEFAULT_TEAM,
|
||||
},
|
||||
dispatch(updateAngledFlagTeam({
|
||||
[flag]: teams[index],
|
||||
}));
|
||||
|
||||
}
|
||||
};
|
||||
return (
|
||||
|
||||
@@ -3,7 +3,7 @@ import { findIndex } from "lodash";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
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 { Car } from "../../../../types/state";
|
||||
import { carMatch } from "../../../../utils/comparators";
|
||||
@@ -21,13 +21,13 @@ export function GridSelection() {
|
||||
|
||||
const carClick = (car: Car, selected: boolean) => () => {
|
||||
if (selected) {
|
||||
dispatch(selectedCarsRemove(car));
|
||||
dispatch(removeSelectedCars(car));
|
||||
} else {
|
||||
dispatch(selectedCarsAdd(car));
|
||||
dispatch(pushSelectedCars(car));
|
||||
}
|
||||
};
|
||||
const carDoubleClick = (car: Car) => () => {
|
||||
dispatch(selectedCarsClear(car));
|
||||
dispatch(clearSelectedCars(car));
|
||||
};
|
||||
|
||||
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,
|
||||
previewContent: ReactNode,
|
||||
prototypeControls: ReactNode,
|
||||
showAnimationSpeedSelector?: boolean,
|
||||
};
|
||||
export const Workspace = ({
|
||||
workspaceId,
|
||||
previewContent,
|
||||
prototypeControls,
|
||||
showAnimationSpeedSelector = false,
|
||||
}: WorkspaceProps) => {
|
||||
const dispatch = useDispatch();
|
||||
const { animatedBG, workspaceProperties } = useSelector(workspaceSelector);
|
||||
const { animatedBG, darkBG, workspaceProperties } = useSelector(workspaceSelector);
|
||||
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -56,6 +58,7 @@ export const Workspace = ({
|
||||
<PreviewWindow
|
||||
dimensions={workspaceProperties.previewWindowDimensions}
|
||||
animatedBG={animatedBG}
|
||||
darkBG={darkBG}
|
||||
>
|
||||
{previewContent}
|
||||
<OverlayDisplay
|
||||
@@ -63,7 +66,9 @@ export const Workspace = ({
|
||||
/>
|
||||
</PreviewWindow>
|
||||
<ControlsContainer>
|
||||
<WorkspaceControls />
|
||||
<WorkspaceControls
|
||||
showAnimationSpeedSelector={showAnimationSpeedSelector}
|
||||
/>
|
||||
{prototypeControls}
|
||||
</ControlsContainer>
|
||||
</Stack>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import styled, { css, keyframes } from "styled-components";
|
||||
import { PadBox } from "@bedrock-layout/padbox";
|
||||
|
||||
import bg from "../../../public/images/misc/checker-40x40.png";
|
||||
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`
|
||||
from { background-position: 0 0; }
|
||||
to { background-position: 80px -40px; }
|
||||
@@ -12,6 +14,7 @@ const scrollAnimation = keyframes`
|
||||
export type PreviewWindowProps = {
|
||||
dimensions: Dimensions,
|
||||
animatedBG?: boolean,
|
||||
darkBG?: boolean,
|
||||
};
|
||||
export const PreviewWindow = styled.div<PreviewWindowProps>`
|
||||
position: relative;
|
||||
@@ -24,7 +27,7 @@ export const PreviewWindow = styled.div<PreviewWindowProps>`
|
||||
|
||||
border-radius: 1em;
|
||||
|
||||
background-image: url("${bg}");
|
||||
background-image: url("${({ darkBG }) => darkBG ? bgDark : bgLight}");
|
||||
background-position: 0px 0px;
|
||||
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 { Split } from "@bedrock-layout/split";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
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 { 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 { animatedBG } = useSelector(workspaceSelector);
|
||||
const { animatedBG, darkBG } = useSelector(workspaceSelector);
|
||||
|
||||
return(
|
||||
<Grid gutter="sm" minItemWidth="100px">
|
||||
<PadBox padding="sm">
|
||||
<Split gutter="md">
|
||||
<InlineCluster as={PadBox} padding="sm" gutter="md">
|
||||
<Toggle
|
||||
label="Animate BG"
|
||||
toggled={animatedBG}
|
||||
onToggle={(value: boolean) => {
|
||||
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 />
|
||||
</Grid>
|
||||
</Split>
|
||||
);
|
||||
};
|
||||
@@ -7,15 +7,17 @@ import { mainMenuDimensionsSelector } from "../../features/pageDimensions/pageDi
|
||||
import { setDimensions } from "../../features/pageDimensions/pageDimensionsSlice";
|
||||
|
||||
import { FullScreenContainer } from "../Common/FullScreenContainer.styled";
|
||||
import { IndexHeading } from "../Common/IndexHeading.styled";
|
||||
import { WorkspaceList } from "./WorkspaceList";
|
||||
import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
|
||||
|
||||
import { Workspace } from "./Workspace";
|
||||
import { ChyronPrototypeControls } from "./PrototypingControls/ChyronPrototype";
|
||||
import { AngledFlagWorkSpace } from "./CustomWorkSpaces/AngledFlagWorkSpace";
|
||||
import { AngledFlagWorkspace } from "./CustomWorkSpaces/AngledFlagWorkspace";
|
||||
import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPrototype";
|
||||
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;
|
||||
|
||||
@@ -53,32 +55,41 @@ export default function Workspaces() {
|
||||
<Route path="chyron" element={
|
||||
<Workspace
|
||||
workspaceId="chyron"
|
||||
previewContent={<ChyronContainer />}
|
||||
previewContent={<ChyronContainer debug />}
|
||||
prototypeControls={<ChyronPrototypeControls />}
|
||||
showAnimationSpeedSelector
|
||||
/>
|
||||
} />
|
||||
<Route path="chyronWide" element={
|
||||
<Workspace
|
||||
workspaceId="chyronWide"
|
||||
previewContent={<ChyronContainer />}
|
||||
previewContent={<ChyronContainer debug />}
|
||||
prototypeControls={<ChyronPrototypeControls />}
|
||||
showAnimationSpeedSelector
|
||||
/>
|
||||
} />
|
||||
<Route path="angledFlagCountry" element={
|
||||
<Workspace
|
||||
workspaceId="angledFlagCountry"
|
||||
previewContent={<AngledFlagWorkSpace flagMode="country"/>}
|
||||
previewContent={<AngledFlagWorkspace flagMode="country"/>}
|
||||
prototypeControls={<AngledFlagPrototypeControls flagMode="country" />}
|
||||
/>
|
||||
} />
|
||||
<Route path="angledFlagTeam" element={
|
||||
<Workspace
|
||||
workspaceId="angledFlagTeam"
|
||||
previewContent={<AngledFlagWorkSpace flagMode="team"/>}
|
||||
previewContent={<AngledFlagWorkspace 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>
|
||||
</FullScreenContainer>
|
||||
</LayoutGridItem>
|
||||
|
||||
@@ -13,6 +13,7 @@ export const workspaces: WorkspaceObject = {
|
||||
"chyron-driver-medium-full-vet.png",
|
||||
"chyron-driver-medium-full-per.png",
|
||||
"chyron-driver-medium-full-msc.png",
|
||||
"chyron-driver-medium-op0-ham.png",
|
||||
"chyron-driver-medium-op1-ham.png",
|
||||
"chyron-driver-medium-op2-ham.png",
|
||||
"chyron-driver-medium-full-ham.png",
|
||||
@@ -67,4 +68,20 @@ export const workspaces: WorkspaceObject = {
|
||||
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",
|
||||
initialState,
|
||||
reducers: {
|
||||
selectedCarsAdd: (state, action: PayloadAction<Car>) => {
|
||||
pushSelectedCars: (state, action: PayloadAction<Car>) => {
|
||||
const index = findIndex(state.selectedCars, carMatch(action.payload));
|
||||
if (index === -1) {
|
||||
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];
|
||||
},
|
||||
selectedCarsRemove: (state, action: PayloadAction<Car | number>) => {
|
||||
removeSelectedCars: (state, action: PayloadAction<Car | number>) => {
|
||||
const index = typeof action.payload === "number"
|
||||
? action.payload
|
||||
: findIndex(state.selectedCars, carMatch(action.payload));
|
||||
@@ -36,7 +36,7 @@ export const broadcastDirectorSlice = createSlice({
|
||||
* car.
|
||||
* @param action Car (optional)
|
||||
*/
|
||||
selectedCarsClear: (state, action: PayloadAction<Optional<Car>>) => {
|
||||
clearSelectedCars: (state, action: PayloadAction<Optional<Car>>) => {
|
||||
if (action.payload == null) {
|
||||
state.selectedCars = [];
|
||||
} else {
|
||||
@@ -47,9 +47,9 @@ export const broadcastDirectorSlice = createSlice({
|
||||
});
|
||||
|
||||
export const {
|
||||
selectedCarsAdd,
|
||||
selectedCarsSet,
|
||||
selectedCarsRemove,
|
||||
selectedCarsClear,
|
||||
pushSelectedCars,
|
||||
setSelectedCars,
|
||||
removeSelectedCars,
|
||||
clearSelectedCars,
|
||||
} = broadcastDirectorSlice.actions;
|
||||
export default broadcastDirectorSlice.reducer;
|
||||
@@ -10,10 +10,10 @@ export const broadcastGraphicsSlice = createSlice({
|
||||
name: "broadcastGraphics",
|
||||
initialState,
|
||||
reducers: {
|
||||
chyronsSet: (state, action: PayloadAction<BGChyrons>) => {
|
||||
setChyrons: (state, action: PayloadAction<BGChyrons>) => {
|
||||
state.chyrons = action.payload;
|
||||
},
|
||||
chyronsOpenStateSet: (state, action: PayloadAction<OpenState>) => {
|
||||
setChyronsOpenState: (state, action: PayloadAction<OpenState>) => {
|
||||
if (state.chyrons == null) return;
|
||||
state.chyrons.openState = action.payload;
|
||||
|
||||
@@ -21,7 +21,7 @@ export const broadcastGraphicsSlice = createSlice({
|
||||
state.chyrons.openState = action.payload;
|
||||
}
|
||||
},
|
||||
chyronsOpenStateIncrement: (state) => {
|
||||
incrementChyronsOpenState: (state) => {
|
||||
if (state.chyrons == null) return;
|
||||
++state.chyrons.openState;
|
||||
|
||||
@@ -29,16 +29,16 @@ export const broadcastGraphicsSlice = createSlice({
|
||||
++state.chyrons.openState;
|
||||
}
|
||||
},
|
||||
chyronsClear: (state) => {
|
||||
clearChyrons: (state) => {
|
||||
state.chyrons = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const {
|
||||
chyronsSet,
|
||||
chyronsOpenStateSet,
|
||||
chyronsOpenStateIncrement,
|
||||
chyronsClear,
|
||||
setChyrons,
|
||||
setChyronsOpenState,
|
||||
incrementChyronsOpenState,
|
||||
clearChyrons,
|
||||
} = broadcastGraphicsSlice.actions;
|
||||
export default broadcastGraphicsSlice.reducer;
|
||||
@@ -46,13 +46,13 @@ export const eventSlice = createSlice({
|
||||
name: "event",
|
||||
initialState,
|
||||
reducers: {
|
||||
courseFlagSet: (state, action: PayloadAction<CourseFlag>) => {
|
||||
setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
|
||||
state.courseStatus.courseFlag = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const {
|
||||
courseFlagSet,
|
||||
setCourseFlag,
|
||||
} = eventSlice.actions;
|
||||
export default eventSlice.reducer;
|
||||
@@ -1,15 +1,18 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { PrototypeState, RootState, WorkspaceId, WorkspaceProperties } from "../../types/state";
|
||||
import { Fraction } from "../../types/style";
|
||||
|
||||
const initialState: RootState["workspace"] = {
|
||||
workspaceId: "",
|
||||
animatedBG: true,
|
||||
darkBG: false,
|
||||
debugDurationMultiplier: 1.0,
|
||||
workspaceProperties: {
|
||||
name: "undefined",
|
||||
overlayIds: [],
|
||||
previewWindowDimensions: { width: 0, height: 0 },
|
||||
},
|
||||
prototypeState: null,
|
||||
prototypeState: {},
|
||||
};
|
||||
|
||||
export type UpdateWorkspaceAction = {
|
||||
@@ -27,12 +30,64 @@ export const workspaceSlice = createSlice({
|
||||
setAnimatedBG: (state, action: PayloadAction<boolean>) => {
|
||||
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>) => {
|
||||
state.workspaceId = action.payload.workspaceId;
|
||||
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 {
|
||||
setWorkspaceId,
|
||||
setAnimatedBG,
|
||||
setDarkBG,
|
||||
setDebugDurationMultiplier,
|
||||
updateWorkspace,
|
||||
setPrototypeState,
|
||||
updateAngledFlagCountry,
|
||||
updateAngledFlagTeam,
|
||||
updateVenetianTransition,
|
||||
} = workspaceSlice.actions;
|
||||
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 { Corner, Fraction } from "./style";
|
||||
|
||||
export interface RootState {
|
||||
pageDimensions: PageDimensions;
|
||||
@@ -21,8 +22,10 @@ export interface Dimensions { width: number; height: number; }
|
||||
export interface Workspace {
|
||||
workspaceId: WorkspaceId;
|
||||
animatedBG: boolean;
|
||||
darkBG: boolean;
|
||||
debugDurationMultiplier: Fraction,
|
||||
workspaceProperties: WorkspaceProperties;
|
||||
prototypeState: Optional<PrototypeState>;
|
||||
prototypeState: PrototypeState;
|
||||
}
|
||||
|
||||
export type WorkspaceId = string;
|
||||
@@ -40,6 +43,12 @@ export interface PrototypeState {
|
||||
flagA: TeamId;
|
||||
flagB: TeamId;
|
||||
};
|
||||
venetianTransition?: {
|
||||
mode: string,
|
||||
subMode: string,
|
||||
showBG: boolean;
|
||||
wipeStartingCorner: Corner,
|
||||
};
|
||||
}
|
||||
|
||||
// Overlay Tool
|
||||
|
||||
@@ -4,6 +4,39 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Type to remind you that we're dealing with seconds.
|
||||
*/
|
||||
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 [
|
||||
|
||||
// ]
|
||||
}
|
||||