View use-prefers-reduced-motion.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react' | |
const QUERY_STRING = '(prefers-reduced-motion: no-preference)' | |
const EVENT = 'change' | |
const usePrefersReducedMotion = () => { | |
const [prefersReducedMotion, setPrefersReducedMotion] = useState(true) | |
useEffect(() => { | |
const query = window.matchMedia(QUERY_STRING) |
View gatsby-browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Fragment } from 'react'; | |
export const wrapPageElement = ({ element, props }) => { | |
const { | |
location: { pathname }, | |
} = props | |
return ( | |
<Fragment> | |
<header className={`${pathname === '/' ? 'some-class' : 'some-other-class'} `}> |
View gatsby-browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const onRouteUpdate = ({ location }) => { | |
const jumplink = document.getElementById(location.hash) | |
if (jumplink) { | |
window.scrollTo({ | |
top: jumplink.offsetTop, | |
}) | |
} | |
return true | |
} |
View hybrid-svg.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useStaticQuery, graphql } from 'gatsby'; | |
import { GatsbyImage, getImage } from 'gatsby-plugin-image'; | |
const Test = () => { | |
const { | |
file: { | |
childImageSharp: { gatsbyImageData } | |
} | |
} = useStaticQuery(graphql` |
View use-local-storage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react' | |
const useLocalStorage = (key, initialValue) => { | |
const [storedValue, setStoredValue] = useState(initialValue) | |
const setValue = (value) => { | |
try { | |
const valueToStore = | |
value instanceof Function ? value(storedValue) : value | |
setStoredValue(valueToStore) | |
window.localStorage.setItem(key, JSON.stringify(valueToStore)) |
View test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
const Page = () => { | |
const [response, setResponse] = useState(false); | |
useEffect(() => { | |
const getData = async () => { | |
const response = await fetch( | |
'https://api.oceandrivers.com/api/ODWeather' | |
); |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
stories: ["../src/**/*.stories.tsx"], | |
addons: ["@storybook/addon-actions", "@storybook/addon-docs"], | |
webpackFinal: async (config) => { | |
config.module.rules.push( | |
{ | |
// Config for js and jsx files | |
test: /\.(js|jsx)$/, | |
use: [ | |
{ |
View Shopify Checkout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Fragment, FunctionComponent, useState, useEffect } from 'react' | |
import { Box, Grid, Message, Button } from 'theme-ui' | |
import { Client } from 'shopify-buy' | |
import { Loader } from '../loader' | |
import { Confetti } from '../confetti' | |
interface ICheckoutProps { | |
/** Shopify Buy client */ |
View contentful-render.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const ContentfulRender = ({ children }) => { | |
return <>{process.env.GATSBY_CONTENTFUL_KEY ? <>{children}</> : null}</>; | |
}; | |
export default ContentfulRender; |
View Theme UI Animation Keyframes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using the example from https://paulie.dev/posts/2021/02/theme-ui-alpha-6/#css-keyframes | |
you could also store the animationName as a const | |
const animationTypeOne = keyframes({ | |
'0%': { | |
opacity: 1, | |
}, |
NewerOlder