Skip to content

Commit 3b5b893

Browse files
author
Bryce Flory
committed
Merge branch 'master' into categories
2 parents 7fe7bb4 + 02032dd commit 3b5b893

14 files changed

+132
-18
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ add_action( 'graphql_register_types', 'coa_register_graphql_connection' );
6868
- ~~[ ] Use Gatsby Image for responsiveness~~ Unnecessary since using CDN
6969
- [ ] Lazy load images, maybe(?)
7070
- [x] ~~Gallery popup~~
71-
- [ ] EXIF data to lightbox images
71+
- [x] ~~EXIF data to lightbox images~~
7272
- [x] ~~Add social share~~
7373
- [x] ~~FontAwesome integration~~
7474
- [ ] Add page transitions

Diff for: src/blocks/Gallery/CoreGalleryBlock.data.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = () => {
1313
galleryImages {
1414
nodes {
1515
mediaItemId
16+
mediaItemUrl
1617
mediaDetails {
1718
meta {
1819
aperture

Diff for: src/blocks/Gallery/CoreGalleryBlock.js

+66-13
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,97 @@ import Lightbox from 'react-image-lightbox'
33
import 'react-image-lightbox/style.css'
44

55
const CoreGalleryBlock = ({ attributes, galleryImages }) => {
6-
console.log(attributes)
6+
77
const {columns, images, imageCrop, align, caption} = attributes
8-
9-
// convert images JSON into array
10-
let imgs = JSON.parse(images)
118

129
// Set State for Lightbox
1310
const [photoIndex, setPhotoIndex] = useState(0)
1411
const [isOpen, setIsOpen] = useState(false)
1512

13+
// Shutter Speed conversion function
14+
function sSpeed(d) {
15+
if (d >= 1) {
16+
return Math.round(d) + "s"
17+
}
18+
var df = 1,
19+
top = 1,
20+
bot = 1
21+
var tol = 1e-8 // seems to allow for d > 1e-4
22+
while (df !== d && Math.abs(df - d) > tol) {
23+
if (df < d) {
24+
top += 1
25+
} else {
26+
bot += 1
27+
top = parseInt(d * bot, 10)
28+
}
29+
df = top / bot
30+
}
31+
if (top > 1) {
32+
bot = Math.round(bot / top)
33+
top = 1
34+
}
35+
if (bot <= 1) {
36+
return "1s"
37+
}
38+
return top + "/" + bot + "s"
39+
}
40+
1641
return (
1742
<figure className={`wp-block-gallery columns-${columns} is-cropped`}>
1843
<ul className="blocks-gallery-grid">
19-
{imgs.map( (img, index) => {
44+
{galleryImages.nodes.map((img, index) => {
2045
// setup onclick function to handle state change
2146
function updateOnClick() {
2247
setPhotoIndex(index)
2348
setIsOpen(true)
2449
}
2550
return (
26-
<li key={index} onClick={updateOnClick} className="blocks-gallery-item">
51+
<li
52+
key={index}
53+
onClick={updateOnClick}
54+
className="blocks-gallery-item"
55+
>
2756
<figure>
28-
<img src={img.url} />
57+
<img src={img.mediaItemUrl} />
2958
</figure>
3059
</li>
3160
)
3261
})}
33-
3462
</ul>
3563

3664
{isOpen && (
3765
<Lightbox
38-
mainSrc={imgs[photoIndex].url}
39-
nextSrc={imgs[(photoIndex + 1) % imgs.length].url}
40-
prevSrc={imgs[(photoIndex + imgs.length - 1) % imgs.length].url}
66+
mainSrc={galleryImages.nodes[photoIndex].mediaItemUrl}
67+
nextSrc={
68+
galleryImages.nodes[(photoIndex + 1) % galleryImages.nodes.length]
69+
.mediaItemUrl
70+
}
71+
prevSrc={
72+
galleryImages.nodes[
73+
(photoIndex + galleryImages.nodes.length - 1) %
74+
galleryImages.nodes.length
75+
].mediaItemUrl
76+
}
4177
onCloseRequest={() => setIsOpen(false)}
42-
onMovePrevRequest={() => setPhotoIndex( (photoIndex + imgs.length -1) % imgs.length )}
43-
onMoveNextRequest={() => setPhotoIndex( (photoIndex + 1) % imgs.length )}
78+
onMovePrevRequest={() =>
79+
setPhotoIndex(
80+
(photoIndex + galleryImages.nodes.length - 1) %
81+
galleryImages.nodes.length
82+
)
83+
}
84+
onMoveNextRequest={() =>
85+
setPhotoIndex((photoIndex + 1) % galleryImages.nodes.length)
86+
}
87+
enableZoom={false}
88+
imageCaption={`Camera: ${
89+
galleryImages.nodes[photoIndex].mediaDetails.meta.camera
90+
}, Aperture: f/${
91+
galleryImages.nodes[photoIndex].mediaDetails.meta.aperture
92+
}, ISO: ${
93+
galleryImages.nodes[photoIndex].mediaDetails.meta.iso
94+
}, Shutter Speed: ${sSpeed(
95+
galleryImages.nodes[photoIndex].mediaDetails.meta.shutterSpeed
96+
)}`}
4497
/>
4598
)}
4699
</figure>

Diff for: src/blocks/Html/CoreHtmlBlock.data.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = () => {
2+
return `
3+
... on WPGraphQL_CoreHtmlBlock {
4+
originalContent
5+
}
6+
`
7+
}

Diff for: src/blocks/Html/CoreHtmlBlock.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react"
2+
import ReactHtmlParser from 'react-html-parser'
3+
4+
const CoreHtmlBlock = ({ originalContent }) => {
5+
6+
return (
7+
ReactHtmlParser(originalContent)
8+
)
9+
}
10+
11+
export default CoreHtmlBlock

Diff for: src/blocks/Html/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from "./CoreHtmlBlock"

Diff for: src/blocks/Image/CoreImageBlock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from "react"
2-
import ReactHtmlParser from "react-html-parser"
32

43
const CoreImageBlock = ({ attributes }) => {
54
const { align, caption, className, url, alt, id } = attributes
65

76
return (
87
<figure className="wp-block-image">
98
<img src={url} alt={alt} />
9+
<figcaption>{caption}</figcaption>
1010
</figure>
1111
)
1212
}

Diff for: src/blocks/Video/CoreVideoBlock.data.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = () => {
2+
return `
3+
... on WPGraphQL_CoreVideoBlock {
4+
attributes {
5+
src
6+
poster
7+
preload
8+
playsInline
9+
muted
10+
loop
11+
controls
12+
className
13+
caption
14+
autoplay
15+
align
16+
}
17+
}
18+
`
19+
}

Diff for: src/blocks/Video/CoreVideoBlock.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from "react"
2+
3+
const CoreVideoBlock = ({ attributes }) => {
4+
const { src, poster, preoload, playsInline, muted, loop, controls, className, caption, autoplay, align } = attributes
5+
6+
return (
7+
<figure className="wp-block-video aligncenter">
8+
<video controls src={src}></video>
9+
<figcaption>{caption}</figcaption>
10+
</figure>
11+
)
12+
13+
}
14+
15+
export default CoreVideoBlock

Diff for: src/blocks/Video/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './CoreVideoBlock'

Diff for: src/components/AllBlocks.js

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import CoreListBlock from "../blocks/List"
55
import CoreImageBlock from "../blocks/Image"
66
import CoreHeadingBlock from "../blocks/Heading"
77
import CoreGalleryBlock from "../blocks/Gallery"
8+
import CoreVideoBlock from "../blocks/Video"
9+
import CoreHtmlBlock from "../blocks/Html"
810

911
const AllBlocks = ({ blockData }) => {
1012

@@ -25,6 +27,8 @@ const AllBlocks = ({ blockData }) => {
2527
WPGraphQL_CoreImageBlock: CoreImageBlock,
2628
WPGraphQL_CoreHeadingBlock: CoreHeadingBlock,
2729
WPGraphQL_CoreGalleryBlock: CoreGalleryBlock,
30+
WPGraphQL_CoreVideoBlock: CoreVideoBlock,
31+
WPGraphQL_CoreHtmlBlock: CoreHtmlBlock,
2832
page_default: Default,
2933
}
3034

Diff for: src/components/layout.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,9 @@ section.wp-block-cover-image>h2 {
860860

861861
.wp-block-image figcaption {
862862
margin-top: .5em;
863-
margin-bottom: 1em
863+
margin-bottom: 1em;
864+
margin-left: .5em;
865+
font-size: .8rem;
864866
}
865867

866868
.is-style-circle-mask img {

Diff for: src/templates/pages/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const SinglePage = props => {
1313
<Layout>
1414
<Helmet bodyAttributes={{ class: 'page' }} />
1515
<div id="primary" className="content-area wrapper">
16-
<div className="grid-wrapper">
16+
<div className="grid-wrapper grid-main">
1717
<main id="main" className="site-main" role="main">
1818
<article data-id={id} id={`post-${postId}`} className={`post-${postId} page type-page status-publish hentry entry`} >
1919
<header className="entry-header">

Diff for: src/templates/posts/single.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const SinglePost = ({ pageContext }) => {
2828
next,
2929
},
3030
} = pageContext
31-
console.log(pageContext.prev)
31+
3232
const allBlocks = blocks || []
3333

3434
return (

0 commit comments

Comments
 (0)