1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-06-23 01:36:39 +02:00
portfolio/src/pages/{ProjectsYaml.slug}.jsx

126 lines
2.9 KiB
React
Raw Normal View History

2018-11-25 01:52:31 +01:00
import React, { PureComponent } from 'react'
2018-04-21 13:39:18 +02:00
import PropTypes from 'prop-types'
2018-06-21 21:06:53 +02:00
import { graphql } from 'gatsby'
2020-11-20 23:36:55 +01:00
import FullWidth from '../components/atoms/FullWidth'
import ProjectImage from '../components/atoms/ProjectImage'
import ProjectTechstack from '../components/molecules/ProjectTechstack'
import ProjectLinks from '../components/molecules/ProjectLinks'
import ProjectNav from '../components/molecules/ProjectNav'
import SEO from '../components/atoms/SEO'
2021-03-12 23:47:28 +01:00
import {
meta,
imageWrap,
headerTitle,
description
} from './{ProjectsYaml.slug}.module.css'
2018-04-21 13:39:18 +02:00
2018-11-25 01:52:31 +01:00
class ProjectMeta extends PureComponent {
static propTypes = {
links: PropTypes.array,
techstack: PropTypes.array
}
render() {
const { links, techstack } = this.props
return (
2021-03-12 23:47:28 +01:00
<footer className={meta}>
2018-11-25 01:52:31 +01:00
{!!links && <ProjectLinks links={links} />}
{!!techstack && <ProjectTechstack techstack={techstack} />}
</footer>
)
}
}
2018-05-22 22:41:59 +02:00
2018-12-07 10:31:35 +01:00
class ProjectImages extends PureComponent {
static propTypes = {
projectImages: PropTypes.array,
title: PropTypes.string
}
2018-05-23 00:03:46 +02:00
2018-12-07 10:31:35 +01:00
render() {
return (
<FullWidth>
{this.props.projectImages.map(({ node }) => (
2021-03-12 23:47:28 +01:00
<div className={imageWrap} key={node.id}>
2018-12-07 10:31:35 +01:00
<ProjectImage fluid={node.fluid} alt={this.props.title} />
</div>
))}
</FullWidth>
)
}
2018-05-23 00:03:46 +02:00
}
2018-11-25 01:52:31 +01:00
export default class Project extends PureComponent {
static propTypes = {
data: PropTypes.object.isRequired,
location: PropTypes.object.isRequired
}
render() {
2018-12-07 10:31:35 +01:00
const { data } = this.props
const project = data.projectsYaml
const projectImages = data.projectImages.edges
const descriptionHtml = data.projectsYaml.fields.descriptionHtml
2018-11-25 01:52:31 +01:00
const { title, links, techstack } = project
return (
<>
<SEO project={project} />
2018-04-21 13:39:18 +02:00
2018-11-25 01:52:31 +01:00
<article>
<header>
2021-03-12 23:47:28 +01:00
<h1 className={headerTitle}>{title}</h1>
2018-11-25 01:52:31 +01:00
</header>
<div
2021-03-12 23:47:28 +01:00
className={description}
2018-11-25 01:52:31 +01:00
dangerouslySetInnerHTML={{ __html: descriptionHtml }}
/>
<ProjectImages projectImages={projectImages} title={title} />
<ProjectMeta links={links} techstack={techstack} />
</article>
<ProjectNav currentSlug={project.slug} />
2018-11-25 01:52:31 +01:00
</>
)
}
}
2018-04-21 13:39:18 +02:00
2018-12-07 10:31:35 +01:00
export const projectQuery = graphql`
query($slug: String!, $imageRegex: String!) {
2018-05-05 00:17:26 +02:00
projectsYaml(slug: { eq: $slug }) {
2018-05-04 14:00:21 +02:00
title
slug
2018-11-25 01:52:31 +01:00
fields {
descriptionHtml
excerpt
2018-11-25 01:52:31 +01:00
}
2018-05-04 14:00:21 +02:00
links {
title
url
2019-11-13 11:59:59 +01:00
icon
2018-04-21 13:39:18 +02:00
}
2018-05-04 14:00:21 +02:00
techstack
2018-05-07 01:43:33 +02:00
img {
childImageSharp {
twitterImage: resize(width: 980) {
src
}
}
}
2018-04-21 13:39:18 +02:00
}
2018-05-04 16:54:08 +02:00
projectImages: allImageSharp(
filter: { fluid: { originalName: { regex: $imageRegex } } }
2018-07-14 02:18:22 +02:00
sort: { fields: [fluid___originalName], order: ASC }
2018-05-04 16:54:08 +02:00
) {
2018-05-04 01:58:43 +02:00
edges {
node {
id
2018-06-19 22:48:33 +02:00
...ProjectImageFluid
2018-04-21 20:01:50 +02:00
}
}
}
2018-04-21 13:39:18 +02:00
}
`