From 79b098af6caf7cbb913698e3c72fcf89ed8d27c4 Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Thu, 10 Feb 2022 19:12:06 -0500 Subject: [PATCH] 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. --- .../Chyrons/ChyronsDirectorControls.tsx | 2 - .../Chyrons/Container/ChyronContainer.tsx | 9 ++- .../Chyrons/Driver/ChyronDriver.tsx | 76 +++++++++++-------- .../Chyrons/Driver/styles.ts | 11 ++- .../Workspaces/Workspace/Workspace.tsx | 6 +- .../WorkspaceControls/WorkspaceControls.tsx | 23 +++++- src/components/Workspaces/WorkspacesRoute.tsx | 6 +- src/features/workspace/workspaceSlice.ts | 6 ++ src/types/state.d.ts | 3 +- 9 files changed, 97 insertions(+), 45 deletions(-) diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx index eefe809..5c5235e 100644 --- a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx +++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx @@ -8,7 +8,6 @@ import { FaCheck, FaStepForward, FaTimes } from "react-icons/fa"; import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector"; import { - clearChyrons, incrementChyronsOpenState, setChyrons, setChyronsOpenState, @@ -60,7 +59,6 @@ export function ChyronsDirectorControls() { }; const buildDriver = () => { - console.log("building driver"); if (selectedCars.length === 0) return; let primaryCar = selectedCars[0]; let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null; diff --git a/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx b/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx index cf5186e..6766c0f 100644 --- a/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx +++ b/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx @@ -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; @@ -15,6 +20,7 @@ export function ChyronContainer() { chyronData={chyrons.driver.primary} subMode={chyrons.subMode} openState={chyrons.openState} + debugDurationMultiplier={debug ? debugDurationMultiplier : 1} /> ); if (chyrons.subMode === "medium" && chyrons.driver.secondary) { @@ -25,6 +31,7 @@ export function ChyronContainer() { chyronData={chyrons.driver.secondary} subMode={chyrons.subMode} openState={chyrons.openState} + debugDurationMultiplier={debug ? debugDurationMultiplier : 1} /> ); diff --git a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx index 651a254..59fc111 100644 --- a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx +++ b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx @@ -1,6 +1,9 @@ -import { BGChyronDriver, BGChyronSubMode, OpenState } 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 { DriverNumber } from "../../Common/DriverNumber"; @@ -24,16 +27,20 @@ import { FlagContainer, DriverPortraitContainer, } from "./styles"; -import { useDispatch } from "react-redux"; -import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice"; import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition"; type ChyronDriverProps = { chyronData: BGChyronDriver, subMode: BGChyronSubMode, 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] : subMode === "large" ? [638, 98] : [0, 0]; @@ -47,7 +54,7 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro const containerFadeAwaySpring = useSpring({ opacity: openState == -1 ? 0 : 1, - config: { duration: 300 }, + config: { duration: 300 * DDM }, delay: 0, onRest: () => { if (openState === -1) { @@ -68,37 +75,36 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro open={openState !== 0} transitionProps={[{ property: "outline", - duration: 1167, + duration: 1167 * DDM, }]} /> @@ -106,21 +112,21 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro {showPosFlag && ( @@ -130,9 +136,9 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro open={openState !== 0} transitionProps={[{ property: "clip-path", - duration: 667, + duration: 667 * DDM, timing: "ease-in-out", - delay: 733, + delay: 733 * DDM, }]} color={teamColor} /> @@ -151,7 +157,11 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro )} - + {car.driver.team.shortName} @@ -159,8 +169,8 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro open={openState !== 0} transitionProps={[{ property: "opacity", - duration: 500, - delay: 1000, + duration: 500 * DDM, + delay: 1000 * DDM, }]} height={baseHeight * 0.9} width={baseHeight * 3} @@ -177,16 +187,16 @@ export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverPro {showPortrait && ( diff --git a/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts b/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts index 5009a20..181290e 100644 --- a/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts +++ b/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts @@ -2,6 +2,7 @@ import { animated } from "@react-spring/web"; import styled, { css, keyframes } from "styled-components"; import { Placement, Px, TransitionArgs } from "../../../../types/style"; +import { Milliseconds } from "../../../../types/util"; import { commonTransition, placementStyleRules } from "../../../../utils/styling"; type OpenProps = { @@ -149,14 +150,18 @@ const blinkingAnimation = keyframes` 86% { opacity: 1 } `; -export const TeamName = styled.div` +type TeamNameProps = OpenProps & { + duration: Milliseconds, + delay: Milliseconds, +} +export const TeamName = styled.div` position: relative; font-family: ${p => p.theme.fonts.f1Regular}; color: #d1d1d1; font-size: 20px; - ${({ open }) => open && css` - animation: ${blinkingAnimation} 233ms step-end 500ms; + ${({ open, duration, delay }) => open && css` + animation: ${blinkingAnimation} ${duration}ms step-end ${delay}ms; `} `; TeamName.displayName = "TeamName"; diff --git a/src/components/Workspaces/Workspace/Workspace.tsx b/src/components/Workspaces/Workspace/Workspace.tsx index 5fe0082..98c02cd 100644 --- a/src/components/Workspaces/Workspace/Workspace.tsx +++ b/src/components/Workspaces/Workspace/Workspace.tsx @@ -19,11 +19,13 @@ type WorkspaceProps = { workspaceId: WorkspaceId, previewContent: ReactNode, prototypeControls: ReactNode, + showAnimationSpeedSelector?: boolean, }; export const Workspace = ({ workspaceId, previewContent, prototypeControls, + showAnimationSpeedSelector = false, }: WorkspaceProps) => { const dispatch = useDispatch(); const { animatedBG, darkBG, workspaceProperties } = useSelector(workspaceSelector); @@ -64,7 +66,9 @@ export const Workspace = ({ /> - + {prototypeControls} diff --git a/src/components/Workspaces/WorkspaceControls/WorkspaceControls.tsx b/src/components/Workspaces/WorkspaceControls/WorkspaceControls.tsx index d06a470..2d8b767 100644 --- a/src/components/Workspaces/WorkspaceControls/WorkspaceControls.tsx +++ b/src/components/Workspaces/WorkspaceControls/WorkspaceControls.tsx @@ -4,12 +4,21 @@ import { Split } from "@bedrock-layout/split"; import { useDispatch, useSelector } from "react-redux"; 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 { 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, darkBG } = useSelector(workspaceSelector); @@ -30,6 +39,16 @@ export const WorkspaceControls = () => { dispatch(setDarkBG(value)); }} /> + {showAnimationSpeedSelector && ( + `x${value}`} + onChange={index => + dispatch(setDebugDurationMultiplier(parseFloat(debugMultipliers[index])))} + slotWidth="4ch" + /> + )} diff --git a/src/components/Workspaces/WorkspacesRoute.tsx b/src/components/Workspaces/WorkspacesRoute.tsx index da75648..34e33e5 100644 --- a/src/components/Workspaces/WorkspacesRoute.tsx +++ b/src/components/Workspaces/WorkspacesRoute.tsx @@ -55,15 +55,17 @@ export default function Workspaces() { } + previewContent={} prototypeControls={} + showAnimationSpeedSelector /> } /> } + previewContent={} prototypeControls={} + showAnimationSpeedSelector /> } /> ) => { state.darkBG = action.payload; }, + setDebugDurationMultiplier: (state, action: PayloadAction) => { + state.debugDurationMultiplier = action.payload; + }, updateWorkspace: (state, action: PayloadAction) => { state.workspaceId = action.payload.workspaceId; state.workspaceProperties = action.payload.workspaceProperties; @@ -91,6 +96,7 @@ export const { setWorkspaceId, setAnimatedBG, setDarkBG, + setDebugDurationMultiplier, updateWorkspace, updateAngledFlagCountry, updateAngledFlagTeam, diff --git a/src/types/state.d.ts b/src/types/state.d.ts index d242e63..c01dc92 100644 --- a/src/types/state.d.ts +++ b/src/types/state.d.ts @@ -1,5 +1,5 @@ import { Milliseconds, Optional } from "./util"; -import { Corner } from "./style"; +import { Corner, Fraction } from "./style"; export interface RootState { pageDimensions: PageDimensions; @@ -23,6 +23,7 @@ export interface Workspace { workspaceId: WorkspaceId; animatedBG: boolean; darkBG: boolean; + debugDurationMultiplier: Fraction, workspaceProperties: WorkspaceProperties; prototypeState: PrototypeState; }