ISSUE-035 - Took some work but have proper type checking for AngledFlag props and have updated everything necessary.

Styling is still to come. Only have Ferrari working.
I've discovered that the team flags are wider than the country flags. So I'll be tackling that necessary change in the next commit before dealing with styling.
This commit is contained in:
Kyle Geib committed 2022-02-01 12:57:40 -05:00
1 parent 57647f6488
commit bd1892ab17
9 files changed
+231 -53

No files matched your search

@@ -1,16 +1,19 @@
import { FlagMode } from "../../../../types/state";
import { ReactNode } from "react";
import { TeamId } from "../../../../types/state";
import { Px } from "../../../../types/style";
import { getTeamFlagStyle } from "../../../../utils/dataLookup";
import {
Container,
Slant,
Sheen,
CountryFlagEdge,
FlagEdge,
CountryFlagDiv,
FlagContainer,
TeamFlagDiv,
} from "./styles";
const countryFlags = require.context("../../../../public/images/countryFlags/angled", true);
// const teamLogos = require.context("../../../../public/images/teamLogos", true);
const teamLogos = require.context("../../../../public/images/logos/team", true);
/**
* To look right, country flags need to be 2:1. Additional editing will be
@@ -19,35 +22,67 @@ const countryFlags = require.context("../../../../public/images/countryFlags/ang
* center.
*/
type AngledFlagProps = {
flagMode: FlagMode,
flag: string,
flagHeight: Px,
flagProps: {
flagMode: "country",
flag: string,
} | {
flagMode: "team",
flag: TeamId,
},
};
export function AngledFlag({ flagMode, flag, flagHeight }: AngledFlagProps) {
const topFlag = flagMode === "country"
? (
export function AngledFlag(props: AngledFlagProps) {
const { flagProps, flagHeight } = props;
let topFlag: ReactNode = null;
let bottomFlag: ReactNode = null;
if (flagProps.flagMode === "country") {
topFlag = (
<CountryFlagDiv
src={countryFlags(`./${flag}.svg`)}
src={countryFlags(`./${flagProps.flag}.svg`)}
height={flagHeight}
width={flagHeight * 2}
>
<CountryFlagEdge
<FlagEdge
x={flagHeight / 2}
height={flagHeight}
girth={flagHeight * 0.07}
/>
</CountryFlagDiv>
) : null; // Team flag here
const bottomFlag = flagMode === "country"
? (
);
bottomFlag = (
<CountryFlagDiv
src={countryFlags(`./${flag}.svg`)}
src={countryFlags(`./${flagProps.flag}.svg`)}
height={flagHeight}
width={flagHeight * 2}
xOffset={-flagHeight * 0.005}
/>
) : null; // Team flag here
);
} else if (flagProps.flagMode === "team") {
topFlag = (
<TeamFlagDiv
src={teamLogos(`./${flagProps.flag}.svg`)}
height={flagHeight}
width={flagHeight * 2}
style={getTeamFlagStyle(flagProps.flag)}
>
<FlagEdge
x={flagHeight / 2}
height={flagHeight}
girth={flagHeight * 0.07}
/>
</TeamFlagDiv>
);
bottomFlag = (
<TeamFlagDiv
src={teamLogos(`./${flagProps.flag}.svg`)}
height={flagHeight}
width={flagHeight * 2}
style={getTeamFlagStyle(flagProps.flag)}
/>
);
}
return (
<Container width={flagHeight * 6} height={flagHeight * 3}>