ISSUE-045 - Venetian Blinds - Wipe, blinds closing, and blinds color all working.
This commit is contained in:
1 parent
3ce590d794
commit
78073b1eb2
5 files changed
+102
-28
No files matched your search
+44
-11
@@ -2,21 +2,32 @@ import { useState } from "react";
|
|||||||
import { useSpring, animated } from "@react-spring/web";
|
import { useSpring, animated } from "@react-spring/web";
|
||||||
import useMeasure from "react-use-measure";
|
import useMeasure from "react-use-measure";
|
||||||
|
|
||||||
import { VenetianBlindsFilter } from "./styles";
|
import { AnimatedVenetianBlindsFilter, VenetianBlindsFilter } from "./styles";
|
||||||
import { wipeCustomDegClip } from "../../../../utils/styling";
|
import { wipeCustomDegClip } from "../../../../utils/styling";
|
||||||
import { Corner } from "../../../../types/style";
|
import { Corner, Degrees, Px } from "../../../../types/style";
|
||||||
|
import { Milliseconds } from "../../../../types/util";
|
||||||
|
|
||||||
type VenetianBlindsTransitionProps = {
|
type VenetianBlindsTransitionProps = {
|
||||||
blindsColor: string,
|
blindsColor: string,
|
||||||
blindsAngle: number,
|
blindsColorFadeDuration: Milliseconds,
|
||||||
wipeAngle: number,
|
blindsColorFadeDelay?: Milliseconds,
|
||||||
wipeDuration: number,
|
blindsAngle: Degrees,
|
||||||
|
blindsOpenDuration: Milliseconds,
|
||||||
|
blindsOpenDelay?: Milliseconds,
|
||||||
|
blindsSize: { opaque: Px, transparent: Px },
|
||||||
|
wipeAngle: Degrees,
|
||||||
|
wipeDuration: Milliseconds,
|
||||||
wipeStartingCorner: Corner,
|
wipeStartingCorner: Corner,
|
||||||
};
|
};
|
||||||
export const VenetianBlindsTransition = (
|
export const VenetianBlindsTransition = (
|
||||||
{
|
{
|
||||||
blindsColor,
|
blindsColor,
|
||||||
|
blindsColorFadeDuration,
|
||||||
|
blindsColorFadeDelay = 0,
|
||||||
blindsAngle,
|
blindsAngle,
|
||||||
|
blindsOpenDuration,
|
||||||
|
blindsOpenDelay = 0,
|
||||||
|
blindsSize,
|
||||||
wipeAngle,
|
wipeAngle,
|
||||||
wipeDuration,
|
wipeDuration,
|
||||||
wipeStartingCorner,
|
wipeStartingCorner,
|
||||||
@@ -31,11 +42,16 @@ export const VenetianBlindsTransition = (
|
|||||||
const [state, toggle] = useState(true);
|
const [state, toggle] = useState(true);
|
||||||
|
|
||||||
const { wipe } = useSpring({
|
const { wipe } = useSpring({
|
||||||
from: { wipe: 0 },
|
|
||||||
wipe: state ? 1 : 0,
|
wipe: state ? 1 : 0,
|
||||||
config: { duration: wipeDuration },
|
config: { duration: wipeDuration },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const blindsSpring = useSpring({
|
||||||
|
opacity: state ? 1 : 0,
|
||||||
|
config: { duration: blindsOpenDuration },
|
||||||
|
delay: blindsOpenDelay,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div onClick={() => toggle(!state)}>
|
<div onClick={() => toggle(!state)}>
|
||||||
<animated.div
|
<animated.div
|
||||||
@@ -51,13 +67,30 @@ export const VenetianBlindsTransition = (
|
|||||||
return `polygon(${a1}px ${a2}px, ${b1}px ${b2}px, ${c1}px ${c2}px)`;
|
return `polygon(${a1}px ${a2}px, ${b1}px ${b2}px, ${c1}px ${c2}px)`;
|
||||||
}),
|
}),
|
||||||
}}
|
}}
|
||||||
|
ref={childRef}
|
||||||
>
|
>
|
||||||
|
<AnimatedVenetianBlindsFilter
|
||||||
|
style={blindsSpring}
|
||||||
|
blindsAngle={blindsAngle}
|
||||||
|
transparentWidth={blindsSize.transparent}
|
||||||
|
opaqueWidth={blindsSize.opaque}
|
||||||
|
blindsColor={blindsColor}
|
||||||
|
blindsColorFadeDuration={blindsColorFadeDuration}
|
||||||
|
blindsColorFadeDelay={blindsColorFadeDelay}
|
||||||
|
blindsClosed={!!state}
|
||||||
|
mirror={true} // Mirror version provides the opposite blinds.
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</AnimatedVenetianBlindsFilter>
|
||||||
<VenetianBlindsFilter
|
<VenetianBlindsFilter
|
||||||
deg={blindsAngle}
|
blindsAngle={blindsAngle}
|
||||||
transparentWidth={3}
|
transparentWidth={blindsSize.transparent}
|
||||||
opaqueWidth={5}
|
opaqueWidth={blindsSize.opaque}
|
||||||
opaqueColor={blindsColor}
|
blindsColor={blindsColor}
|
||||||
ref={childRef}
|
blindsColorFadeDuration={blindsColorFadeDuration}
|
||||||
|
blindsColorFadeDelay={blindsColorFadeDelay}
|
||||||
|
blindsClosed={!!state}
|
||||||
|
mirror={false}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</VenetianBlindsFilter>
|
</VenetianBlindsFilter>
|
||||||
|
|||||||
@@ -1,23 +1,43 @@
|
|||||||
|
import { animated } from "@react-spring/web";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { Px } from "../../../../types/style";
|
|
||||||
|
import { Degrees, Px } from "../../../../types/style";
|
||||||
|
import { Milliseconds } from "../../../../types/util";
|
||||||
|
|
||||||
type VenetianBlindsFilterProps = {
|
type VenetianBlindsFilterProps = {
|
||||||
deg: number,
|
blindsAngle: Degrees,
|
||||||
transparentWidth: Px,
|
transparentWidth: Px,
|
||||||
opaqueWidth: Px,
|
opaqueWidth: Px,
|
||||||
opaqueColor: string,
|
blindsColor: string,
|
||||||
|
blindsColorFadeDuration: Milliseconds,
|
||||||
|
blindsColorFadeDelay?: Milliseconds,
|
||||||
|
blindsClosed: boolean,
|
||||||
|
mirror?: boolean,
|
||||||
};
|
};
|
||||||
export const VenetianBlindsFilter = styled.div<VenetianBlindsFilterProps>`
|
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(
|
mask-image: repeating-linear-gradient(
|
||||||
${({ deg }) => deg}deg,
|
${({ blindsAngle }) => blindsAngle}deg,
|
||||||
black,
|
var(--A),
|
||||||
black ${({ opaqueWidth }) => opaqueWidth}px,
|
var(--A) ${({ opaqueWidth }) => opaqueWidth}px,
|
||||||
transparent ${({ opaqueWidth }) => opaqueWidth}px,
|
var(--B) ${({ opaqueWidth }) => opaqueWidth}px,
|
||||||
transparent ${({ transparentWidth, opaqueWidth }) => transparentWidth + 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";
|
VenetianBlindsFilter.displayName = "VenetianBlindsFilter";
|
||||||
|
|
||||||
|
export const AnimatedVenetianBlindsFilter = animated(VenetianBlindsFilter);
|
||||||
|
AnimatedVenetianBlindsFilter.displayName = "AnimatedVenetianBlindsFilter";
|
||||||
+15
-7
@@ -16,23 +16,31 @@ export function VenetianBlindsWorkspace() {
|
|||||||
<BasicBlock width={450} height={450} color={bgColor} >
|
<BasicBlock width={450} height={450} color={bgColor} >
|
||||||
{prototypeState?.venetianTransition?.mode === "driverPortrait" ? (
|
{prototypeState?.venetianTransition?.mode === "driverPortrait" ? (
|
||||||
<VenetianBlindsTransition
|
<VenetianBlindsTransition
|
||||||
blindsColor={theme.colors.teams.mercedes + "b5"}
|
blindsColor={theme.colors.teams.redBull}
|
||||||
|
blindsColorFadeDuration={600}
|
||||||
|
blindsColorFadeDelay={300}
|
||||||
blindsAngle={-45}
|
blindsAngle={-45}
|
||||||
|
blindsOpenDuration={600}
|
||||||
|
blindsOpenDelay={600}
|
||||||
|
blindsSize={{ transparent: 2, opaque: 5 }}
|
||||||
wipeAngle={45}
|
wipeAngle={45}
|
||||||
wipeDuration={500}
|
wipeDuration={600}
|
||||||
wipeStartingCorner="topLeft"
|
wipeStartingCorner="topLeft"
|
||||||
>
|
>
|
||||||
<DriverPortrait
|
<DriverPortrait
|
||||||
driverId="hamilton"
|
driverId="verstappen"
|
||||||
height={150}
|
height={250}
|
||||||
/>
|
/>
|
||||||
</VenetianBlindsTransition>
|
</VenetianBlindsTransition>
|
||||||
) : (
|
) : (
|
||||||
<VenetianBlindsTransition
|
<VenetianBlindsTransition
|
||||||
blindsColor="#f60d0db5"
|
blindsColor="#f60d0d"
|
||||||
|
blindsColorFadeDuration={400}
|
||||||
blindsAngle={-45}
|
blindsAngle={-45}
|
||||||
wipeAngle={35}
|
blindsOpenDuration={120}
|
||||||
wipeDuration={350}
|
blindsSize={{ transparent: 3, opaque: 6 }}
|
||||||
|
wipeAngle={40}
|
||||||
|
wipeDuration={200}
|
||||||
wipeStartingCorner="bottomRight"
|
wipeStartingCorner="bottomRight"
|
||||||
>
|
>
|
||||||
<PositionFlag size={122} number={1} />
|
<PositionFlag size={122} number={1} />
|
||||||
|
|||||||
Vendored
+5
@@ -13,6 +13,11 @@ export type Percent = number;
|
|||||||
*/
|
*/
|
||||||
export type Fraction = 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.
|
* Object to cleanly define relative/absolute placement for a styled component.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
+9
-1
@@ -1,3 +1,11 @@
|
|||||||
export type Optional<TEntity> = TEntity | null;
|
export type Optional<T> = T | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type to remind you that we're dealing with milliseconds.
|
||||||
|
*/
|
||||||
export type Milliseconds = number;
|
export type Milliseconds = number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type to remind you that we're dealing with seconds.
|
||||||
|
*/
|
||||||
export type Seconds = number;
|
export type Seconds = number;
|
||||||
Reference in new issue
Block a user