Skip to content

Commit dcd5254

Browse files
Fran McDadefrano-m
authored andcommitted
feat: restore hero background on home, about and roadmap pages (#636)
1 parent 6b0c29f commit dcd5254

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

app/components/Home/components/Section/components/SectionHero/components/Hero/hero.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ import { SVG } from "./hero.styles";
1919
export interface HeroProps {
2020
gridSize?: number;
2121
height?: number;
22+
width?: number;
2223
}
2324

2425
export const Hero = ({
2526
gridSize = GRID_SIZE,
2627
height = gridSize * 3,
28+
width = 0,
2729
}: HeroProps): JSX.Element => {
2830
return (
2931
<SVG
@@ -46,7 +48,7 @@ export const Hero = ({
4648
<rect
4749
fill={getFillUrl(elementId)}
4850
height={height}
49-
width="100%"
51+
width={width}
5052
x={0}
5153
y={0}
5254
/>

app/components/Home/components/Section/components/SectionHero/sectionHero.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ import {
1717
export const SectionHero = (): JSX.Element => {
1818
return (
1919
<StyledSection>
20-
{(height): JSX.Element => (
20+
{(height, width): JSX.Element => (
2121
<Fragment>
22-
<Hero gridSize={calculateGridSize(height)} height={height} />
22+
<Hero
23+
gridSize={calculateGridSize(height)}
24+
height={height}
25+
width={width}
26+
/>
2327
<SectionLayout>
2428
<Headline>
2529
<Head>

app/components/Layout/components/AppLayout/components/Section/components/SectionHero/components/Hero/hero.styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import styled from "@emotion/styled";
22

33
export const SVG = styled.svg`
44
position: absolute;
5+
width: 100vw;
56
z-index: -1;
67
`;

app/components/Layout/components/AppLayout/components/Section/components/SectionHero/components/Hero/hero.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ import { SVG } from "./hero.styles";
1111
export interface HeroProps {
1212
gridSize?: number;
1313
height?: number;
14+
width?: number;
1415
}
1516

1617
export const Hero = ({
1718
gridSize = GRID_SIZE,
1819
height = gridSize * 1.5,
20+
width = 0,
1921
}: HeroProps): JSX.Element => {
2022
return (
2123
<SVG
2224
fill={FILL.NONE}
2325
height={height}
2426
preserveAspectRatio="xMinYMin meet"
2527
viewBox={getViewBox(gridSize, height)}
26-
width="100%"
2728
xmlns="http://www.w3.org/2000/svg"
2829
>
2930
<SmokeRect gridSize={gridSize} />
@@ -36,7 +37,7 @@ export const Hero = ({
3637
<rect
3738
fill={getFillUrl(elementId)}
3839
height={height}
39-
width="100%"
40+
width={width}
4041
x={0}
4142
y={0}
4243
/>

app/components/Layout/components/AppLayout/components/Section/components/SectionHero/sectionHero.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ export const SectionHero = ({
2727
}: SectionHeroProps): JSX.Element => {
2828
return (
2929
<StyledSection>
30-
{(height): JSX.Element => (
30+
{(height, width): JSX.Element => (
3131
<Fragment>
32-
<Hero gridSize={calculateGridSize(height)} height={height} />
32+
<Hero
33+
gridSize={calculateGridSize(height)}
34+
height={height}
35+
width={width}
36+
/>
3337
<SectionLayout>
3438
<Headline>
3539
<Breadcrumbs breadcrumbs={breadcrumbs} />
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import {
2-
getBorderBoxSizeHeight,
2+
getBorderBoxSize,
33
useResizeObserver,
44
} from "@databiosphere/findable-ui/lib/hooks/useResizeObserver";
55
import { useRef } from "react";
66
import { StyledSection } from "./section.styles";
77

88
export interface SectionProps {
9-
children: (height?: number) => JSX.Element;
9+
children: (height?: number, width?: number) => JSX.Element;
1010
className?: string;
1111
}
1212

1313
export const Section = ({ children, className }: SectionProps): JSX.Element => {
1414
const sectionRef = useRef<HTMLElement>(null);
15-
const { height } =
16-
useResizeObserver(sectionRef, getBorderBoxSizeHeight) || {};
15+
const { height, width } =
16+
useResizeObserver(sectionRef, getBorderBoxSize) || {};
1717
return (
1818
<StyledSection className={className} ref={sectionRef}>
19-
{children?.(height)}
19+
{children?.(height, width)}
2020
</StyledSection>
2121
);
2222
};

0 commit comments

Comments
 (0)