ISSUE-032 - Progress checkpoint.
Have a lot of the scaffolding in place. Next step is to make the Chyron controls actually work. Dramatic re-thinking of the chyron state definitions. Lots of goofy type following tricks in broadcastGraphics.ts.
This commit is contained in:
1 parent
8e4ac1243b
commit
5e7940a151
15 files changed
+261
-49
No files matched your search
@@ -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",
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
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";
|
||||
|
||||
export function ChyronsDirectorControls() {
|
||||
// Use state to prevent unnecessary resetting on re-renders.
|
||||
const [chyronModes] = useState<Array<BGChyronMode>>(getChyronModesList());
|
||||
const [chyronSubModes, setChyronSubModes] = useState<Array<BGChyronSubMode>>([]);
|
||||
|
||||
// Interface states.
|
||||
const [chyronMode, setChyronMode] = useState<BGChyronMode>("driver");
|
||||
const [chyronSubMode, setChyronSubMode] = useState<BGChyronSubMode>("medium");
|
||||
const [posFlag, setPosFlag] = useState(true);
|
||||
const [driverNum, setDriverNum] = useState(true);
|
||||
const [portrait, setPortrait] = useState(false);
|
||||
const [flagMode, setFlagMode] = useState<FlagMode>("country");
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
||||
|
||||
useEffect(() => {
|
||||
setChyronSubModes(getChyronSubModesList(chyronMode));
|
||||
}, [chyronMode]);
|
||||
|
||||
const onLaunch = () => {
|
||||
const x = 0;
|
||||
return x;
|
||||
};
|
||||
|
||||
return (
|
||||
<InlineCluster gutter="md">
|
||||
<Title>Chyrons</Title>
|
||||
<SlotContainer width={100}>
|
||||
<SlotSelector
|
||||
items={chyronModes}
|
||||
onChange={index => setChyronMode(chyronModes[index])}
|
||||
/>
|
||||
</SlotContainer>
|
||||
<SlotContainer width={100}>
|
||||
<SlotSelector
|
||||
items={chyronSubModes}
|
||||
onChange={index => setChyronSubMode(chyronSubModes[index])}
|
||||
/>
|
||||
</SlotContainer>
|
||||
<OpenButton
|
||||
disabled={false}
|
||||
>
|
||||
<FaPlay size="0.8em" />
|
||||
</OpenButton>
|
||||
<Button
|
||||
disabled={false}
|
||||
>
|
||||
<FaStepForward size="0.8em" />
|
||||
</Button>
|
||||
<CloseButton
|
||||
disabled={false}
|
||||
>
|
||||
<FaStop size="0.8em" />
|
||||
</CloseButton>
|
||||
<Toggle
|
||||
label="Pos. Flag"
|
||||
toggled={posFlag}
|
||||
onToggle={setPosFlag}
|
||||
/>
|
||||
<Toggle
|
||||
label="Driver Num."
|
||||
toggled={driverNum}
|
||||
onToggle={setDriverNum}
|
||||
/>
|
||||
<Toggle
|
||||
label="Portrait"
|
||||
toggled={portrait}
|
||||
onToggle={setPortrait}
|
||||
/>
|
||||
<SlotContainer width={200}>
|
||||
<SlotSelector
|
||||
label="Flag Mode"
|
||||
items={flagModeList}
|
||||
onChange={index => setFlagMode(flagModeList[index])}
|
||||
/>
|
||||
</SlotContainer>
|
||||
</InlineCluster>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./ChyronsDirectorControls";
|
||||
@@ -0,0 +1,43 @@
|
||||
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,
|
||||
};
|
||||
export const Button = styled.button<ButtonProps>`
|
||||
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;
|
||||
`;
|
||||
Button.displayName = "Button";
|
||||
|
||||
export const OpenButton = styled(Button)<ButtonProps>`
|
||||
background-color: ${({ disabled }) => disabled
|
||||
? p => p.theme.colors.disabledGreen : p => p.theme.colors.activeGreen};
|
||||
`;
|
||||
OpenButton.displayName = "OpenButton";
|
||||
|
||||
export const CloseButton = styled(Button)<ButtonProps>`
|
||||
background-color: ${({ disabled }) => disabled
|
||||
? p => p.theme.colors.disabledRed : p => p.theme.colors.activeRed};
|
||||
`;
|
||||
CloseButton.displayName = "CloseButton";
|
||||
@@ -2,19 +2,26 @@ 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<string>,
|
||||
onChange: (index: number) => void,
|
||||
label?: string,
|
||||
removePrefix?: boolean,
|
||||
formatter?: (value: string) => string,
|
||||
initialIndex?: number,
|
||||
disabled?: boolean,
|
||||
};
|
||||
/**
|
||||
* 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,
|
||||
@@ -63,10 +70,15 @@ export function SlotSelector({
|
||||
}, [index]);
|
||||
|
||||
return (
|
||||
<Inline gutter="sm" stretch="end" align="end">
|
||||
{(label ?? null) && (
|
||||
<SelectorLabel>{label}</SelectorLabel>
|
||||
)}
|
||||
<SlotWindow onClick={onClick} disabled={disabled}>
|
||||
{transitions((style, i) => (
|
||||
<SlotText as={animated.span} style={style}>{getItem(i)}</SlotText>
|
||||
))}
|
||||
</SlotWindow>
|
||||
</Inline>
|
||||
);
|
||||
}
|
||||
@@ -20,13 +20,21 @@ export const SlotWindow = styled.div<SlotWindowProps>`
|
||||
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";
|
||||
@@ -5,7 +5,7 @@ type ToggleContainerProps = {
|
||||
}
|
||||
export const ToggleContainer = styled.div<ToggleContainerProps>`
|
||||
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<ToggleCircleProps>`
|
||||
${({ toggled }) => toggled ? css`right: 0;` : css`left: 0;`}
|
||||
`;
|
||||
ToggleCircle.displayName = "ToggleCircle";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
||||
|
||||
@@ -9,15 +8,6 @@ import { BasicBlock } from "./styles";
|
||||
|
||||
export function AngledFlagWorkSpace() {
|
||||
const { prototypeState } = useSelector(workspaceSelector);
|
||||
// const dispatch = useDispatch();
|
||||
// useEffect(() => {
|
||||
// dispatch(setPrototypeState({
|
||||
// angledFlag: {
|
||||
// flagA: "GBR",
|
||||
// flagB: "GBR",
|
||||
// },
|
||||
// }));
|
||||
// }, [currentWorkspaceId]);
|
||||
|
||||
return (
|
||||
<BasicBlock width={750} height={450} color="rgba(30, 30, 30, .7)">
|
||||
|
||||
+10
-4
@@ -1,15 +1,21 @@
|
||||
import { Grid } from "@bedrock-layout/grid";
|
||||
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 (
|
||||
<Grid gutter="md">
|
||||
<Split gutter="md">
|
||||
<PadBox padding="md">
|
||||
<ChyronControlsContainer>
|
||||
<ChyronsDirectorControls />
|
||||
</ChyronControlsContainer>
|
||||
</PadBox>
|
||||
<PadBox padding="md">
|
||||
<GridSelection />
|
||||
</PadBox>
|
||||
<span>Launcher/Closer</span>
|
||||
</Grid>
|
||||
</Split>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import styled from "styled-components";
|
||||
|
||||
export const ChyronControlsContainer = styled.div`
|
||||
width: 420px;
|
||||
height: auto;
|
||||
`;
|
||||
ChyronControlsContainer.displayName = "ChyronControlsContainer";
|
||||
@@ -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<string, unknown>,
|
||||
},
|
||||
},
|
||||
} = {
|
||||
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<FlagMode> = ["country", "team", "none"];
|
||||
|
||||
export function getChyronModesList(): Array<BGChyronMode> {
|
||||
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<BGChyronSubMode> {
|
||||
return keys(chyronsData[mode]?.subModes ?? {});
|
||||
}
|
||||
|
||||
export function getChyronSubModeProps(
|
||||
mode: BGChyronMode,
|
||||
subMode: BGChyronSubMode,
|
||||
): Record<string, unknown> {
|
||||
return chyronsData[mode]?.subModes[subMode] ?? {};
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export const broadcastGraphicsSlice = createSlice({
|
||||
chyronsLaunch: (state, action: PayloadAction<BGChyrons>) => {
|
||||
state.chyrons = action.payload;
|
||||
},
|
||||
chyronsSetOpenState: (state, action: PayloadAction<OpenState>) => {
|
||||
chyronsOpenStateSet: (state, action: PayloadAction<OpenState>) => {
|
||||
if (state.chyrons == null) return;
|
||||
state.chyrons.primary.openState = action.payload;
|
||||
|
||||
@@ -21,6 +21,14 @@ export const broadcastGraphicsSlice = createSlice({
|
||||
state.chyrons.secondary.openState = action.payload;
|
||||
}
|
||||
},
|
||||
chyronsOpenStateIncrement: (state) => {
|
||||
if (state.chyrons == null) return;
|
||||
++state.chyrons.primary.openState;
|
||||
|
||||
if (state.chyrons.secondary != null) {
|
||||
++state.chyrons.secondary.openState;
|
||||
}
|
||||
},
|
||||
chyronsClear: (state) => {
|
||||
state.chyrons = null;
|
||||
},
|
||||
@@ -29,6 +37,8 @@ export const broadcastGraphicsSlice = createSlice({
|
||||
|
||||
export const {
|
||||
chyronsLaunch,
|
||||
chyronsOpenStateSet,
|
||||
chyronsOpenStateIncrement,
|
||||
chyronsClear,
|
||||
} = broadcastGraphicsSlice.actions;
|
||||
export default broadcastGraphicsSlice.reducer;
|
||||
@@ -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",
|
||||
|
||||
Vendored
+13
-29
@@ -195,7 +195,7 @@ export interface BGBaseState {
|
||||
openState: OpenState;
|
||||
}
|
||||
/**
|
||||
* -1 closing, 0 closed, 1 open, 2... different states
|
||||
* -1 closing, 0 closed, 1 open, 2... different states (for progressive anims)
|
||||
*/
|
||||
export type OpenState = number;
|
||||
|
||||
@@ -209,40 +209,24 @@ export interface BroadcastGraphics {
|
||||
}
|
||||
|
||||
// Chyrons
|
||||
export type FlagMode = "country" | "team";
|
||||
export type BGChyronMode =
|
||||
| "driver-basic-small"
|
||||
| "driver-basic-medium"
|
||||
| "driver-basic-large";
|
||||
export type BGChyronMode = string;
|
||||
export type BGChyronSubMode = string;
|
||||
export interface BGChyron extends BGBaseState {
|
||||
mode: BGChyronMode;
|
||||
car: Car;
|
||||
flagMode: FlagMode;
|
||||
showPosFlag: boolean;
|
||||
showDriverNumber: boolean;
|
||||
dimensions: Dimensions;
|
||||
props?: unknown;
|
||||
}
|
||||
export interface BGChyrons {
|
||||
primary: BGChyron;
|
||||
secondary: Optional<BGChyron>;
|
||||
// sponsorGem: BGSponsorGem;
|
||||
}
|
||||
export interface BGChyronMedium extends BGChyron {
|
||||
mode: "driver-basic-medium";
|
||||
dimensions: {
|
||||
width: 582;
|
||||
height: 72;
|
||||
}
|
||||
props: {
|
||||
showPortrait: boolean;
|
||||
}
|
||||
}
|
||||
export interface BGChyronLarge extends BGChyron {
|
||||
mode: "driver-basic-large";
|
||||
dimensions: {
|
||||
width: 638;
|
||||
height: 98;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user