diff --git a/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/VenetianBlindsTransition.tsx b/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/VenetianBlindsTransition.tsx index 2638c2b..ae01c5d 100644 --- a/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/VenetianBlindsTransition.tsx +++ b/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/VenetianBlindsTransition.tsx @@ -2,21 +2,32 @@ import { useState } from "react"; import { useSpring, animated } from "@react-spring/web"; import useMeasure from "react-use-measure"; -import { VenetianBlindsFilter } from "./styles"; +import { AnimatedVenetianBlindsFilter, VenetianBlindsFilter } from "./styles"; import { wipeCustomDegClip } from "../../../../utils/styling"; -import { Corner } from "../../../../types/style"; +import { Corner, Degrees, Px } from "../../../../types/style"; +import { Milliseconds } from "../../../../types/util"; type VenetianBlindsTransitionProps = { blindsColor: string, - blindsAngle: number, - wipeAngle: number, - wipeDuration: number, + blindsColorFadeDuration: Milliseconds, + blindsColorFadeDelay?: Milliseconds, + blindsAngle: Degrees, + blindsOpenDuration: Milliseconds, + blindsOpenDelay?: Milliseconds, + blindsSize: { opaque: Px, transparent: Px }, + wipeAngle: Degrees, + wipeDuration: Milliseconds, wipeStartingCorner: Corner, }; export const VenetianBlindsTransition = ( { blindsColor, + blindsColorFadeDuration, + blindsColorFadeDelay = 0, blindsAngle, + blindsOpenDuration, + blindsOpenDelay = 0, + blindsSize, wipeAngle, wipeDuration, wipeStartingCorner, @@ -31,11 +42,16 @@ export const VenetianBlindsTransition = ( const [state, toggle] = useState(true); const { wipe } = useSpring({ - from: { wipe: 0 }, wipe: state ? 1 : 0, config: { duration: wipeDuration }, }); + const blindsSpring = useSpring({ + opacity: state ? 1 : 0, + config: { duration: blindsOpenDuration }, + delay: blindsOpenDelay, + }); + return (
toggle(!state)}> + + {children} + {children} diff --git a/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/styles.ts b/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/styles.ts index d15e123..da5ef57 100644 --- a/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/styles.ts +++ b/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/styles.ts @@ -1,23 +1,43 @@ +import { animated } from "@react-spring/web"; import styled from "styled-components"; -import { Px } from "../../../../types/style"; + +import { Degrees, Px } from "../../../../types/style"; +import { Milliseconds } from "../../../../types/util"; type VenetianBlindsFilterProps = { - deg: number, + blindsAngle: Degrees, transparentWidth: Px, opaqueWidth: Px, - opaqueColor: string, + blindsColor: string, + blindsColorFadeDuration: Milliseconds, + blindsColorFadeDelay?: Milliseconds, + blindsClosed: boolean, + mirror?: boolean, }; export const VenetianBlindsFilter = styled.div` + position: ${({ mirror }) => mirror ? "absolute" : null}; + + --A: ${({ mirror }) => mirror ? "transparent" : "black"}; + --B: ${({ mirror }) => mirror ? "black" : "transparent"}; + mask-image: repeating-linear-gradient( - ${({ deg }) => deg}deg, - black, - black ${({ opaqueWidth }) => opaqueWidth}px, - transparent ${({ opaqueWidth }) => opaqueWidth}px, - transparent ${({ transparentWidth, opaqueWidth }) => transparentWidth + opaqueWidth}px + ${({ blindsAngle }) => blindsAngle}deg, + var(--A), + var(--A) ${({ opaqueWidth }) => opaqueWidth}px, + var(--B) ${({ opaqueWidth }) => opaqueWidth}px, + var(--B) ${({ transparentWidth, opaqueWidth }) => transparentWidth + opaqueWidth}px ); > * { - box-shadow: inset 0 0 0 99999px ${({ opaqueColor }) => opaqueColor}; + box-shadow: inset 0 0 0 99999px ${({ blindsColor, blindsClosed }) => + `${blindsColor}${blindsClosed ? "00" : "cc"}`}; + transition: box-shadow + ${({ blindsColorFadeDuration }) => blindsColorFadeDuration}ms + cubic-bezier(0.88, 0.18, 0.96, 0.75) + ${({ blindsColorFadeDelay = 0 }) => blindsColorFadeDelay}ms; } `; VenetianBlindsFilter.displayName = "VenetianBlindsFilter"; + +export const AnimatedVenetianBlindsFilter = animated(VenetianBlindsFilter); +AnimatedVenetianBlindsFilter.displayName = "AnimatedVenetianBlindsFilter"; diff --git a/src/components/Workspaces/CustomWorkSpaces/VenetianBlindsWorkspace/VenetianBlindsWorkspace.tsx b/src/components/Workspaces/CustomWorkSpaces/VenetianBlindsWorkspace/VenetianBlindsWorkspace.tsx index 1afa237..97aebae 100644 --- a/src/components/Workspaces/CustomWorkSpaces/VenetianBlindsWorkspace/VenetianBlindsWorkspace.tsx +++ b/src/components/Workspaces/CustomWorkSpaces/VenetianBlindsWorkspace/VenetianBlindsWorkspace.tsx @@ -16,23 +16,31 @@ export function VenetianBlindsWorkspace() { {prototypeState?.venetianTransition?.mode === "driverPortrait" ? ( ) : ( diff --git a/src/types/style.d.ts b/src/types/style.d.ts index 7fa6fcc..8c627c5 100644 --- a/src/types/style.d.ts +++ b/src/types/style.d.ts @@ -13,6 +13,11 @@ export type Percent = number; */ export type Fraction = number; +/** + * Type to remind you that we're dealing with degrees (0-360, etc). + */ +export type Degrees = number; + /** * Object to cleanly define relative/absolute placement for a styled component. */ diff --git a/src/types/util.d.ts b/src/types/util.d.ts index 86126fb..09ccfa6 100644 --- a/src/types/util.d.ts +++ b/src/types/util.d.ts @@ -1,3 +1,11 @@ -export type Optional = TEntity | null; +export type Optional = T | null; + +/** + * Type to remind you that we're dealing with milliseconds. + */ export type Milliseconds = number; + +/** + * Type to remind you that we're dealing with seconds. + */ export type Seconds = number;