From 81aa71be2aba39c260d05139790bc72e7c9001d3 Mon Sep 17 00:00:00 2001 From: ayan4m1 Date: Thu, 8 Feb 2024 03:47:17 -0500 Subject: [PATCH] get justified grid working for image gallery --- src/pages/images.js | 54 +++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/src/pages/images.js b/src/pages/images.js index 0bc0827..a185178 100644 --- a/src/pages/images.js +++ b/src/pages/images.js @@ -1,9 +1,11 @@ import { useMemo } from 'react'; import { graphql } from 'gatsby'; import PropTypes from 'prop-types'; -import { compareAsc, parseISO } from 'date-fns'; -import { Col, Container, Row } from 'react-bootstrap'; +import { Container, Row, Col } from 'react-bootstrap'; import { GatsbyImage, getImage } from 'gatsby-plugin-image'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faImagePortrait } from '@fortawesome/free-solid-svg-icons'; +import { compareAsc, parseISO } from 'date-fns'; import Layout from 'components/layout'; @@ -12,7 +14,9 @@ export default function ImagesPage({ data }) { const newData = data.allImageSharp.nodes.map((node) => ({ id: node.id, date: node.fields.exif.meta.dateTaken ?? '1970-01-01T00:00:00', - image: getImage(node) + image: getImage(node), + height: node.gatsbyImageData.height, + width: node.gatsbyImageData.width })); newData.sort((a, b) => compareAsc(parseISO(a.date), parseISO(b.date))); @@ -20,16 +24,42 @@ export default function ImagesPage({ data }) { return newData; }, [data]); + // const firstImageDate = imageData[0].date; + // const lastImageData = imageData[imageData.length - 1].date; + + // const monthSpan = differenceInMonths( + // parseISO(lastImageData), + // parseISO(firstImageDate) + // ); + return ( -

Images

+ + +

+ {' '} + Images +

+ +
- {imageData.map(({ id, image }) => ( - - - - ))} + + {imageData.map(({ id, image, height, width }) => ( + + ))} +
@@ -45,11 +75,7 @@ export const pageQuery = graphql` allImageSharp { nodes { id - gatsbyImageData( - layout: CONSTRAINED - placeholder: BLURRED - formats: [WEBP] - ) + gatsbyImageData(height: 200) fields { exif { meta {