From d5b653da9d48bc248af67c7a5f0b6240cdb3c2e7 Mon Sep 17 00:00:00 2001 From: Kyle Geib Date: Mon, 31 Jan 2022 12:44:12 -0500 Subject: [PATCH] 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. --- .../Chyrons/ChyronsDirectorControls.tsx | 100 +++++++++++------- .../Inputs/SlotSelector/SlotSelector.tsx | 4 +- .../Common/Inputs/SlotSelector/styles.ts | 4 +- .../ChyronPrototypeControls.tsx | 2 +- 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx index e546fe3..ca1f0c5 100644 --- a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx +++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx @@ -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,36 +39,17 @@ 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) => ( + - Chyrons - - setChyronMode(chyronModes[index])} - /> - - - setChyronSubMode(chyronSubModes[index])} - /> - - - - - - - - - - - setFlagMode(flagModeList[index])} + {subMode === "medium" && ( + - + )} + setFlagMode(flagModeList[index])} + slotWidth="12ch" + /> ); + + return ( + + + Chyrons + + setChyronMode(chyronModes[index])} + /> + setChyronSubMode(chyronSubModes[index])} + /> + + + + + + + + + + + + {controlSelector(chyronMode, chyronSubMode)} + + ); } diff --git a/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx b/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx index 7472929..b9f8c50 100644 --- a/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx +++ b/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx @@ -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) && ( {label} )} - + {transitions((style, i) => ( {getItem(i)} ))} diff --git a/src/components/Common/Inputs/SlotSelector/styles.ts b/src/components/Common/Inputs/SlotSelector/styles.ts index 5996590..9a2f580 100644 --- a/src/components/Common/Inputs/SlotSelector/styles.ts +++ b/src/components/Common/Inputs/SlotSelector/styles.ts @@ -2,11 +2,13 @@ import styled from "styled-components"; type SlotWindowProps = { disabled: boolean, + width?: string, }; export const SlotWindow = styled.div` position: relative; height: 1.5em; - width: auto; + width: ${({ width = "auto" }) => width}; + min-width: 6ch; border-radius: 0.6em; background-color: ${({ disabled }) => disabled diff --git a/src/components/Workspaces/PrototypingControls/ChyronPrototype/ChyronPrototypeControls.tsx b/src/components/Workspaces/PrototypingControls/ChyronPrototype/ChyronPrototypeControls.tsx index 9f22149..44945cc 100644 --- a/src/components/Workspaces/PrototypingControls/ChyronPrototype/ChyronPrototypeControls.tsx +++ b/src/components/Workspaces/PrototypingControls/ChyronPrototype/ChyronPrototypeControls.tsx @@ -8,7 +8,7 @@ import { ChyronControlsContainer } from "./styles"; export function ChyronPrototypeControls() { return ( - +