ISSUE-032 - Have Chyron prototyping controls configured and hooked up.
Support for double driver chyrons. Serious refactoring of the BroadcastGraphics states. Simplification and improvements to how the chyron states work (I was using interfaces in a way that was incompatible with reality and have fixed it).
This commit is contained in:
1 parent
d5b653da9d
commit
0625361a18
16 files changed
+233
-124
No files matched your search
@@ -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<FlagMode>("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 (
|
||||
<InlineCluster gutter="md">
|
||||
<Toggle
|
||||
label="Pos. Flag"
|
||||
toggled={posFlag}
|
||||
onToggle={setPosFlag}
|
||||
/>
|
||||
<Toggle
|
||||
label="Driver Num."
|
||||
toggled={driverNum}
|
||||
onToggle={setDriverNum}
|
||||
/>
|
||||
{subMode === "medium" && (
|
||||
<Toggle
|
||||
label="Portrait"
|
||||
toggled={portrait}
|
||||
onToggle={setPortrait}
|
||||
/>
|
||||
)}
|
||||
<SlotSelector
|
||||
label="Flag Mode"
|
||||
items={flagModeList}
|
||||
onChange={index => setFlagMode(flagModeList[index])}
|
||||
slotWidth="12ch"
|
||||
/>
|
||||
</InlineCluster>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const driverMode = (subMode: BGChyronSubMode) => (
|
||||
|
||||
<InlineCluster gutter="md">
|
||||
<Toggle
|
||||
label="Pos. Flag"
|
||||
toggled={posFlag}
|
||||
onToggle={setPosFlag}
|
||||
/>
|
||||
<Toggle
|
||||
label="Driver Num."
|
||||
toggled={driverNum}
|
||||
onToggle={setDriverNum}
|
||||
/>
|
||||
{subMode === "medium" && (
|
||||
<Toggle
|
||||
label="Portrait"
|
||||
toggled={portrait}
|
||||
onToggle={setPortrait}
|
||||
/>
|
||||
)}
|
||||
<SlotSelector
|
||||
label="Flag Mode"
|
||||
items={flagModeList}
|
||||
onChange={index => setFlagMode(flagModeList[index])}
|
||||
slotWidth="12ch"
|
||||
/>
|
||||
</InlineCluster>
|
||||
);
|
||||
|
||||
return (
|
||||
<Stack gutter="md">
|
||||
<Inline gutter="md" stretch={1}>
|
||||
@@ -92,23 +133,26 @@ export function ChyronsDirectorControls() {
|
||||
</Inline>
|
||||
<Inline gutter="sm">
|
||||
<OpenButton
|
||||
disabled={false}
|
||||
onClick={onOpen}
|
||||
disabled={chyrons != null}
|
||||
>
|
||||
<FaPlay size="0.8em" />
|
||||
</OpenButton>
|
||||
<Button
|
||||
disabled={false}
|
||||
onClick={onNext}
|
||||
disabled={chyrons == null}
|
||||
>
|
||||
<FaStepForward size="0.8em" />
|
||||
</Button>
|
||||
<CloseButton
|
||||
disabled={false}
|
||||
onClick={onClose}
|
||||
disabled={chyrons == null}
|
||||
>
|
||||
<FaStop size="0.8em" />
|
||||
</CloseButton>
|
||||
</Inline>
|
||||
</Inline>
|
||||
{controlSelector(chyronMode, chyronSubMode)}
|
||||
{modeControls(chyronMode, chyronSubMode)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -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<SlotContainerProps>`
|
||||
width: ${({ width }) => `${width}px`};
|
||||
`;
|
||||
SlotContainer.displayName = "SlotContainer";
|
||||
|
||||
type ButtonProps = {
|
||||
disabled: boolean,
|
||||
};
|
||||
@@ -27,6 +18,13 @@ export const Button = styled.button<ButtonProps>`
|
||||
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";
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<Inline gutter="none">
|
||||
|
||||
<ChyronDriver
|
||||
chyronData={chyrons.driver.primary}
|
||||
subMode={chyrons.subMode}
|
||||
/>
|
||||
{chyrons.subMode == "medium" && chyrons.driver.secondary && (
|
||||
<>
|
||||
<Spacer />
|
||||
<ChyronDriver
|
||||
chyronData={chyrons.driver.secondary}
|
||||
subMode={chyrons.subMode}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Inline>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./ChyronContainer";
|
||||
@@ -0,0 +1,6 @@
|
||||
import styled from "styled-components";
|
||||
|
||||
export const Spacer = styled.div`
|
||||
width: 32px;
|
||||
`;
|
||||
Spacer.displayName = "Spacer";
|
||||
@@ -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 (
|
||||
<BaseBackground width={baseWidth} height={baseHeight}>
|
||||
<Spacer width="6px" />
|
||||
<PositionFlag containerHeight={baseHeight}>
|
||||
<PositionNumber containerHeight={baseHeight}>1</PositionNumber>
|
||||
</PositionFlag>
|
||||
{showPosFlag && (
|
||||
<PositionFlag containerHeight={baseHeight}>
|
||||
<PositionNumber containerHeight={baseHeight}>
|
||||
{car.position}
|
||||
</PositionNumber>
|
||||
</PositionFlag>
|
||||
)}
|
||||
<Spacer width="8px" />
|
||||
<TeamColorBar color={theme.colors.teams[driver.team.id]} />
|
||||
<TeamColorBar color={theme.colors.teams[car.driver.team.id]} />
|
||||
<Spacer width="8px" />
|
||||
<TextContainer>
|
||||
<NameContainer>
|
||||
<FirstName>{driver.firstName}</FirstName>
|
||||
<LastName>{driver.lastName}</LastName>
|
||||
<NumberContainer>
|
||||
<DriverNumber
|
||||
teamId={driver.team.id}
|
||||
fontSize="29px"
|
||||
number={driver.number}
|
||||
/>
|
||||
</NumberContainer>
|
||||
<FirstName>{car.driver.firstName}</FirstName>
|
||||
<LastName>{car.driver.lastName}</LastName>
|
||||
{showDriverNumber && (
|
||||
<NumberContainer>
|
||||
<DriverNumber
|
||||
teamId={car.driver.team.id}
|
||||
fontSize="29px"
|
||||
number={car.driver.number}
|
||||
/>
|
||||
</NumberContainer>
|
||||
)}
|
||||
</NameContainer>
|
||||
<TeamName>{driver.team.shortName}</TeamName>
|
||||
<TeamName>{car.driver.team.shortName}</TeamName>
|
||||
</TextContainer>
|
||||
<FlagContainer
|
||||
height={baseHeight * 0.9}
|
||||
@@ -52,15 +65,11 @@ export function ChyronDriver() {
|
||||
right={-baseHeight * 0.6}
|
||||
>
|
||||
<AngledFlag
|
||||
flagMode="country"
|
||||
flag={driver.nationality}
|
||||
flagMode={flagMode}
|
||||
flag={car.driver.nationality}
|
||||
flagHeight={baseHeight * 0.9}
|
||||
/>
|
||||
</FlagContainer>
|
||||
</BaseBackground>
|
||||
);
|
||||
}
|
||||
|
||||
// export function ChyronDriverStateContainer() {
|
||||
|
||||
// }
|
||||
@@ -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 (
|
||||
<BasicBlock width={750} height={450} color="rgba(30, 30, 30, .7)">
|
||||
<AngledFlag
|
||||
flagMode="country"
|
||||
flagMode={flagMode}
|
||||
flag={prototypeState?.angledFlag?.flagA ?? "GBR"}
|
||||
flagHeight={64}
|
||||
/>
|
||||
<AngledFlag
|
||||
flagMode="country"
|
||||
flagMode={flagMode}
|
||||
flag={prototypeState?.angledFlag?.flagB ?? "GBR"}
|
||||
flagHeight={128}
|
||||
/>
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ export function AngledFlagPrototypeControls() {
|
||||
};
|
||||
return (
|
||||
<Split as={PadBox} gutter="md" padding="md">
|
||||
<SlotSelector items={countries} onChange={onChange("flagA")}/>
|
||||
<SlotSelector items={countries} onChange={onChange("flagB")}/>
|
||||
<SlotSelector label="64px" items={countries} onChange={onChange("flagA")}/>
|
||||
<SlotSelector label="128px" items={countries} onChange={onChange("flagB")}/>
|
||||
</Split>
|
||||
);
|
||||
}
|
||||
@@ -13,9 +13,7 @@ export type PreviewWindowProps = {
|
||||
dimensions: Dimensions,
|
||||
animatedBG?: boolean,
|
||||
};
|
||||
export const PreviewWindow = styled(PadBox).attrs(() => ({
|
||||
padding: "lg",
|
||||
}))<PreviewWindowProps>`
|
||||
export const PreviewWindow = styled.div<PreviewWindowProps>`
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
@@ -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() {
|
||||
>
|
||||
<Routes>
|
||||
<Route index element={<h1>Workspaces Home</h1>} />
|
||||
<Route path="chyronDriver" element={
|
||||
<Route path="chyron" element={
|
||||
<Workspace
|
||||
workspaceId="chyronDriver"
|
||||
previewContent={<ChyronDriver />}
|
||||
workspaceId="chyron"
|
||||
previewContent={<ChyronContainer />}
|
||||
prototypeControls={<ChyronPrototypeControls />}
|
||||
/>
|
||||
} />
|
||||
<Route path="angledFlag" element={
|
||||
<Route path="chyronWide" element={
|
||||
<Workspace
|
||||
workspaceId="angledFlag"
|
||||
previewContent={<AngledFlagWorkSpace />}
|
||||
workspaceId="chyronWide"
|
||||
previewContent={<ChyronContainer />}
|
||||
prototypeControls={<ChyronPrototypeControls />}
|
||||
/>
|
||||
} />
|
||||
<Route path="angledFlagCountry" element={
|
||||
<Workspace
|
||||
workspaceId="angledFlagCountry"
|
||||
previewContent={<AngledFlagWorkSpace flagMode="country"/>}
|
||||
prototypeControls={<AngledFlagPrototypeControls />}
|
||||
/>
|
||||
} />
|
||||
|
||||
Reference in new issue
Block a user