diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx index ca1f0c5..7e1a02e 100644 --- a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx +++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx @@ -1,18 +1,23 @@ import { InlineCluster } from "@bedrock-layout/inline-cluster"; import { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; - -import { FaPlay, FaStepForward, FaStop } from "react-icons/fa"; -import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; - -import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics"; -import { BGChyronMode, BGChyronSubMode, FlagMode } from "../../../../types/state"; - -import { SlotSelector } from "../../../Common/Inputs/SlotSelector"; -import { Button, CloseButton, OpenButton, SlotContainer, Title } from "./styles"; -import { Toggle } from "../../../Common/Inputs/Toggle"; import { Stack } from "@bedrock-layout/stack"; import { Inline } from "@bedrock-layout/inline"; +import { FaPlay, FaStepForward, FaStop } from "react-icons/fa"; + +import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; +import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector"; +import { + chyronsClear, + chyronsOpenStateIncrement, + chyronsSet, +} from "../../../../features/broadcast/graphics/broadcastGraphicsSlice"; +import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics"; +import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode } from "../../../../types/state"; + +import { SlotSelector } from "../../../Common/Inputs/SlotSelector"; +import { Button, CloseButton, OpenButton, Title } from "./styles"; +import { Toggle } from "../../../Common/Inputs/Toggle"; export function ChyronsDirectorControls() { // Use state to prevent unnecessary resetting on re-renders. @@ -27,55 +32,91 @@ export function ChyronsDirectorControls() { const [portrait, setPortrait] = useState(false); const [flagMode, setFlagMode] = useState("country"); + // Central state. const dispatch = useDispatch(); const { chyrons } = useSelector(broadcastGraphicsSelector); + const { selectedCars } = useSelector(broadcastDirectorSelector); useEffect(() => { setChyronSubModes(getChyronSubModesList(chyronMode)); }, [chyronMode]); - const onLaunch = () => { - const x = 0; - return x; + 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)); + } }; - const controlSelector = (mode: BGChyronMode, subMode: BGChyronSubMode) => { + const onNext = () => { + dispatch(chyronsOpenStateIncrement()); + }; + + const onClose = () => { + dispatch(chyronsClear()); + }; + + const buildDriverChyron = (car: Car): BGChyronDriver => ({ + car, + flagMode, + showPosFlag: posFlag, + showDriverNumber: driverNum, + showPortrait: chyronSubMode === "large" ? false : portrait, + }); + + const modeControls = (mode: BGChyronMode, subMode: BGChyronSubMode) => { if (mode === "driver") { - return driverMode(subMode); + return ( + + + + {subMode === "medium" && ( + + )} + setFlagMode(flagModeList[index])} + slotWidth="12ch" + /> + + ); } else { return null; } }; - const driverMode = (subMode: BGChyronSubMode) => ( - - - - - {subMode === "medium" && ( - - )} - setFlagMode(flagModeList[index])} - slotWidth="12ch" - /> - - ); - return ( @@ -92,23 +133,26 @@ export function ChyronsDirectorControls() { - {controlSelector(chyronMode, chyronSubMode)} + {modeControls(chyronMode, chyronSubMode)} ); } diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/styles.ts b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/styles.ts index 75f02dc..869a386 100644 --- a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/styles.ts +++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/styles.ts @@ -1,19 +1,10 @@ import styled from "styled-components"; -import { Px } from "../../../../types/style"; export const Title = styled.h4` font-family: ${p => p.theme.fonts.f1Italic}; `; Title.displayName = "Title"; -type SlotContainerProps = { - width: Px, -}; -export const SlotContainer = styled.div` - width: ${({ width }) => `${width}px`}; -`; -SlotContainer.displayName = "SlotContainer"; - type ButtonProps = { disabled: boolean, }; @@ -27,6 +18,13 @@ export const Button = styled.button` border: 1px black solid; cursor: pointer; + + &:hover { + box-shadow: inset 0px 0px 10px 0px rgba(0, 0, 0, 0.3); + } + &:active { + box-shadow: inset 0px 0px 10px 4px rgba(255, 255, 255, 0.8); + } `; Button.displayName = "Button"; diff --git a/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx b/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx new file mode 100644 index 0000000..bc220b7 --- /dev/null +++ b/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx @@ -0,0 +1,32 @@ +import { Inline } from "@bedrock-layout/inline"; +import { useSelector } from "react-redux"; + +import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; + +import { ChyronDriver } from "../Driver"; +import { Spacer } from "./styles"; + +export function ChyronContainer() { + const { chyrons } = useSelector(broadcastGraphicsSelector); + + if (chyrons == null || chyrons.driver == null) return null; + + return ( + + + + {chyrons.subMode == "medium" && chyrons.driver.secondary && ( + <> + + + + )} + + ); +} diff --git a/src/components/BroadcastGraphics/Chyrons/Container/index.ts b/src/components/BroadcastGraphics/Chyrons/Container/index.ts new file mode 100644 index 0000000..b130ced --- /dev/null +++ b/src/components/BroadcastGraphics/Chyrons/Container/index.ts @@ -0,0 +1 @@ +export * from "./ChyronContainer"; diff --git a/src/components/BroadcastGraphics/Chyrons/Container/styles.ts b/src/components/BroadcastGraphics/Chyrons/Container/styles.ts new file mode 100644 index 0000000..8805b35 --- /dev/null +++ b/src/components/BroadcastGraphics/Chyrons/Container/styles.ts @@ -0,0 +1,6 @@ +import styled from "styled-components"; + +export const Spacer = styled.div` + width: 32px; +`; +Spacer.displayName = "Spacer"; diff --git a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx index 6f5714f..d3e23d9 100644 --- a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx +++ b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx @@ -1,3 +1,7 @@ +import { BGChyronDriver, BGChyronSubMode } from "../../../../types/state"; + +import { theme } from "../../../../shared/theme"; + import { DriverNumber } from "../../Common/DriverNumber"; import { AngledFlag } from "../../Common/AngledFlag"; import { @@ -14,37 +18,46 @@ import { TextContainer, FlagContainer, } from "./styles"; -import { drivers } from "../../../../domain/data/teams"; -import { theme } from "../../../../shared/theme"; -export function ChyronDriver() { - // TODO - Get driver details from Redux. - const driver = drivers["hamilton"]; - const baseWidth = 582; - const baseHeight = 72; +type ChyronDriverProps = { + chyronData: BGChyronDriver, + subMode: BGChyronSubMode, +}; +export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) { + const [baseWidth, baseHeight] = subMode === "medium" ? [582, 72] + : subMode === "large" ? [638, 98] + : [0, 0]; + + const { car, flagMode, showPosFlag, showDriverNumber } = chyronData; return ( - - 1 - + {showPosFlag && ( + + + {car.position} + + + )} - + - {driver.firstName} - {driver.lastName} - - - + {car.driver.firstName} + {car.driver.lastName} + {showDriverNumber && ( + + + + )} - {driver.team.shortName} + {car.driver.team.shortName} ); } - -// export function ChyronDriverStateContainer() { - -// } diff --git a/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx b/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx index 08ecf83..cfcc591 100644 --- a/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx +++ b/src/components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace.tsx @@ -1,23 +1,26 @@ import { useSelector } from "react-redux"; import { workspaceSelector } from "../../../features/workspace/workspaceSelector"; +import { FlagMode } from "../../../types/state"; import { AngledFlag } from "../../BroadcastGraphics/Common/AngledFlag"; import { BasicBlock } from "./styles"; - -export function AngledFlagWorkSpace() { +type AngledFlagWorkSpaceProps = { + flagMode: FlagMode, +}; +export function AngledFlagWorkSpace({ flagMode }: AngledFlagWorkSpaceProps) { const { prototypeState } = useSelector(workspaceSelector); return ( diff --git a/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx index d1ddb0c..38c3cd6 100644 --- a/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx +++ b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx @@ -26,8 +26,8 @@ export function AngledFlagPrototypeControls() { }; return ( - - + + ); } diff --git a/src/components/Workspaces/Workspace/styles.ts b/src/components/Workspaces/Workspace/styles.ts index 8d689ed..8a270ba 100644 --- a/src/components/Workspaces/Workspace/styles.ts +++ b/src/components/Workspaces/Workspace/styles.ts @@ -13,9 +13,7 @@ export type PreviewWindowProps = { dimensions: Dimensions, animatedBG?: boolean, }; -export const PreviewWindow = styled(PadBox).attrs(() => ({ - padding: "lg", -}))` +export const PreviewWindow = styled.div` position: relative; display: flex; justify-content: center; diff --git a/src/components/Workspaces/WorkspacesRoute.tsx b/src/components/Workspaces/WorkspacesRoute.tsx index eaab0bb..8660810 100644 --- a/src/components/Workspaces/WorkspacesRoute.tsx +++ b/src/components/Workspaces/WorkspacesRoute.tsx @@ -11,10 +11,10 @@ import { WorkspaceList } from "./WorkspaceList"; import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled"; import { Workspace } from "./Workspace"; -import { ChyronDriver } from "../BroadcastGraphics/Chyrons/Driver"; import { ChyronPrototypeControls } from "./PrototypingControls/ChyronPrototype"; import { AngledFlagWorkSpace } from "./CustomWorkSpaces/AngledFlagWorkSpace"; import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPrototype"; +import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container"; const WORKSPACE_LIST_WIDTH = 180; @@ -49,17 +49,24 @@ export default function Workspaces() { > Workspaces Home} /> - } + workspaceId="chyron" + previewContent={} prototypeControls={} /> } /> - } + workspaceId="chyronWide" + previewContent={} + prototypeControls={} + /> + } /> + } prototypeControls={} /> } /> diff --git a/src/domain/data/workspaces.ts b/src/domain/data/workspaces.ts index 16086cd..a1132f9 100644 --- a/src/domain/data/workspaces.ts +++ b/src/domain/data/workspaces.ts @@ -4,8 +4,8 @@ type WorkspaceObject = { [id: WorkspaceId]: WorkspaceProperties, }; export const workspaces: WorkspaceObject = { - chyronDriver: { - name: "Chyron Driver", + chyron: { + name: "Chyron", overlayIds: [ "chyron-driver-medium-full-ham.png", "chyron-driver-medium-full-alo.png", @@ -24,11 +24,21 @@ export const workspaces: WorkspaceObject = { ], previewWindowDimensions: { width: 750, - height: 300, + height: 400, }, }, - angledFlag: { - name: "Angled Flag", + chyronWide: { + name: "Chyron (Wide)", + overlayIds: [ + "chyron-driver-medium-full-sai-ric.png", + ], + previewWindowDimensions: { + width: 1200, + height: 150, + }, + }, + angledFlagCountry: { + name: "Angled Flag (Country)", overlayIds: [ "angled-flag-gbr.png", ], diff --git a/src/features/broadcast/director/broadcastDirectorSlice.ts b/src/features/broadcast/director/broadcastDirectorSlice.ts index 0406510..5bd72aa 100644 --- a/src/features/broadcast/director/broadcastDirectorSlice.ts +++ b/src/features/broadcast/director/broadcastDirectorSlice.ts @@ -32,7 +32,9 @@ export const broadcastDirectorSlice = createSlice({ }, /** * Shortcut to clear out selected cars. There is also a trick - if you - * @param action Car (optional) - if provided, it'll clear all and add this. + * provide a single Car it'll replace all selected cars with that single + * car. + * @param action Car (optional) */ selectedCarsClear: (state, action: PayloadAction>) => { if (action.payload == null) { diff --git a/src/features/broadcast/graphics/broadcastGraphicsSlice.ts b/src/features/broadcast/graphics/broadcastGraphicsSlice.ts index 0d8be0b..d5acc27 100644 --- a/src/features/broadcast/graphics/broadcastGraphicsSlice.ts +++ b/src/features/broadcast/graphics/broadcastGraphicsSlice.ts @@ -10,23 +10,23 @@ export const broadcastGraphicsSlice = createSlice({ name: "broadcastGraphics", initialState, reducers: { - chyronsLaunch: (state, action: PayloadAction) => { + chyronsSet: (state, action: PayloadAction) => { state.chyrons = action.payload; }, chyronsOpenStateSet: (state, action: PayloadAction) => { if (state.chyrons == null) return; - state.chyrons.primary.openState = action.payload; + state.chyrons.openState = action.payload; - if (state.chyrons.secondary != null) { - state.chyrons.secondary.openState = action.payload; + if (state.chyrons != null) { + state.chyrons.openState = action.payload; } }, chyronsOpenStateIncrement: (state) => { if (state.chyrons == null) return; - ++state.chyrons.primary.openState; + ++state.chyrons.openState; - if (state.chyrons.secondary != null) { - ++state.chyrons.secondary.openState; + if (state.chyrons != null) { + ++state.chyrons.openState; } }, chyronsClear: (state) => { @@ -36,7 +36,7 @@ export const broadcastGraphicsSlice = createSlice({ }); export const { - chyronsLaunch, + chyronsSet, chyronsOpenStateSet, chyronsOpenStateIncrement, chyronsClear, diff --git a/src/features/event/eventSlice.ts b/src/features/event/eventSlice.ts index 83114f0..108ded2 100644 --- a/src/features/event/eventSlice.ts +++ b/src/features/event/eventSlice.ts @@ -20,8 +20,8 @@ const initialState: RootState["event"] = { }, grid: [ { position: 1, driver: cloneDriver("verstappen") }, - { position: 3, driver: cloneDriver("hamilton") }, - { position: 2, driver: cloneDriver("bottas") }, + { position: 2, driver: cloneDriver("hamilton") }, + { position: 3, driver: cloneDriver("bottas") }, { position: 4, driver: cloneDriver("perez") }, { position: 5, driver: cloneDriver("sainz") }, { position: 6, driver: cloneDriver("norris") }, diff --git a/src/public/images/overlays/chyron-driver-medium-full-sai-ric.png b/src/public/images/overlays/chyron-driver-medium-full-sai-ric.png new file mode 100644 index 0000000..080c654 Binary files /dev/null and b/src/public/images/overlays/chyron-driver-medium-full-sai-ric.png differ diff --git a/src/types/state.d.ts b/src/types/state.d.ts index 4f083e1..157a83a 100644 --- a/src/types/state.d.ts +++ b/src/types/state.d.ts @@ -211,22 +211,21 @@ export interface BroadcastGraphics { // Chyrons export type BGChyronMode = string; export type BGChyronSubMode = string; -export interface BGChyron extends BGBaseState { +export interface BGChyrons extends BGBaseState { mode: BGChyronMode; -} -export interface BGChyrons { - primary: BGChyron; - secondary: Optional; + subMode: BGChyronSubMode; + driver?: { + primary: BGChyronDriver; + secondary: Optional; + } // sponsorGem: BGSponsorGem; } -export type FlagMode = "country" | "team" | "none"; export interface BGChyronDriver extends BGChyron { car: Car; - subMode: BGChyronSubMode; - baseDimensions: Dimensions; flagMode: FlagMode; showPosFlag: boolean; showDriverNumber: boolean; showPortrait: boolean; } +export type FlagMode = "country" | "team" | "none";