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 { 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,21 +39,58 @@ 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">
|
||||||
|
<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>
|
<Title>Chyrons</Title>
|
||||||
<SlotContainer width={100}>
|
<Inline gutter="md" stretch="all">
|
||||||
<SlotSelector
|
<SlotSelector
|
||||||
items={chyronModes}
|
items={chyronModes}
|
||||||
onChange={index => setChyronMode(chyronModes[index])}
|
onChange={index => setChyronMode(chyronModes[index])}
|
||||||
/>
|
/>
|
||||||
</SlotContainer>
|
|
||||||
<SlotContainer width={100}>
|
|
||||||
<SlotSelector
|
<SlotSelector
|
||||||
items={chyronSubModes}
|
items={chyronSubModes}
|
||||||
onChange={index => setChyronSubMode(chyronSubModes[index])}
|
onChange={index => setChyronSubMode(chyronSubModes[index])}
|
||||||
/>
|
/>
|
||||||
</SlotContainer>
|
</Inline>
|
||||||
|
<Inline gutter="sm">
|
||||||
<OpenButton
|
<OpenButton
|
||||||
disabled={false}
|
disabled={false}
|
||||||
>
|
>
|
||||||
@@ -67,28 +106,9 @@ export function ChyronsDirectorControls() {
|
|||||||
>
|
>
|
||||||
<FaStop size="0.8em" />
|
<FaStop size="0.8em" />
|
||||||
</CloseButton>
|
</CloseButton>
|
||||||
<Toggle
|
</Inline>
|
||||||
label="Pos. Flag"
|
</Inline>
|
||||||
toggled={posFlag}
|
{controlSelector(chyronMode, chyronSubMode)}
|
||||||
onToggle={setPosFlag}
|
</Stack>
|
||||||
/>
|
|
||||||
<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>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
+1
-1
@@ -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>
|
||||||
|
|||||||
Reference in new issue
Block a user