Skip to content

Commit

Permalink
made the sponsor section work
Browse files Browse the repository at this point in the history
  • Loading branch information
bahorn committed Dec 18, 2019
1 parent c955ed4 commit 31ecf5d
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 66 deletions.
7 changes: 7 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ module.exports = {
path: `${__dirname}/src/collections/team`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `sponsor`,
path: `${__dirname}/src/collections/sponsors`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
Expand Down
7 changes: 7 additions & 0 deletions src/collections/sponsors/partner/mlh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: MLH
url: https://mlh.io/
logo: /sponsors/mlh-logo-color.svg
tier: partner
type: sponsor
---
141 changes: 77 additions & 64 deletions src/components/Sponsors/Sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,38 @@ import { Jumbotron, Container, Card, Row, Col } from 'reactstrap'

import { DiagonalSplit } from '..'

// TODO: Replace with sponsors from CMS
const tempSponsors = [
// {
// tierName: 'Platinum',
// color: '#CCC2C2',
// // sponsors: [{ name: 'Company name', logo: 'image source', link: 'url' }],
// },
// {
// tierName: 'Gold',
// color: '#C98910',
// sponsors: [],
// },
// {
// tierName: 'Silver',
// color: '#A8A8A8',
// sponsors: [],
// },
// {
// tierName: 'Bronze',
// color: '#965A38',
// sponsors: [],
// },
]
const sponsorTiers = {
platinum: {
name: 'Platinum',
color: '#CCC2C2',
order: 1,
companies: [],
},
gold: {
name: 'Gold',
color: '#C98910',
order: 2,
companies: [],
},
silver: {
name: 'Silver',
color: '#A8A8A8',
order: 3,
companies: [],
},
bronze: {
name: 'Bronze',
color: '#965A38',
order: 4,
companies: [],
},
partner: {
name: 'Partner',
color: '#323232',
order: 5,
companies: [],
},
}

const ComingSoon = () => (
<p className="mt-4 mb-4" style={{ textAlign: 'center', opacity: 0.6 }}>
Expand All @@ -36,49 +45,53 @@ const ComingSoon = () => (
</p>
)

export class Sponsors extends Component {
render() {
return (
<Jumbotron style={{ padding: 0 }}>
<DiagonalSplit invert />
<Container
className="jumbotron-padding"
style={{ paddingTop: '4em', paddingBottom: '2em' }}>
<h1 style={{ textAlign: 'center' }}>Sponsors</h1>

const Tier = ({ tier }) => (
<div key={tier.name}>
<h2 className="mt-5" style={{ color: tier.color, textAlign: 'center' }}>
{tier.name.toUpperCase()}
</h2>
<Row className="justify-content-md-center">
{tier.companies && tier.companies.length ? (
tier.companies.map(sponsor => (
<Col xs="6" sm="4">
<a href={sponsor.url}>
<img src={sponsor.logo} alt={sponsor.name} />
</a>
</Col>
))
) : (
<Col>
<ComingSoon />
</Col>
)}
</Row>
</div>
)

<p className="mt-4 mb-4" style={{ textAlign: 'center' }}>
Interested in sponsoring? Email us at{' '}
<a href="mailto:[email protected]">[email protected]</a>!
</p>
export const Sponsors = ({ sponsors }) => {
/* Build up the tier list */
let tierList = { ...sponsorTiers }
sponsors.map(company => {
const { name, url, logo, tier } = company
tierList[tier].companies.push({ name, url, logo })
})
const sponsorData = Object.values(tierList).sort((a, b) => a.order - b.order)
return (
<Jumbotron style={{ padding: 0 }}>
<DiagonalSplit invert />
<Container className="jumbotron-padding" style={{ paddingTop: '4em', paddingBottom: '2em' }}>
<h1 style={{ textAlign: 'center' }}>Sponsors</h1>

{tempSponsors.map(tier => (
<div key={tier.tierName}>
<h2 className="mt-5" style={{ color: tier.color, textAlign: 'center' }}>
{tier.tierName.toUpperCase()}
</h2>
{sponsorData.map(tier => (
<div>{tier.companies.length > 0 && <Tier tier={tier} />}</div>
))}

<Row className="justify-content-md-center">
{tier.sponsors && tier.sponsors.length ? (
tier.sponsors.map(sponsor => (
<Col xs="6" sm="4">
<Card>
<h3>{sponsor.name}</h3>
</Card>
</Col>
))
) : (
<Col>
<ComingSoon />
</Col>
)}
</Row>
</div>
))}
</Container>
<DiagonalSplit />
</Jumbotron>
)
}
<p className="mt-4 mb-4" style={{ textAlign: 'center' }}>
Interested in sponsoring? Email us at{' '}
<a href="mailto:[email protected]">[email protected]</a>!
</p>
</Container>
<DiagonalSplit />
</Jumbotron>
)
}
22 changes: 20 additions & 2 deletions src/templates/index-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '../components'

export default function IndexPage({ data, pageContext: { font } }) {
const { markdownRemark, howToFindUs, faq, team, file } = data
const { markdownRemark, howToFindUs, faq, team, file, sponsor } = data
const { frontmatter, html } = markdownRemark

useEffect(() => {
Expand All @@ -33,6 +33,9 @@ export default function IndexPage({ data, pageContext: { font } }) {
const teamData = team.edges
.map(e => ({ ...e.node, ...e.node.frontmatter }))
.filter(e => e.type === 'team')
const sponsorData = sponsor.edges
.map(e => ({ ...e.node, ...e.node.frontmatter }))
.filter(e => e.type === 'sponsor')

const backgroundImage = file.childImageSharp.fluid

Expand Down Expand Up @@ -114,7 +117,7 @@ export default function IndexPage({ data, pageContext: { font } }) {
<Map />
</Container>

<Sponsors className="mb-10" />
<Sponsors sponsors={sponsorData} className="mb-10" />

<Container style={{ marginTop: '3em', marginBottom: '3em' }}>
<h2 style={{ marginTop: '1.5rem' }}>
Expand Down Expand Up @@ -197,6 +200,21 @@ export const pageQuery = graphql`
}
}
sponsor: allMarkdownRemark(filter: { frontmatter: { type: { eq: "sponsor" } } }) {
edges {
node {
id
frontmatter {
name
url
logo
tier
type
}
}
}
}
file(relativePath: { eq: "CH-20190316-20-27-27.jpg" }) {
childImageSharp {
fluid(quality: 90, maxWidth: 1920) {
Expand Down
1 change: 1 addition & 0 deletions static/sponsors/mlh-logo-color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 31ecf5d

Please sign in to comment.