diff --git a/package.json b/package.json index 1e02dbe..15f2b71 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "lodash": "^4.17.21", "react": "^17.0.2", "react-dom": "^17.0.2", + "react-icons": "^4.3.1", "react-redux": "^7.2.6", "react-router-dom": "6", "react-scripts": "5.0.0", diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx new file mode 100644 index 0000000..7e1a02e --- /dev/null +++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx @@ -0,0 +1,158 @@ +import { InlineCluster } from "@bedrock-layout/inline-cluster"; +import { useEffect, useState } from "react"; +import { useDispatch, useSelector } from "react-redux"; +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. + const [chyronModes] = useState>(getChyronModesList()); + const [chyronSubModes, setChyronSubModes] = useState>([]); + + // Interface states. + const [chyronMode, setChyronMode] = useState("driver"); + const [chyronSubMode, setChyronSubMode] = useState("medium"); + const [posFlag, setPosFlag] = useState(true); + const [driverNum, setDriverNum] = useState(true); + 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 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 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 ( + + + + {subMode === "medium" && ( + + )} + setFlagMode(flagModeList[index])} + slotWidth="12ch" + /> + + ); + } else { + return null; + } + }; + + return ( + + + Chyrons + + setChyronMode(chyronModes[index])} + /> + setChyronSubMode(chyronSubModes[index])} + /> + + + + + + + + + + + + {modeControls(chyronMode, chyronSubMode)} + + ); +} diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/index.ts b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/index.ts new file mode 100644 index 0000000..e69fc02 --- /dev/null +++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/index.ts @@ -0,0 +1 @@ +export * from "./ChyronsDirectorControls"; diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/styles.ts b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/styles.ts new file mode 100644 index 0000000..869a386 --- /dev/null +++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/styles.ts @@ -0,0 +1,41 @@ +import styled from "styled-components"; + +export const Title = styled.h4` + font-family: ${p => p.theme.fonts.f1Italic}; +`; +Title.displayName = "Title"; + +type ButtonProps = { + disabled: boolean, +}; +export const Button = styled.button` + font-family: ${p => p.theme.fonts.f1Regular}; + color: ${({ disabled }) => disabled + ? p => p.theme.colors.grey : "black"}; + + background-color: ${p => p.theme.colors.lightGrey}; + border-radius: ${p => p.theme.design.button.borderRadius}; + 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"; + +export const OpenButton = styled(Button)` + background-color: ${({ disabled }) => disabled + ? p => p.theme.colors.disabledGreen : p => p.theme.colors.activeGreen}; +`; +OpenButton.displayName = "OpenButton"; + +export const CloseButton = styled(Button)` + background-color: ${({ disabled }) => disabled + ? p => p.theme.colors.disabledRed : p => p.theme.colors.activeRed}; +`; +CloseButton.displayName = "CloseButton"; 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 c0c223d..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} diff --git a/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx b/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx index 5c72800..b9f8c50 100644 --- a/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx +++ b/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx @@ -2,27 +2,42 @@ import { useEffect, useMemo, useState } from "react"; import { animated, useSpringRef, useTransition } from "@react-spring/web"; import { findPrefixCount } from "../../../../utils/strings"; -import { SlotText, SlotWindow } from "./styles"; +import { SelectorLabel, SlotText, SlotWindow } from "./styles"; +import { Inline } from "@bedrock-layout/inline"; type SlotSelectorProps = { items: Array, - onChange: (value: string) => void, + onChange: (index: number) => void, + label?: string, removePrefix?: boolean, formatter?: (value: string) => string, initialIndex?: number, + disabled?: boolean, + slotWidth?: string, }; +/** + * If items are defined in a component make sure they are stateful to prevent + * random resets of the index during changes. + */ export function SlotSelector({ items, onChange, + label, removePrefix = false, formatter = (x) => x, initialIndex = 0, + disabled = false, + slotWidth = "6ch", }: SlotSelectorProps) { const [index, setIndex] = useState(initialIndex); const [prefixMask, setPrefixMask] = useState(0); const [formattedItems, setFormattedItems] = useState>([]); - // useMemo makes these functions only run once when mounting. Not ever re-render. + useEffect(() => { + setIndex(initialIndex); + }, [items]); + + // useMemo makes these functions only run once when mounting. Not every re-render. useMemo(() => { const tempFormattedItems = items.map(item => formatter(item)); setFormattedItems(tempFormattedItems); @@ -30,25 +45,26 @@ export function SlotSelector({ }, [items]); const onClick = () => { + if (disabled) return; const nextIndex = (index + 1) % items.length; setIndex(nextIndex); - onChange(items[nextIndex]); + onChange(nextIndex); }; const getItem = (i: number) => formattedItems.length && removePrefix && formattedItems[0].length !== prefixMask ? - formattedItems[i].slice(prefixMask) : + formattedItems[i]?.slice(prefixMask) ?? undefined : formattedItems[i]; const transRef = useSpringRef(); const transitions = useTransition(index, { ref: transRef, keys: null, - from: { opacity: 0, transform: "translate3d(0, 100%, 0" }, - enter: { opacity: 1, transform: "translate3d(0, 0%, 0" }, - leave: { opacity: 0, transform: "translate3d(0, -100%, 0" }, + from: { opacity: 0, transform: "translate3d(0, 100%, 0)" }, + enter: { opacity: 1, transform: "translate3d(0, 0%, 0)" }, + leave: { opacity: 0, transform: "translate3d(0, -100%, 0)" }, }); useEffect(() => { @@ -56,10 +72,15 @@ export function SlotSelector({ }, [index]); return ( - - {transitions((style, i) => ( - {getItem(i)} - ))} - + + {(label ?? null) && ( + {label} + )} + + {transitions((style, i) => ( + {getItem(i)} + ))} + + ); } diff --git a/src/components/Common/Inputs/SlotSelector/styles.ts b/src/components/Common/Inputs/SlotSelector/styles.ts index 132395a..9a2f580 100644 --- a/src/components/Common/Inputs/SlotSelector/styles.ts +++ b/src/components/Common/Inputs/SlotSelector/styles.ts @@ -1,12 +1,18 @@ import styled from "styled-components"; -export const SlotWindow = styled.div` +type SlotWindowProps = { + disabled: boolean, + width?: string, +}; +export const SlotWindow = styled.div` position: relative; height: 1.5em; - width: auto; + width: ${({ width = "auto" }) => width}; + min-width: 6ch; border-radius: 0.6em; - background-color: white; + background-color: ${({ disabled }) => disabled + ? p => p.theme.colors.lightGrey : "white"}; box-shadow: inset 0 0 50px -50px ${p => p.theme.colors.darkGrey}; border: 1px solid ${p => p.theme.colors.darkGrey}; @@ -16,13 +22,21 @@ export const SlotWindow = styled.div` white-space: nowrap; text-overflow: ellipsis; `; +SlotWindow.displayName = "SlotWindow"; export const SlotText = styled.span` position: absolute; display: block; margin-left: .4em; font-family: ${p => p.theme.fonts.f1Regular}; - font-size: 0.9em; + font-size: ${p => p.theme.fontSizes.selector}; color: ${p => p.theme.colors.darkGrey}; user-select: none; `; +SlotText.displayName = "SlotText"; + +export const SelectorLabel = styled.span` + font-family: ${p => p.theme.fonts.f1Regular}; + font-size: ${p => p.theme.fontSizes.label}; +`; +SelectorLabel.displayName = "SelectorLabel"; diff --git a/src/components/Common/Inputs/Toggle/styles.ts b/src/components/Common/Inputs/Toggle/styles.ts index e51a11b..5be4f32 100644 --- a/src/components/Common/Inputs/Toggle/styles.ts +++ b/src/components/Common/Inputs/Toggle/styles.ts @@ -5,7 +5,7 @@ type ToggleContainerProps = { } export const ToggleContainer = styled.div` display: flex; - justify-content: center; + align-items: flex-end; font-size: ${({ fontSize = "inherit" }) => fontSize}; `; ToggleContainer.displayName = "ToggleContainer"; @@ -24,7 +24,10 @@ ToggleInput.displayName = "ToggleInput"; export const ToggleLabelText = styled.span` margin-right: 1ch; + font-family: ${p => p.theme.fonts.f1Regular}; + font-size: ${p => p.theme.fontSizes.label}; `; +ToggleLabelText.displayName = "ToggleLabelText"; export const ToggleLabel = styled.label` display: block; @@ -95,4 +98,3 @@ export const ToggleCircle = styled.div` ${({ toggled }) => toggled ? css`right: 0;` : css`left: 0;`} `; ToggleCircle.displayName = "ToggleCircle"; - diff --git a/src/components/Common/MenuItem.styled.ts b/src/components/Common/MenuItem.styled.ts index cc7bad7..2ed6020 100644 --- a/src/components/Common/MenuItem.styled.ts +++ b/src/components/Common/MenuItem.styled.ts @@ -12,7 +12,7 @@ type MenuItemProps = { }; export const MenuItem = styled(PadBox).attrs(() => ({ padding: ["sm", "lg"], -})) ` +}))` border-radius: ${p => p.theme.design.button.borderRadius}; color: ${p => p.theme.colors.darkGrey}; font-family: ${p => p.theme.fonts.f1Regular}; diff --git a/src/components/OverlayTool/OverlayControl/OverlayControl.tsx b/src/components/OverlayTool/OverlayControl/OverlayControl.tsx index 261dd2d..b6b8c09 100644 --- a/src/components/OverlayTool/OverlayControl/OverlayControl.tsx +++ b/src/components/OverlayTool/OverlayControl/OverlayControl.tsx @@ -46,9 +46,10 @@ export function OverlayControl() { /> dispatch(setCurrentOverlayId(value))} + onChange={(index) => dispatch(setCurrentOverlayId(overlayIds[index]))} removePrefix formatter={(value) => value.replace(/(\.png)|(\.jpg)$/, "")} + disabled={!visible} /> diff --git a/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx new file mode 100644 index 0000000..38c3cd6 --- /dev/null +++ b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/AngledFlagPrototypeControls.tsx @@ -0,0 +1,33 @@ +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 { setPrototypeState } from "../../../../features/workspace/workspaceSlice"; + +import { SlotSelector } from "../../../Common/Inputs/SlotSelector"; + +const countries = [ + "GBR", "NLD", "FIN", "JPN", "FRA", "DEU", "MEX", "POL", "MCO", "CHN", "THA", + "CAN", "RUS", "RAF", "AUS", "ESP", "ITA", +]; + +export function AngledFlagPrototypeControls() { + const dispatch = useDispatch(); + const { prototypeState } = useSelector(workspaceSelector); + + const onChange = (flag: "flagA" | "flagB") => (index: number) => { + dispatch(setPrototypeState({ + angledFlag: { + flagA: flag === "flagA" ? countries[index] : prototypeState?.angledFlag?.flagA ?? "GBR", + flagB: flag === "flagB" ? countries[index] : prototypeState?.angledFlag?.flagB ?? "GBR", + }, + })); + }; + return ( + + + + + ); +} diff --git a/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/index.ts b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/index.ts new file mode 100644 index 0000000..87fc05a --- /dev/null +++ b/src/components/Workspaces/PrototypingControls/AngledFlagPrototype/index.ts @@ -0,0 +1 @@ +export * from "./AngledFlagPrototypeControls"; diff --git a/src/components/Workspaces/PrototypingControls/ChyronPrototype/ChyronPrototypeControls.tsx b/src/components/Workspaces/PrototypingControls/ChyronPrototype/ChyronPrototypeControls.tsx new file mode 100644 index 0000000..44945cc --- /dev/null +++ b/src/components/Workspaces/PrototypingControls/ChyronPrototype/ChyronPrototypeControls.tsx @@ -0,0 +1,21 @@ +import { PadBox } from "@bedrock-layout/padbox"; +import { Split } from "@bedrock-layout/split"; +import { ChyronsDirectorControls } from "../../../Broadcast/BroadcastDirectorUI/Chyrons"; + +import { GridSelection } from "../GridSelection"; +import { ChyronControlsContainer } from "./styles"; + +export function ChyronPrototypeControls() { + return ( + + + + + + + + + + + ); +} diff --git a/src/components/Workspaces/PrototypingControls/ChyronPrototype/index.ts b/src/components/Workspaces/PrototypingControls/ChyronPrototype/index.ts new file mode 100644 index 0000000..e5e3b7d --- /dev/null +++ b/src/components/Workspaces/PrototypingControls/ChyronPrototype/index.ts @@ -0,0 +1 @@ +export * from "./ChyronPrototypeControls"; diff --git a/src/components/Workspaces/PrototypingControls/ChyronPrototype/styles.ts b/src/components/Workspaces/PrototypingControls/ChyronPrototype/styles.ts new file mode 100644 index 0000000..6f0499e --- /dev/null +++ b/src/components/Workspaces/PrototypingControls/ChyronPrototype/styles.ts @@ -0,0 +1,7 @@ +import styled from "styled-components"; + +export const ChyronControlsContainer = styled.div` + width: 420px; + height: auto; +`; +ChyronControlsContainer.displayName = "ChyronControlsContainer"; diff --git a/src/components/Workspaces/PrototypingControls/GridSelection/GridSelection.tsx b/src/components/Workspaces/PrototypingControls/GridSelection/GridSelection.tsx new file mode 100644 index 0000000..9f6b7a7 --- /dev/null +++ b/src/components/Workspaces/PrototypingControls/GridSelection/GridSelection.tsx @@ -0,0 +1,58 @@ +import { InlineCluster } from "@bedrock-layout/inline-cluster"; +import { findIndex } from "lodash"; +import { useDispatch, useSelector } from "react-redux"; + +import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector"; +import { selectedCarsAdd, selectedCarsClear, selectedCarsRemove } from "../../../../features/broadcast/director/broadcastDirectorSlice"; +import { eventSelector } from "../../../../features/event/eventSelector"; +import { Car } from "../../../../types/state"; +import { carMatch } from "../../../../utils/comparators"; + +import { DriverLabel, GridItem, SelectionLabel } from "./styles"; + +export function GridSelection() { + const dispatch = useDispatch(); + const { + grid, + } = useSelector(eventSelector); + const { + selectedCars, + } = useSelector(broadcastDirectorSelector); + + const carClick = (car: Car, selected: boolean) => () => { + if (selected) { + dispatch(selectedCarsRemove(car)); + } else { + dispatch(selectedCarsAdd(car)); + } + }; + const carDoubleClick = (car: Car) => () => { + dispatch(selectedCarsClear(car)); + }; + + return ( + + {grid.map(car => { + const selectedIndex = findIndex(selectedCars, carMatch(car)); + const selected = selectedIndex !== -1; + const onClick = carClick(car, selected); + const onDoubleClick = carDoubleClick(car); + return ( + + + {car.driver.initials} + + {selected && ( + {selectedIndex + 1} + )} + + ); + })} + + ); +} diff --git a/src/components/Workspaces/PrototypingControls/GridSelection/index.ts b/src/components/Workspaces/PrototypingControls/GridSelection/index.ts new file mode 100644 index 0000000..86a2232 --- /dev/null +++ b/src/components/Workspaces/PrototypingControls/GridSelection/index.ts @@ -0,0 +1 @@ +export * from "./GridSelection"; diff --git a/src/components/Workspaces/PrototypingControls/GridSelection/styles.ts b/src/components/Workspaces/PrototypingControls/GridSelection/styles.ts new file mode 100644 index 0000000..88f8bb6 --- /dev/null +++ b/src/components/Workspaces/PrototypingControls/GridSelection/styles.ts @@ -0,0 +1,42 @@ +import { PadBox } from "@bedrock-layout/padbox"; +import styled from "styled-components"; + +type GridItemProps = { + selected: boolean, +}; +export const GridItem = styled(PadBox).attrs(() => ({ + padding: ["md", "xs"], +}))` + position: relative; + width: 4.5ch; + border-radius: 0.2em; + + font-family: ${p => p.theme.fonts.f1Regular}; + font-size: 0.8em; + text-align: center; + user-select: none; + + background-color: ${({ selected }) => selected + ? p => p.theme.colors.grey + : p => p.theme.colors.faintGrey}; + + &:hover { + background-color: ${({ selected }) => selected ? p => p.theme.colors.darkGrey : p => p.theme.colors.grey}; + > span { + color: ${p => p.theme.colors.faintGrey}; + } + } + + cursor: pointer; +`; + +export const DriverLabel = styled.span` + text-transform: uppercase; +`; + +export const SelectionLabel = styled.span` + position: absolute; + bottom: 0; + right: 5%; + font-size: 0.3em; +`; diff --git a/src/components/Workspaces/Workspace/Workspace.tsx b/src/components/Workspaces/Workspace/Workspace.tsx index 6f903ef..e4ce926 100644 --- a/src/components/Workspaces/Workspace/Workspace.tsx +++ b/src/components/Workspaces/Workspace/Workspace.tsx @@ -1,5 +1,4 @@ -import { useEffect } from "react"; -import { useParams } from "react-router-dom"; +import { ReactNode, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { Center } from "@bedrock-layout/center"; import { Stack } from "@bedrock-layout/stack"; @@ -10,20 +9,27 @@ import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSe import { newWorkspace } from "../../../features/overlayTool/overlayToolSlice"; import { PreviewWindow, H2, ControlsContainer } from "./styles"; -import { WorkspaceControls } from "./WorkspaceControls/WorkspaceControls"; +import { WorkspaceControls } from "../WorkspaceControls"; import { OverlayDisplay } from "../../OverlayTool"; -import { fetchBroadcastGraphic, workspaces } from "../../../domain/data/workspaces"; +import { workspaces } from "../../../domain/data/workspaces"; +import { WorkspaceId } from "../../../types/state"; -export const Workspace = () => { +type WorkspaceProps = { + workspaceId: WorkspaceId, + previewContent: ReactNode, + prototypeControls: ReactNode, +}; +export const Workspace = ({ + workspaceId, + previewContent, + prototypeControls, +}: WorkspaceProps) => { const dispatch = useDispatch(); - const { workspaceId } = useParams(); const { animatedBG, workspaceProperties } = useSelector(workspaceSelector); const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector); useEffect(() => { - if (workspaceId == null) return; - // Update workspace store for ID. dispatch(updateWorkspace({ workspaceId, @@ -39,8 +45,6 @@ export const Workspace = () => { } }, [workspaceId]); - if (workspaceId == null) return null; - return ( { dimensions={workspaceProperties.previewWindowDimensions} animatedBG={animatedBG} > - {fetchBroadcastGraphic(workspaceId)} + {previewContent} + {prototypeControls} ); 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/Workspace/WorkspaceControls/WorkspaceControls.tsx b/src/components/Workspaces/WorkspaceControls/WorkspaceControls.tsx similarity index 68% rename from src/components/Workspaces/Workspace/WorkspaceControls/WorkspaceControls.tsx rename to src/components/Workspaces/WorkspaceControls/WorkspaceControls.tsx index ea90e0a..406d9be 100644 --- a/src/components/Workspaces/Workspace/WorkspaceControls/WorkspaceControls.tsx +++ b/src/components/Workspaces/WorkspaceControls/WorkspaceControls.tsx @@ -2,11 +2,11 @@ import { Grid } from "@bedrock-layout/grid"; import { PadBox } from "@bedrock-layout/padbox"; import { useDispatch, useSelector } from "react-redux"; -import { workspaceSelector } from "../../../../features/workspace/workspaceSelector"; -import { setAnimatedBG } from "../../../../features/workspace/workspaceSlice"; +import { workspaceSelector } from "../../../features/workspace/workspaceSelector"; +import { setAnimatedBG } from "../../../features/workspace/workspaceSlice"; -import { Toggle } from "../../../Common/Inputs/Toggle"; -import { OverlayControl } from "../../../OverlayTool"; +import { Toggle } from "../../Common/Inputs/Toggle"; +import { OverlayControl } from "../../OverlayTool"; export const WorkspaceControls = () => { const dispatch = useDispatch(); diff --git a/src/components/Workspaces/WorkspaceControls/index.ts b/src/components/Workspaces/WorkspaceControls/index.ts new file mode 100644 index 0000000..53db3ad --- /dev/null +++ b/src/components/Workspaces/WorkspaceControls/index.ts @@ -0,0 +1 @@ +export * from "./WorkspaceControls"; diff --git a/src/components/Workspaces/WorkspacesRoute.tsx b/src/components/Workspaces/WorkspacesRoute.tsx index dcf3bf5..8660810 100644 --- a/src/components/Workspaces/WorkspacesRoute.tsx +++ b/src/components/Workspaces/WorkspacesRoute.tsx @@ -1,6 +1,6 @@ import { useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { Outlet } from "react-router-dom"; +import { Route, Routes } from "react-router-dom"; import useMeasure from "react-use-measure"; import { mainMenuDimensionsSelector } from "../../features/pageDimensions/pageDimensionsSelector"; @@ -10,6 +10,12 @@ import { FullScreenContainer } from "../Common/FullScreenContainer.styled"; import { WorkspaceList } from "./WorkspaceList"; import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled"; +import { Workspace } from "./Workspace"; +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; export default function Workspaces() { @@ -41,7 +47,31 @@ export default function Workspaces() { heightCutoff={mainMenuHeight} widthCutoff={WORKSPACE_LIST_WIDTH} > - + + Workspaces Home} /> + } + prototypeControls={} + /> + } /> + } + prototypeControls={} + /> + } /> + } + prototypeControls={} + /> + } /> + Unknown Workspace} /> + diff --git a/src/domain/data/broadcastGraphics.ts b/src/domain/data/broadcastGraphics.ts new file mode 100644 index 0000000..05940ce --- /dev/null +++ b/src/domain/data/broadcastGraphics.ts @@ -0,0 +1,42 @@ +import { keys } from "lodash"; +import { BGChyronSubMode, BGChyronMode, BGRelativePos, FlagMode } from "../../types/state"; + +// Chyrons Section +const chyronsData: { + [mode: BGChyronMode]: { + relativePos: BGRelativePos, + subModes: { + [subMode: BGChyronSubMode]: Record, + }, + }, +} = { + driver: { + relativePos: { top: "0", right: "0", bottom: "0", left: "0" }, + subModes: { + medium: { width: 582, height: 72 }, + large: { width: 638, height: 98 }, + }, + }, +}; + +export const flagModeList: Array = ["country", "team", "none"]; + +export function getChyronModesList(): Array { + return keys(chyronsData); +} + +export function getChyronRelativePos(mode: BGChyronMode): BGRelativePos { + return chyronsData[mode]?.relativePos + ?? { top: "0", right: "0", bottom: "0", left: "0" }; +} + +export function getChyronSubModesList(mode: BGChyronMode): Array { + return keys(chyronsData[mode]?.subModes ?? {}); +} + +export function getChyronSubModeProps( + mode: BGChyronMode, + subMode: BGChyronSubMode, +): Record { + return chyronsData[mode]?.subModes[subMode] ?? {}; +} diff --git a/src/domain/data/workspaces.ts b/src/domain/data/workspaces.ts index 1c4db41..a1132f9 100644 --- a/src/domain/data/workspaces.ts +++ b/src/domain/data/workspaces.ts @@ -1,16 +1,11 @@ -import { ReactNode } from "react"; import { WorkspaceId, WorkspaceProperties } from "../../types/state"; -// Broadcast Graphics -import { ChyronDriver } from "../../components/BroadcastGraphics/Chyrons/Driver"; -import { AngledFlagWorkSpace } from "../../components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace"; - 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", @@ -29,11 +24,21 @@ export const workspaces: WorkspaceObject = { ], previewWindowDimensions: { width: 750, - height: 200, + 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", ], @@ -43,12 +48,3 @@ export const workspaces: WorkspaceObject = { }, }, }; - -export function fetchBroadcastGraphic(workspaceId: WorkspaceId): ReactNode { - switch(workspaceId) { - case "chyronDriver": return ChyronDriver(); - case "angledFlag": return AngledFlagWorkSpace(); - default: return null; - } -} - diff --git a/src/features/broadcast/director/broadcastDirectorSelector.ts b/src/features/broadcast/director/broadcastDirectorSelector.ts new file mode 100644 index 0000000..2709bf7 --- /dev/null +++ b/src/features/broadcast/director/broadcastDirectorSelector.ts @@ -0,0 +1,3 @@ +import { RootState } from "../../../types/state"; + +export const broadcastDirectorSelector = (state: RootState) => state.broadcastDirector; diff --git a/src/features/broadcast/director/broadcastDirectorSlice.ts b/src/features/broadcast/director/broadcastDirectorSlice.ts new file mode 100644 index 0000000..5bd72aa --- /dev/null +++ b/src/features/broadcast/director/broadcastDirectorSlice.ts @@ -0,0 +1,55 @@ +import { createSlice, PayloadAction } from "@reduxjs/toolkit"; +import { findIndex } from "lodash"; + +import { RootState, Car } from "../../../types/state"; +import { Optional } from "../../../types/util"; +import { carMatch } from "../../../utils/comparators"; + +const initialState: RootState["broadcastDirector"] = { + selectedCars: [], +}; + +export const broadcastDirectorSlice = createSlice({ + name: "broadcastDirector", + initialState, + reducers: { + selectedCarsAdd: (state, action: PayloadAction) => { + const index = findIndex(state.selectedCars, carMatch(action.payload)); + if (index === -1) { + state.selectedCars = state.selectedCars.concat(action.payload); + } + }, + selectedCarsSet: (state, action: PayloadAction) => { // Might be removed. + state.selectedCars = [action.payload]; + }, + selectedCarsRemove: (state, action: PayloadAction) => { + const index = typeof action.payload === "number" + ? action.payload + : findIndex(state.selectedCars, carMatch(action.payload)); + state.selectedCars = state.selectedCars.slice(0, index).concat( + state.selectedCars.slice(index + 1), + ); + }, + /** + * Shortcut to clear out selected cars. There is also a trick - if you + * 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) { + state.selectedCars = []; + } else { + state.selectedCars = [action.payload]; + } + }, + }, +}); + +export const { + selectedCarsAdd, + selectedCarsSet, + selectedCarsRemove, + selectedCarsClear, +} = broadcastDirectorSlice.actions; +export default broadcastDirectorSlice.reducer; diff --git a/src/features/broadcast/graphics/broadcastGraphicsSelector.ts b/src/features/broadcast/graphics/broadcastGraphicsSelector.ts new file mode 100644 index 0000000..fce0697 --- /dev/null +++ b/src/features/broadcast/graphics/broadcastGraphicsSelector.ts @@ -0,0 +1,3 @@ +import { RootState } from "../../../types/state"; + +export const broadcastGraphicsSelector = (state: RootState) => state.broadcastGraphics; diff --git a/src/features/broadcast/graphics/broadcastGraphicsSlice.ts b/src/features/broadcast/graphics/broadcastGraphicsSlice.ts new file mode 100644 index 0000000..d5acc27 --- /dev/null +++ b/src/features/broadcast/graphics/broadcastGraphicsSlice.ts @@ -0,0 +1,44 @@ +import { createSlice, PayloadAction } from "@reduxjs/toolkit"; + +import { BGChyrons, OpenState, RootState } from "../../../types/state"; + +const initialState: RootState["broadcastGraphics"] = { + chyrons: null, +}; + +export const broadcastGraphicsSlice = createSlice({ + name: "broadcastGraphics", + initialState, + reducers: { + chyronsSet: (state, action: PayloadAction) => { + state.chyrons = action.payload; + }, + chyronsOpenStateSet: (state, action: PayloadAction) => { + if (state.chyrons == null) return; + state.chyrons.openState = action.payload; + + if (state.chyrons != null) { + state.chyrons.openState = action.payload; + } + }, + chyronsOpenStateIncrement: (state) => { + if (state.chyrons == null) return; + ++state.chyrons.openState; + + if (state.chyrons != null) { + ++state.chyrons.openState; + } + }, + chyronsClear: (state) => { + state.chyrons = null; + }, + }, +}); + +export const { + chyronsSet, + chyronsOpenStateSet, + chyronsOpenStateIncrement, + chyronsClear, +} = broadcastGraphicsSlice.actions; +export default broadcastGraphicsSlice.reducer; diff --git a/src/features/event/eventSelector.ts b/src/features/event/eventSelector.ts new file mode 100644 index 0000000..9ce42d5 --- /dev/null +++ b/src/features/event/eventSelector.ts @@ -0,0 +1,3 @@ +import { RootState } from "../../types/state"; + +export const eventSelector = (state: RootState) => state.event; diff --git a/src/features/event/eventSlice.ts b/src/features/event/eventSlice.ts new file mode 100644 index 0000000..108ded2 --- /dev/null +++ b/src/features/event/eventSlice.ts @@ -0,0 +1,58 @@ +import { createSlice, PayloadAction } from "@reduxjs/toolkit"; + +import { CourseFlag, RootState } from "../../types/state"; +import { cloneDriver } from "../../utils/dataLookup"; + +const initialState: RootState["event"] = { + trackName: "Melbourne", + courseStatus: { + courseFlag: "green", + sectorFlags: ["green", "green", "green"], + safetyCar: "clear", + virtualSafetyCar: "clear", + }, + mode: "race", + progress: { + startTime: Date.now(), + timeLimit: 60 * 60 * 2 * 1000, + currentLap: 1, + lapCount: 10, + }, + grid: [ + { position: 1, driver: cloneDriver("verstappen") }, + { 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") }, + { position: 7, driver: cloneDriver("leclerc") }, + { position: 8, driver: cloneDriver("ricciardo") }, + { position: 9, driver: cloneDriver("gasly") }, + { position: 10, driver: cloneDriver("alonso") }, + { position: 11, driver: cloneDriver("ocon") }, + { position: 12, driver: cloneDriver("vettel") }, + { position: 13, driver: cloneDriver("stroll") }, + { position: 14, driver: cloneDriver("tsunoda") }, + { position: 15, driver: cloneDriver("russell") }, + { position: 16, driver: cloneDriver("raikkonen") }, + { position: 17, driver: cloneDriver("latifi") }, + { position: 18, driver: cloneDriver("giovinazzi") }, + { position: 19, driver: cloneDriver("schumacher") }, + { position: 20, driver: cloneDriver("mazepin") }, + ], +}; + +export const eventSlice = createSlice({ + name: "event", + initialState, + reducers: { + courseFlagSet: (state, action: PayloadAction) => { + state.courseStatus.courseFlag = action.payload; + }, + }, +}); + +export const { + courseFlagSet, +} = eventSlice.actions; +export default eventSlice.reducer; diff --git a/src/features/workspace/workspaceSlice.ts b/src/features/workspace/workspaceSlice.ts index 9913f80..417a956 100644 --- a/src/features/workspace/workspaceSlice.ts +++ b/src/features/workspace/workspaceSlice.ts @@ -1,5 +1,5 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; -import { RootState, WorkspaceId, WorkspaceProperties } from "../../types/state"; +import { PrototypeState, RootState, WorkspaceId, WorkspaceProperties } from "../../types/state"; const initialState: RootState["workspace"] = { workspaceId: "", @@ -9,6 +9,7 @@ const initialState: RootState["workspace"] = { overlayIds: [], previewWindowDimensions: { width: 0, height: 0 }, }, + prototypeState: null, }; export type UpdateWorkspaceAction = { @@ -30,6 +31,9 @@ export const workspaceSlice = createSlice({ state.workspaceId = action.payload.workspaceId; state.workspaceProperties = action.payload.workspaceProperties; }, + setPrototypeState: (state, action: PayloadAction) => { + state.prototypeState = action.payload; + }, }, }); @@ -37,5 +41,6 @@ export const { setWorkspaceId, setAnimatedBG, updateWorkspace, + setPrototypeState, } = workspaceSlice.actions; export default workspaceSlice.reducer; diff --git a/src/index.tsx b/src/index.tsx index 735b07f..f6042fe 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -26,10 +26,7 @@ ReactDOM.render( }> Home} /> } /> - }> - Workspaces Home} /> - } /> - + } /> Page Not Found} /> diff --git a/src/public/images/countryFlags/AUS.svg b/src/public/images/countryFlags/AUS.svg deleted file mode 100644 index 3d1060d..0000000 --- a/src/public/images/countryFlags/AUS.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/public/images/countryFlags/CAN.svg b/src/public/images/countryFlags/CAN.svg deleted file mode 100644 index 472c431..0000000 --- a/src/public/images/countryFlags/CAN.svg +++ /dev/null @@ -1,5 +0,0 @@ - - Flag of Canada (Pantone colours) - - - diff --git a/src/public/images/countryFlags/CHN.svg b/src/public/images/countryFlags/CHN.svg deleted file mode 100644 index 61f4fdc..0000000 --- a/src/public/images/countryFlags/CHN.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/public/images/countryFlags/DEU.svg b/src/public/images/countryFlags/DEU.svg deleted file mode 100644 index 4a5a153..0000000 --- a/src/public/images/countryFlags/DEU.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/public/images/countryFlags/ESP.svg b/src/public/images/countryFlags/ESP.svg deleted file mode 100644 index 8fda47a..0000000 --- a/src/public/images/countryFlags/ESP.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/images/countryFlags/FIN.svg b/src/public/images/countryFlags/FIN.svg deleted file mode 100644 index e7f293b..0000000 --- a/src/public/images/countryFlags/FIN.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/public/images/countryFlags/FRA.svg b/src/public/images/countryFlags/FRA.svg deleted file mode 100644 index 3165e37..0000000 --- a/src/public/images/countryFlags/FRA.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/public/images/countryFlags/GBR.svg b/src/public/images/countryFlags/GBR.svg deleted file mode 100644 index 37f96ce..0000000 --- a/src/public/images/countryFlags/GBR.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/public/images/countryFlags/ITA.svg b/src/public/images/countryFlags/ITA.svg deleted file mode 100644 index 9ee6003..0000000 --- a/src/public/images/countryFlags/ITA.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/public/images/countryFlags/JPN.svg b/src/public/images/countryFlags/JPN.svg deleted file mode 100644 index 8f45475..0000000 --- a/src/public/images/countryFlags/JPN.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/public/images/countryFlags/MCO.svg b/src/public/images/countryFlags/MCO.svg deleted file mode 100644 index 797f9f2..0000000 --- a/src/public/images/countryFlags/MCO.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/images/countryFlags/MEX.svg b/src/public/images/countryFlags/MEX.svg deleted file mode 100644 index 7a80b6f..0000000 --- a/src/public/images/countryFlags/MEX.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/public/images/countryFlags/NLD.svg b/src/public/images/countryFlags/NLD.svg deleted file mode 100644 index f19bd00..0000000 --- a/src/public/images/countryFlags/NLD.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/public/images/countryFlags/POL.svg b/src/public/images/countryFlags/POL.svg deleted file mode 100644 index b08d025..0000000 --- a/src/public/images/countryFlags/POL.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/public/images/countryFlags/RAF.svg b/src/public/images/countryFlags/RAF.svg deleted file mode 100644 index 9c187b0..0000000 --- a/src/public/images/countryFlags/RAF.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/public/images/countryFlags/RUS.svg b/src/public/images/countryFlags/RUS.svg deleted file mode 100644 index 387307f..0000000 --- a/src/public/images/countryFlags/RUS.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/public/images/countryFlags/THA.svg b/src/public/images/countryFlags/THA.svg deleted file mode 100644 index 2a9fa1c..0000000 --- a/src/public/images/countryFlags/THA.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/public/images/countryFlags/angled/ESP.svg b/src/public/images/countryFlags/angled/ESP.svg index 0105dfe..82b7058 100644 --- a/src/public/images/countryFlags/angled/ESP.svg +++ b/src/public/images/countryFlags/angled/ESP.svg @@ -1,505 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/public/images/countryFlags/angled/MEX.svg b/src/public/images/countryFlags/angled/MEX.svg index 4aead72..4c9b6fe 100644 --- a/src/public/images/countryFlags/angled/MEX.svg +++ b/src/public/images/countryFlags/angled/MEX.svg @@ -1,390 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file 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/shared/theme.ts b/src/shared/theme.ts index 755e588..019b999 100644 --- a/src/shared/theme.ts +++ b/src/shared/theme.ts @@ -15,6 +15,9 @@ export const theme = { blue: "#387af5", pink: "#eb57a3", activeGreen: "#65c466", + disabledGreen: "#b1d3b2", + activeRed: "#e63746", + disabledRed: "#e08a91", grey: "#aaa", lightGrey: "#ddd", faintGrey: "#eee", @@ -33,6 +36,10 @@ export const theme = { williams: "#005aff", }, }, + fontSizes: { + label: "0.9em", + selector: "0.9em", + }, design: { button: { borderRadius: "0.25rem", diff --git a/src/store.ts b/src/store.ts index 5cc2731..82c1c83 100644 --- a/src/store.ts +++ b/src/store.ts @@ -3,11 +3,17 @@ import { configureStore, combineReducers } from "@reduxjs/toolkit"; import pageDimensions from "./features/pageDimensions/pageDimensionsSlice"; import workspace from "./features/workspace/workspaceSlice"; import overlayTool from "./features/overlayTool/overlayToolSlice"; +import event from "./features/event/eventSlice"; +import broadcastDirector from "./features/broadcast/director/broadcastDirectorSlice"; +import broadcastGraphics from "./features/broadcast/graphics/broadcastGraphicsSlice"; export const store = configureStore({ reducer: combineReducers({ pageDimensions, workspace, overlayTool, + event, + broadcastDirector, + broadcastGraphics, }), }); diff --git a/src/types/state.d.ts b/src/types/state.d.ts index 0b6e997..157a83a 100644 --- a/src/types/state.d.ts +++ b/src/types/state.d.ts @@ -1,7 +1,12 @@ +import { Milliseconds, Optional } from "./util"; + export interface RootState { pageDimensions: PageDimensions; workspace: Workspace; overlayTool: OverlayTool; + event: Event, + broadcastDirector: BroadcastDirector; + broadcastGraphics: BroadcastGraphics; } // Page Dimensions @@ -17,6 +22,7 @@ export interface Workspace { workspaceId: WorkspaceId; animatedBG: boolean; workspaceProperties: WorkspaceProperties; + prototypeState: Optional; } export type WorkspaceId = string; @@ -25,6 +31,12 @@ export interface WorkspaceProperties { overlayIds: OverlayIds; previewWindowDimensions: Dimensions; } +export interface PrototypeState { + angledFlag?: { + flagA: string; + flagB: string; + }; +} // Overlay Tool export interface OverlayTool { @@ -42,14 +54,54 @@ export interface OverlayItem { opacity: number; } -// Race State. +// Event State +export interface Event { + trackName: string; + courseStatus: CourseStatus; + mode: EventMode; + progress: EventProgress; + grid: Grid; +} +export interface EventProgress { + startTime: Milliseconds; + timeLimit: Milliseconds; + currentLap: number; + lapCount: number; +} +export type EventMode = + | "race" + | "sprint" + | "p1" + | "p2" + | "p3" + | "q1" + | "q2" + | "q3"; +export interface CourseStatus { + courseFlag: CourseFlags; + sectorFlags: Array; + safetyCar: SafetyCarStatus; + virtualSafetyCar: VirtualSafetyCarStatus; +} +export type CourseFlag = + | "green" + | "yellow" + | "doubleYellow" + | "chequered" + | "red" + | "white" + | "redYellow"; +export type SafetyCarStatus = "clear" | "starting" | "out" | "ending"; +export type VirtualSafetyCarStatus = "clear" | "out" | "ending"; +export type Grid = Array; // Grid order does not change. export interface Car { position: number; driver: Driver; - // status: ???; + // status: ???; // retired + // flags: ???, // blue, red, meatball, black/white, black + // notices: ???; // Penalties, warnings, investigations, blue flags, etc // distance: number; } -export type Grid = Array; export interface Driver { id: DriverId; firstName: string; @@ -126,6 +178,11 @@ export type TeamFullName = | "Red Bull Racing" | "Williams Racing"; +// Broadcast Director +export interface BroadcastDirector { + selectedCars: Array; +} + // Broadcast Graphics export interface BGRelativePos { top?: string; @@ -133,34 +190,42 @@ export interface BGRelativePos { bottom?: string; left?: string; } +export interface BGBaseState { + relativePos: BGRelativePos; + openState: OpenState; +} +/** + * -1 closing, 0 closed, 1 open, 2... different states (for progressive anims) + */ +export type OpenState = number; + export interface BroadcastGraphics { // timingBoard: BGTimingBoard; // statusIndicator: BGStatusIndicator; // indicators: BGIndicators - chyrons: BGChyrons; + chyrons: Optional; // gems: BGGems // toasts: BGToasts; } -export interface BGChyrons { - primary: BGChyron; - secondary: BGChyron; +// Chyrons +export type BGChyronMode = string; +export type BGChyronSubMode = string; +export interface BGChyrons extends BGBaseState { + mode: BGChyronMode; + subMode: BGChyronSubMode; + driver?: { + primary: BGChyronDriver; + secondary: Optional; + } // sponsorGem: BGSponsorGem; } -export type FlagMode = "country" | "team"; -export type BGChyronMode = - | "driver-basic-small" - | "driver-basic-medium" - | "driver-basic-large"; -export interface BGChyron extends BGRelativePos { - mode: BGChyronMode; - cars: Array; -} -export interface BGChyronMedium extends BGChyron { - mode: "driver-basic-medium"; - flag: FlagMode; +export interface BGChyronDriver extends BGChyron { + car: Car; + flagMode: FlagMode; showPosFlag: boolean; showDriverNumber: boolean; + showPortrait: boolean; } - +export type FlagMode = "country" | "team" | "none"; diff --git a/src/types/util.d.ts b/src/types/util.d.ts new file mode 100644 index 0000000..86126fb --- /dev/null +++ b/src/types/util.d.ts @@ -0,0 +1,3 @@ +export type Optional = TEntity | null; +export type Milliseconds = number; +export type Seconds = number; diff --git a/src/utils/comparators.ts b/src/utils/comparators.ts new file mode 100644 index 0000000..29d5265 --- /dev/null +++ b/src/utils/comparators.ts @@ -0,0 +1,4 @@ +import { Car } from "../types/state"; + +export const carMatch = (targetCar: Car) => (checkedCar: Car) => + checkedCar.driver.id === targetCar.driver.id; diff --git a/src/utils/dataLookup.ts b/src/utils/dataLookup.ts index 6731b3c..dc48757 100644 --- a/src/utils/dataLookup.ts +++ b/src/utils/dataLookup.ts @@ -1,3 +1,4 @@ +import { cloneDeep } from "lodash"; import { drivers, teams, teamNumberStyles, NumberStyle } from "../domain/data/teams"; import { Driver, DriverId, Team, TeamId } from "../types/state"; @@ -11,10 +12,16 @@ import { Driver, DriverId, Team, TeamId } from "../types/state"; export function getDriver(driverId: DriverId): Driver { return drivers[driverId]; } +export function cloneDriver(driverId: DriverId): Driver { + return cloneDeep(drivers[driverId]); +} export function getTeam(teamId: TeamId): Team { return teams[teamId]; } +export function cloneTeam(teamId: TeamId): Team { + return cloneDeep(teams[teamId]); +} export function getTeamNumberStyle(teamId: TeamId): NumberStyle { return teamNumberStyles[teamId]; diff --git a/yarn.lock b/yarn.lock index b665779..b3da133 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7726,6 +7726,11 @@ react-error-overlay@^6.0.10: resolved "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.10.tgz" integrity sha512-mKR90fX7Pm5seCOfz8q9F+66VCc1PGsWSBxKbITjfKVQHMNF2zudxHnMdJiB1fRCb+XsbQV9sO9DCkgsMQgBIA== +react-icons@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.3.1.tgz#2fa92aebbbc71f43d2db2ed1aed07361124e91ca" + integrity sha512-cB10MXLTs3gVuXimblAdI71jrJx8njrJZmNMEMC+sQu5B/BIOmlsAjskdqpn81y8UBVEGuHODd7/ci5DvoSzTQ== + react-is@^16.7.0, react-is@^16.8.1: version "16.13.1" resolved "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz"