Skip to content

Commit

Permalink
gatsby v3 update
Browse files Browse the repository at this point in the history
  • Loading branch information
decimoseptimo committed May 8, 2021
1 parent eda80f7 commit 0ada472
Show file tree
Hide file tree
Showing 17 changed files with 10,755 additions and 11,414 deletions.
13 changes: 6 additions & 7 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
},
},
`gatsby-transformer-json`,
`gatsby-plugin-image`,
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
Expand Down Expand Up @@ -73,13 +74,11 @@ module.exports = {
description
images {
childImageSharp {
fluid(maxWidth: 1080) {
base64
aspectRatio
src
srcSet
sizes
}
gatsbyImageData(
width: 550
layout: CONSTRAINED
placeholder: BLURRED
)
}
}
}
Expand Down
21,913 changes: 10,625 additions & 11,288 deletions package-lock.json

Large diffs are not rendered by default.

55 changes: 28 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,48 @@
"version": "0.1.0",
"author": "Kyle Mathews <[email protected]>",
"dependencies": {
"gatsby": "^2.29.2",
"gatsby": "^3.1.2",
"gatsby-awesome-pagination": "^0.3.6",
"gatsby-image": "^2.8.0",
"gatsby-image": "^3.1.0",
"gatsby-plugin-favicon": "^3.1.6",
"gatsby-plugin-image": "^1.1.2",
"gatsby-plugin-local-search": "^2.0.0",
"gatsby-plugin-manifest": "^2.9.1",
"gatsby-plugin-offline": "^3.7.1",
"gatsby-plugin-react-helmet": "^3.7.0",
"gatsby-plugin-sharp": "^2.11.2",
"gatsby-plugin-styled-jsx": "^3.7.0",
"gatsby-source-filesystem": "^2.8.1",
"gatsby-transformer-json": "^2.8.0",
"gatsby-transformer-sharp": "^2.9.0",
"mobile-detect": "^1.4.4",
"gatsby-plugin-manifest": "^3.1.0",
"gatsby-plugin-offline": "^4.1.0",
"gatsby-plugin-react-helmet": "^4.1.0",
"gatsby-plugin-sharp": "^3.1.2",
"gatsby-plugin-styled-jsx": "^4.1.0",
"gatsby-source-filesystem": "^3.1.0",
"gatsby-transformer-json": "^3.1.0",
"gatsby-transformer-sharp": "^3.1.0",
"mobile-detect": "^1.4.5",
"normalize.css": "^8.0.1",
"prop-types": "^15.7.2",
"query-string": "^6.13.7",
"rc-collapse": "^2.1.0",
"rc-input-number": "^6.1.2",
"rc-pagination": "^3.1.3",
"react": "^17.0.1",
"react-autosuggest": "^10.0.4",
"react-dom": "^17.0.1",
"query-string": "^7.0.0",
"rc-collapse": "^3.1.0",
"rc-input-number": "^7.0.2",
"rc-pagination": "^3.1.6",
"react": "^17.0.2",
"react-autosuggest": "^10.1.0",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
"react-highlight-words": "^0.16.0",
"react-hook-form": "^6.13.1",
"react-icons": "^4.1.0",
"react-lunr": "^1.0.0",
"react-nl2br": "^1.0.1",
"react-slick": "^0.27.13",
"react-highlight-words": "^0.17.0",
"react-hook-form": "^6.15.5",
"react-icons": "^4.2.0",
"react-lunr": "^1.1.0",
"react-nl2br": "^1.0.2",
"react-slick": "^0.28.1",
"react-use-flexsearch": "^0.1.1",
"simplebar": "^5.3.0",
"simplebar-react": "^2.3.0",
"slick-carousel": "^1.8.1",
"slugify": "^1.4.6",
"styled-jsx": "^3.3.2",
"slugify": "^1.5.0",
"styled-jsx": "^3.4.4",
"typeface-source-sans-pro": "0.0.75"
},
"devDependencies": {
"@types/styled-jsx": "^2.2.8",
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.18",
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.21",
"mark.js": "^8.11.1",
"prettier": "^2.2.1"
},
Expand Down
37 changes: 9 additions & 28 deletions src/components/image.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
import React from "react"
import { StaticQuery, graphql } from "gatsby"
import Img from "gatsby-image"

/*
* This component is built using `gatsby-image` to automatically serve optimized
* images with lazy loading and reduced file sizes. The image is loaded using a
* `StaticQuery`, which allows us to load the image from directly within this
* component, rather than having to pass the image data down from forms.
*
* For more information, see the docs:
* - `gatsby-image`: https://gatsby.dev/gatsby-image
* - `StaticQuery`: https://gatsby.dev/staticquery
*/
import { StaticImage } from "gatsby-plugin-image"

const Image = () => (
<StaticQuery
query={graphql`
query {
placeholderImage: file(relativePath: { eq: "gatsby-astronaut.png" }) {
childImageSharp {
fluid(maxWidth: 300) {
...GatsbyImageSharpFluid
}
}
}
}
`}
render={(data) => (
<Img fluid={data.placeholderImage.childImageSharp.fluid} />
)}
<StaticImage
src="../images/gatsby-astronaut.png"
width={300}
quality={95}
formats={["auto", "webp", "avif"]}
alt="A Gatsby astronaut"
// style={{ marginBottom: `1.45rem` }}
/>
)

export default Image
2 changes: 1 addition & 1 deletion src/components/inputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const InputNumber = ({
min,
max,
onChange,
onDelete,
onDelete = null,
}) => {
// console.log("\nInputNumber!")
// console.log(value)
Expand Down
7 changes: 7 additions & 0 deletions src/components/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect } from "react"
import PropTypes from "prop-types"
import SimpleBar from "simplebar-react"
import "simplebar/dist/simplebar.min.css"
import _JSXStyle from "styled-jsx/style"

