feat: style other pages to match home

This commit is contained in:
Jean-Philippe Sirois
2019-08-23 17:03:10 -04:00
parent 0af9faf322
commit 67bb1c2cdd
6 changed files with 87 additions and 31 deletions
+20 -5
View File
@@ -1,7 +1,12 @@
import { Link } from "gatsby" 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" import * as SC from "./styles"
interface IHeaderProps {
isHome: boolean
}
function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) { function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) {
return ( return (
<SC.MenuItem to={to} activeClassName="active"> <SC.MenuItem to={to} activeClassName="active">
@@ -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 ( return (
<SC.HeaderWrapper> <SC.HeaderWrapper isHome={isHome}>
<SC.StyledWavesTop /> <WavesTop />
<SC.StyledWavesBottom /> <SC.FadedBottomWave faded={!isHome}>
<WavesBottom />
</SC.FadedBottomWave>
<SC.StyledParticles <SC.StyledParticles
noop={noop}
params={{ params={{
particles: { particles: {
number: { value: 5, density: { enable: true, value_area: 500 } }, number: { value: 5, density: { enable: true, value_area: 500 } },
+18 -16
View File
@@ -3,16 +3,14 @@ import Particles from "react-particles-js"
import styled from "styled-components" import styled from "styled-components"
import DiscordLogo from "../../images/discord-logo.svg" import DiscordLogo from "../../images/discord-logo.svg"
import TPHLogo from "../../images/tph-logo.svg" import TPHLogo from "../../images/tph-logo.svg"
import WavesBottom from "../../images/waves-bot.svg"
import WavesTop from "../../images/waves-top.svg"
export const HeaderWrapper = styled.header` export const HeaderWrapper = styled.header<{ isHome: boolean }>`
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: 100%; width: 100%;
position: relative; position: relative;
min-height: 100vh; min-height: ${props => (props.isHome ? "100vh" : "auto")};
background: #121240; background: #121240;
overflow: hidden; overflow: hidden;
` `
@@ -35,21 +33,25 @@ export const Title = styled.h1`
} }
` `
export const StyledWavesTop = styled(WavesTop)` export const FadedBottomWave = styled.div<{ faded: boolean }>`
width: 100vw;
max-width: 100%;
position: absolute;
top: 0;
`
export const StyledWavesBottom = styled(WavesBottom)`
width: 100vw;
max-width: 100%;
position: absolute; position: absolute;
transform: translateY(${props => (props.faded ? "100%" : 0)});
bottom: 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( mask-image: -webkit-linear-gradient(
top, top,
rgba(0, 0, 0, 0) 5%, rgba(0, 0, 0, 0) 5%,
@@ -93,7 +95,7 @@ export const StyledDiscordLogo = styled(DiscordLogo)`
export const InnerWrapper = styled.div` export const InnerWrapper = styled.div`
width: 800px; width: 800px;
max-width: calc(100% - 64px); max-width: calc(100% - 64px);
padding: 0 32px; padding: 32px;
position: relative; position: relative;
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
+11 -9
View File
@@ -6,12 +6,13 @@
*/ */
import { graphql, useStaticQuery } from "gatsby" import { graphql, useStaticQuery } from "gatsby"
import React, { PropsWithChildren } from "react" import React, { Fragment, PropsWithChildren } from "react"
import { GlobalStyles } from "../../globalStyles" import { GlobalStyles } from "../../globalStyles"
import { Container } from "../Container" import { Container } from "../Container"
import { Footer } from "../Footer" import { Footer } from "../Footer"
import { Header } from "../Header" import { Header } from "../Header"
import { WavesBottom } from "../Waves"
import * as SC from "./styles" import * as SC from "./styles"
export function Layout({ export function Layout({
@@ -32,16 +33,17 @@ export function Layout({
return ( return (
<SC.LayoutWrapper> <SC.LayoutWrapper>
<GlobalStyles /> <GlobalStyles />
<Header /> <Header isHome={isHome} />
{!isHome && ( {!isHome && (
<SC.MainContent> <Fragment>
<Container> <SC.MainContent>
<h1>{data.site.siteMetadata.title}</h1> <Container>{children}</Container>
{children} </SC.MainContent>
</Container> <Footer />
</SC.MainContent> <WavesBottom />
<SC.WavesSpacer />
</Fragment>
)} )}
{!isHome && <Footer />}
</SC.LayoutWrapper> </SC.LayoutWrapper>
) )
} }
+11 -1
View File
@@ -1,13 +1,23 @@
import styled from "styled-components" import styled from "styled-components"
export const LayoutWrapper = styled.div` export const LayoutWrapper = styled.div`
background: #121240;
color: #fff;
position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
` `
export const MainContent = styled.main` export const MainContent = styled.main`
margin-top: 64px;
display: flex; display: flex;
justify-content: center; justify-content: center;
max-width: 800px; width: 800px;
max-width: calc(100% - 64px);
padding: 0 32px;
`
export const WavesSpacer = styled.div`
height: 50vw;
` `
+10
View File
@@ -0,0 +1,10 @@
import React from "react"
import * as SC from "./styles"
export function WavesTop() {
return <SC.StyledWavesTop />
}
export function WavesBottom() {
return <SC.StyledWavesBottom />
}
+17
View File
@@ -0,0 +1,17 @@
import styled from "styled-components"
import WavesBottom from "../../images/waves-bot.svg"
import WavesTop from "../../images/waves-top.svg"
export const StyledWavesTop = styled(WavesTop)`
width: 100vw;
max-width: 100%;
position: absolute;
top: 0;
`
export const StyledWavesBottom = styled(WavesBottom)`
width: 100vw;
max-width: 100%;
position: absolute;
bottom: 0;
`