This commit is contained in:
@@ -19,7 +19,12 @@ jobs:
|
|||||||
node-version: 18
|
node-version: 18
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm install
|
run: |
|
||||||
|
npm install --legacy-peer-deps
|
||||||
|
npm install -g gatsby-cli
|
||||||
|
|
||||||
|
- name: Clean Gatsby cache
|
||||||
|
run: gatsby clean
|
||||||
|
|
||||||
- name: Build Gatsby Site
|
- name: Build Gatsby Site
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports = {
|
|||||||
background_color: '#663399',
|
background_color: '#663399',
|
||||||
theme_color: '#663399',
|
theme_color: '#663399',
|
||||||
display: 'minimal-ui',
|
display: 'minimal-ui',
|
||||||
icon: 'src/assets/images/website-icon-dt.png', // This path is relative to the root of the site.
|
icon: 'src/assets/images/website-icon-dt.png',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'gatsby-plugin-sass',
|
'gatsby-plugin-sass',
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-helmet": "^6.1.0",
|
"react-helmet": "^6.1.0",
|
||||||
"react-images": "^1.2.0-beta.7"
|
"yet-another-react-lightbox": "^3.15.6"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"gatsby"
|
"gatsby"
|
||||||
|
|||||||
@@ -1,106 +1,50 @@
|
|||||||
import PropTypes from 'prop-types';
|
import React, { useState } from 'react'
|
||||||
import React, { Component } from 'react';
|
import Lightbox from "yet-another-react-lightbox"
|
||||||
import Lightbox from 'react-images';
|
import "yet-another-react-lightbox/styles.css"
|
||||||
|
|
||||||
class Gallery extends Component {
|
const Gallery = ({ images }) => {
|
||||||
constructor () {
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
super();
|
const [photoIndex, setPhotoIndex] = useState(0)
|
||||||
|
|
||||||
this.state = {
|
const openLightbox = (index) => {
|
||||||
lightboxIsOpen: false,
|
setPhotoIndex(index)
|
||||||
currentImage: 0,
|
setIsOpen(true)
|
||||||
};
|
}
|
||||||
|
|
||||||
this.closeLightbox = this.closeLightbox.bind(this);
|
return (
|
||||||
this.gotoNext = this.gotoNext.bind(this);
|
<>
|
||||||
this.gotoPrevious = this.gotoPrevious.bind(this);
|
{isOpen && (
|
||||||
this.gotoImage = this.gotoImage.bind(this);
|
|
||||||
this.handleClickImage = this.handleClickImage.bind(this);
|
|
||||||
this.openLightbox = this.openLightbox.bind(this);
|
|
||||||
}
|
|
||||||
openLightbox (index, event) {
|
|
||||||
event.preventDefault();
|
|
||||||
this.setState({
|
|
||||||
currentImage: index,
|
|
||||||
lightboxIsOpen: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
closeLightbox () {
|
|
||||||
this.setState({
|
|
||||||
currentImage: 0,
|
|
||||||
lightboxIsOpen: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
gotoPrevious () {
|
|
||||||
this.setState({
|
|
||||||
currentImage: this.state.currentImage - 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
gotoNext () {
|
|
||||||
this.setState({
|
|
||||||
currentImage: this.state.currentImage + 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
gotoImage (index) {
|
|
||||||
this.setState({
|
|
||||||
currentImage: index,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handleClickImage () {
|
|
||||||
if (this.state.currentImage === this.props.images.length - 1) return;
|
|
||||||
|
|
||||||
this.gotoNext();
|
|
||||||
}
|
|
||||||
renderGallery () {
|
|
||||||
const { images } = this.props;
|
|
||||||
|
|
||||||
if (!images) return;
|
|
||||||
|
|
||||||
const gallery = images.map((obj, i) => {
|
|
||||||
return (
|
|
||||||
<article className="6u 12u$(xsmall) work-item" key={i}>
|
|
||||||
<a
|
|
||||||
className="image fit thumb"
|
|
||||||
href={obj.src}
|
|
||||||
onClick={(e) => this.openLightbox(i, e)}
|
|
||||||
>
|
|
||||||
<img src={obj.thumbnail} alt={obj.caption}/>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<h3>{obj.caption}</h3>
|
|
||||||
<p>{obj.description}</p>
|
|
||||||
</article>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="row">
|
|
||||||
{gallery}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
render () {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
{this.renderGallery()}
|
|
||||||
<Lightbox
|
<Lightbox
|
||||||
currentImage={this.state.currentImage}
|
open={isOpen}
|
||||||
images={this.props.images}
|
close={() => setIsOpen(false)}
|
||||||
isOpen={this.state.lightboxIsOpen}
|
index={photoIndex}
|
||||||
onClickImage={this.handleClickImage}
|
slides={images.map(img => ({
|
||||||
onClickNext={this.gotoNext}
|
src: img.src,
|
||||||
onClickPrev={this.gotoPrevious}
|
title: img.caption,
|
||||||
onClickThumbnail={this.gotoImage}
|
description: img.description
|
||||||
onClose={this.closeLightbox}
|
}))}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
<div className="row">
|
||||||
|
{images.map((obj, i) => (
|
||||||
|
<article className="6u 12u$(xsmall) work-item" key={i}>
|
||||||
|
<a
|
||||||
|
className="image fit thumb"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
openLightbox(i)
|
||||||
|
}}
|
||||||
|
href={obj.src}
|
||||||
|
>
|
||||||
|
<img src={obj.thumbnail} alt={obj.caption} />
|
||||||
|
</a>
|
||||||
|
<h3>{obj.caption}</h3>
|
||||||
|
<p>{obj.description}</p>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
</>
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Gallery.displayName = 'Gallery';
|
export default Gallery
|
||||||
Gallery.propTypes = {
|
|
||||||
images: PropTypes.array
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Gallery;
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Helmet from 'react-helmet'
|
import { Helmet } from 'react-helmet'
|
||||||
|
|
||||||
import Layout from '../components/layout'
|
import Layout from '../components/layout'
|
||||||
// import Lightbox from 'react-images'
|
// import Lightbox from 'react-images'
|
||||||
@@ -39,11 +39,11 @@ class HomeIndex extends React.Component {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
lightboxIsOpen: false,
|
invalid: false,
|
||||||
currentImage: 0,
|
displayErrors: false,
|
||||||
};
|
res: null
|
||||||
|
}
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this)
|
||||||
this.closeLightbox = this.closeLightbox.bind(this);
|
this.closeLightbox = this.closeLightbox.bind(this);
|
||||||
this.gotoNext = this.gotoNext.bind(this);
|
this.gotoNext = this.gotoNext.bind(this);
|
||||||
this.gotoPrevious = this.gotoPrevious.bind(this);
|
this.gotoPrevious = this.gotoPrevious.bind(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user