ISSUE-031 - Refactor improvements to ChyronDriver component. Relying less on absolute positioning and hard-coded values.

I realized that there are some variations of the driver chyron. Such as the one without a position flag.
This commit is contained in:
Kyle Geib committed 2022-01-21 18:21:08 -05:00
1 parent db14bf902f
commit a7ca0aecb0
3 files changed
+60 -31

No files matched your search

@@ -2,11 +2,12 @@ import { DriverNumber } from "../../Common/DriverNumber";
import {
BaseBackground,
FirstName,
FlagNumber,
PositionNumber,
LastName,
NameContainer,
NumberContainer,
NumberFlag,
PositionFlag,
Spacer,
TeamColorBar,
TeamName,
TextContainer,
@@ -15,12 +16,18 @@ import {
export function ChyronDriverBasic() {
// TODO - Get driver details from Redux.
const baseWidth = 582;
const baseHeight = 72;
return (
<BaseBackground>
<NumberFlag>
<FlagNumber>1</FlagNumber>
</NumberFlag>
<BaseBackground width={baseWidth} height={baseHeight}>
<Spacer width="6px" />
<PositionFlag containerHeight={baseHeight}>
<PositionNumber containerHeight={baseHeight}>1</PositionNumber>
</PositionFlag>
<Spacer width="8px" />
<TeamColorBar color="#00d2be" />
<Spacer width="8px" />
<TextContainer>
<NameContainer>
<FirstName>Lewis</FirstName>
@@ -1 +1 @@
export * from "./ChyronDriverBasic";
export * from "./ChyronDriver";
@@ -1,21 +1,31 @@
import styled from "styled-components";
export const BaseBackground = styled.div`
type BaseBackgroundProps = {
width: number, // px
height: number, // px
};
export const BaseBackground = styled.div<BaseBackgroundProps>`
position: relative;
width: 582px;
height: 72px;
width: ${({ width }) => `${width}px`};
height: ${({ height }) => `${height}px`};
display: flex;
align-items: center;
border-bottom-right-radius: 11px;
background-color: #000;
overflow: hidden;
`;
BaseBackground.displayName = "BaseBackground";
export const NumberFlag = styled.div`
position: absolute;
width: 61px;
height: 61px;
top: 6px;
left: 6px;
type PositionFlagProps = {
containerHeight: number, // px
};
export const PositionFlag = styled.div<PositionFlagProps>`
position: relative;
height: ${({ containerHeight }) => `${containerHeight * 0.85}px`};
width: ${({ containerHeight }) => `${containerHeight * 0.85}px`};
border-bottom-right-radius: 9px;
background-color: #f4f3ee;
@@ -24,34 +34,36 @@ export const NumberFlag = styled.div`
align-items: center;
justify-content: center;
`;
NumberFlag.displayName = "NumberFlag";
PositionFlag.displayName = "PositionFlag";
export const FlagNumber = styled.span`
type PositionNumberProps = {
containerHeight: number, // px
};
export const PositionNumber = styled.span<PositionNumberProps>`
font-family: ${p => p.theme.fonts.f1Regular};
font-size: 39px;
font-size: ${({ containerHeight }) => `${containerHeight * 0.85 * 0.64}px`};
margin-top: 2px;
`;
FlagNumber.displayName = "FlagNumber";
PositionNumber.displayName = "PositionNumber";
type TeamColorBarProps = {
color: string,
};
export const TeamColorBar = styled.div<TeamColorBarProps>`
position: absolute;
width: 6px;
height: 45px;
top: 14px;
left: 75px;
position: relative;
width: 1%; // 6px;
height: 63%;
background-color: ${({ color }) => color};
`;
TeamColorBar.displayName = "TeamColorBar";
export const TextContainer = styled.div`
position: absolute;
width: 100%;
position: relative;
display: flex;
flex-direction: column;
height: 100%;
left: 90px;
`;
TextContainer.displayName = "TextContainer";
@@ -86,11 +98,21 @@ export const NumberContainer = styled.div`
`;
NumberContainer.displayName = "NumberContainer";
export const TeamName = styled.span`
position: absolute;
export const TeamName = styled.div`
position: relative;
font-family: ${p => p.theme.fonts.f1Regular};
color: #d1d1d1;
font-size: 20px;
bottom: 6px;
`;
TeamName.displayName = "TeamName";
type SpacerProps = {
width?: string,
height?: string;
};
export const Spacer = styled.div<SpacerProps>`
width: ${({ width = "0" }) => width};
height: ${({ height = "0" }) => height};
`;
Spacer.displayName = "Spacer";