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