import Header from "./header"
import Overlay from "./overlay"
Expand Down Expand Up @@ -32,6 +33,12 @@ import {
} from "./sidepanel/panels"
import "./layout.css"

// Temp fix for "_JSXStyle is not defined" error
// https://github.com/vercel/styled-jsx/issues/695#issuecomment-805346577
if (typeof global !== "undefined") {
Object.assign(global, { _JSXStyle })
}

const Layout = ({ location, children }) => {
const { getFromRoutesHistory, setToRoutesHistory } = useRoutesHistory()
const routes = useGetRoutes()
Expand Down
7 changes: 5 additions & 2 deletions src/components/product/productCard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { Link } from "gatsby"
import Img from "gatsby-image"
import { GatsbyImage } from "gatsby-plugin-image"

import Image from "../image"

Expand All @@ -15,7 +15,10 @@ const ProductCard = ({
hasMountedAndHasValue,
}) => {
const image = data.images ? (
<Img fluid={data.images[0].childImageSharp.fluid} alt={data.title} />
<GatsbyImage
image={data.images[0].childImageSharp.gatsbyImageData}
alt={data.title}
/>
) : (
<Image />
)
Expand Down
13 changes: 7 additions & 6 deletions src/components/product/productGallery.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useRef, useState, useMemo } from "react"
import Slider from "react-slick"
import Image from "gatsby-image"
import { GatsbyImage } from "gatsby-plugin-image"
import "../../../node_modules/slick-carousel/slick/slick.css"
import "../../../node_modules/slick-carousel/slick/slick-theme.css"

Expand Down Expand Up @@ -53,8 +53,8 @@ const ProductGallery = (props) => {
onMouseOver={() => updateSlide(index)}
className={`image ${activeThumb === index ? "active" : ""}`}
>
<Image
fluid={value.childImageSharp.fluid}
<GatsbyImage
image={value.childImageSharp.gatsbyImageData}
alt={value.title}
key={index}
/>
Expand All @@ -68,12 +68,13 @@ const ProductGallery = (props) => {
<Slider className="slider" ref={sliderRef} {...settings}>
{images.map((value, index) => (
<div className="slide" key={index}>
<Image fluid={value.childImageSharp.fluid} />
{/*<img src={value.childImageSharp.fluid.src} />*/}
<GatsbyImage
image={value.childImageSharp.gatsbyImageData}
alt={value.title}
/>
</div>
))}
</Slider>
{/*<Asd/>*/}
</div>
),
[]
Expand Down
8 changes: 4 additions & 4 deletions src/components/sidepanel/panels/cart/cartItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { Link } from "gatsby"
import Img from "gatsby-image"
import { GatsbyImage } from "gatsby-plugin-image"

import InputNumber from "../../../inputNumber"
import Image from "../../../image"
Expand All @@ -21,17 +21,17 @@ const CartItem = (props) => {

const price = round(props.price)
const image = images ? (
<Img
<GatsbyImage
image={images[0].childImageSharp.gatsbyImageData}
className="thumb"
fluid={images[0].childImageSharp.fluid}
alt={title}
/>
) : (
<Image />
)

const itemTotal = () => {
return round(price * count, 2)
return round(Number(price) * count, 2)
}

return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/sidepanel/panels/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { graphql, Link, useStaticQuery } from "gatsby"
import slugify from "slugify"
import Collapse from "rc-collapse"
import "rc-collapse/assets/index.css"
import motion from '../../../utils/motionUtil'
import { IconContext } from "react-icons"
import { AiOutlineRight } from "react-icons/ai"

Expand Down Expand Up @@ -68,7 +69,7 @@ const Categories = () => {
)

const generateCollapse = (obj) => (
<Collapse accordion expandIcon={expandIcon}>
<Collapse accordion expandIcon={expandIcon} openMotion={motion}>
{obj.map(({ _id, name, children }) => {
return children ? (
getPanel(_id, name, children)
Expand Down
Binary file not shown.
Binary file removed src/images/harashi-logo-inverse.png
Binary file not shown.
8 changes: 5 additions & 3 deletions src/templates/categoryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ export const pageQuery = graphql`
slug
images {
childImageSharp {
fluid(maxWidth: 550) {
...GatsbyImageSharpFluid
}
gatsbyImageData(
width: 550
layout: CONSTRAINED
placeholder: BLURRED
)
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/templates/productIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ export const pageQuery = graphql`
slug
images {
childImageSharp {
fluid(maxWidth: 550) {
...GatsbyImageSharpFluid
}
gatsbyImageData(
width: 550
layout: CONSTRAINED
placeholder: BLURRED
)
}
}
}
Expand Down
35 changes: 14 additions & 21 deletions src/templates/productView.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,21 @@ const ProductView = (props) => {

export default ProductView

export const query = graphql`
query($_id: String!) {
productsJson(_id: { eq: $_id }) {
_id
title
price
unit
min_quantity
max_quantity
slug
description
images {
childImageSharp {
fluid(maxWidth: 1080) {
base64
aspectRatio
src
srcSet
sizes
}
}
export const query = graphql`query ($_id: String!) {
productsJson(_id: {eq: $_id}) {
_id
title
price
unit
min_quantity
max_quantity
slug
description
images {
childImageSharp {
gatsbyImageData(placeholder: BLURRED, layout: FULL_WIDTH)
}
}
}
}
`
Loading

0 comments on commit 0ada472

Please sign in to comment.