ISSUE-045 - Venetian Blinds - Working on the basic concept of the blinds filter.

Created a new workspace to test this all out in.
Offering two differing test subjects: A position flag and a driver portrait. This is useful because the images need to be treated differently compared to simple divs.
Figured out a way of tinting both divs and images: Severely offset internal outline styling with semi-opaque colors.
Moved DriverPortrait into its own component. Makes sense as portraits appear in various places. Plan to offer prop between front-facing and 3/4 facing photos (I have a collection of both).
Created a new "Position" type that can be used, with a special function, to place elements through a common prop.
This commit is contained in:
Kyle Geib committed 2022-02-04 15:24:55 -05:00
1 parent e747a7d7c3
commit 38aeedea65
19 files changed
+240 -37

No files matched your search

@@ -5,6 +5,7 @@ import { theme } from "../../../../shared/theme";
import { DriverNumber } from "../../Common/DriverNumber";
import { AngledFlag } from "../../Common/AngledFlag";
import { PositionFlag } from "../../Common/PositionFlag";
import { DriverPortrait } from "../../Common/DriverPortrait";
import {
BaseBackground,
FirstName,
@@ -16,12 +17,10 @@ import {
TeamName,
TextContainer,
FlagContainer,
PortraitDiv,
BaseContainer,
DriverPortraitContainer,
} from "./styles";
const driverPortraits = require.context("../../../../public/images/drivers/front", true);
type ChyronDriverProps = {
chyronData: BGChyronDriver,
subMode: BGChyronSubMode,
@@ -76,11 +75,13 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
</FlagContainer>
</BaseBackground>
{showPortrait && (
<PortraitDiv
src={driverPortraits(`./${car.driver.id}.png`)}
height={baseHeight * 2.5}
rightMargin={-5}
/>
<DriverPortraitContainer placement={{ right: "-5px", bottom: "0" }}>
<DriverPortrait
driverId={car.driver.id}
height={baseHeight * 2.5}
verticalOffsetPercentage={18}
/>
</DriverPortraitContainer>
)}
</BaseContainer>
);
@@ -1,5 +1,6 @@
import styled from "styled-components";
import { Px } from "../../../../types/style";
import { Placement, Px } from "../../../../types/style";
import { placementStyleRules } from "../../../../utils/styling";
type BaseContainerProps = {
width: Px,
@@ -117,23 +118,12 @@ export const FlagContainer = styled.div<FlagContainerProps>`
`;
FlagContainer.displayName = "FlagContainer";
type PortraitDivProps = {
src: string,
height: Px,
rightMargin: Px,
type DriverPortraitContainerProps = {
placement: Placement,
};
export const PortraitDiv = styled.div<PortraitDivProps>`
export const DriverPortraitContainer = styled.div<DriverPortraitContainerProps>`
position: absolute;
height: ${({ height }) => `${height}px`};
width: ${({ height }) => `${height * 1.4}px`};
bottom: 0;
right: ${({ rightMargin }) => `${rightMargin}px`};
background-image: url(${({ src }) => src});
background-size: contain;
background-repeat: no-repeat;
background-position: center ${({ height }) => `${height * .18}px`};
${({ placement }) => placementStyleRules(placement)}
`;
PortraitDiv.displayName = "PortraitDiv";
DriverPortraitContainer.displayName = "DriverPortraitContainer";
@@ -0,0 +1,25 @@
import { DriverId } from "../../../../types/state";
import { Percent, Px } from "../../../../types/style";
import { PortraitDiv } from "./styles";
const driverPortraits = require.context("../../../../public/images/drivers/front", true);
type DriverPortraitProps = {
driverId: DriverId,
height: Px,
verticalOffsetPercentage?: Percent,
};
export function DriverPortrait({
driverId,
height,
verticalOffsetPercentage = 0,
}: DriverPortraitProps) {
return (
<PortraitDiv
src={driverPortraits(`./${driverId}.png`)}
height={height}
verticalOffsetPercentage={verticalOffsetPercentage}
/>
);
}
@@ -0,0 +1 @@
export * from "./DriverPortrait";
@@ -0,0 +1,29 @@
import styled from "styled-components";
import { Percent, Px } from "../../../../types/style";
type PortraitDivProps = {
src: string,
height: Px,
verticalOffsetPercentage: Percent,
};
export const PortraitDiv = styled.div<PortraitDivProps>`
height: ${({ height }) => `${height}px`};
width: ${({ height }) => `${height * 1.4}px`};
--image: url(${({ src }) => src});
--position: center ${({ height, verticalOffsetPercentage }) =>
`${height * (verticalOffsetPercentage / 100)}px`};
background-image: var(--image);
background-size: contain;
background-repeat: no-repeat;
background-position: var(--position);
/* Redundant masking to allow special filters to work. */
mask-image: var(--image);
mask-size: contain;
mask-repeat: no-repeat;
mask-position: var(--position);
`;
PortraitDiv.displayName = "PortraitDiv";
@@ -0,0 +1,17 @@
import { VenetianBlindsFilter } from "./styles";
type VenetianBlindsTransitionProps = {
color: string,
};
export const VenetianBlindsTransition = (
{ color, children }: React.PropsWithChildren<VenetianBlindsTransitionProps>,
) => (
<VenetianBlindsFilter
deg={-45}
transparentWidth={3}
opaqueWidth={5}
opaqueColor={color}
>
{children}
</VenetianBlindsFilter>
);
@@ -0,0 +1 @@
export * from "./VenetianBlindsTransition";
@@ -0,0 +1,23 @@
import styled from "styled-components";
import { Px } from "../../../../types/style";
type VenetianBlindsFilterProps = {
deg: number,
transparentWidth: Px,
opaqueWidth: Px,
opaqueColor: string,
};
export const VenetianBlindsFilter = styled.div<VenetianBlindsFilterProps>`
mask-image: repeating-linear-gradient(
${({ deg }) => deg}deg,
black,
black ${({ opaqueWidth }) => opaqueWidth}px,
transparent ${({ opaqueWidth }) => opaqueWidth}px,
transparent ${({ transparentWidth, opaqueWidth }) => transparentWidth + opaqueWidth}px
);
> * {
box-shadow: inset 0 0 0 99999px ${({ opaqueColor }) => opaqueColor};
}
`;
VenetianBlindsFilter.displayName = "VenetianBlindsFilter";