diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index ed848d1..31d7dfe 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -1,7 +1,12 @@ import { Link } from "gatsby" -import React, { PropsWithChildren } from "react" +import React, { PropsWithChildren, useLayoutEffect, useState } from "react" +import { WavesBottom, WavesTop } from "../Waves" import * as SC from "./styles" +interface IHeaderProps { + isHome: boolean +} + function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) { return ( @@ -11,12 +16,22 @@ function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) { ) } -export function Header() { +export function Header({ isHome }: IHeaderProps) { + // Hack to force Particle.js to rerender + const [noop, setNoop] = useState(0) + useLayoutEffect(() => { + setNoop(prevState => prevState + 1) + }, [isHome]) + return ( - - - + + + + + + ` display: flex; justify-content: center; align-items: center; width: 100%; position: relative; - min-height: 100vh; + min-height: ${props => (props.isHome ? "100vh" : "auto")}; background: #121240; overflow: hidden; ` @@ -35,21 +33,25 @@ export const Title = styled.h1` } ` -export const StyledWavesTop = styled(WavesTop)` - width: 100vw; - max-width: 100%; - position: absolute; - top: 0; -` - -export const StyledWavesBottom = styled(WavesBottom)` - width: 100vw; - max-width: 100%; +export const FadedBottomWave = styled.div<{ faded: boolean }>` position: absolute; + transform: translateY(${props => (props.faded ? "100%" : 0)}); bottom: 0; + left: 0; + right: 0; + transition: opacity 0.5s, transform 0.5s; + opacity: ${props => (props.faded ? 0 : 1)}; + + ${props => + props.faded && + css` + svg { + position: static; + } + `} ` -export const StyledParticles = styled(Particles)` +export const StyledParticles = styled(Particles)<{ noop: number }>` mask-image: -webkit-linear-gradient( top, rgba(0, 0, 0, 0) 5%, @@ -93,7 +95,7 @@ export const StyledDiscordLogo = styled(DiscordLogo)` export const InnerWrapper = styled.div` width: 800px; max-width: calc(100% - 64px); - padding: 0 32px; + padding: 32px; position: relative; display: flex; align-items: flex-start; diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 5a2d69e..c899a70 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -6,12 +6,13 @@ */ import { graphql, useStaticQuery } from "gatsby" -import React, { PropsWithChildren } from "react" +import React, { Fragment, PropsWithChildren } from "react" import { GlobalStyles } from "../../globalStyles" import { Container } from "../Container" import { Footer } from "../Footer" import { Header } from "../Header" +import { WavesBottom } from "../Waves" import * as SC from "./styles" export function Layout({ @@ -32,16 +33,17 @@ export function Layout({ return ( -
+
{!isHome && ( - - -

{data.site.siteMetadata.title}

- {children} -
-
+ + + {children} + +