Merge remote-tracking branch 'origin/Venetian_Blinds' into ISSUE-045
No files matched your search
@@ -4,25 +4,23 @@ import { theme } from "../../../../shared/theme";
|
||||
|
||||
import { DriverNumber } from "../../Common/DriverNumber";
|
||||
import { AngledFlag } from "../../Common/AngledFlag";
|
||||
import { PositionFlag } from "../../Common/PositionFlag";
|
||||
import { DriverPortrait } from "../../Common/DriverPortrait";
|
||||
import {
|
||||
BaseBackground,
|
||||
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);
|
||||
|
||||
type ChyronDriverProps = {
|
||||
chyronData: BGChyronDriver,
|
||||
subMode: BGChyronSubMode,
|
||||
@@ -42,11 +40,7 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
<BaseBackground >
|
||||
<Spacer width="6px" />
|
||||
{showPosFlag && (
|
||||
<PositionFlag containerHeight={baseHeight}>
|
||||
<PositionNumber containerHeight={baseHeight}>
|
||||
{car.position}
|
||||
</PositionNumber>
|
||||
</PositionFlag>
|
||||
<PositionFlag size={baseHeight * 0.85} number={car.position} />
|
||||
)}
|
||||
<Spacer width="8px" />
|
||||
<TeamColorBar color={theme.colors.teams[car.driver.team.id]} />
|
||||
@@ -81,11 +75,13 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
</FlagContainer>
|
||||
</BaseBackground>
|
||||
{showPortrait && (
|
||||
<PortraitDiv
|
||||
src={driverPortraits(`./${car.driver.id}.png`)}
|
||||
height={baseHeight * 2.5}
|
||||
rightMargin={-5}
|
||||
/>
|
||||
<DriverPortraitContainer placement={{ right: "-5px", bottom: "0" }}>
|
||||
<DriverPortrait
|
||||
driverId={car.driver.id}
|
||||
height={baseHeight * 2.5}
|
||||
verticalOffsetPercentage={18}
|
||||
/>
|
||||
</DriverPortraitContainer>
|
||||
)}
|
||||
</BaseContainer>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import styled from "styled-components";
|
||||
import { Px } from "../../../../types/style";
|
||||
import { Placement, Px } from "../../../../types/style";
|
||||
import { placementStyleRules } from "../../../../utils/styling";
|
||||
|
||||
type BaseContainerProps = {
|
||||
width: Px,
|
||||
@@ -27,33 +28,6 @@ export const BaseBackground = styled.div`
|
||||
`;
|
||||
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";
|
||||
|
||||
type TeamColorBarProps = {
|
||||
color: string,
|
||||
};
|
||||
@@ -144,23 +118,12 @@ export const FlagContainer = styled.div<FlagContainerProps>`
|
||||
`;
|
||||
FlagContainer.displayName = "FlagContainer";
|
||||
|
||||
type PortraitDivProps = {
|
||||
src: string,
|
||||
height: Px,
|
||||
rightMargin: Px,
|
||||
type DriverPortraitContainerProps = {
|
||||
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`};
|
||||
|
||||
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`};
|
||||
${({ placement }) => placementStyleRules(placement)}
|
||||
`;
|
||||
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,119 @@
|
||||
import { useSpring, animated } 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 },
|
||||
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 [a1, a2, b1, b2, c1, c2] = wipeCustomDegClip(
|
||||
childWidth,
|
||||
childHeight,
|
||||
wipeProgress,
|
||||
wipeStartingCorner,
|
||||
wipeAngle,
|
||||
);
|
||||
return `polygon(${a1}px ${a2}px, ${b1}px ${b2}px, ${c1}px ${c2}px)`;
|
||||
}),
|
||||
}}
|
||||
ref={childRef}
|
||||
>
|
||||
<AnimatedVenetianBlindsFilter
|
||||
style={blindsSpring}
|
||||
blindsAngle={blindsAngle}
|
||||
transparentWidth={blindsSize.transparent}
|
||||
opaqueWidth={blindsSize.opaque}
|
||||
blindsColor={blindsColor}
|
||||
blindsColorFadeDuration={blindsColorFadeDuration}
|
||||
blindsColorFadeDelay={blindsColorFadeDelay}
|
||||
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}
|
||||
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,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { workspaceSelector } from "../../../../features/workspace/workspaceSelec
|
||||
import { FlagMode, TeamId } from "../../../../types/state";
|
||||
|
||||
import { AngledFlag } from "../../../BroadcastGraphics/Common/AngledFlag";
|
||||
import { BasicBlock } from "./styles";
|
||||
import { BasicBlock } from "../styles";
|
||||
|
||||
type AngledFlagWorkspaceProps = {
|
||||
flagMode: FlagMode,
|
||||
|
||||
@@ -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";
|
||||
@@ -1,5 +1,5 @@
|
||||
import styled from "styled-components";
|
||||
import { Px } from "../../../../types/style";
|
||||
import { Px } from "../../../types/style";
|
||||
|
||||
type BasicBlockProps = {
|
||||
width: Px,
|
||||
@@ -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 (
|
||||
|
||||
@@ -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";
|
||||
@@ -7,6 +7,7 @@ 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";
|
||||
|
||||
@@ -15,7 +16,8 @@ import { ChyronPrototypeControls } from "./PrototypingControls/ChyronPrototype";
|
||||
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;
|
||||
|
||||
@@ -78,11 +80,11 @@ export default function Workspaces() {
|
||||
prototypeControls={<AngledFlagPrototypeControls flagMode="team"/>}
|
||||
/>
|
||||
} />
|
||||
<Route path="venetianTransitionPosFlag" element={
|
||||
<Route path="venetianTransition" element={
|
||||
<Workspace
|
||||
workspaceId="venetianTransitionPosFlag"
|
||||
previewContent={null}
|
||||
prototypeControls={null}
|
||||
workspaceId="venetianTransition"
|
||||
previewContent={<VenetianBlindsWorkspace />}
|
||||
prototypeControls={<VenetianBlindsPrototypeControls />}
|
||||
/>
|
||||
} />
|
||||
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
|
||||
|
||||
@@ -67,4 +67,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,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -9,7 +9,7 @@ const initialState: RootState["workspace"] = {
|
||||
overlayIds: [],
|
||||
previewWindowDimensions: { width: 0, height: 0 },
|
||||
},
|
||||
prototypeState: null,
|
||||
prototypeState: {},
|
||||
};
|
||||
|
||||
export type UpdateWorkspaceAction = {
|
||||
@@ -31,8 +31,54 @@ export const workspaceSlice = createSlice({
|
||||
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,
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -41,6 +87,8 @@ export const {
|
||||
setWorkspaceId,
|
||||
setAnimatedBG,
|
||||
updateWorkspace,
|
||||
setPrototypeState,
|
||||
updateAngledFlagCountry,
|
||||
updateAngledFlagTeam,
|
||||
updateVenetianTransition,
|
||||
} = workspaceSlice.actions;
|
||||
export default workspaceSlice.reducer;
|
||||
|
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 } from "./style";
|
||||
|
||||
export interface RootState {
|
||||
pageDimensions: PageDimensions;
|
||||
@@ -22,7 +23,7 @@ export interface Workspace {
|
||||
workspaceId: WorkspaceId;
|
||||
animatedBG: boolean;
|
||||
workspaceProperties: WorkspaceProperties;
|
||||
prototypeState: Optional<PrototypeState>;
|
||||
prototypeState: PrototypeState;
|
||||
}
|
||||
|
||||
export type WorkspaceId = string;
|
||||
@@ -40,6 +41,12 @@ export interface PrototypeState {
|
||||
flagA: TeamId;
|
||||
flagB: TeamId;
|
||||
};
|
||||
venetianTransition?: {
|
||||
mode: string,
|
||||
subMode: string,
|
||||
showBG: boolean;
|
||||
wipeStartingCorner: Corner,
|
||||
};
|
||||
}
|
||||
|
||||
// Overlay Tool
|
||||
|
||||
@@ -4,6 +4,31 @@
|
||||
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";
|
||||
@@ -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,62 @@
|
||||
import { css }from "styled-components";
|
||||
import { clamp } from "lodash";
|
||||
|
||||
import { Corner, Fraction, Placement, Px } 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,
|
||||
];
|
||||
}
|
||||
}
|
||||