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:
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 { Stack } from "@bedrock-layout/stack";
|
||||
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 { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
clearChyrons,
|
||||
incrementChyronsOpenState,
|
||||
setChyrons,
|
||||
setChyronsOpenState,
|
||||
} from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||
import { flagModeList, getChyronModesList, getChyronSubModesList } from "../../../../domain/data/broadcastGraphics";
|
||||
import { BGChyronDriver, BGChyronMode, BGChyrons, BGChyronSubMode, Car, FlagMode } from "../../../../types/state";
|
||||
@@ -37,12 +38,41 @@ export function ChyronsDirectorControls() {
|
||||
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
||||
const { selectedCars } = useSelector(broadcastDirectorSelector);
|
||||
|
||||
|
||||
|
||||
// Handle changes to the chyron mode so submodes can be changed accordingly.
|
||||
useEffect(() => {
|
||||
setChyronSubModes(getChyronSubModesList(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 = () => {
|
||||
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;
|
||||
let primaryCar = selectedCars[0];
|
||||
let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
|
||||
@@ -54,7 +84,7 @@ export function ChyronsDirectorControls() {
|
||||
primaryCar = selectedCars[1];
|
||||
}
|
||||
const newChyrons: BGChyrons = {
|
||||
openState: 1,
|
||||
openState: 0,
|
||||
relativePos: { top: "0", right: "0", bottom: "0", left: "0" },
|
||||
mode: chyronMode,
|
||||
subMode: chyronSubMode,
|
||||
@@ -64,15 +94,6 @@ export function ChyronsDirectorControls() {
|
||||
},
|
||||
};
|
||||
dispatch(setChyrons(newChyrons));
|
||||
}
|
||||
};
|
||||
|
||||
const onNext = () => {
|
||||
dispatch(incrementChyronsOpenState());
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
dispatch(clearChyrons());
|
||||
};
|
||||
|
||||
const buildDriverChyron = (car: Car): BGChyronDriver => ({
|
||||
@@ -136,19 +157,19 @@ export function ChyronsDirectorControls() {
|
||||
onClick={onOpen}
|
||||
disabled={chyrons != null}
|
||||
>
|
||||
<FaPlay size="0.8em" />
|
||||
<FaCheck size="0.8em" />
|
||||
</OpenButton>
|
||||
<Button
|
||||
onClick={onNext}
|
||||
disabled={chyrons == null}
|
||||
disabled={chyrons == null || chyrons.openState === -1}
|
||||
>
|
||||
<FaStepForward size="0.8em" />
|
||||
</Button>
|
||||
<CloseButton
|
||||
onClick={onClose}
|
||||
disabled={chyrons == null}
|
||||
disabled={chyrons == null || chyrons.openState <= 0}
|
||||
>
|
||||
<FaStop size="0.8em" />
|
||||
<FaTimes size="0.8em" />
|
||||
</CloseButton>
|
||||
</Inline>
|
||||
</Inline>
|
||||
|
||||
@@ -14,6 +14,7 @@ export function ChyronContainer() {
|
||||
<ChyronDriver
|
||||
chyronData={chyrons.driver.primary}
|
||||
subMode={chyrons.subMode}
|
||||
openState={chyrons.openState}
|
||||
/>
|
||||
);
|
||||
if (chyrons.subMode === "medium" && chyrons.driver.secondary) {
|
||||
@@ -23,6 +24,7 @@ export function ChyronContainer() {
|
||||
<ChyronDriver
|
||||
chyronData={chyrons.driver.secondary}
|
||||
subMode={chyrons.subMode}
|
||||
openState={chyrons.openState}
|
||||
/>
|
||||
</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";
|
||||
|
||||
@@ -7,7 +8,11 @@ import { AngledFlag } from "../../Common/AngledFlag";
|
||||
import { PositionFlag } from "../../Common/PositionFlag";
|
||||
import { DriverPortrait } from "../../Common/DriverPortrait";
|
||||
import {
|
||||
BaseBackground,
|
||||
AnimatedBaseContainer,
|
||||
BaseLayout,
|
||||
BaseOutline,
|
||||
BaseBlack,
|
||||
BaseBackgroundColor,
|
||||
FirstName,
|
||||
LastName,
|
||||
NameContainer,
|
||||
@@ -17,15 +22,18 @@ import {
|
||||
TeamName,
|
||||
TextContainer,
|
||||
FlagContainer,
|
||||
BaseContainer,
|
||||
DriverPortraitContainer,
|
||||
} from "./styles";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||
import { VenetianBlindsTransition } from "../../Common/VenetianBlindsTransition";
|
||||
|
||||
type ChyronDriverProps = {
|
||||
chyronData: BGChyronDriver,
|
||||
subMode: BGChyronSubMode,
|
||||
openState: OpenState,
|
||||
};
|
||||
export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
export function ChyronDriver({ chyronData, subMode, openState }: ChyronDriverProps) {
|
||||
const [baseWidth, baseHeight] = subMode === "medium" ? [582, 72]
|
||||
: subMode === "large" ? [638, 98]
|
||||
: [0, 0];
|
||||
@@ -35,15 +43,98 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
? { flagMode, flag: car.driver.nationality }
|
||||
: 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 (
|
||||
<BaseContainer width={baseWidth} height={baseHeight}>
|
||||
<BaseBackground >
|
||||
<AnimatedBaseContainer
|
||||
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" />
|
||||
{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} />
|
||||
</VenetianBlindsTransition>
|
||||
)}
|
||||
<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" />
|
||||
<TextContainer>
|
||||
<NameContainer>
|
||||
@@ -62,6 +153,12 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
<TeamName>{car.driver.team.shortName}</TeamName>
|
||||
</TextContainer>
|
||||
<FlagContainer
|
||||
open={openState !== 0}
|
||||
transitionProps={[{
|
||||
property: "opacity",
|
||||
duration: 500,
|
||||
delay: 1000,
|
||||
}]}
|
||||
height={baseHeight * 0.9}
|
||||
width={baseHeight * 3}
|
||||
right={-baseHeight * 0.6}
|
||||
@@ -73,8 +170,22 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
/>
|
||||
)}
|
||||
</FlagContainer>
|
||||
</BaseBackground>
|
||||
</BaseLayout>
|
||||
{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" }}>
|
||||
<DriverPortrait
|
||||
driverId={car.driver.id}
|
||||
@@ -82,7 +193,8 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
||||
verticalOffsetPercentage={18}
|
||||
/>
|
||||
</DriverPortraitContainer>
|
||||
</VenetianBlindsTransition>
|
||||
)}
|
||||
</BaseContainer>
|
||||
</AnimatedBaseContainer>
|
||||
);
|
||||
}
|
||||
@@ -1,42 +1,99 @@
|
||||
import { animated } from "@react-spring/web";
|
||||
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,
|
||||
height: Px,
|
||||
};
|
||||
export const BaseContainer = styled.div<BaseContainerProps>`
|
||||
export const AnimatedBaseContainer = animated(
|
||||
styled.div<AnimatedBaseContainerProps>`
|
||||
position: relative;
|
||||
width: ${({ width }) => `${width}px`};
|
||||
height: ${({ height }) => `${height}px`};
|
||||
`;
|
||||
BaseContainer.displayName = "BaseContainer";
|
||||
`,
|
||||
);
|
||||
AnimatedBaseContainer.displayName = "AnimatedBaseContainer";
|
||||
|
||||
export const BaseBackground = styled.div`
|
||||
position: relative;
|
||||
const BaseShape = styled.div`
|
||||
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%;
|
||||
width: 100%;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
border-bottom-right-radius: 11px;
|
||||
background-color: #000;
|
||||
|
||||
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 = {
|
||||
color: string,
|
||||
};
|
||||
export const TeamColorBar = styled.div<TeamColorBarProps>`
|
||||
export const TeamColorBar = styled.div<TeamColorBarProps & TransitionProps>`
|
||||
position: relative;
|
||||
width: 1%; // 6px;
|
||||
height: 63%;
|
||||
|
||||
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";
|
||||
|
||||
@@ -103,7 +160,7 @@ type FlagContainerProps = {
|
||||
width: Px,
|
||||
right: Px,
|
||||
};
|
||||
export const FlagContainer = styled.div<FlagContainerProps>`
|
||||
export const FlagContainer = styled.div<FlagContainerProps & TransitionProps>`
|
||||
position: absolute;
|
||||
right: ${({ right }) => `${right}px`};
|
||||
|
||||
@@ -115,6 +172,10 @@ export const FlagContainer = styled.div<FlagContainerProps>`
|
||||
width: ${({ width }) => `${width}px`};
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
opacity: ${({ open }) => open ? 1 : 0};
|
||||
|
||||
${({ transitionProps }) => commonTransition(transitionProps)};
|
||||
`;
|
||||
FlagContainer.displayName = "FlagContainer";
|
||||
|
||||
|
||||
Vendored
+8
@@ -32,3 +32,11 @@ export interface Placement {
|
||||
* Useful to initialize movements from.
|
||||
*/
|
||||
export type Corner = "topLeft" | "topRight" | "bottomRight" | "bottomLeft";
|
||||
|
||||
|
||||
export interface TransitionArgs {
|
||||
property?: string,
|
||||
duration?: Milliseconds,
|
||||
timing?: string
|
||||
delay?: Milliseconds,
|
||||
}
|
||||
+11
-1
@@ -1,7 +1,7 @@
|
||||
import { css }from "styled-components";
|
||||
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) {
|
||||
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(", ")
|
||||
+ ";"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user