Merge pull request #36 from TiE23/ISSUE-031

ISSUE-031 - Almost forgot (I closed issue and merged the branch too e…
This commit is contained in:
Kyle Geib authored and GitHub committed 2022-01-25 19:44:06 -05:00
commit ef0b58e98b
38 files changed
+126 -39

No files matched your search

@@ -1,9 +1,16 @@
import { FlagMode } from "../../../../types/state"; import { FlagMode } from "../../../../types/state";
import { Px } from "../../../../types/style"; import { Px } from "../../../../types/style";
import { Container, NationalFlag, Slant, Sheen, NationalFlagEdge } from "./styles"; import {
Container,
Slant,
Sheen,
CountryFlagEdge,
CountryFlagDiv,
FlagContainer,
} from "./styles";
const flags = require.context("../../../../public/images/flags/angled", true); const countryFlags = require.context("../../../../public/images/countryFlags/angled", true);
const logos = require.context("../../../../public/images/logos", true); // const teamLogos = require.context("../../../../public/images/teamLogos", true);
/** /**
* To look right, country flags need to be 2:1. Additional editing will be * To look right, country flags need to be 2:1. Additional editing will be
@@ -17,24 +24,55 @@ type AngledFlagProps = {
flagHeight: Px, flagHeight: Px,
}; };
export function AngledFlag({ flagMode, flag, flagHeight }: AngledFlagProps) { export function AngledFlag({ flagMode, flag, flagHeight }: AngledFlagProps) {
const topFlag = flagMode === "country"
? (
<CountryFlagDiv
src={countryFlags(`./${flag}.svg`)}
height={flagHeight}
width={flagHeight * 2}
>
<CountryFlagEdge
x={flagHeight / 2}
height={flagHeight}
girth={flagHeight * 0.07}
/>
</CountryFlagDiv>
) : null; // Team flag here
const bottomFlag = flagMode === "country"
? (
<CountryFlagDiv
src={countryFlags(`./${flag}.svg`)}
height={flagHeight}
width={flagHeight * 2}
xOffset={-flagHeight * 0.005}
/>
) : null; // Team flag here
return ( return (
<Container width={flagHeight * 6} height={flagHeight * 3}> <Container width={flagHeight * 6} height={flagHeight * 3}>
<Slant x={0} height={flagHeight * 3} girth={flagHeight * 2.4} /> <Slant x={0} height={flagHeight * 3} girth={flagHeight * 2.4} />
{flagMode === "country" ? ( <FlagContainer
<> height={flagHeight}
<NationalFlag width={flagHeight * 2} // Dynamic width...
alt="" collapsedWidth={flagHeight * 2}
src={flags(`./${flag}.svg`)} masked
height={flagHeight} >
/> <FlagContainer
<NationalFlagEdge height={flagHeight}
x={-(flagHeight / 2) + ((flagHeight * 0.07) / 2)} width={flagHeight * 2}
height={flagHeight} collapsedWidth={flagHeight * 2}
girth={flagHeight * 0.07} topFlag
/> >
</> {topFlag}
) : null} </FlagContainer>
<Sheen x={-10} height={flagHeight * 3} girth={flagHeight * 1.1} /> {bottomFlag}
</FlagContainer>
<Sheen
x={-flagHeight / 6.4}
height={flagHeight * 3}
girth={flagHeight * 1.1}
/>
</Container> </Container>
); );
} }
@@ -1,4 +1,4 @@
import styled from "styled-components"; import styled, { css } from "styled-components";
import { Px } from "../../../../types/style"; import { Px } from "../../../../types/style";
type ContainerProps = { type ContainerProps = {
@@ -26,25 +26,68 @@ export const Container = styled.div<ContainerProps>`
`; `;
Container.displayName = "Container"; Container.displayName = "Container";
type NationalFlagProps = { type FlagContainerProps = {
height: Px, height: Px,
width: Px,
collapsedWidth: Px,
topFlag?: boolean,
masked?: boolean,
}; };
export const NationalFlag = styled.img<NationalFlagProps>` export const FlagContainer = styled.div<FlagContainerProps>`
max-inline-size: unset; position: absolute;
height: ${({ height }) => `${height}px`}; height: ${({ height }) => `${height}px`};
clip-path: polygon(50% 0, 100% 0, 100% 30%, 66% 100%, 0 100%, 0 100%); width: ${({ width }) => `${width}px`};
mask-image: linear-gradient( ${({ masked = false }) => masked && css`
60deg, mask-image: linear-gradient(
transparent 0%, 60deg,
black 15%, transparent 0%,
black 85%, black 15%,
transparent 100% black 85%,
); transparent 100%
);
`}
${({ width, collapsedWidth, topFlag = false }) => topFlag
? css`
clip-path: polygon(
${((collapsedWidth * .5) / width) * 100}% 0,
95% 0,
${((1 - ((collapsedWidth * .55) / width)) * 100)}% 100%,
0 100%
);
`
: css`
clip-path: polygon(
${((collapsedWidth * .5) / width) * 100}% 0,
100% 0,
100% 30%,
${((1 - ((collapsedWidth * .34) / width)) * 100)}% 100%,
0 100%
);
`}
`; `;
NationalFlag.displayName = "NationalFlag"; FlagContainer.displayName = "FlagContainer";
type CountryFlagDivProps = {
src: string,
height: Px,
width: Px,
xOffset?: Px,
};
export const CountryFlagDiv = styled.div<CountryFlagDivProps>`
height: ${({ height }) => `${height}px`};
width: ${({ width }) => `${width}px`};
background-image: url(${({ src }) => src});
background-size: ${({ width, height }) => `${width}px ${height}px`};
background-repeat: no-repeat;
${({ xOffset }) => xOffset == null
? css`background-position: center;`
: css`background-position-x: ${xOffset}px`}
`;
CountryFlagDiv.displayName = "CountryFlagDiv";
type SlashProps = { type SlashProps = {
x: Px, x?: Px,
height: Px, height: Px,
girth: Px, girth: Px,
}; };
@@ -67,9 +110,9 @@ export const Sheen = styled.div<SlashProps>`
box-shadow: box-shadow:
0.02em 0 0.005em 0.015em rgba(0, 0, 0, 0.2), 0.02em 0 0.005em 0.015em rgba(0, 0, 0, 0.2),
1em 0 0 1em rgba(0, 0, 0, 0.5); 1em 0 0 1em rgba(0, 0, 0, 0.5);
transform: skew(-45deg, 0deg) translateX(${({ x }) => `${x}px`}); transform: skew(-45deg, 0deg) translateX(${({ x = 0 }) => `${x}px`});
border-left: 0.015em solid rgba(255, 255, 255, 0.25); border-left: 0.015em solid rgba(255, 255, 255, 0.1);
`; `;
Sheen.displayName = "Sheen"; Sheen.displayName = "Sheen";
@@ -79,18 +122,18 @@ export const Slant = styled.div<SlashProps>`
width: ${({ girth }) => `${girth}px`}; width: ${({ girth }) => `${girth}px`};
background: #1a1a28; background: #1a1a28;
transform: skewX(-45deg) translateX(${({ x }) => `${x}px`}); transform: skewX(-45deg) translateX(${({ x = 0 }) => `${x}px`});
`; `;
Slant.displayName = "Slant"; Slant.displayName = "Slant";
export const NationalFlagEdge = styled.div<SlashProps>` export const CountryFlagEdge = styled.div<SlashProps>`
position: absolute; position: absolute;
height: ${({ height }) => `${height}px`}; height: ${({ height }) => `${height}px`};
width: ${({ girth }) => `${girth}px`}; width: ${({ girth }) => `${girth}px`};
background: ${p => p.theme.colors.lightGrey}; background: ${p => p.theme.colors.lightGrey};
opacity: 0.5; opacity: 0.5;
transform: skewX(-45deg) translateX(${({ x }) => `${x}px`}); transform: skewX(-45deg) translateX(${({ x = 0 }) => `${x}px`});
mask-image: linear-gradient( mask-image: linear-gradient(
to top, to top,
@@ -99,3 +142,4 @@ export const NationalFlagEdge = styled.div<SlashProps>`
black 100% black 100%
); );
`; `;
CountryFlagEdge.displayName = "CountryFlagEdge";
@@ -3,12 +3,17 @@ import { BasicBlock } from "./styles";
export function AngledFlagWorkSpace() { export function AngledFlagWorkSpace() {
return ( return (
<BasicBlock width={400} height={400} color="rgba(30, 30, 30, .7)"> <BasicBlock width={750} height={450} color="rgba(30, 30, 30, .7)">
<AngledFlag <AngledFlag
flagMode="country" flagMode="country"
flag="GBR" flag="GBR"
flagHeight={64} flagHeight={64}
/> />
<AngledFlag
flagMode="country"
flag="MEX"
flagHeight={128}
/>
</BasicBlock> </BasicBlock>
); );
} }
+1 -1
View File
@@ -38,7 +38,7 @@ export const workspaces: WorkspaceObject = {
"angled-flag-gbr.png", "angled-flag-gbr.png",
], ],
previewWindowDimensions: { previewWindowDimensions: {
width: 500, width: 800,
height: 500, height: 500,
}, },
}, },
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.