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:
1 parent
5e7940a151
commit
d5b653da9d
4 files changed
+55
-31
No files matched your search
@@ -11,6 +11,8 @@ 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";
|
||||
|
||||
export function ChyronsDirectorControls() {
|
||||
// Use state to prevent unnecessary resetting on re-renders.
|
||||
@@ -37,21 +39,58 @@ export function ChyronsDirectorControls() {
|
||||
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">
|
||||
<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}>
|
||||
<Title>Chyrons</Title>
|
||||
<SlotContainer width={100}>
|
||||
<Inline gutter="md" stretch="all">
|
||||
<SlotSelector
|
||||
items={chyronModes}
|
||||
onChange={index => setChyronMode(chyronModes[index])}
|
||||
/>
|
||||
</SlotContainer>
|
||||
<SlotContainer width={100}>
|
||||
<SlotSelector
|
||||
items={chyronSubModes}
|
||||
onChange={index => setChyronSubMode(chyronSubModes[index])}
|
||||
/>
|
||||
</SlotContainer>
|
||||
</Inline>
|
||||
<Inline gutter="sm">
|
||||
<OpenButton
|
||||
disabled={false}
|
||||
>
|
||||
@@ -67,28 +106,9 @@ export function ChyronsDirectorControls() {
|
||||
>
|
||||
<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>
|
||||
</Inline>
|
||||
</Inline>
|
||||
{controlSelector(chyronMode, chyronSubMode)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ type SlotSelectorProps = {
|
||||
formatter?: (value: string) => string,
|
||||
initialIndex?: number,
|
||||
disabled?: boolean,
|
||||
slotWidth?: string,
|
||||
};
|
||||
/**
|
||||
* If items are defined in a component make sure they are stateful to prevent
|
||||
@@ -26,6 +27,7 @@ export function SlotSelector({
|
||||
formatter = (x) => x,
|
||||
initialIndex = 0,
|
||||
disabled = false,
|
||||
slotWidth = "6ch",
|
||||
}: SlotSelectorProps) {
|
||||
const [index, setIndex] = useState(initialIndex);
|
||||
const [prefixMask, setPrefixMask] = useState(0);
|
||||
@@ -74,7 +76,7 @@ export function SlotSelector({
|
||||
{(label ?? null) && (
|
||||
<SelectorLabel>{label}</SelectorLabel>
|
||||
)}
|
||||
<SlotWindow onClick={onClick} disabled={disabled}>
|
||||
<SlotWindow onClick={onClick} disabled={disabled} width={slotWidth}>
|
||||
{transitions((style, i) => (
|
||||
<SlotText as={animated.span} style={style}>{getItem(i)}</SlotText>
|
||||
))}
|
||||
|
||||
@@ -2,11 +2,13 @@ import styled from "styled-components";
|
||||
|
||||
type SlotWindowProps = {
|
||||
disabled: boolean,
|
||||
width?: string,
|
||||
};
|
||||
export const SlotWindow = styled.div<SlotWindowProps>`
|
||||
position: relative;
|
||||
height: 1.5em;
|
||||
width: auto;
|
||||
width: ${({ width = "auto" }) => width};
|
||||
min-width: 6ch;
|
||||
|
||||
border-radius: 0.6em;
|
||||
background-color: ${({ disabled }) => disabled
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import { ChyronControlsContainer } from "./styles";
|
||||
export function ChyronPrototypeControls() {
|
||||
return (
|
||||
<Split gutter="md">
|
||||
<PadBox padding="md">
|
||||
<PadBox padding={["lg", "md", "md"]}>
|
||||
<ChyronControlsContainer>
|
||||
<ChyronsDirectorControls />
|
||||
</ChyronControlsContainer>
|
||||
|
||||
Reference in new issue
Block a user