diff --git a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx
index 7e9a981..221ec80 100644
--- a/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx
+++ b/src/components/Broadcast/BroadcastDirectorUI/Chyrons/ChyronsDirectorControls.tsx
@@ -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,34 +38,29 @@ 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]);
- const onOpen = () => {
- if (chyronMode === "driver") {
- if (selectedCars.length === 0) return;
- let primaryCar = selectedCars[0];
- let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
+ // 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]);
- // Auto-sort drivers by position so trailing car always appears second.
- if (chyronSubMode === "medium" && secondaryCar != null
- && secondaryCar.position < primaryCar.position) {
- secondaryCar = selectedCars[0];
- primaryCar = selectedCars[1];
- }
- const newChyrons: BGChyrons = {
- openState: 1,
- relativePos: { top: "0", right: "0", bottom: "0", left: "0" },
- mode: chyronMode,
- subMode: chyronSubMode,
- driver: {
- primary: buildDriverChyron(primaryCar),
- secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null,
- },
- };
- dispatch(setChyrons(newChyrons));
- }
+
+ const onOpen = () => {
+ // dispatch(setChyronsOpenState(1));
+ buildDriver();
};
const onNext = () => {
@@ -72,7 +68,32 @@ export function ChyronsDirectorControls() {
};
const onClose = () => {
- dispatch(clearChyrons());
+ 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;
+
+ // Auto-sort drivers by position so trailing car always appears second.
+ if (chyronSubMode === "medium" && secondaryCar != null
+ && secondaryCar.position < primaryCar.position) {
+ secondaryCar = selectedCars[0];
+ primaryCar = selectedCars[1];
+ }
+ const newChyrons: BGChyrons = {
+ openState: 0,
+ relativePos: { top: "0", right: "0", bottom: "0", left: "0" },
+ mode: chyronMode,
+ subMode: chyronSubMode,
+ driver: {
+ primary: buildDriverChyron(primaryCar),
+ secondary: secondaryCar != null ? buildDriverChyron(secondaryCar) : null,
+ },
+ };
+ dispatch(setChyrons(newChyrons));
};
const buildDriverChyron = (car: Car): BGChyronDriver => ({
@@ -136,19 +157,19 @@ export function ChyronsDirectorControls() {
onClick={onOpen}
disabled={chyrons != null}
>
-
+
-
+
diff --git a/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx b/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx
index 908d367..cf5186e 100644
--- a/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx
+++ b/src/components/BroadcastGraphics/Chyrons/Container/ChyronContainer.tsx
@@ -14,6 +14,7 @@ export function ChyronContainer() {
);
if (chyrons.subMode === "medium" && chyrons.driver.secondary) {
@@ -23,6 +24,7 @@ export function ChyronContainer() {
);
diff --git a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx
index be19b50..c4e61a5 100644
--- a/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx
+++ b/src/components/BroadcastGraphics/Chyrons/Driver/ChyronDriver.tsx
@@ -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 (
-
-
+
+
+
+
+
{showPosFlag && (
-
+
+
+
)}
-
+
@@ -62,6 +153,12 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
{car.driver.team.shortName}
)}
-
+
{showPortrait && (
-
-
-
+
+
+
+
+
)}
-
+
);
}
diff --git a/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts b/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts
index 537c022..2814542 100644
--- a/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts
+++ b/src/components/BroadcastGraphics/Chyrons/Driver/styles.ts
@@ -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`
- position: relative;
- width: ${({ width }) => `${width}px`};
- height: ${({ height }) => `${height}px`};
-`;
-BaseContainer.displayName = "BaseContainer";
+export const AnimatedBaseContainer = animated(
+ styled.div`
+ position: relative;
+ width: ${({ width }) => `${width}px`};
+ height: ${({ height }) => `${height}px`};
+ `,
+);
+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)`
+ 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)`
+ 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)`
+ width: 100%;
+
+ background-color: ${({ teamColor }) => teamColor};
+ opacity: ${({ open }) => open ? 0 : 1};
+
+ ${({ transitionProps }) => commonTransition(transitionProps)};
+`;
+BaseBackgroundColor.displayName = "BaseBackgroundColor";
+
+export const BaseLayout = styled(BaseShape)`
+ 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`
+export const TeamColorBar = styled.div`
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`
+export const FlagContainer = styled.div`
position: absolute;
right: ${({ right }) => `${right}px`};
@@ -115,6 +172,10 @@ export const FlagContainer = styled.div`
width: ${({ width }) => `${width}px`};
overflow: hidden;
+
+ opacity: ${({ open }) => open ? 1 : 0};
+
+ ${({ transitionProps }) => commonTransition(transitionProps)};
`;
FlagContainer.displayName = "FlagContainer";
diff --git a/src/types/style.d.ts b/src/types/style.d.ts
index 8c627c5..64e22dd 100644
--- a/src/types/style.d.ts
+++ b/src/types/style.d.ts
@@ -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,
+}
diff --git a/src/utils/styling.ts b/src/utils/styling.ts
index d94b93e..15f3f60 100644
--- a/src/utils/styling.ts
+++ b/src/utils/styling.ts
@@ -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(", ")
+ + ";"
+ );
+}