import React from 'react'; import { graphql, useStaticQuery } from 'gatsby'; import { connect } from 'react-redux'; import AniLink from 'gatsby-plugin-transition-link/AniLink'; import ReactCSSTransitionReplace from 'react-css-transition-replace'; import config from '../../../config'; import { toggleDarkMode } from '../state/app'; import SearchIcon from './SVGs/SearchIcon'; import GithubIcon from './SVGs/GithubIcon'; import DarkModeIcon from './SVGs/DarkModeIcon'; import LightModeIcon from './SVGs/LightModeIcon'; import ListIcon from './SVGs/ListIcon'; // =================================================== // Application-level UI component // =================================================== const Shell = ({ isDarkMode, isSearch, isList, dispatch, withIcon = true, withTitle = true, children, }) => { const data = useStaticQuery(graphql` query SiteTitleQuery { site { siteMetadata { title description } } file(relativePath: { eq: "30s-icon.png" }) { id childImageSharp { original { src } } } snippetDataJson(meta: { type: { eq: "snippetListingArray" } }) { data { title id attributes { tags } } } } `); let viewportWidth = typeof window !== 'undefined' && window.innerWidth; return (
{/* Menu */}
{/* eslint-disable-next-line */} {/* The use of React.Fragment here will cause a lot of errors to show up in webber:dev. Truth is, this is the only decent way I found to deal with this module's odd behavior. Keep as is, unless you can provide a better solution, in which case please send a PR. */} {isDarkMode ? ( dispatch(toggleDarkMode(!isDarkMode))} /> ) : ( dispatch(toggleDarkMode(!isDarkMode))} /> )}
{/* Content */}
{withTitle ? (

{data.site.siteMetadata.title} {withIcon ? ( Logo ) : ( '' )}

) : ( '' )} {children}
); }; export default connect( state => ({ isDarkMode: state.app.isDarkMode, lastPageTitle: state.app.lastPageTitle, lastPageUrl: state.app.lastPageUrl, searchQuery: state.app.searchQuery, }), null, )(Shell);