From 58da0e4895fffc1bed3868fa7c121be695207a3a Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Thu, 17 Mar 2022 08:56:55 -0400 Subject: [PATCH] ISSUE-053 - Placed Chyrons on video feed. Adjusted the method that placement is determined. It didn't make much sense to define Placement in state, so I've moved it to the central theme object instead. I also took the time to support +10 laps and minutes with a special xScale setting for the TimingTowerRows. --- .../Chyrons/ChyronsDirectorControls.tsx | 1 - src/components/Broadcast/Layout/Layout.tsx | 14 +++++-- .../Broadcast/VideoFeed/VideoFeed.tsx | 14 +++++-- src/components/Broadcast/VideoFeed/styles.ts | 13 ++++++- .../Chyrons/Container/ChyronContainer.tsx | 37 ++++++++++--------- .../Chyrons/Container/styles.ts | 12 ++++++ .../TimingBoard/TimingBoard.tsx | 8 ++-- .../TimingTower/TimingTowerRow.tsx | 7 ++++ .../TimingBoard/TimingTower/styles.ts | 1 + .../BroadcastGraphics/TimingBoard/styles.ts | 2 +- .../graphics/broadcastGraphicsSlice.ts | 3 +- src/shared/theme.ts | 6 +++ src/types/state.ts | 3 +- 13 files changed, 86 insertions(+), 35 deletions(-) diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx index 2bb577b..6e4e87f 100644 --- a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx +++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx @@ -71,7 +71,6 @@ export function ChyronsDirectorControls() { } const newChyrons: BGChyrons = { openState: 0, - placement: { top: "0", right: "0", bottom: "0", left: "0" }, mode: chyronMode, subMode: chyronSubMode, driver: { diff --git a/src/components/Broadcast/Layout/Layout.tsx b/src/components/Broadcast/Layout/Layout.tsx index e9d5489..fb7fe3f 100644 --- a/src/components/Broadcast/Layout/Layout.tsx +++ b/src/components/Broadcast/Layout/Layout.tsx @@ -1,7 +1,10 @@ -import { MockupBlock } from "../../Common/MockupBlock.styled"; +import { PadBox } from "@bedrock-layout/padbox"; + import VideoFeed from "../VideoFeed/VideoFeed"; +import { MockupBlock } from "../../Common/MockupBlock.styled"; import { LayoutGrid, LayoutGridItem } from "../../Common/LayoutGrid.styled"; import { TimingTowerPrototypeControls } from "../../Workspaces/PrototypingControls/TimingTowerPrototype"; +import { ChyronsDirectorControls } from "../BroadcastDirectorUI/Chyrons"; type LayoutProps = { headerHeight?: number, @@ -17,7 +20,7 @@ export function Layout({ headerHeight }: LayoutProps) { >Timing Board UI - + @@ -33,8 +36,11 @@ export function Layout({ headerHeight }: LayoutProps) { >Race Director UI - - + + + + + ); diff --git a/src/components/Broadcast/VideoFeed/VideoFeed.tsx b/src/components/Broadcast/VideoFeed/VideoFeed.tsx index ee79789..c8fd11c 100644 --- a/src/components/Broadcast/VideoFeed/VideoFeed.tsx +++ b/src/components/Broadcast/VideoFeed/VideoFeed.tsx @@ -3,10 +3,12 @@ import useMeasure from "react-use-measure"; import { calculateFitSize, calculateScale } from "../../../utils/styling"; import { theme } from "../../../shared/theme"; -import { VideoFeedFrame, BackgroundImageDiv, DimensionsSpan, BroadcastLayout } from "./styles"; +import { VideoFeedFrame, BackgroundImageDiv, DimensionsSpan, BroadcastLayout, Logo } from "./styles"; import { TimingBoard } from "../../BroadcastGraphics/TimingBoard"; +import { ChyronContainer } from "../../BroadcastGraphics/Chyrons/Container"; import bg from "../../../public/images/misc/bg-standin.jpg"; +import f1Logo from "../../../public/images/logos/f1-logo-white.svg"; export default function VideoFeed() { const [frameRef, { @@ -17,6 +19,8 @@ export default function VideoFeed() { const { dimensionsWidthPx: broadcastWidth, dimensionsHeightPx: broadcastHeight, + logoHeightPx, + placement, } = theme.broadcast; const [layoutWidth, layoutHeight] = calculateFitSize(frameWidth, frameHeight, @@ -27,11 +31,15 @@ export default function VideoFeed() { return ( - {Math.floor(frameWidth)} x {Math.floor(frameHeight)}px + Frame: {Math.floor(frameWidth)} x {Math.floor(frameHeight)}px +
+ Scaled: {Math.floor(layoutWidth)} x {Math.floor(layoutHeight)}px ({(layoutScale * 100).toFixed(1)}%)
- + + +
); diff --git a/src/components/Broadcast/VideoFeed/styles.ts b/src/components/Broadcast/VideoFeed/styles.ts index 835d68e..734f2b1 100644 --- a/src/components/Broadcast/VideoFeed/styles.ts +++ b/src/components/Broadcast/VideoFeed/styles.ts @@ -1,6 +1,7 @@ import styled, { css } from "styled-components/macro"; -import { Fraction, Px } from "../../../types/style"; +import { Fraction, Placement, Px } from "../../../types/style"; +import { placementStyleRules } from "../../../utils/styling"; type VideoFeedFrameProps = { centered?: boolean, @@ -61,3 +62,13 @@ export const DimensionsSpan = styled.span` color: ${p => p.theme.colors.textWhite}; font-family: ${p => p.theme.fonts.f1Regular}; `; + +type LogoProps = { + placement: Placement, + height: Px, +}; +export const Logo = styled.img` + position: absolute; + ${({ placement }) => placementStyleRules(placement)} + height: ${({ height }) => height}px; +`; diff --git a/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx b/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx index 6766c0f..be3f11e 100644 --- a/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx +++ b/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx @@ -2,14 +2,16 @@ import { useSelector } from "react-redux"; import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; import { workspaceSelector } from "../../../../features/workspace/workspaceSelector"; +import { Placement } from "../../../../types/style"; import { ChyronDriver } from "../Driver"; -import { DoubleChyronContainer } from "./styles"; +import { ChyronPlacement, DoubleChyronContainer } from "./styles"; type ChyronContainerProps = { debug?: boolean, + placement?: Placement, }; -export function ChyronContainer({ debug = false }: ChyronContainerProps) { +export function ChyronContainer({ debug = false, placement = {} }: ChyronContainerProps) { const { chyrons } = useSelector(broadcastGraphicsSelector); const { debugDurationMultiplier } = useSelector(workspaceSelector); @@ -23,19 +25,20 @@ export function ChyronContainer({ debug = false }: ChyronContainerProps) { debugDurationMultiplier={debug ? debugDurationMultiplier : 1} /> ); - if (chyrons.subMode === "medium" && chyrons.driver.secondary) { - return ( - - {primary} - - - ); - } else { - return primary; - } + + return ( + + {chyrons.subMode === "medium" && chyrons.driver.secondary ? ( + + {primary} + + + ) : primary} + + ); } diff --git a/src/components/BroadcastGraphics/Chyrons/Container/styles.ts b/src/components/BroadcastGraphics/Chyrons/Container/styles.ts index 7ce6563..7766d88 100644 --- a/src/components/BroadcastGraphics/Chyrons/Container/styles.ts +++ b/src/components/BroadcastGraphics/Chyrons/Container/styles.ts @@ -1,7 +1,19 @@ import styled from "styled-components/macro"; +import { Placement } from "../../../../types/style"; +import { placementStyleRules } from "../../../../utils/styling"; + export const DoubleChyronContainer = styled.div` display: flex; justify-content: space-between; width: 1196px; `; + + +type ChyronPlacementProps = { + placement: Placement, +}; +export const ChyronPlacement = styled.div` + position: absolute; + ${({ placement }) => placementStyleRules(placement)} +`; diff --git a/src/components/BroadcastGraphics/TimingBoard/TimingBoard.tsx b/src/components/BroadcastGraphics/TimingBoard/TimingBoard.tsx index 1cd86ac..b1e8202 100644 --- a/src/components/BroadcastGraphics/TimingBoard/TimingBoard.tsx +++ b/src/components/BroadcastGraphics/TimingBoard/TimingBoard.tsx @@ -1,21 +1,21 @@ import { useSelector } from "react-redux"; import { workspaceSelector } from "../../../features/workspace/workspaceSelector"; +import { Placement } from "../../../types/style"; import { TimingBoardLayout } from "./styles"; import { TimingTower } from "./TimingTower"; import { StatusIndicator } from "./StatusIndicator"; -import { broadcastGraphicsSelector } from "../../../features/broadcast/graphics/broadcastGraphicsSelector"; type TimingBoardProps = { debug?: boolean, + placement?: Placement, }; -export function TimingBoard({ debug = false }: TimingBoardProps) { +export function TimingBoard({ debug = false, placement = {} }: TimingBoardProps) { const { debugDurationMultiplier } = useSelector(workspaceSelector); - const { timingBoard } = useSelector(broadcastGraphicsSelector); return ( - + diff --git a/src/components/BroadcastGraphics/TimingBoard/TimingTower/TimingTowerRow.tsx b/src/components/BroadcastGraphics/TimingBoard/TimingTower/TimingTowerRow.tsx index 71ff63a..e867d16 100644 --- a/src/components/BroadcastGraphics/TimingBoard/TimingTower/TimingTowerRow.tsx +++ b/src/components/BroadcastGraphics/TimingBoard/TimingTower/TimingTowerRow.tsx @@ -153,6 +153,13 @@ export function TimingTowerRow({ xScale = rightHalfContent.includes(":") ? 0.75 : 0.9; yScale = rightHalfContent.includes("+") ? 1.1 : 1.0; + + if (rightHalfContent.includes("LAPS") && rightHalfContent.length > 7) { + xScale = 0.85; // Extreme edge case where +10 laps or more behind. + } + if (rightHalfContent.length > 9) { + xScale = 0.7; // Extreme edge case where +10 minutes or more behind. + } } return ( diff --git a/src/components/BroadcastGraphics/TimingBoard/TimingTower/styles.ts b/src/components/BroadcastGraphics/TimingBoard/TimingTower/styles.ts index d09dcca..1f2977f 100644 --- a/src/components/BroadcastGraphics/TimingBoard/TimingTower/styles.ts +++ b/src/components/BroadcastGraphics/TimingBoard/TimingTower/styles.ts @@ -221,6 +221,7 @@ export const TimeDiff = styled.span` color: ${p => p.theme.colors.textWhite}; font-family: ${p => p.theme.fonts.f1Regular}; font-size: 20px; + white-space: nowrap; text-align: end; diff --git a/src/components/BroadcastGraphics/TimingBoard/styles.ts b/src/components/BroadcastGraphics/TimingBoard/styles.ts index a5802ed..1072346 100644 --- a/src/components/BroadcastGraphics/TimingBoard/styles.ts +++ b/src/components/BroadcastGraphics/TimingBoard/styles.ts @@ -7,7 +7,7 @@ type TimingBoardLayoutProps = { placement: Placement, }; export const TimingBoardLayout = styled.div` - position: relative; + position: absolute; ${({ placement }) => placementStyleRules(placement)} display: flex; diff --git a/src/features/broadcast/graphics/broadcastGraphicsSlice.ts b/src/features/broadcast/graphics/broadcastGraphicsSlice.ts index 5e41089..3e2fcd9 100644 --- a/src/features/broadcast/graphics/broadcastGraphicsSlice.ts +++ b/src/features/broadcast/graphics/broadcastGraphicsSlice.ts @@ -13,13 +13,12 @@ import { const initialState: RootState["broadcastGraphics"] = { chyrons: null, timingBoard: { - placement: { top: "54px", left: "96px" }, openState: 1, statusIndicator: { mode: BGStatusIndicatorModes.LapNarrow, }, timingTower: { - open: 1, + openState: 1, displayMode: BGTimingTowerDisplayMode.LeftAndRight, splitsMode: BGTimingTowerSplitsMode.Leader, focusedCars: [], diff --git a/src/shared/theme.ts b/src/shared/theme.ts index fa5c275..de7f0f5 100644 --- a/src/shared/theme.ts +++ b/src/shared/theme.ts @@ -105,6 +105,12 @@ export const theme = { broadcast: { dimensionsWidthPx: 1920, dimensionsHeightPx: 1080, + logoHeightPx: 40, + placement: { + chyrons: { bottom: "52px", left: "378px" }, + timingBoard: { top: "54px", left: "96px" }, + logo: { left: "86px", bottom: "52px" }, + }, }, }; diff --git a/src/types/state.ts b/src/types/state.ts index a91b509..19bffdc 100644 --- a/src/types/state.ts +++ b/src/types/state.ts @@ -254,7 +254,6 @@ export interface BroadcastDirector { // Broadcast Graphics export interface BGBaseState { - placement: Placement; openState: OpenState; } /** @@ -287,7 +286,7 @@ export enum BGStatusIndicatorModes { // Timing Tower export interface BGTimingTower { - open: OpenState; + openState: OpenState; displayMode: BGTimingTowerDisplayMode; splitsMode: BGTimingTowerSplitsMode, focusedCars: Car[],