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:
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 { DriverNumber } from "../../Common/DriverNumber";
|
||||||
import { AngledFlag } from "../../Common/AngledFlag";
|
import { AngledFlag } from "../../Common/AngledFlag";
|
||||||
import { PositionFlag } from "../../Common/PositionFlag";
|
import { PositionFlag } from "../../Common/PositionFlag";
|
||||||
|
import { DriverPortrait } from "../../Common/DriverPortrait";
|
||||||
import {
|
import {
|
||||||
BaseBackground,
|
BaseBackground,
|
||||||
FirstName,
|
FirstName,
|
||||||
@@ -16,12 +17,10 @@ import {
|
|||||||
TeamName,
|
TeamName,
|
||||||
TextContainer,
|
TextContainer,
|
||||||
FlagContainer,
|
FlagContainer,
|
||||||
PortraitDiv,
|
|
||||||
BaseContainer,
|
BaseContainer,
|
||||||
|
DriverPortraitContainer,
|
||||||
} from "./styles";
|
} from "./styles";
|
||||||
|
|
||||||
const driverPortraits = require.context("../../../../public/images/drivers/front", true);
|
|
||||||
|
|
||||||
type ChyronDriverProps = {
|
type ChyronDriverProps = {
|
||||||
chyronData: BGChyronDriver,
|
chyronData: BGChyronDriver,
|
||||||
subMode: BGChyronSubMode,
|
subMode: BGChyronSubMode,
|
||||||
@@ -76,11 +75,13 @@ export function ChyronDriver({ chyronData, subMode }: ChyronDriverProps) {
|
|||||||
</FlagContainer>
|
</FlagContainer>
|
||||||
</BaseBackground>
|
</BaseBackground>
|
||||||
{showPortrait && (
|
{showPortrait && (
|
||||||
<PortraitDiv
|
<DriverPortraitContainer placement={{ right: "-5px", bottom: "0" }}>
|
||||||
src={driverPortraits(`./${car.driver.id}.png`)}
|
<DriverPortrait
|
||||||
height={baseHeight * 2.5}
|
driverId={car.driver.id}
|
||||||
rightMargin={-5}
|
height={baseHeight * 2.5}
|
||||||
/>
|
verticalOffsetPercentage={18}
|
||||||
|
/>
|
||||||
|
</DriverPortraitContainer>
|
||||||
)}
|
)}
|
||||||
</BaseContainer>
|
</BaseContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { Px } from "../../../../types/style";
|
import { Placement, Px } from "../../../../types/style";
|
||||||
|
import { placementStyleRules } from "../../../../utils/styling";
|
||||||
|
|
||||||
type BaseContainerProps = {
|
type BaseContainerProps = {
|
||||||
width: Px,
|
width: Px,
|
||||||
@@ -117,23 +118,12 @@ export const FlagContainer = styled.div<FlagContainerProps>`
|
|||||||
`;
|
`;
|
||||||
FlagContainer.displayName = "FlagContainer";
|
FlagContainer.displayName = "FlagContainer";
|
||||||
|
|
||||||
type PortraitDivProps = {
|
type DriverPortraitContainerProps = {
|
||||||
src: string,
|
placement: Placement,
|
||||||
height: Px,
|
|
||||||
rightMargin: Px,
|
|
||||||
};
|
};
|
||||||
export const PortraitDiv = styled.div<PortraitDivProps>`
|
export const DriverPortraitContainer = styled.div<DriverPortraitContainerProps>`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
height: ${({ height }) => `${height}px`};
|
${({ placement }) => placementStyleRules(placement)}
|
||||||
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`};
|
|
||||||
`;
|
`;
|
||||||
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";
|
||||||
+17
@@ -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";
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import { workspaceSelector } from "../../../../features/workspace/workspaceSelec
|
|||||||
import { FlagMode, TeamId } from "../../../../types/state";
|
import { FlagMode, TeamId } from "../../../../types/state";
|
||||||
|
|
||||||
import { AngledFlag } from "../../../BroadcastGraphics/Common/AngledFlag";
|
import { AngledFlag } from "../../../BroadcastGraphics/Common/AngledFlag";
|
||||||
import { BasicBlock } from "./styles";
|
import { BasicBlock } from "../styles";
|
||||||
|
|
||||||
type AngledFlagWorkspaceProps = {
|
type AngledFlagWorkspaceProps = {
|
||||||
flagMode: FlagMode,
|
flagMode: FlagMode,
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
import { useSelector } from "react-redux";
|
||||||
|
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||||
|
import { theme } from "../../../../shared/theme";
|
||||||
|
import { DriverPortrait } from "../../../BroadcastGraphics/Common/DriverPortrait";
|
||||||
|
import { PositionFlag } from "../../../BroadcastGraphics/Common/PositionFlag";
|
||||||
|
import { VenetianBlindsTransition } from "../../../BroadcastGraphics/Common/VenetianBlindsTransition";
|
||||||
|
import { BasicBlock } from "../styles";
|
||||||
|
|
||||||
|
export function VenetianBlindsWorkspace() {
|
||||||
|
const { prototypeState } = useSelector(workspaceSelector);
|
||||||
|
|
||||||
|
const bgColor = prototypeState?.venetianTransition?.showBG
|
||||||
|
? "black" : "transparent";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BasicBlock width={450} height={450} color={bgColor} >
|
||||||
|
{prototypeState?.venetianTransition?.mode === "driverPortrait" ? (
|
||||||
|
<VenetianBlindsTransition color={theme.colors.teams.mercedes + "b5"}>
|
||||||
|
<DriverPortrait
|
||||||
|
driverId="hamilton"
|
||||||
|
height={150}
|
||||||
|
/>
|
||||||
|
</VenetianBlindsTransition>
|
||||||
|
) : (
|
||||||
|
<VenetianBlindsTransition color="#f60d0db5">
|
||||||
|
<PositionFlag size={122} number={1} />
|
||||||
|
</VenetianBlindsTransition>
|
||||||
|
)}
|
||||||
|
</BasicBlock>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./VenetianBlindsWorkspace";
|
||||||
+2
-1
@@ -1,5 +1,5 @@
|
|||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { Px } from "../../../../types/style";
|
import { Px } from "../../../types/style";
|
||||||
|
|
||||||
type BasicBlockProps = {
|
type BasicBlockProps = {
|
||||||
width: Px,
|
width: Px,
|
||||||
@@ -19,3 +19,4 @@ export const BasicBlock = styled.div<BasicBlockProps>`
|
|||||||
|
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
`;
|
`;
|
||||||
|
BasicBlock.displayName = "BasicBlock";
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||||
|
import { setPrototypeState } from "../../../../features/workspace/workspaceSlice";
|
||||||
|
import { VenetianTransitionWorkspaceMode } from "../../../../types/state";
|
||||||
|
|
||||||
|
import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
|
||||||
|
import { Toggle } from "../../../Common/Inputs/Toggle";
|
||||||
|
|
||||||
|
const modes: Array<VenetianTransitionWorkspaceMode> = [
|
||||||
|
"positionFlag",
|
||||||
|
"driverPortrait",
|
||||||
|
];
|
||||||
|
|
||||||
|
export function VenetianBlindsPrototypeControls() {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { prototypeState } = useSelector(workspaceSelector);
|
||||||
|
|
||||||
|
const onChange = (index: number) => {
|
||||||
|
dispatch(setPrototypeState({
|
||||||
|
venetianTransition: {
|
||||||
|
mode: modes[index],
|
||||||
|
showBG: prototypeState?.venetianTransition?.showBG ?? false,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const onToggle = (value: boolean) => {
|
||||||
|
dispatch(setPrototypeState({
|
||||||
|
venetianTransition: {
|
||||||
|
mode: prototypeState?.venetianTransition?.mode ?? "positionFlag",
|
||||||
|
showBG: value,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<InlineCluster as={PadBox} gutter="md" padding="md">
|
||||||
|
<SlotSelector
|
||||||
|
items={modes}
|
||||||
|
onChange={onChange}
|
||||||
|
label="Mode"
|
||||||
|
slotWidth="200px"
|
||||||
|
/>
|
||||||
|
<Toggle
|
||||||
|
toggled={prototypeState?.venetianTransition?.showBG ?? false}
|
||||||
|
onToggle={onToggle}
|
||||||
|
label="Show BG"
|
||||||
|
/>
|
||||||
|
</InlineCluster>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./VenetianBlindsPrototypeControls";
|
||||||
@@ -7,6 +7,7 @@ import { mainMenuDimensionsSelector } from "../../features/pageDimensions/pageDi
|
|||||||
import { setDimensions } from "../../features/pageDimensions/pageDimensionsSlice";
|
import { setDimensions } from "../../features/pageDimensions/pageDimensionsSlice";
|
||||||
|
|
||||||
import { FullScreenContainer } from "../Common/FullScreenContainer.styled";
|
import { FullScreenContainer } from "../Common/FullScreenContainer.styled";
|
||||||
|
import { IndexHeading } from "../Common/IndexHeading.styled";
|
||||||
import { WorkspaceList } from "./WorkspaceList";
|
import { WorkspaceList } from "./WorkspaceList";
|
||||||
import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
|
import { LayoutGrid, LayoutGridItem } from "../Common/LayoutGrid.styled";
|
||||||
|
|
||||||
@@ -15,7 +16,8 @@ import { ChyronPrototypeControls } from "./PrototypingControls/ChyronPrototype";
|
|||||||
import { AngledFlagWorkspace } from "./CustomWorkSpaces/AngledFlagWorkspace";
|
import { AngledFlagWorkspace } from "./CustomWorkSpaces/AngledFlagWorkspace";
|
||||||
import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPrototype";
|
import { AngledFlagPrototypeControls } from "./PrototypingControls/AngledFlagPrototype";
|
||||||
import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
||||||
import { IndexHeading } from "../Common/IndexHeading.styled";
|
import { VenetianBlindsWorkspace } from "./CustomWorkSpaces/VenetianBlindsWorkspace";
|
||||||
|
import { VenetianBlindsPrototypeControls } from "./PrototypingControls/VenetianBlindsPrototype";
|
||||||
|
|
||||||
const WORKSPACE_LIST_WIDTH = 180;
|
const WORKSPACE_LIST_WIDTH = 180;
|
||||||
|
|
||||||
@@ -78,11 +80,11 @@ export default function Workspaces() {
|
|||||||
prototypeControls={<AngledFlagPrototypeControls flagMode="team"/>}
|
prototypeControls={<AngledFlagPrototypeControls flagMode="team"/>}
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
<Route path="venetianTransitionPosFlag" element={
|
<Route path="venetianTransition" element={
|
||||||
<Workspace
|
<Workspace
|
||||||
workspaceId="venetianTransitionPosFlag"
|
workspaceId="venetianTransition"
|
||||||
previewContent={null}
|
previewContent={<VenetianBlindsWorkspace />}
|
||||||
prototypeControls={null}
|
prototypeControls={<VenetianBlindsPrototypeControls />}
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
|
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ export const workspaces: WorkspaceObject = {
|
|||||||
height: 500,
|
height: 500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
venetianTransitionPosFlag: {
|
venetianTransition: {
|
||||||
name: "Venetian Transition (Pos Flag)",
|
name: "Venetian Transition",
|
||||||
overlayIds: [
|
overlayIds: [
|
||||||
"venetian-pos-1.png",
|
"venetian-pos-1.png",
|
||||||
"venetian-pos-2.png",
|
"venetian-pos-2.png",
|
||||||
@@ -79,8 +79,8 @@ export const workspaces: WorkspaceObject = {
|
|||||||
"venetian-pos-7.png",
|
"venetian-pos-7.png",
|
||||||
],
|
],
|
||||||
previewWindowDimensions: {
|
previewWindowDimensions: {
|
||||||
width: 300,
|
width: 700,
|
||||||
height: 300,
|
height: 500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
Vendored
+5
@@ -40,7 +40,12 @@ export interface PrototypeState {
|
|||||||
flagA: TeamId;
|
flagA: TeamId;
|
||||||
flagB: TeamId;
|
flagB: TeamId;
|
||||||
};
|
};
|
||||||
|
venetianTransition?: {
|
||||||
|
mode: VenetianTransitionWorkspaceMode;
|
||||||
|
showBG: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
export type VenetianTransitionWorkspaceMode = "positionFlag" | "driverPortrait";
|
||||||
|
|
||||||
// Overlay Tool
|
// Overlay Tool
|
||||||
export interface OverlayTool {
|
export interface OverlayTool {
|
||||||
|
|||||||
Vendored
+11
-1
@@ -4,6 +4,16 @@
|
|||||||
export type Px = number;
|
export type Px = number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type to remind you that we're dealing with percentages.
|
* Type to remind you that we're dealing with percentages (100 = 100%).
|
||||||
*/
|
*/
|
||||||
export type Percent = number;
|
export type Percent = number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object to cleanly define relative/absolute placement for a styled component.
|
||||||
|
*/
|
||||||
|
export interface Placement {
|
||||||
|
top?: string;
|
||||||
|
right?: string;
|
||||||
|
bottom?: string;
|
||||||
|
left?: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { css }from "styled-components";
|
||||||
|
|
||||||
|
import { Placement } from "../types/style";
|
||||||
|
|
||||||
|
export function placementStyleRules(pos: Placement) {
|
||||||
|
return css`
|
||||||
|
${pos.top ? `top: ${pos.top};` : ""}
|
||||||
|
${pos.right ? `right: ${pos.right};` : ""}
|
||||||
|
${pos.bottom ? `bottom: ${pos.bottom};` : ""}
|
||||||
|
${pos.left ? `left: ${pos.left};` : ""}
|
||||||
|
`;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user