ISSUE-045 - Chyron Body - Great progress today! It's starting to look legit!

Massive change to the way that Chyrons are built and deployed.
Still need to figure out what's wrong with the portrait and the Venetian blinds causing issues.
Still need to make the team name flicker.
This commit is contained in:
Kyle Geib committed 2022-02-09 18:47:07 -05:00
1 parent fd18703d1a
commit b545750f70
6 files changed
+254 -40

No files matched your search

@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { Stack } from "@bedrock-layout/stack"; import { Stack } from "@bedrock-layout/stack";
import { Inline } from "@bedrock-layout/inline"; import { Inline } from "@bedrock-layout/inline";
import { FaPlay, FaStepForward, FaStop } from "react-icons/fa"; import { FaCheck, FaStepForward, FaTimes } from "react-icons/fa";
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector"; import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector"; import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
@@ -11,6 +11,7 @@ import {
clearChyrons, clearChyrons,
incrementChyronsOpenState, incrementChyronsOpenState,
setChyrons, setChyrons,
setChyronsOpenState,
} from "../../../../features/broadcast/graphics/broadcastGraphicsSlice"; } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics"; import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics";
import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode } from "../../../../types/state"; import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode } from "../../../../types/state";
@@ -37,12 +38,41 @@ export function ChyronsDirectorControls() {
const { chyrons } = useSelector(broadcastGraphicsSelector); const { chyrons } = useSelector(broadcastGraphicsSelector);
const { selectedCars } = useSelector(broadcastDirectorSelector); const { selectedCars } = useSelector(broadcastDirectorSelector);
// Handle changes to the chyron mode so submodes can be changed accordingly.
useEffect(() => { useEffect(() => {
setChyronSubModes(getChyronSubModesList(chyronMode)); setChyronSubModes(getChyronSubModesList(chyronMode));
}, [chyronMode]); }, [chyronMode]);
// Handle changes to selected cars
// useEffect(() => {
// console.log(selectedCars, chyrons);
// // Do not change chyrons while in a non-closed state.
// if (chyrons != null && chyrons.openState !== 0) {
// return;
// }
// if (chyronMode === "driver") {
// buildDriver();
// }
// }, [selectedCars]);
const onOpen = () => { const onOpen = () => {
if (chyronMode === "driver") { // dispatch(setChyronsOpenState(1));
buildDriver();
};
const onNext = () => {
dispatch(incrementChyronsOpenState());
};
const onClose = () => {
dispatch(setChyronsOpenState(-1));
};
const buildDriver = () => {
console.log("building driver");
if (selectedCars.length === 0) return; if (selectedCars.length === 0) return;
let primaryCar = selectedCars[0]; let primaryCar = selectedCars[0];
let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null; let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
@@ -54,7 +84,7 @@ export function ChyronsDirectorControls() {
primaryCar = selectedCars[1]; primaryCar = selectedCars[1];
} }
const newChyrons: BGChyrons = { const newChyrons: BGChyrons = {
openState: 1, openState: 0,
relativePos: { top: "0", right: "0", bottom: "0", left: "0" }, relativePos: { top: "0", right: "0", bottom: "0", left: "0" },
mode: chyronMode, mode: chyronMode,
subMode: chyronSubMode, subMode: chyronSubMode,
@@ -64,15 +94,6 @@ export function ChyronsDirectorControls() {
}, },
}; };
dispatch(setChyrons(newChyrons)); dispatch(setChyrons(newChyrons));
}
};
const onNext = () => {
dispatch(incrementChyronsOpenState());
};
const onClose = () => {
dispatch(clearChyrons());
}; };
const buildDriverChyron = (car: Car): BGChyronDriver => ({ const buildDriverChyron = (car: Car): BGChyronDriver => ({
@@ -136,19 +157,19 @@ export function ChyronsDirectorControls() {
onClick={onOpen} onClick={onOpen}
disabled={chyrons != null} disabled={chyrons != null}
> >
<FaPlay size="0.8em" /> <FaCheck size="0.8em" />
</OpenButton> </OpenButton>
<Button <Button
onClick={onNext} onClick={onNext}
disabled={chyrons == null} disabled={chyrons == null || chyrons.openState === -1}
> >
<FaStepForward size="0.8em" /> <FaStepForward size="0.8em" />
</Button> </Button>
<CloseButton <CloseButton
onClick={onClose} onClick={onClose}
disabled={chyrons == null} disabled={chyrons == null || chyrons.openState <= 0}
> >
<FaStop size="0.8em" /> <FaTimes size="0.8em" />
</CloseButton> </CloseButton>
</Inline> </Inline>
</Inline> </Inline>
@@ -14,6 +14,7 @@ export function ChyronContainer() {
<ChyronDriver <ChyronDriver
chyronData={chyrons.driver.primary} chyronData={chyrons.driver.primary}
subMode={chyrons.subMode} subMode={chyrons.subMode}
openState={chyrons.openState}
/> />
); );
if (chyrons.subMode === "medium" && chyrons.driver.secondary) { if (chyrons.subMode === "medium" && chyrons.driver.secondary) {
@@ -23,6 +24,7 @@ export function ChyronContainer() {
<ChyronDriver <ChyronDriver
chyronData={chyrons.driver.secondary} chyronData={chyrons.driver.secondary}
subMode={chyrons.subMode} subMode={chyrons.subMode}
openState={chyrons.openState}
/> />
</DoubleChyronContainer> </DoubleChyronContainer>
); );
@@ -1,4 +1,5 @@
import { BGChyronDriver, BGChyronSubMode } from "../../../../types/state"; import { BGChyronDriver, BGChyronSubMode, OpenState } from "../../../../types/state";
import { useSpring } from "@react-spring/web";
import { theme } from "../../../../shared/theme"; import { theme } from "../../../../shared/theme";
@@ -7,7 +8,11 @@ import { AngledFlag } from "../../Common/AngledFlag";
import { PositionFlag } from "../../Common/PositionFlag"; import { PositionFlag } from "../../Common/PositionFlag";
import { DriverPortrait } from "../../Common/DriverPortrait"; import { DriverPortrait } from "../../Common/DriverPortrait";
import { import {
BaseBackground, AnimatedBaseContainer,
BaseLayout,
BaseOutline,
BaseBlack,
BaseBackgroundColor,
FirstName, FirstName,
LastName, LastName,
NameContainer, NameContainer,
@@ -17,15 +22,18 @@ import {
TeamName, TeamName,
TextContainer, TextContainer,
FlagContainer, FlagContainer,
BaseContainer,
DriverPortraitContainer, DriverPortraitContainer,
} from "./styles"; } from "./styles";
import { useDispatch } from "react-redux";
import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition";
type ChyronDriverProps = { type ChyronDriverProps = {
chyronData: BGChyronDriver, chyronData: BGChyronDriver,
subMode: BGChyronSubMode, subMode: BGChyronSubMode,
openState: OpenState,
}; };
export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) { export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverProps) {
const [baseWidth, baseHeight] = subMode === "medium" ? [582, 72] const [baseWidth, baseHeight] = subMode === "medium" ? [582, 72]
: subMode === "large" ? [638, 98] : subMode === "large" ? [638, 98]
: [0, 0]; : [0, 0];
@@ -35,15 +43,98 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
? { flagMode, flag: car.driver.nationality } ? { flagMode, flag: car.driver.nationality }
: flagMode === "team" ? { flagMode, flag: car.driver.team.id } : undefined; : flagMode === "team" ? { flagMode, flag: car.driver.team.id } : undefined;
const dispatch = useDispatch();
const containerFadeAwaySpring = useSpring({
opacity: openState == -1 ? 0 : 1,
config: { duration: 300 },
delay: 0,
onRest: () => {
if (openState === -1) {
dispatch(clearChyrons());
}
},
});
const teamColor = theme.colors.teams[car.driver.team.id];
return ( return (
<BaseContainer width={baseWidth} height={baseHeight}> <AnimatedBaseContainer
<BaseBackground > width={baseWidth}
height={baseHeight}
style={containerFadeAwaySpring}
>
<BaseOutline
open={openState !== 0}
transitionProps={[{
property: "outline",
duration: 1000,
}]}
/>
<BaseBlack
open={openState !== 0}
transitionProps={[{
property: "opacity",
duration: 800,
timing: "ease-in",
}, {
property: "width",
duration: 400,
timing: "ease-out",
delay: 100,
}]}
/>
<BaseLayout
open={openState !== 0}
transitionProps={[{
property: "clip-path",
duration: 800,
timing: "ease-in",
}]}
>
<BaseBackgroundColor
open={openState !== 0}
transitionProps={[{
property: "opacity",
duration: 600,
delay: 900,
}]}
teamColor={teamColor}
/>
<Spacer width="6px" /> <Spacer width="6px" />
{showPosFlag && ( {showPosFlag && (
<VenetianBlindsTransition
visible={openState !== 0}
delay={500}
blindsColor="#f60d0d"
blindsColorFadeDuration={300}
blindsColorFadeDelay={200}
blindsAngle={-45}
blindsOpenDuration={100}
blindsOpenDelay={150}
blindsSize={{ transparent: 3, opaque: 6 }}
wipeAngle={40}
wipeDuration={300}
wipeStartingCorner="bottomRight"
opacityStart={0.1}
opacityDuration={200}
opacityDelay={100}
spanBlinkDuration={500}
>
<PositionFlag size={baseHeight * 0.85} number={car.position} /> <PositionFlag size={baseHeight * 0.85} number={car.position} />
</VenetianBlindsTransition>
)} )}
<Spacer width="8px" /> <Spacer width="8px" />
<TeamColorBar color={theme.colors.teams[car.driver.team.id]} /> <TeamColorBar
open={openState !== 0}
transitionProps={[{
property: "clip-path",
duration: 750,
timing: "ease-in-out",
delay: 750,
}]}
color={teamColor}
/>
<Spacer width="8px" /> <Spacer width="8px" />
<TextContainer> <TextContainer>
<NameContainer> <NameContainer>
@@ -62,6 +153,12 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
<TeamName>{car.driver.team.shortName}</TeamName> <TeamName>{car.driver.team.shortName}</TeamName>
</TextContainer> </TextContainer>
<FlagContainer <FlagContainer
open={openState !== 0}
transitionProps={[{
property: "opacity",
duration: 500,
delay: 1000,
}]}
height={baseHeight * 0.9} height={baseHeight * 0.9}
width={baseHeight * 3} width={baseHeight * 3}
right={-baseHeight * 0.6} right={-baseHeight * 0.6}
@@ -73,8 +170,22 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
/> />
)} )}
</FlagContainer> </FlagContainer>
</BaseBackground> </BaseLayout>
{showPortrait && ( {showPortrait && (
<VenetianBlindsTransition
visible={openState !== 0}
delay={1500}
blindsColor={teamColor}
blindsColorFadeDuration={600}
blindsColorFadeDelay={300}
blindsAngle={-45}
blindsOpenDuration={600}
blindsOpenDelay={600}
blindsSize={{ transparent: 2, opaque: 5 }}
wipeAngle={45}
wipeDuration={600}
wipeStartingCorner="bottomRight"
>
<DriverPortraitContainer placement={{ right: "-5px", bottom: "0" }}> <DriverPortraitContainer placement={{ right: "-5px", bottom: "0" }}>
<DriverPortrait <DriverPortrait
driverId={car.driver.id} driverId={car.driver.id}
@@ -82,7 +193,8 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
verticalOffsetPercentage={18} verticalOffsetPercentage={18}
/> />
</DriverPortraitContainer> </DriverPortraitContainer>
</VenetianBlindsTransition>
)} )}
</BaseContainer> </AnimatedBaseContainer>
); );
} }
@@ -1,42 +1,99 @@
import { animated } from "@react-spring/web";
import styled from "styled-components"; import styled from "styled-components";
import { Placement, Px } from "../../../../types/style";
import { placementStyleRules } from "../../../../utils/styling";
type BaseContainerProps = { import { Placement, Px, TransitionArgs } from "../../../../types/style";
import { commonTransition, placementStyleRules } from "../../../../utils/styling";
type TransitionProps = {
open: boolean,
transitionProps: TransitionArgs[],
};
type AnimatedBaseContainerProps = {
width: Px, width: Px,
height: Px, height: Px,
}; };
export const BaseContainer = styled.div<BaseContainerProps>` export const AnimatedBaseContainer = animated(
styled.div<AnimatedBaseContainerProps>`
position: relative; position: relative;
width: ${({ width }) => `${width}px`}; width: ${({ width }) => `${width}px`};
height: ${({ height }) => `${height}px`}; height: ${({ height }) => `${height}px`};
`; `,
BaseContainer.displayName = "BaseContainer"; );
AnimatedBaseContainer.displayName = "AnimatedBaseContainer";
export const BaseBackground = styled.div` const BaseShape = styled.div`
position: relative; position: absolute;
height: 100%;
border-bottom-right-radius: 11px;
`;
export const BaseOutline = styled(BaseShape)<TransitionProps>`
width: 100%;
opacity: ${({ open }) => open ? 1 : 0};
outline: ${({ open }) => open
? "2px solid #ffffff00"
: "5px solid #ffffffff"};
${({ transitionProps }) => commonTransition(transitionProps)};
`;
BaseOutline.displayName = "BaseOutline";
export const BaseBlack = styled(BaseShape)<TransitionProps>`
opacity: ${({ open }) => open ? 1 : 0.1};
width: ${({ open }) => open ? 100 : 0}%;
background-color: black;
${({ transitionProps }) => commonTransition(transitionProps)};
`;
BaseBlack.displayName = "BaseBlack";
type BaseBackgroundColorProps = {
teamColor: string,
};
export const BaseBackgroundColor = styled(BaseShape)<BaseBackgroundColorProps & TransitionProps>`
width: 100%;
background-color: ${({ teamColor }) => teamColor};
opacity: ${({ open }) => open ? 0 : 1};
${({ transitionProps }) => commonTransition(transitionProps)};
`;
BaseBackgroundColor.displayName = "BaseBackgroundColor";
export const BaseLayout = styled(BaseShape)<TransitionProps>`
position: absolute;
height: 100%; height: 100%;
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
border-bottom-right-radius: 11px;
background-color: #000;
overflow: hidden; overflow: hidden;
clip-path: ${({ open }) => open
? "polygon(0 0, 100% 0, 100% 100%, 0 100%)"
: "polygon(0 0, 0 0, -50% 100%, -50% 100%)"};
${({ transitionProps }) => commonTransition(transitionProps)};
`; `;
BaseBackground.displayName = "BaseBackground";
type TeamColorBarProps = { type TeamColorBarProps = {
color: string, color: string,
}; };
export const TeamColorBar = styled.div<TeamColorBarProps>` export const TeamColorBar = styled.div<TeamColorBarProps & TransitionProps>`
position: relative; position: relative;
width: 1%; // 6px; width: 1%; // 6px;
height: 63%; height: 63%;
background-color: ${({ color }) => color}; background-color: ${({ color }) => color};
clip-path: ${({ open }) => open
? "polygon(0 0, 100% 0, 100% 100%, 0 100%)"
: "polygon(0 0, 100% 0, 100% 0, 0 0)"};
${({ transitionProps }) => commonTransition(transitionProps)};
`; `;
TeamColorBar.displayName = "TeamColorBar"; TeamColorBar.displayName = "TeamColorBar";
@@ -103,7 +160,7 @@ type FlagContainerProps = {
width: Px, width: Px,
right: Px, right: Px,
}; };
export const FlagContainer = styled.div<FlagContainerProps>` export const FlagContainer = styled.div<FlagContainerProps & TransitionProps>`
position: absolute; position: absolute;
right: ${({ right }) => `${right}px`}; right: ${({ right }) => `${right}px`};
@@ -115,6 +172,10 @@ export const FlagContainer = styled.div<FlagContainerProps>`
width: ${({ width }) => `${width}px`}; width: ${({ width }) => `${width}px`};
overflow: hidden; overflow: hidden;
opacity: ${({ open }) => open ? 1 : 0};
${({ transitionProps }) => commonTransition(transitionProps)};
`; `;
FlagContainer.displayName = "FlagContainer"; FlagContainer.displayName = "FlagContainer";
+8
View File
@@ -32,3 +32,11 @@ export interface Placement {
* Useful to initialize movements from. * Useful to initialize movements from.
*/ */
export type Corner = "topLeft" | "topRight" | "bottomRight" | "bottomLeft"; export type Corner = "topLeft" | "topRight" | "bottomRight" | "bottomLeft";
export interface TransitionArgs {
property?: string,
duration?: Milliseconds,
timing?: string
delay?: Milliseconds,
}
+11 -1
View File
@@ -1,7 +1,7 @@
import { css }from "styled-components"; import { css }from "styled-components";
import { clamp } from "lodash"; import { clamp } from "lodash";
import { Corner, Fraction, Placement, Px } from "../types/style"; import { Corner, Fraction, Placement, Px, TransitionArgs } from "../types/style";
export function placementStyleRules(pos: Placement) { export function placementStyleRules(pos: Placement) {
return css` return css`
@@ -60,3 +60,13 @@ export function wipeCustomDegClip(
]; ];
} }
} }
export function commonTransition(propsArray: TransitionArgs[]) {
return (
"transition: "
+ propsArray.map(p => `
${p?.property ?? "all"} ${p?.duration ?? 1000}ms ${p?.timing ?? ""} ${p?.delay ?? 0}ms
`).join(", ")
+ ";"
);
}