Skip to content

Commit d563e5c

Browse files
Merge branch 'master' into feature/add-footer-copyright
2 parents 4ed340e + df34578 commit d563e5c

File tree

17 files changed

+191
-33
lines changed

17 files changed

+191
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2222
- nav component styling and intersection api
2323
- CardsColumns.js and Card.js
2424
- footer copyright
25+
- Header.js component
2526

2627
### Fixed
2728

components/Hero.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { useState, useEffect } from 'react';
2+
import Image from 'next/image';
3+
import Nav from './Nav';
4+
import Container from './Container';
5+
import styles from '../styles/Hero.module.scss';
6+
7+
export default function Hero({
8+
title,
9+
imgBg,
10+
imgAlt,
11+
dynamicTitles = [],
12+
content,
13+
customClass,
14+
titleClass,
15+
}) {
16+
const [titleIndex, setTitleIndex] = useState(0);
17+
const handleTitleIndex = () => {
18+
setTitleIndex(titleIndex >= dynamicTitles.length - 1 ? 0 : titleIndex + 1);
19+
};
20+
21+
useEffect(() => {
22+
const dynamicTitleEl = document.getElementById('dynamicTitle');
23+
if (dynamicTitleEl.style.opacity === '1') {
24+
dynamicTitleEl.style.opacity = '0';
25+
} else {
26+
dynamicTitleEl.style.opacity = '1';
27+
}
28+
}, [titleIndex]);
29+
30+
setTimeout(handleTitleIndex, 1350);
31+
32+
return (
33+
<div
34+
className={`${styles.header} ${customClass ? styles[customClass] : ''}`}
35+
>
36+
<Nav />
37+
<Image
38+
src={imgBg}
39+
alt={imgAlt}
40+
className={styles.imageBg}
41+
layout="fill"
42+
objectFit="cover"
43+
objectPosition="center"
44+
priority
45+
/>
46+
<Container className={styles.header__content}>
47+
<div className={styles.header__content__upper}>
48+
<h1 className={titleClass ? `${styles[titleClass]}` : ''}>
49+
{title}
50+
{dynamicTitles && (
51+
<span id="dynamicTitle"> {dynamicTitles[titleIndex]}</span>
52+
)}
53+
</h1>
54+
</div>
55+
<div className={styles.header__content__bottom}>
56+
<p>{content}</p>
57+
</div>
58+
</Container>
59+
</div>
60+
);
61+
}

components/Layout.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
import Nav from './Nav';
1+
import { useRouter } from 'next/router';
2+
import { heroOptions } from '../utils/hero-options';
3+
import Hero from './Hero';
24
import Meta from './Meta';
35
import Footer from './Footer';
46
import styles from '../styles/Layout.module.scss';
57

68
export default function Layout({ children }) {
9+
const router = useRouter();
10+
const heroPathKeys = Object.keys(heroOptions)
11+
.sort((a, b) => a - b)
12+
.filter(k => router.pathname.startsWith(k));
13+
14+
const heroKey = heroPathKeys[heroPathKeys.length - 1];
715
return (
816
<>
917
<Meta />
10-
<Nav />
11-
<main className={styles.main}>{children}</main>
12-
<Footer />
18+
<main className={styles.main}>
19+
<Hero {...heroOptions[heroKey]} />
20+
{children}
21+
<Footer />
22+
</main>
1323
</>
1424
);
1525
}

components/Nav.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default function Nav() {
1515
useEffect(() => {
1616
const observer = new IntersectionObserver(
1717
([entry]) => {
18+
if (!containerRef.current) return;
1819
if (!entry.isIntersecting) {
1920
containerRef.current.classList.add(styles.sticky);
2021
} else {

pages/about-us.js renamed to pages/about.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default function AboutUs() {
22
return (
33
<div className="about-us">
4-
<h1>About Us</h1>
4+
<h2>About Us</h2>
55
<p>We're building this page.</p>
66
<p>Stay tuned!</p>
77
</div>

pages/blog/first-post.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default function FirstPost() {
22
return (
3-
<div class="post">
4-
<h1>First Post</h1>
3+
<div className="post">
4+
<h2>First Post</h2>
55
<p>We're building this page.</p>
66
<p>Stay tuned!</p>
77
</div>

pages/blog/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Link from 'next/link';
33
export default function Blog() {
44
return (
55
<div className="blog">
6-
<h1>Blog Page</h1>
6+
<h2>Blog Page</h2>
77
<p>We're building this page. Stay tuned!</p>
88
<ul>
99
<li>

pages/contact-us.js renamed to pages/contact.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default function ContactUs() {
22
return (
33
<div className="contact-us">
4-
<h1>Contact Us</h1>
4+
<h2>Contact Us</h2>
55
<p>We're building this page.</p>
66
<p>Stay tuned!</p>
77
</div>

pages/index.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,12 @@ import { white, primary } from '../styles/TwoColumn.module.scss';
77

88
export default function Home() {
99
return (
10-
<div className={styles.inner}>
11-
<div className={styles.description}>
12-
<h1 className={styles.title}>&lt; Web Dev wannabe? /&gt;</h1>
13-
<p>
14-
Hold our hand and enjoy the road to learn how to start a new project,
15-
the magic behind Github while working in a team environment, and much
16-
more...
17-
</p>
18-
</div>
19-
10+
<>
2011
<TwoColumn
2112
title="Let's grow together."
2213
image="/images/join-us.jpg"
2314
content="The Web Dev Path is a team of professional developers project that aims to provide a comprehensive path for people who seek to begin their web development journey."
24-
link="/about-us"
15+
link="/about"
2516
customBtnClass="inverted-grey"
2617
/>
2718

@@ -48,7 +39,7 @@ export default function Home() {
4839
'Would you like to volunteer? For roles other than mentor/mentee, please get in touch.',
4940
'Are you an experienced web dev who wants to become a mentor? Welcome!',
5041
]}
51-
links={['/about-us', '/contact-us', '/about-us']}
42+
links={['/about', '/contact', '/about']}
5243
linkText={['Learn more', 'Contact us', 'Learn more']}
5344
/>
5445

@@ -59,10 +50,10 @@ export default function Home() {
5950
content="Web Dev Path can help your nonprofit with web projects of various sizes. Connect with us to find out how."
6051
color={white}
6152
bgColor={primary}
62-
link="/about-us"
53+
link="/about"
6354
customInnerClass="non-profit"
6455
customBtnClass="inverted-white"
6556
/>
66-
</div>
57+
</>
6758
);
6859
}

public/images/about-us-bg.png

11.8 MB
Loading

0 commit comments

Comments
 (0)