ISSUE-031 - Big update. AngledFlag component is born!
It's not 100% complete - I still need to add the second, slightly offset sub flag that goes beneath the main flag, creating a sort of refractive-glass/parallax effect. Needed to add a new workspace. Thankfully it's pretty easy to add a new workspace. So, kinda nice. Did a lot of work making 2:1 versions of each flag in vector. Was a bit of a pain in the ass. Renamed a prop for ProgressSlider, "onBarColor" because prefixing a prop with "on" is special for React and it gets upset and spits out an error.
This commit is contained in:
1 parent
55e07a444e
commit
4a9c124832
46 files changed
+1063
-70
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { DriverNumber } from "../../Common/DriverNumber";
|
||||
import { AngledFlag } from "../../Common/AngledFlag";
|
||||
import {
|
||||
BaseBackground,
|
||||
FirstName,
|
||||
@@ -11,10 +12,14 @@ import {
|
||||
TeamColorBar,
|
||||
TeamName,
|
||||
TextContainer,
|
||||
FlagContainer,
|
||||
} from "./styles";
|
||||
import { drivers } from "../../../../domain/data/teams";
|
||||
import { theme } from "../../../../shared/theme";
|
||||
|
||||
export function ChyronDriver() {
|
||||
// TODO - Get driver details from Redux.
|
||||
const driver = drivers["hamilton"];
|
||||
|
||||
const baseWidth = 582;
|
||||
const baseHeight = 72;
|
||||
@@ -26,18 +31,33 @@ export function ChyronDriver() {
|
||||
<PositionNumber containerHeight={baseHeight}>1</PositionNumber>
|
||||
</PositionFlag>
|
||||
<Spacer width="8px" />
|
||||
<TeamColorBar color="#00d2be" />
|
||||
<TeamColorBar color={theme.colors.teams[driver.team.id]} />
|
||||
<Spacer width="8px" />
|
||||
<TextContainer>
|
||||
<NameContainer>
|
||||
<FirstName>Lewis</FirstName>
|
||||
<LastName>Hamilton</LastName>
|
||||
<FirstName>{driver.firstName}</FirstName>
|
||||
<LastName>{driver.lastName}</LastName>
|
||||
<NumberContainer>
|
||||
<DriverNumber teamId="mercedes" fontSize="29px" number={44} />
|
||||
<DriverNumber
|
||||
teamId={driver.team.id}
|
||||
fontSize="29px"
|
||||
number={driver.number}
|
||||
/>
|
||||
</NumberContainer>
|
||||
</NameContainer>
|
||||
<TeamName>Mercedes</TeamName>
|
||||
<TeamName>{driver.team.shortName}</TeamName>
|
||||
</TextContainer>
|
||||
<FlagContainer
|
||||
height={baseHeight * 0.9}
|
||||
width={250}
|
||||
>
|
||||
<AngledFlag
|
||||
flagMode="country"
|
||||
flag={driver.nationality}
|
||||
flagHeight={64}
|
||||
/>
|
||||
|
||||
</FlagContainer>
|
||||
</BaseBackground>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import styled from "styled-components";
|
||||
import { Px } from "../../../../types/style";
|
||||
|
||||
type BaseBackgroundProps = {
|
||||
width: number, // px
|
||||
height: number, // px
|
||||
width: Px,
|
||||
height: Px,
|
||||
};
|
||||
export const BaseBackground = styled.div<BaseBackgroundProps>`
|
||||
position: relative;
|
||||
@@ -20,7 +21,7 @@ export const BaseBackground = styled.div<BaseBackgroundProps>`
|
||||
BaseBackground.displayName = "BaseBackground";
|
||||
|
||||
type PositionFlagProps = {
|
||||
containerHeight: number, // px
|
||||
containerHeight: Px,
|
||||
};
|
||||
export const PositionFlag = styled.div<PositionFlagProps>`
|
||||
position: relative;
|
||||
@@ -37,7 +38,7 @@ export const PositionFlag = styled.div<PositionFlagProps>`
|
||||
PositionFlag.displayName = "PositionFlag";
|
||||
|
||||
type PositionNumberProps = {
|
||||
containerHeight: number, // px
|
||||
containerHeight: Px,
|
||||
};
|
||||
export const PositionNumber = styled.span<PositionNumberProps>`
|
||||
font-family: ${p => p.theme.fonts.f1Regular};
|
||||
@@ -116,3 +117,22 @@ export const Spacer = styled.div<SpacerProps>`
|
||||
height: ${({ height = "0" }) => height};
|
||||
`;
|
||||
Spacer.displayName = "Spacer";
|
||||
|
||||
type FlagContainerProps = {
|
||||
height: Px,
|
||||
width: Px,
|
||||
};
|
||||
export const FlagContainer = styled.div<FlagContainerProps>`
|
||||
position: absolute;
|
||||
right: -65px;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
|
||||
height: ${({ height }) => `${height}px`};
|
||||
width: ${({ width }) => `${width}px`};
|
||||
|
||||
overflow: hidden;
|
||||
`;
|
||||
FlagContainer.displayName = "FlagContainer";
|
||||
@@ -0,0 +1,40 @@
|
||||
import { FlagMode } from "../../../../types/state";
|
||||
import { Px } from "../../../../types/style";
|
||||
import { Container, NationalFlag, Slant, Sheen, NationalFlagEdge } from "./styles";
|
||||
|
||||
const flags = require.context("../../../../public/images/flags/angled", true);
|
||||
const logos = require.context("../../../../public/images/logos", true);
|
||||
|
||||
/**
|
||||
* To look right, country flags need to be 2:1. Additional editing will be
|
||||
* necessary for some flags to not cut off prominent elements. Ex: China's flag
|
||||
* would have its stars mostly cut out without edits to place them closer to the
|
||||
* center.
|
||||
*/
|
||||
type AngledFlagProps = {
|
||||
flagMode: FlagMode,
|
||||
flag: string,
|
||||
flagHeight: Px,
|
||||
};
|
||||
export function AngledFlag({ flagMode, flag, flagHeight }: AngledFlagProps) {
|
||||
return (
|
||||
<Container width={flagHeight * 6} height={flagHeight * 3}>
|
||||
<Slant x={0} height={flagHeight * 3} girth={flagHeight * 2.4} />
|
||||
{flagMode === "country" ? (
|
||||
<>
|
||||
<NationalFlag
|
||||
alt=""
|
||||
src={flags(`./${flag}.svg`)}
|
||||
height={flagHeight}
|
||||
/>
|
||||
<NationalFlagEdge
|
||||
x={-(flagHeight / 2) + ((flagHeight * 0.07) / 2)}
|
||||
height={flagHeight}
|
||||
girth={flagHeight * 0.07}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
<Sheen x={-10} height={flagHeight * 3} girth={flagHeight * 1.1} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./AngledFlag";
|
||||
@@ -0,0 +1,107 @@
|
||||
import styled from "styled-components";
|
||||
import { Px } from "../../../../types/style";
|
||||
|
||||
type ContainerProps = {
|
||||
height: Px,
|
||||
width: Px,
|
||||
};
|
||||
export const Container = styled.div<ContainerProps>`
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
width: ${({ width }) => `${width}px`};
|
||||
height: ${({ height }) => `${height}px`};
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
transparent 0%,
|
||||
transparent 10%,
|
||||
black 40%,
|
||||
black 60%,
|
||||
transparent 90%,
|
||||
transparent 100%
|
||||
);
|
||||
`;
|
||||
|
||||
type NationalFlagProps = {
|
||||
height: Px,
|
||||
};
|
||||
export const NationalFlag = styled.img<NationalFlagProps>`
|
||||
max-inline-size: unset;
|
||||
height: ${({ height }) => `${height}px`};
|
||||
clip-path: polygon(50% 0, 100% 0, 100% 30%, 60% 100%, 0 100%, 0 100%);
|
||||
mask-image: linear-gradient(
|
||||
to right,
|
||||
transparent 0%,
|
||||
black 15%,
|
||||
black 85%,
|
||||
transparent 100%
|
||||
);
|
||||
mask-image: radial-gradient(
|
||||
circle at center,
|
||||
black 0%,
|
||||
black 80%,
|
||||
transparent 96%,
|
||||
transparent 100%
|
||||
);
|
||||
`;
|
||||
NationalFlag.displayName = "NationalFlag";
|
||||
|
||||
type SlashProps = {
|
||||
x: Px,
|
||||
height: Px,
|
||||
girth: Px,
|
||||
};
|
||||
export const Sheen = styled.div<SlashProps>`
|
||||
position: absolute;
|
||||
height: ${({ height }) => `${height}px`};
|
||||
width: ${({ girth }) => `${girth}px`};
|
||||
|
||||
background: linear-gradient(
|
||||
to top,
|
||||
transparent 0%,
|
||||
transparent 20%,
|
||||
rgba(255, 255, 255, 0.15) 45%,
|
||||
rgba(255, 255, 255, 0.15) 55%,
|
||||
transparent 80%,
|
||||
transparent 100%
|
||||
);
|
||||
font-size: ${({ height }) => `${height}px`}; // Hack to let me use em.
|
||||
|
||||
box-shadow:
|
||||
0.02em 0 0.005em 0.015em rgba(0, 0, 0, 0.2),
|
||||
1em 0 0 1em rgba(0, 0, 0, 0.1);
|
||||
transform: skew(-45deg, 0deg) translateX(${({ x }) => `${x}px`});
|
||||
|
||||
border-left: 0.015em solid rgba(255, 255, 255, 0.25);
|
||||
`;
|
||||
Sheen.displayName = "Sheen";
|
||||
|
||||
export const Slant = styled.div<SlashProps>`
|
||||
position: absolute;
|
||||
height: ${({ height }) => `${height}px`};
|
||||
width: ${({ girth }) => `${girth}px`};
|
||||
|
||||
background: #1a1a28;
|
||||
transform: skewX(-45deg) translateX(${({ x }) => `${x}px`});
|
||||
`;
|
||||
Slant.displayName = "Slant";
|
||||
|
||||
export const NationalFlagEdge = styled.div<SlashProps>`
|
||||
position: absolute;
|
||||
height: ${({ height }) => `${height}px`};
|
||||
width: ${({ girth }) => `${girth}px`};
|
||||
|
||||
background: ${p => p.theme.colors.lightGrey};
|
||||
opacity: 0.5;
|
||||
transform: skewX(-45deg) translateX(${({ x }) => `${x}px`});
|
||||
|
||||
mask-image: linear-gradient(
|
||||
to top,
|
||||
transparent 0%,
|
||||
transparent 10%,
|
||||
black 100%
|
||||
);
|
||||
`;
|
||||
@@ -77,7 +77,7 @@ export function ProgressSlider({
|
||||
) ? -1 : value > 0.1 ? 4 : 3 // Tuned fitting considerations.
|
||||
}
|
||||
disabled={disabled}
|
||||
onBarColor={labelColor}
|
||||
color={labelColor}
|
||||
>
|
||||
{formatter(value)}
|
||||
</ProgressSliderBarIndicator>
|
||||
|
||||
@@ -62,7 +62,7 @@ ProgressSliderBarHandle.displayName = "ProgressSliderBarHandle";
|
||||
type ProgressSliderBarIndicatorProps = {
|
||||
left: number,
|
||||
disabled: boolean,
|
||||
onBarColor?: string,
|
||||
color?: string,
|
||||
};
|
||||
export const ProgressSliderBarIndicator = styled.span<ProgressSliderBarIndicatorProps>`
|
||||
display: block;
|
||||
@@ -72,11 +72,11 @@ export const ProgressSliderBarIndicator = styled.span<ProgressSliderBarIndicator
|
||||
|
||||
font-family: ${p => p.theme.fonts.f1Regular};
|
||||
font-size: 0.9em;
|
||||
color: ${({ onBarColor, left, disabled }) => (
|
||||
color: ${({ color, left, disabled }) => (
|
||||
left < 0
|
||||
? disabled
|
||||
? (p => p.theme.colors.darkGrey)
|
||||
: onBarColor ?? "white"
|
||||
: color ?? "white"
|
||||
: (p => p.theme.colors.darkGrey)
|
||||
)};
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { AngledFlag } from "../../BroadcastGraphics/Common/AngledFlag";
|
||||
import { BasicBlock } from "./styles";
|
||||
|
||||
export function AngledFlagWorkSpace() {
|
||||
return (
|
||||
<BasicBlock width={400} height={400} color="rgba(30, 30, 30, .7)">
|
||||
<AngledFlag
|
||||
flagMode="country"
|
||||
flag="JPN"
|
||||
flagHeight={64}
|
||||
/>
|
||||
</BasicBlock>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import styled from "styled-components";
|
||||
import { Px } from "../../../types/style";
|
||||
|
||||
type BasicBlockProps = {
|
||||
width: Px,
|
||||
height: Px,
|
||||
color: string,
|
||||
center?: boolean,
|
||||
}
|
||||
export const BasicBlock = styled.div<BasicBlockProps>`
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
width: ${({ width }) => `${width}px`};
|
||||
height: ${({ height }) => `${height}px`};
|
||||
|
||||
background-color: ${({ color }) => color};
|
||||
|
||||
border-radius: 15px;
|
||||
`;
|
||||
Reference in new issue
Block a user