ISSUE-032 - Making some organizational changes to how the Chyron director controls are built. Have more work to perform but making a checkpoint commit to keep track of my work so far.

This commit is contained in:
Kyle Geib committed 2022-01-31 12:44:12 -05:00
1 parent 5e7940a151
commit d5b653da9d
4 files changed
+67 -43

No files matched your search

@@ -11,6 +11,8 @@ import { BGChyronMode, BGChyronSubMode, FlagMode } from "../../../../types/state
import { SlotSelector } from "../../../Common/Inputs/SlotSelector"; import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
import { Button, CloseButton, OpenButton, SlotContainer, Title } from "./styles"; import { Button, CloseButton, OpenButton, SlotContainer, Title } from "./styles";
import { Toggle } from "../../../Common/Inputs/Toggle"; import { Toggle } from "../../../Common/Inputs/Toggle";
import { Stack } from "@bedrock-layout/stack";
import { Inline } from "@bedrock-layout/inline";
export function ChyronsDirectorControls() { export function ChyronsDirectorControls() {
// Use state to prevent unnecessary resetting on re-renders. // Use state to prevent unnecessary resetting on re-renders.
@@ -37,36 +39,17 @@ export function ChyronsDirectorControls() {
return x; return x;
}; };
return ( const controlSelector = (mode: BGChyronMode, subMode: BGChyronSubMode) => {
if (mode === "driver") {
return driverMode(subMode);
} else {
return null;
}
};
const driverMode = (subMode: BGChyronSubMode) => (
<InlineCluster gutter="md"> <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 <Toggle
label="Pos. Flag" label="Pos. Flag"
toggled={posFlag} toggled={posFlag}
@@ -77,18 +60,55 @@ export function ChyronsDirectorControls() {
toggled={driverNum} toggled={driverNum}
onToggle={setDriverNum} onToggle={setDriverNum}
/> />
<Toggle {subMode === "medium" && (
label="Portrait" <Toggle
toggled={portrait} label="Portrait"
onToggle={setPortrait} toggled={portrait}
/> onToggle={setPortrait}
<SlotContainer width={200}>
<SlotSelector
label="Flag Mode"
items={flagModeList}
onChange={index => setFlagMode(flagModeList[index])}
/> />
</SlotContainer> )}
<SlotSelector
label="Flag Mode"
items={flagModeList}
onChange={index => setFlagMode(flagModeList[index])}
slotWidth="12ch"
/>
</InlineCluster> </InlineCluster>
); );
return (
<Stack gutter="md">
<Inline gutter="md" stretch={1}>
<Title>Chyrons</Title>
<Inline gutter="md" stretch="all">
<SlotSelector
items={chyronModes}
onChange={index => setChyronMode(chyronModes[index])}
/>
<SlotSelector
items={chyronSubModes}
onChange={index => setChyronSubMode(chyronSubModes[index])}
/>
</Inline>
<Inline gutter="sm">
<OpenButton
disabled={false}
>
<FaPlay size="0.8em" />
</OpenButton>
<Button
disabled={false}
>
<FaStepForward size="0.8em" />
</Button>
<CloseButton
disabled={false}
>
<FaStop size="0.8em" />
</CloseButton>
</Inline>
</Inline>
{controlSelector(chyronMode, chyronSubMode)}
</Stack>
);
} }
@@ -13,6 +13,7 @@ type SlotSelectorProps = {
formatter?: (value: string) => string, formatter?: (value: string) => string,
initialIndex?: number, initialIndex?: number,
disabled?: boolean, disabled?: boolean,
slotWidth?: string,
}; };
/** /**
* If items are defined in a component make sure they are stateful to prevent * If items are defined in a component make sure they are stateful to prevent
@@ -26,6 +27,7 @@ export function SlotSelector({
formatter = (x) => x, formatter = (x) => x,
initialIndex = 0, initialIndex = 0,
disabled = false, disabled = false,
slotWidth = "6ch",
}: SlotSelectorProps) { }: SlotSelectorProps) {
const [index, setIndex] = useState(initialIndex); const [index, setIndex] = useState(initialIndex);
const [prefixMask, setPrefixMask] = useState(0); const [prefixMask, setPrefixMask] = useState(0);
@@ -74,7 +76,7 @@ export function SlotSelector({
{(label ?? null) && ( {(label ?? null) && (
<SelectorLabel>{label}</SelectorLabel> <SelectorLabel>{label}</SelectorLabel>
)} )}
<SlotWindow onClick={onClick} disabled={disabled}> <SlotWindow onClick={onClick} disabled={disabled} width={slotWidth}>
{transitions((style, i) => ( {transitions((style, i) => (
<SlotText as={animated.span} style={style}>{getItem(i)}</SlotText> <SlotText as={animated.span} style={style}>{getItem(i)}</SlotText>
))} ))}
@@ -2,11 +2,13 @@ import styled from "styled-components";
type SlotWindowProps = { type SlotWindowProps = {
disabled: boolean, disabled: boolean,
width?: string,
}; };
export const SlotWindow = styled.div<SlotWindowProps>` export const SlotWindow = styled.div<SlotWindowProps>`
position: relative; position: relative;
height: 1.5em; height: 1.5em;
width: auto; width: ${({ width = "auto" }) => width};
min-width: 6ch;
border-radius: 0.6em; border-radius: 0.6em;
background-color: ${({ disabled }) => disabled background-color: ${({ disabled }) => disabled
@@ -8,7 +8,7 @@ import { ChyronControlsContainer } from "./styles";
export function ChyronPrototypeControls() { export function ChyronPrototypeControls() {
return ( return (
<Split gutter="md"> <Split gutter="md">
<PadBox padding="md"> <PadBox padding={["lg", "md", "md"]}>
<ChyronControlsContainer> <ChyronControlsContainer>
<ChyronsDirectorControls /> <ChyronsDirectorControls />
</ChyronControlsContainer> </ChyronControlsContainer>