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

@@ -2,19 +2,26 @@ import { useEffect, useMemo, useState } from "react";
import { animated, useSpringRef, useTransition } from "@react-spring/web";
import { findPrefixCount } from "../../../../utils/strings";
import { SlotText, SlotWindow } from "./styles";
import { SelectorLabel, SlotText, SlotWindow } from "./styles";
import { Inline } from "@bedrock-layout/inline";
type SlotSelectorProps = {
items: Array<string>,
onChange: (index: number) => void,
label?: string,
removePrefix?: boolean,
formatter?: (value: string) => string,
initialIndex?: number,
disabled?: boolean,
};
/**
* If items are defined in a component make sure they are stateful to prevent
* random resets of the index during changes.
*/
export function SlotSelector({
items,
onChange,
label,
removePrefix = false,
formatter = (x) => x,
initialIndex = 0,
@@ -63,10 +70,15 @@ export function SlotSelector({
}, [index]);
return (
<SlotWindow onClick={onClick} disabled={disabled}>
{transitions((style, i) => (
<SlotText as={animated.span} style={style}>{getItem(i)}</SlotText>
))}
</SlotWindow>
<Inline gutter="sm" stretch="end" align="end">
{(label ?? null) && (
<SelectorLabel>{label}</SelectorLabel>
)}
<SlotWindow onClick={onClick} disabled={disabled}>
{transitions((style, i) => (
<SlotText as={animated.span} style={style}>{getItem(i)}</SlotText>
))}
</SlotWindow>
</Inline>
);
}
@@ -20,13 +20,21 @@ export const SlotWindow = styled.div<SlotWindowProps>`
white-space: nowrap;
text-overflow: ellipsis;
`;
SlotWindow.displayName = "SlotWindow";
export const SlotText = styled.span`
position: absolute;
display: block;
margin-left: .4em;
font-family: ${p => p.theme.fonts.f1Regular};
font-size: 0.9em;
font-size: ${p => p.theme.fontSizes.selector};
color: ${p => p.theme.colors.darkGrey};
user-select: none;
`;
SlotText.displayName = "SlotText";
export const SelectorLabel = styled.span`
font-family: ${p => p.theme.fonts.f1Regular};
font-size: ${p => p.theme.fontSizes.label};
`;
SelectorLabel.displayName = "SelectorLabel";
@@ -5,7 +5,7 @@ type ToggleContainerProps = {
}
export const ToggleContainer = styled.div<ToggleContainerProps>`
display: flex;
justify-content: center;
align-items: flex-end;
font-size: ${({ fontSize = "inherit" }) => fontSize};
`;
ToggleContainer.displayName = "ToggleContainer";
@@ -24,7 +24,10 @@ ToggleInput.displayName = "ToggleInput";
export const ToggleLabelText = styled.span`
margin-right: 1ch;
font-family: ${p => p.theme.fonts.f1Regular};
font-size: ${p => p.theme.fontSizes.label};
`;
ToggleLabelText.displayName = "ToggleLabelText";
export const ToggleLabel = styled.label`
display: block;
@@ -95,4 +98,3 @@ export const ToggleCircle = styled.div<ToggleCircleProps>`
${({ toggled }) => toggled ? css`right: 0;` : css`left: 0;`}
`;
ToggleCircle.displayName = "ToggleCircle";