diff --git a/src/components/Gallery.tsx b/src/components/Gallery.tsx index e7a66886..22c81ef1 100644 --- a/src/components/Gallery.tsx +++ b/src/components/Gallery.tsx @@ -25,7 +25,7 @@ export const Gallery: React.FC = ({ images }) => { $('#gallery').justifiedGallery({ rowHeight: 240, captions: false, - margins: 1 + margins: 4 }) }, []) diff --git a/src/templates/project.tsx b/src/templates/project.tsx index 0b774c0e..687b59cf 100644 --- a/src/templates/project.tsx +++ b/src/templates/project.tsx @@ -1,128 +1,36 @@ import { graphql, PageProps } from 'gatsby' -import { GatsbyImage, getSrc, getSrcSet } from 'gatsby-plugin-image' -import React, { Component } from 'react' -import Lightbox from 'react-images' +import React from 'react' import styled from 'styled-components' +import Gallery from '../components/Gallery' import Layout from '../components/Layout' import ProjectHeader from '../components/ProjectHeader' import SEO from '../components/SEO' -const Background = styled.div` - background-color: ${(props) => props.theme.colors.bg}; - position: relative; - padding: 2rem 0 0 0; -` - -const OuterWrapper = styled.div` +const Content = styled.div` padding: 0 ${(props) => props.theme.contentPadding}; - margin: -5rem auto 0 auto; - - column-count: 1; - column-gap: 15px; - - @media (min-width: ${(props) => props.theme.breakpoints.xs}) { - column-count: 2; - } - @media (min-width: ${(props) => props.theme.breakpoints.m}) { - column-count: 3; - } - @media (min-width: ${(props) => props.theme.breakpoints.l}) { - column-count: 4; - } ` -const InnerWrapper = styled.div` - break-inside: avoid; - margin-bottom: 15px; - cursor: pointer; - - // Fix column layout on safari - @media not all and (min-resolution: 0.001dpcm) { - @media { - display: inline-block; - width: 100%; - margin-bottom: 10px; - } - } -` - -class Project extends Component> { - img = null - - state = { - photo: undefined, - lightbox: false, - // eslint-disable-next-line react/destructuring-assignment - photos: this.props.data.images.edges.map((image) => ({ - srcSet: getSrcSet(image.node.childImageSharp.fluid), - src: getSrc(image.node.childImageSharp.fixed), - thumbnail: getSrc(image.node.childImageSharp.fixed) - })) - } - - gotoPrevLightboxImage() { - const { photo } = this.state - this.setState({ photo: photo - 1 }) - } - - gotoNextLightboxImage() { - const { photo } = this.state - this.setState({ photo: photo + 1 }) - } - - openLightbox(photo, event) { - this.img = event.target - event.preventDefault() - this.setState({ lightbox: true, photo }) - } - - closeLightbox() { - this.setState({ lightbox: false }) - if (this.img) { - this.img.scrollIntoView() - this.img = null - } - } - - render() { - const { - pageContext: { slug }, - children, - data: { mdx: postNode, images: imgs } - } = this.props - const images = imgs.edges - const project = postNode.frontmatter - const { photos, photo, lightbox } = this.state - return ( - - - - - - - {images.map((image, i) => ( - this.openLightbox(i, e)}> - - - ))} - - - this.gotoPrevLightboxImage()} - onClickNext={() => this.gotoNextLightboxImage()} - onClose={() => this.closeLightbox()} - onClickThumbnail={(p) => this.setState({ photo: p })} - /> - - - ) - } +const Project = ({ + children, + pageContext: { slug }, + data: { mdx: postNode, images } +}: PageProps) => { + const project = postNode.frontmatter + return ( + + + + + + ({ + fixed: image.node.childImageSharp.fixed, + fluid: image.node.childImageSharp.fluid + }))} + /> + + + ) } export default Project