Files
test/src/components/BroadcastGraphics/Common/VenetianBlindsTransition/styles.ts
T
Kyle Geib 16c29df42f ISSUE-045 - Venetian Blinds - Improvements to Venetian Blinds prototype controls.
Now you have 10 different options (5 for position flag and 5 for driver portrait) to play with, as well as a slot selector to choose different starting corners.
I have to admit that I didn't want to deal with type juggling with DriverId so I do a pretty hacky job. This is just for prototyping purposes so it really shouldn't be much of a focus for me, right?
Added an overall delay prop for VenetianBlindsTransition so that I don't need to deal with special timing issues for the DriverChyron animation in the future.
2022-02-08 15:14:04 -05:00

65 lines
2.0 KiB
TypeScript

import { animated } from "@react-spring/web";
import styled, { css, keyframes } from "styled-components";
import { Degrees, Px } from "../../../../types/style";
import { Milliseconds } from "../../../../types/util";
const spanBlinkAnimation = keyframes`
0% { opacity: 0 }
62% { opacity: 1 }
72% { opacity: 0 }
81% { opacity: 1 }
91% { opacity: 0 }
100% { opacity: 1 }
`;
type VenetianBlindsFilterProps = {
blindsAngle: Degrees,
transparentWidth: Px,
opaqueWidth: Px,
blindsColor: string,
blindsColorFadeDuration: Milliseconds,
blindsColorFadeDelay?: Milliseconds,
blindsClosing: boolean,
mirror?: boolean,
spanBlinkDuration?: Milliseconds,
spanBlinkDelay?: Milliseconds,
};
export const VenetianBlindsFilter = styled.div<VenetianBlindsFilterProps>`
position: ${({ mirror }) => mirror ? "absolute" : null};
--A: ${({ mirror }) => mirror ? "transparent" : "black"};
--B: ${({ mirror }) => mirror ? "black" : "transparent"};
mask-image: repeating-linear-gradient(
${({ 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 ${({ blindsColor, blindsClosing }) =>
`${blindsColor}${blindsClosing ? "00" : "cc"}`};
transition: box-shadow
${({ blindsColorFadeDuration }) => blindsColorFadeDuration}ms
cubic-bezier(0.88, 0.18, 0.96, 0.75)
${({ blindsColorFadeDelay = 0 }) => blindsColorFadeDelay}ms;
}
${({ blindsClosing, spanBlinkDuration, spanBlinkDelay = 0 }) => (
blindsClosing && spanBlinkDuration
? css`
span {
animation: ${spanBlinkAnimation} ${spanBlinkDuration}ms step-end ${spanBlinkDelay}ms;
};
`
: null)
}
`;
VenetianBlindsFilter.displayName = "VenetianBlindsFilter";
export const AnimatedVenetianBlindsFilter = animated(VenetianBlindsFilter);
AnimatedVenetianBlindsFilter.displayName = "AnimatedVenetianBlindsFilter";