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:
Kyle Geib committed 2022-01-24 16:15:43 -05:00
1 parent 55e07a444e
commit 4a9c124832
46 files changed
+1063 -70

No files matched your search

@@ -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%
);
`;