Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 98136c8

Browse files
committedJan 14, 2020
Add hero, sponsors, and style to chapter page
1 parent 2a9faaa commit 98136c8

File tree

10 files changed

+135
-14
lines changed

10 files changed

+135
-14
lines changed
 

‎content/chapters/seattle.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"city": "Seattle"
2+
"city": "Seattle",
3+
"photo": "chapters/seattle.jpg",
4+
"meetup": "https://www.meetup.com/WSC-Seattle"
35
}

‎gatsby-node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ exports.createPages = ({ actions, graphql }) => {
4848
node {
4949
id
5050
city
51+
photo
5152
fields {
5253
slug
5354
}
@@ -81,12 +82,14 @@ exports.createPages = ({ actions, graphql }) => {
8182
chapterPages.forEach(edge => {
8283
const id = edge.node.id
8384
const city = edge.node.city
85+
const photo = edge.node.photo
8486
createPage({
8587
path: edge.node.fields.slug,
8688
component: path.resolve(`src/templates/chapter.js`),
8789
context: {
8890
id,
8991
city,
92+
photo,
9093
},
9194
})
9295
})

‎src/components/external-link/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3+
import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons'
4+
5+
const ExternalLink = ({ href, text }) => (
6+
<a href={href} className="link" target="_blank" rel="noopener noreferrer">
7+
{text}&nbsp;
8+
<FontAwesomeIcon icon={faExternalLinkAlt} aria-hidden />
9+
</a>
10+
)
11+
12+
export default ExternalLink

‎src/components/header/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const Header = () => {
3030
<Img
3131
fixed={data.file.childImageSharp.fixed}
3232
alt="Write/Speak/Code logo in full color"
33-
className={styles.logo}
3433
/>
3534
</Link>
3635
<Menu />

‎src/components/hero/hero.module.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.overlay {
2+
background: linear-gradient(
3+
to right,
4+
RGBA(255, 255, 255, 0.5),
5+
RGBA(255, 255, 255, 0.5)
6+
);
7+
width: 100%;
8+
height: 100%;
9+
display: table;
10+
}
11+
12+
.hero {
13+
margin: 4em 2em;
14+
@media screen and (min-width: 50em) {
15+
margin: 8em 2em;
16+
}
17+
@media screen and (min-width: 95em) {
18+
max-width: var(--container);
19+
margin: 8em auto;
20+
}
21+
22+
h1,
23+
a {
24+
display: inline;
25+
background: var(--white);
26+
padding: 0.25em 0.5em;
27+
}
28+
a {
29+
background-color: var(--mint);
30+
}
31+
}
32+
33+
.cta {
34+
margin-top: 1em;
35+
}

‎src/components/hero/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react'
2+
import BackgroundImage from 'gatsby-background-image'
3+
import ExternalLink from '../external-link'
4+
5+
import styles from './hero.module.css'
6+
7+
const Hero = ({ title, link, photo }) => (
8+
<div className={styles.container}>
9+
<BackgroundImage
10+
Tag="section"
11+
fluid={photo}
12+
backgroundColor={`var(--mint)`}
13+
alt={`${title} chapter photo`}
14+
>
15+
<div className={styles.overlay}>
16+
<section className={styles.hero}>
17+
<h1>{title}</h1>
18+
<div className={styles.cta}>
19+
<ExternalLink href={link} text="Join the meetup group" />
20+
</div>
21+
</section>
22+
</div>
23+
</BackgroundImage>
24+
</div>
25+
)
26+
27+
export default Hero

‎src/components/sponsors/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ import techbychoice from '../../../content/sponsors/techbychoice.json'
4646
import brooklynjs from '../../../content/sponsors/brooklynjs.json'
4747
import outintech from '../../../content/sponsors/out-in-tech.json'
4848

49+
// Basic grid component for chapter pages
50+
export const SponsorsGrid = ({ sponsors }) => (
51+
<section className={[styles['other'], styles.levelSection].join(' ')}>
52+
<h3 className={styles.heading}>Chapter Sponsors</h3>
53+
<div className={styles.grid}>
54+
{sponsors.map(sponsor => (
55+
<Sponsor company={sponsor.node} key={sponsor.id} />
56+
))}
57+
</div>
58+
</section>
59+
)
60+
61+
// Custom grid for homepage and conference page
4962
const Sponsors = ({ sponsors, isConference }) => {
5063
return (
5164
<section id="sponsorship">

‎src/images/chapters/seattle.jpg

1.57 MB
Loading

‎src/layouts/base.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ a {
6464
color: inherit;
6565
}
6666

67+
.container {
68+
margin: 2em;
69+
@media screen and (min-width: 90em) {
70+
max-width: var(--container);
71+
margin: 0 auto;
72+
}
73+
}
74+
6775
.link {
6876
display: inline;
6977
border-bottom: 4px solid;

‎src/templates/chapter.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
11
import React from 'react'
22
import { graphql } from 'gatsby'
3-
import Layout from '../layouts/default'
3+
import { SkipNavLink, SkipNavContent } from '@reach/skip-nav'
4+
import Header from '../components/header'
5+
import Footer from '../components/footer'
6+
import { SponsorsGrid } from '../components/sponsors'
7+
8+
import Hero from '../components/hero'
49

510
const ChapterTemplate = ({ data }) => {
611
const { chaptersJson: chapter, allSponsorsJson: sponsors } = data
712
return (
8-
<Layout>
9-
<section>
10-
<h1>{chapter.city}</h1>
11-
<ul>
12-
{sponsors.edges.map(sponsor => (
13-
<li key={sponsor.node.id}>{sponsor.node.name}</li>
14-
))}
15-
</ul>
16-
</section>
17-
</Layout>
13+
<>
14+
<SkipNavLink />
15+
<Header />
16+
<SkipNavContent>
17+
<main>
18+
<Hero
19+
title={chapter.city}
20+
link={chapter.meetup}
21+
photo={data.file.childImageSharp.fluid}
22+
/>
23+
24+
<section className="container">
25+
<SponsorsGrid sponsors={sponsors.edges} />
26+
</section>
27+
</main>
28+
</SkipNavContent>
29+
<Footer />
30+
</>
1831
)
1932
}
2033

2134
export default ChapterTemplate
2235

2336
export const chapterQuery = graphql`
24-
query Chapter($id: String!, $city: String!) {
37+
query Chapter($id: String!, $city: String!, $photo: String!) {
2538
chaptersJson(id: { eq: $id }) {
2639
city
40+
meetup
41+
photo
2742
}
2843
allSponsorsJson(
2944
filter: { sponsorships: { elemMatch: { city: { eq: $city } } } }
@@ -37,5 +52,12 @@ export const chapterQuery = graphql`
3752
}
3853
}
3954
}
55+
file(relativePath: { eq: $photo }) {
56+
childImageSharp {
57+
fluid(maxWidth: 3600) {
58+
...GatsbyImageSharpFluid_tracedSVG
59+
}
60+
}
61+
}
4062
}
4163
`

0 commit comments

Comments
 (0)
Please sign in to comment.