Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nwHacks registrations temporarily closed banner #177

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions components/Banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import styled from 'styled-components'

const BannerContainer = styled.div`
background: linear-gradient(92.58deg, #0defe1 0%, #78ff96 100%);
position: absolute;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it's possible to shift the hero down such that the banner isn't covering it? or do you think it looks good enough already haha

  • removing position: absolute; looks to fix it on mobile but I haven't thoroughly checked this

image

z-index: 1;
height: 134px;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: left;
padding: 20px 64px;
gap: 10px;
color: #2c2543;
font-size: 0.8rem;
@media (min-width: 768px) {
padding-right: 100px;
font-size: 20px;
}
`

const BannerHeader = styled.div`
font-weight: 700;
`

const BannerText = styled.div`
font-weight: 600;
`

const Banner = () => (
<BannerContainer>
<BannerHeader>IMPORTANT UPDATE:</BannerHeader>
<BannerText>
nwHacks 2024 is not currently accepting applications. The application form will open on November 20th, 2023.
</BannerText>
</BannerContainer>
)

export default Banner
3 changes: 2 additions & 1 deletion components/Hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const HeroContainer = styled.div`
padding-bottom: 69%;
background: url(/assets/hero_illustration.svg);
background-repeat: no-repeat;
background-position: top;
background-position: center;
background-size: contain;
padding-top: 134px;
`;

const HeroTextContainer = styled.div`
Expand Down
48 changes: 26 additions & 22 deletions components/NavBar.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import styled from 'styled-components';
import { useState, useEffect } from 'react';

import { SCREEN_BREAKPOINTS } from '../pages/_app';
import { SCREEN_BREAKPOINTS, BANNER_OFFSET } from '../pages/_app';
import fireDb from '../utilities/firebase';

const NavBarContainer = styled.nav`
position: fixed;
top: 0;
position: ${p => (p.stayAtTop ? 'absolute' : 'fixed')};
top: ${p => (p.stayAtTop ? BANNER_OFFSET : '0')}px;
left: 50%;
transform: translate(-50%, 0);
z-index: 3;
Expand Down Expand Up @@ -222,6 +222,7 @@ const NavBar = () => {
const [showDropdown, setShowDropdown] = useState(false);
const [visibility, setVisibility] = useState('visible');
const [opacity, setOpacity] = useState('1');
const [stayAtTop, setStayAtTop] = useState(true);

const [config, setConfig] = useState(null);

Expand All @@ -230,6 +231,27 @@ const NavBar = () => {
setConfig(wwwConfig);
};

const handleScroll = () => {
let lastScroll = 0
return () => {
const scroll = window.pageYOffset || document.documentElement.scrollTop
if (scroll <= BANNER_OFFSET) {
setStayAtTop(true)
setVisibility('visible')
setOpacity('1')
} else if (scroll > lastScroll) {
setStayAtTop(false)
setVisibility('hidden')
setOpacity('0')
setStayAtTop(0)
} else {
setVisibility('visible')
setOpacity('1')
}
lastScroll = scroll
}
}

useEffect(() => {
window.addEventListener('scroll', handleScroll());
window.addEventListener('resize', handleResize);
Expand All @@ -246,24 +268,6 @@ const NavBar = () => {
}
};

const handleScroll = () => {
var lastScroll = 0;
return () => {
const scroll = window.pageYOffset || document.documentElement.scrollTop;
if (scroll <= 0) {
setVisibility('visible');
setOpacity('1');
} else if (scroll > lastScroll) {
setVisibility('hidden');
setOpacity('0');
} else {
setVisibility('visible');
setOpacity('1');
}
lastScroll = scroll;
};
};

if (showDropdown) {
return (
<>
Expand Down Expand Up @@ -306,7 +310,7 @@ const NavBar = () => {
}

return (
<NavBarContainer visibility={visibility} opacity={opacity}>
<NavBarContainer visibility={visibility} opacity={opacity} stayAtTop={stayAtTop}>
<NavGroupContainer>
<a href='/'>
<NwPlusLogo
Expand Down
1 change: 1 addition & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const SCREEN_BREAKPOINTS = {
tabletLarge: 1024,
desktop: 1200,
};
export const BANNER_OFFSET = 134;

const theme = {
colors: {
Expand Down
2 changes: 2 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Hackathons from '../components/Hackathons'
import Hero from '../components/Hero'
import ResourceContainer from '../components/ResourceContainer'
import Stats from '../components/Stats'
import Banner from '../components/Banner'
// Typography
import {
Title1,
Expand Down Expand Up @@ -105,6 +106,7 @@ export default function Home() {
</Head>
<Background>
<NavBar/>
<Banner />
<Hero />
<ContentContainer
id="about"
Expand Down
Loading