ISSUE-045 - Chyron Body - Added debugDurationMultiplier value that allows me to slow down animations in certain workspaces.

Made TeamName component more customizable with its timing. Now all animations in Chyron are configurable from outside of the styled-component definition.
New Debug option for ChyronContainer so that this animation modifier can never accidentally be active in the main broadcast view.
This commit is contained in:
Kyle Geib committed 2022-02-10 19:12:18 -05:00
1 parent 9ff77cc88a
commit 79b098af6c
9 files changed
+97 -45

No files matched your search

@@ -8,7 +8,6 @@ import { FaCheck, FaStepForward, FaTimes } from "react-icons/fa";
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector"; import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
import { import {
clearChyrons,
incrementChyronsOpenState, incrementChyronsOpenState,
setChyrons, setChyrons,
setChyronsOpenState, setChyronsOpenState,
@@ -60,7 +59,6 @@ export function ChyronsDirectorControls() {
}; };
const buildDriver = () => { const buildDriver = () => {
console.log("building driver");
if (selectedCars.length === 0) return; if (selectedCars.length === 0) return;
let primaryCar = selectedCars[0]; let primaryCar = selectedCars[0];
let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null; let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
@@ -1,12 +1,17 @@
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
import { ChyronDriver } from "../Driver"; import { ChyronDriver } from "../Driver";
import { DoubleChyronContainer } from "./styles"; import { DoubleChyronContainer } from "./styles";
export function ChyronContainer() { type ChyronContainerProps = {
debug?: boolean,
};
export function ChyronContainer({ debug = false }: ChyronContainerProps) {
const { chyrons } = useSelector(broadcastGraphicsSelector); const { chyrons } = useSelector(broadcastGraphicsSelector);
const { debugDurationMultiplier } = useSelector(workspaceSelector);
if (chyrons == null || chyrons.driver == null) return null; if (chyrons == null || chyrons.driver == null) return null;
@@ -15,6 +20,7 @@ export function ChyronContainer() {
chyronData={chyrons.driver.primary} chyronData={chyrons.driver.primary}
subMode={chyrons.subMode} subMode={chyrons.subMode}
openState={chyrons.openState} openState={chyrons.openState}
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
/> />
); );
if (chyrons.subMode === "medium" && chyrons.driver.secondary) { if (chyrons.subMode === "medium" && chyrons.driver.secondary) {
@@ -25,6 +31,7 @@ export function ChyronContainer() {
chyronData={chyrons.driver.secondary} chyronData={chyrons.driver.secondary}
subMode={chyrons.subMode} subMode={chyrons.subMode}
openState={chyrons.openState} openState={chyrons.openState}
debugDurationMultiplier={debug ? debugDurationMultiplier : 1}
/> />
</DoubleChyronContainer> </DoubleChyronContainer>
); );
@@ -1,6 +1,9 @@
import { BGChyronDriver, BGChyronSubMode, OpenState } from "../../../../types/state";
import { useSpring } from "@react-spring/web"; import { useSpring } from "@react-spring/web";
import { useDispatch } from "react-redux";
import { BGChyronDriver, BGChyronSubMode, OpenState } from "../../../../types/state";
import { Fraction } from "../../../../types/style";
import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
import { theme } from "../../../../shared/theme"; import { theme } from "../../../../shared/theme";
import { DriverNumber } from "../../Common/DriverNumber"; import { DriverNumber } from "../../Common/DriverNumber";
@@ -24,16 +27,20 @@ import {
FlagContainer, FlagContainer,
DriverPortraitContainer, DriverPortraitContainer,
} from "./styles"; } from "./styles";
import { useDispatch } from "react-redux";
import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition"; import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition";
type ChyronDriverProps = { type ChyronDriverProps = {
chyronData: BGChyronDriver, chyronData: BGChyronDriver,
subMode: BGChyronSubMode, subMode: BGChyronSubMode,
openState: OpenState, openState: OpenState,
debugDurationMultiplier?: Fraction,
}; };
export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverProps) { export function ChyronDriver({
chyronData,
subMode,
openState,
debugDurationMultiplier: DDM = 1.0,
}: ChyronDriverProps) {
const [baseWidth, baseHeight] = subMode === "medium" ? [582, 72] const [baseWidth, baseHeight] = subMode === "medium" ? [582, 72]
: subMode === "large" ? [638, 98] : subMode === "large" ? [638, 98]
: [0, 0]; : [0, 0];
@@ -47,7 +54,7 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro
const containerFadeAwaySpring = useSpring({ const containerFadeAwaySpring = useSpring({
opacity: openState == -1 ? 0 : 1, opacity: openState == -1 ? 0 : 1,
config: { duration: 300 }, config: { duration: 300 * DDM },
delay: 0, delay: 0,
onRest: () => { onRest: () => {
if (openState === -1) { if (openState === -1) {
@@ -68,37 +75,36 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro
open={openState !== 0} open={openState !== 0}
transitionProps={[{ transitionProps={[{
property: "outline", property: "outline",
duration: 1167, duration: 1167 * DDM,
}]} }]}
/> />
<BaseBlack <BaseBlack
open={openState !== 0} open={openState !== 0}
transitionProps={[{ transitionProps={[{
property: "opacity", property: "opacity",
duration: 800, duration: 800 * DDM,
timing: "ease-in", timing: "ease-in",
}, { }, {
property: "width", property: "width",
duration: 667, duration: 667 * DDM,
timing: "ease-out", timing: "ease-out",
delay: 0,
}]} }]}
/> />
<BaseLayout <BaseLayout
open={openState !== 0} open={openState !== 0}
transitionProps={[{ transitionProps={[{
property: "clip-path", property: "clip-path",
duration: 400, duration: 400 * DDM,
timing: "ease-in", timing: "ease-in",
delay: 333, delay: 333 * DDM,
}]} }]}
> >
<BaseBackgroundColor <BaseBackgroundColor
open={openState !== 0} open={openState !== 0}
transitionProps={[{ transitionProps={[{
property: "opacity", property: "opacity",
duration: 566, duration: 566 * DDM,
delay: 600, delay: 600 * DDM,
}]} }]}
teamColor={teamColor} teamColor={teamColor}
/> />
@@ -106,21 +112,21 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro
{showPosFlag && ( {showPosFlag && (
<VenetianBlindsTransition <VenetianBlindsTransition
visible={openState !== 0} visible={openState !== 0}
delay={500} delay={500 * DDM}
blindsColor="#f60d0d" blindsColor="#f60d0d"
blindsColorFadeDuration={300} blindsColorFadeDuration={300 * DDM}
blindsColorFadeDelay={200} blindsColorFadeDelay={200 * DDM}
blindsAngle={-45} blindsAngle={-45}
blindsOpenDuration={100} blindsOpenDuration={100 * DDM}
blindsOpenDelay={150} blindsOpenDelay={150 * DDM}
blindsSize={{ transparent: 3, opaque: 6 }} blindsSize={{ transparent: 3, opaque: 6 }}
wipeAngle={40} wipeAngle={40}
wipeDuration={300} wipeDuration={333 * DDM}
wipeStartingCorner="bottomRight" wipeStartingCorner="bottomRight"
opacityStart={0.1} opacityStart={0.1}
opacityDuration={200} opacityDuration={200 * DDM}
opacityDelay={100} opacityDelay={100 * DDM}
spanBlinkDuration={500} spanBlinkDuration={500 * DDM}
> >
<PositionFlag size={baseHeight * 0.85} number={car.position} /> <PositionFlag size={baseHeight * 0.85} number={car.position} />
</VenetianBlindsTransition> </VenetianBlindsTransition>
@@ -130,9 +136,9 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro
open={openState !== 0} open={openState !== 0}
transitionProps={[{ transitionProps={[{
property: "clip-path", property: "clip-path",
duration: 667, duration: 667 * DDM,
timing: "ease-in-out", timing: "ease-in-out",
delay: 733, delay: 733 * DDM,
}]} }]}
color={teamColor} color={teamColor}
/> />
@@ -151,7 +157,11 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro
</NumberContainer> </NumberContainer>
)} )}
</NameContainer> </NameContainer>
<TeamName open={openState !== 0}> <TeamName
open={openState !== 0}
duration={233 * DDM}
delay={500 * DDM}
>
{car.driver.team.shortName} {car.driver.team.shortName}
</TeamName> </TeamName>
</TextContainer> </TextContainer>
@@ -159,8 +169,8 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro
open={openState !== 0} open={openState !== 0}
transitionProps={[{ transitionProps={[{
property: "opacity", property: "opacity",
duration: 500, duration: 500 * DDM,
delay: 1000, delay: 1000 * DDM,
}]} }]}
height={baseHeight * 0.9} height={baseHeight * 0.9}
width={baseHeight * 3} width={baseHeight * 3}
@@ -177,16 +187,16 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro
{showPortrait && ( {showPortrait && (
<VenetianBlindsTransition <VenetianBlindsTransition
visible={openState !== 0} visible={openState !== 0}
delay={1500} delay={1500 * DDM}
blindsColor={teamColor} blindsColor={teamColor}
blindsColorFadeDuration={600} blindsColorFadeDuration={600 * DDM}
blindsColorFadeDelay={300} blindsColorFadeDelay={300 * DDM}
blindsAngle={-45} blindsAngle={-45}
blindsOpenDuration={600} blindsOpenDuration={600 * DDM}
blindsOpenDelay={600} blindsOpenDelay={600 * DDM}
blindsSize={{ transparent: 2, opaque: 5 }} blindsSize={{ transparent: 2, opaque: 5 }}
wipeAngle={45} wipeAngle={45}
wipeDuration={600} wipeDuration={600 * DDM}
wipeStartingCorner="bottomRight" wipeStartingCorner="bottomRight"
> >
<DriverPortraitContainer placement={{ right: "-5px", bottom: "0" }}> <DriverPortraitContainer placement={{ right: "-5px", bottom: "0" }}>
@@ -2,6 +2,7 @@ import { animated } from "@react-spring/web";
import styled, { css, keyframes } from "styled-components"; import styled, { css, keyframes } from "styled-components";
import { Placement, Px, TransitionArgs } from "../../../../types/style"; import { Placement, Px, TransitionArgs } from "../../../../types/style";
import { Milliseconds } from "../../../../types/util";
import { commonTransition, placementStyleRules } from "../../../../utils/styling"; import { commonTransition, placementStyleRules } from "../../../../utils/styling";
type OpenProps = { type OpenProps = {
@@ -149,14 +150,18 @@ const blinkingAnimation = keyframes`
86% { opacity: 1 } 86% { opacity: 1 }
`; `;
export const TeamName = styled.div<OpenProps>` type TeamNameProps = OpenProps & {
duration: Milliseconds,
delay: Milliseconds,
}
export const TeamName = styled.div<TeamNameProps>`
position: relative; position: relative;
font-family: ${p => p.theme.fonts.f1Regular}; font-family: ${p => p.theme.fonts.f1Regular};
color: #d1d1d1; color: #d1d1d1;
font-size: 20px; font-size: 20px;
${({ open }) => open && css` ${({ open, duration, delay }) => open && css`
animation: ${blinkingAnimation} 233ms step-end 500ms; animation: ${blinkingAnimation} ${duration}ms step-end ${delay}ms;
`} `}
`; `;
TeamName.displayName = "TeamName"; TeamName.displayName = "TeamName";
@@ -19,11 +19,13 @@ type WorkspaceProps = {
workspaceId: WorkspaceId, workspaceId: WorkspaceId,
previewContent: ReactNode, previewContent: ReactNode,
prototypeControls: ReactNode, prototypeControls: ReactNode,
showAnimationSpeedSelector?: boolean,
}; };
export const Workspace = ({ export const Workspace = ({
workspaceId, workspaceId,
previewContent, previewContent,
prototypeControls, prototypeControls,
showAnimationSpeedSelector = false,
}: WorkspaceProps) => { }: WorkspaceProps) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { animatedBG, darkBG, workspaceProperties } = useSelector(workspaceSelector); const { animatedBG, darkBG, workspaceProperties } = useSelector(workspaceSelector);
@@ -64,7 +66,9 @@ export const Workspace = ({
/> />
</PreviewWindow> </PreviewWindow>
<ControlsContainer> <ControlsContainer>
<WorkspaceControls /> <WorkspaceControls
showAnimationSpeedSelector={showAnimationSpeedSelector}
/>
{prototypeControls} {prototypeControls}
</ControlsContainer> </ControlsContainer>
</Stack> </Stack>
@@ -4,12 +4,21 @@ import { Split } from "@bedrock-layout/split";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { workspaceSelector } from "../../../features/workspace/workspaceSelector"; import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
import { setAnimatedBG, setDarkBG } from "../../../features/workspace/workspaceSlice"; import { setAnimatedBG, setDarkBG, setDebugDurationMultiplier } from "../../../features/workspace/workspaceSlice";
import { SlotSelector } from "../../Common/Inputs/SlotSelector";
import { Toggle } from "../../Common/Inputs/Toggle"; import { Toggle } from "../../Common/Inputs/Toggle";
import { OverlayControl } from "../../OverlayTool"; import { OverlayControl } from "../../OverlayTool";
export const WorkspaceControls = () => { const debugMultipliers = ["1", "1.5", "2", "3", "5", "10"];
type WorkspaceControlsProps = {
showAnimationSpeedSelector?: boolean,
};
export const WorkspaceControls = (
{ showAnimationSpeedSelector = false }: WorkspaceControlsProps,
) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { animatedBG, darkBG } = useSelector(workspaceSelector); const { animatedBG, darkBG } = useSelector(workspaceSelector);
@@ -30,6 +39,16 @@ export const WorkspaceControls = () => {
dispatch(setDarkBG(value)); dispatch(setDarkBG(value));
}} }}
/> />
{showAnimationSpeedSelector && (
<SlotSelector
label="Animation Speed"
items={debugMultipliers}
formatter={value => `x${value}`}
onChange={index =>
dispatch(setDebugDurationMultiplier(parseFloat(debugMultipliers[index])))}
slotWidth="4ch"
/>
)}
</InlineCluster> </InlineCluster>
<OverlayControl /> <OverlayControl />
</Split> </Split>
@@ -55,15 +55,17 @@ export default function Workspaces() {
<Route path="chyron" element={ <Route path="chyron" element={
<Workspace <Workspace
workspaceId="chyron" workspaceId="chyron"
previewContent={<ChyronContainer />} previewContent={<ChyronContainer debug />}
prototypeControls={<ChyronPrototypeControls />} prototypeControls={<ChyronPrototypeControls />}
showAnimationSpeedSelector
/> />
} /> } />
<Route path="chyronWide" element={ <Route path="chyronWide" element={
<Workspace <Workspace
workspaceId="chyronWide" workspaceId="chyronWide"
previewContent={<ChyronContainer />} previewContent={<ChyronContainer debug />}
prototypeControls={<ChyronPrototypeControls />} prototypeControls={<ChyronPrototypeControls />}
showAnimationSpeedSelector
/> />
} /> } />
<Route path="angledFlagCountry" element={ <Route path="angledFlagCountry" element={
+6
View File
@@ -1,10 +1,12 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { PrototypeState, RootState, WorkspaceId, WorkspaceProperties } from "../../types/state"; import { PrototypeState, RootState, WorkspaceId, WorkspaceProperties } from "../../types/state";
import { Fraction } from "../../types/style";
const initialState: RootState["workspace"] = { const initialState: RootState["workspace"] = {
workspaceId: "", workspaceId: "",
animatedBG: true, animatedBG: true,
darkBG: false, darkBG: false,
debugDurationMultiplier: 1.0,
workspaceProperties: { workspaceProperties: {
name: "undefined", name: "undefined",
overlayIds: [], overlayIds: [],
@@ -31,6 +33,9 @@ export const workspaceSlice = createSlice({
setDarkBG: (state, action: PayloadAction<boolean>) => { setDarkBG: (state, action: PayloadAction<boolean>) => {
state.darkBG = action.payload; state.darkBG = action.payload;
}, },
setDebugDurationMultiplier: (state, action: PayloadAction<Fraction>) => {
state.debugDurationMultiplier = action.payload;
},
updateWorkspace: (state, action: PayloadAction<UpdateWorkspaceAction>) => { updateWorkspace: (state, action: PayloadAction<UpdateWorkspaceAction>) => {
state.workspaceId = action.payload.workspaceId; state.workspaceId = action.payload.workspaceId;
state.workspaceProperties = action.payload.workspaceProperties; state.workspaceProperties = action.payload.workspaceProperties;
@@ -91,6 +96,7 @@ export const {
setWorkspaceId, setWorkspaceId,
setAnimatedBG, setAnimatedBG,
setDarkBG, setDarkBG,
setDebugDurationMultiplier,
updateWorkspace, updateWorkspace,
updateAngledFlagCountry, updateAngledFlagCountry,
updateAngledFlagTeam, updateAngledFlagTeam,
+2 -1
View File
@@ -1,5 +1,5 @@
import { Milliseconds, Optional } from "./util"; import { Milliseconds, Optional } from "./util";
import { Corner } from "./style"; import { Corner, Fraction } from "./style";
export interface RootState { export interface RootState {
pageDimensions: PageDimensions; pageDimensions: PageDimensions;
@@ -23,6 +23,7 @@ export interface Workspace {
workspaceId: WorkspaceId; workspaceId: WorkspaceId;
animatedBG: boolean; animatedBG: boolean;
darkBG: boolean; darkBG: boolean;
debugDurationMultiplier: Fraction,
workspaceProperties: WorkspaceProperties; workspaceProperties: WorkspaceProperties;
prototypeState: PrototypeState; prototypeState: PrototypeState;
} }