feat: updated hero image

we simplified the hero responsiveness
pull/3056/head
William Grant 1 year ago
parent 9be21ce879
commit 4ffd98ae21

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

@ -11,12 +11,11 @@ const StyledHeroContainer = styled.div<{ positionWithinContainer: PositionWithin
overflow: hidden; overflow: hidden;
z-index: 0; z-index: 0;
// TODO[epic=ses-50] remove this when we have the new mockup with narrower shadows if needed
&:after { &:after {
content: ''; content: '';
position: absolute; position: absolute;
top: 0; top: 0;
right: ${props => (props.positionWithinContainer === 'right' ? '0' : '290px')}; right: 0;
width: 20px; width: 20px;
height: 100%; height: 100%;
background-image: linear-gradient(to right, rgba(27, 27, 27, 0), rgba(27, 27, 27, 1)); background-image: linear-gradient(to right, rgba(27, 27, 27, 0), rgba(27, 27, 27, 1));
@ -24,19 +23,17 @@ const StyledHeroContainer = styled.div<{ positionWithinContainer: PositionWithin
`; `;
const StyledHero = styled.img<{ const StyledHero = styled.img<{
scaleFactor: number;
positionWithinContainer: PositionWithinContainer; positionWithinContainer: PositionWithinContainer;
}>` }>`
width: auto; width: auto;
${props => props.scaleFactor && `height: calc(3701px / ${props.scaleFactor});`} height: 100%;
position: absolute; position: absolute;
top: 50%; top: 50%;
${props => (props.positionWithinContainer === 'right' ? 'right: 0;' : 'left: 0;')} ${props => (props.positionWithinContainer === 'right' ? 'right: -50px;' : 'left: 0;')}
transform: translateY(-50%); transform: translateY(-50%);
`; `;
export const Hero = () => { export const Hero = () => {
const [scaleFactor, setScaleFactor] = useState(2.1); // default width 1024px
const [positionWithinContainer, setPositionWithinContainer] = useState<PositionWithinContainer>( const [positionWithinContainer, setPositionWithinContainer] = useState<PositionWithinContainer>(
'left' 'left'
); );
@ -45,31 +42,17 @@ export const Hero = () => {
useEffect(() => { useEffect(() => {
if (width) { if (width) {
if (width <= 1024) { if (width <= 1920) {
setPositionWithinContainer('right');
setScaleFactor(2.1);
} else if (width <= 1920) {
setPositionWithinContainer('right');
setScaleFactor(2.0);
} else if (width <= 2560) {
setPositionWithinContainer('right'); setPositionWithinContainer('right');
setScaleFactor(1.5);
} else if (width <= 3440) {
setPositionWithinContainer('left');
setScaleFactor(1.5);
} else { } else {
setPositionWithinContainer('left'); setPositionWithinContainer('left');
setScaleFactor(1.5);
} }
} }
}, [width]); }, [width]);
return ( return (
<StyledHeroContainer positionWithinContainer={positionWithinContainer}> <StyledHeroContainer positionWithinContainer={positionWithinContainer}>
<StyledHero <StyledHero src={'images/hero.png'} positionWithinContainer={positionWithinContainer} />
src={'images/hero.png'}
scaleFactor={scaleFactor}
positionWithinContainer={positionWithinContainer}
/>
</StyledHeroContainer> </StyledHeroContainer>
); );
}; };

Loading…
Cancel
Save