From 27cf2e90122b1ce6cb58646bb865108c6d58acb2 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sun, 28 Apr 2019 22:30:20 +0200 Subject: [PATCH] refactor --- gatsby-browser.js | 18 +++-- gatsby-ssr.js | 8 +-- src/components/Layout.jsx | 70 +++++++------------ src/store/{Provider.jsx => AppProvider.jsx} | 0 ...Provider.test.jsx => AppProvider.test.jsx} | 2 +- 5 files changed, 43 insertions(+), 55 deletions(-) rename src/store/{Provider.jsx => AppProvider.jsx} (100%) rename src/store/{Provider.test.jsx => AppProvider.test.jsx} (86%) diff --git a/gatsby-browser.js b/gatsby-browser.js index ad5009f..476e6f8 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -1,7 +1,10 @@ -import './src/styles/global.scss' import React from 'react' -import AppProvider from './src/store/Provider' -import wrapPageElementWithTransition from './src/helpers/wrapPageElement' +import PropTypes from 'prop-types' +import AppProvider from './src/store/AppProvider' +import wrapPageElementWithLayout from './src/helpers/wrapPageElement' + +// Global styles +import './src/styles/global.scss' // IntersectionObserver polyfill for gatsby-image (Safari, IE) if (typeof window !== 'undefined' && !window.IntersectionObserver) { @@ -9,10 +12,13 @@ if (typeof window !== 'undefined' && !window.IntersectionObserver) { } // React Context in Browser -// eslint-disable-next-line export const wrapRootElement = ({ element }) => { return {element} } -// Page Transitions & Layout -export const wrapPageElement = wrapPageElementWithTransition +wrapRootElement.propTypes = { + element: PropTypes.any +} + +// Layout with Page Transitions +export const wrapPageElement = wrapPageElementWithLayout diff --git a/gatsby-ssr.js b/gatsby-ssr.js index 3c4acbe..967eba3 100644 --- a/gatsby-ssr.js +++ b/gatsby-ssr.js @@ -1,7 +1,7 @@ import React from 'react' import { renderToString } from 'react-dom/server' -import AppProvider from './src/store/Provider' -import wrapPageElementWithTransition from './src/helpers/wrapPageElement' +import AppProvider from './src/store/AppProvider' +import wrapPageElementWithLayout from './src/helpers/wrapPageElement' export const replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { // React Context in SSR/build @@ -9,5 +9,5 @@ export const replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { replaceBodyHTMLString(renderToString()) } -// Page Transitions & Layout -export const wrapPageElement = wrapPageElementWithTransition +// Layout with Page Transitions +export const wrapPageElement = wrapPageElementWithLayout diff --git a/src/components/Layout.jsx b/src/components/Layout.jsx index 837bd65..ef17191 100644 --- a/src/components/Layout.jsx +++ b/src/components/Layout.jsx @@ -14,9 +14,6 @@ import styles from './Layout.module.scss' // whyDidYouUpdate(React) // } -const timeout = 250 -const RoutesContainer = posed.div(fadeIn) - const query = graphql` query { contentYaml { @@ -25,42 +22,8 @@ const query = graphql` } ` -const LayoutMarkup = ({ children, data, location }) => { - const { allowedHosts } = data.contentYaml - const isHomepage = location.pathname === '/' - - return ( - <> - - - - - -
-
{children}
- - - -