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:
Kyle Geib committed 2022-01-28 17:53:50 -05:00
1 parent 8e4ac1243b
commit 5e7940a151
15 files changed
+266 -54

No files matched your search

@@ -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";