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 App, { Container } from 'next/app'; | |
import Header from '../components/Header'; | |
import OfflineSupport from '../components/OfflineSupport'; | |
class CustomApp extends App { | |
render() { | |
const { Component, pageProps } = this.props; | |
return ( |
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
const withCSS = require('@zeit/next-css'); | |
const NextWorkboxPlugin = require('next-workbox-webpack-plugin'); | |
const WebpackPwaManifest = require('webpack-pwa-manifest'); | |
const path = require('path'); | |
module.exports = withCSS({ | |
webpack(config, { isServer, buildId, dev }) { | |
const workboxOptions = { | |
clientsClaim: true, |
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, { Component } from 'react'; | |
import Router from 'next/router'; | |
import Head from 'next/head'; | |
import Nav from './Nav'; | |
class Header extends Component { | |
state = { loading: false }; | |
componentDidMount() { |
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'; | |
import ProgressiveImage from 'react-progressive-image'; | |
const Image = ({ src, alt, className }) => ( | |
<ProgressiveImage | |
src={src} | |
placeholder="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" | |
> | |
{(currentSrc, loading) => ( | |
<Fragment> |
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
const { join } = require('path'); | |
const express = require('express'); | |
const next = require('next'); | |
const cache = require('lru-cache'); // for using least-recently-used based caching | |
const PORT = 8000; | |
const dev = process.env.NODE_ENV !== 'production'; | |
const app = next({ dev }); | |
const handle = app.getRequestHandler(); |
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 Head from 'next/head'; | |
import Movie from '../components/Movie'; | |
import Oops from '../components/Oops'; | |
import { getUpcomingMovies } from '../utils/apiCalls'; | |
const Home = ({ movies, error }) => ( | |
<div className="home"> | |
<Head> |
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
{ | |
"rules": [ | |
{ | |
"test": {}, | |
"include": [ | |
"/path/to/project/next-pwa" | |
], | |
"exclude": {}, | |
"use": { | |
"loader": "next-babel-loader", |
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 pageVisibilityApi = () => { | |
let hidden, visibilityChange; | |
if (typeof document.hidden !== "undefined") { | |
// Opera 12.10 and Firefox 18 and later support | |
hidden = "hidden"; | |
visibilityChange = "visibilitychange"; | |
} else if (typeof document.msHidden !== "undefined") { | |
hidden = "msHidden"; | |
visibilityChange = "msvisibilitychange"; | |
} else if (typeof document.webkitHidden !== "undefined") { |
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 { Component } from "react"; | |
import { pageVisibilityApi } from "../pageVisibilityUtils"; | |
const { hidden, visibilityChange } = pageVisibilityApi(); | |
class VisibilityManager extends Component { | |
state = { | |
isVisible: true | |
}; |
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 ReactDOM from "react-dom"; | |
import VisiblityManager from "./components/VisibilityManager"; | |
import Video from "./components/Video"; | |
const App = () => ( | |
<VisiblityManager> | |
{isVisible => <Video active={isVisible} src="https://www.sample-videos.com/video/mp4/480/big_buck_bunny_480p_30mb.mp4" />} | |
</VisiblityManager> |