rsnext/examples/with-mux-video/components/layout.js

186 lines
4.2 KiB
JavaScript
Raw Normal View History

Add example: with-mux-video (#13120) * yarn create next-app * create an upload show page * create upload page to handle in-progress upload and asset when it is ready * move things to a layout component * add some button styling * poll for updates intelligently by dynamically setting refreshInterval on SWR hook * better title * edit gitignore, add MIT license use next 'latest' based on feedback from https://github.com/zeit/next.js/pull/12723 * add some messages and spinner to make this a little nicer * update README with environment variables info and Mux account info * add .now to gitignore * cleaner uploading state - redirect to /v/:playback_id when complete * hardset image width in footer * remove unused styles * adjust title font size on mobile and adjust footer height on mobile * use upchunk 1.0.8 so we don't have to dynamically load it * cleaner error message handling * fix brief error from returning Router on the render * yarn lint-fix * update README with note about .env.local * add min height so the layout doesn't shift after selecting a file * set poster attribute at video element * use getStaticProps and fallback:true to render meta tags for social sharing * create a pages/asset/:id route that we can be on while in the preparing state * add copy about Mux, add twitter share widget * add flash message about video ready for playback * call it pre-rendered instead of server-side rendered * pre-rendering, not server-side rendering * Next.js not NextJS * handle asset creation errors in the UI * call hls.destroy() when the component is unmounted * Updated readme and renamed .env.local * Updated description * add suggested patch with links to source code https://github.com/zeit/next.js/pull/13120#issuecomment-632858572 * Added vercel.json * Updated some links * Removed Prerequisites Co-authored-by: Luis Alvarez <luis@vercel.com>
2020-05-22 23:13:12 +02:00
import Head from 'next/head'
import { MUX_HOME_PAGE_URL } from '../constants'
export default function Layout({
title,
description,
metaTitle,
metaDescription,
image,
children,
loadTwitterWidget,
}) {
return (
<div className="container">
<Head>
<title>Mux + Next.js</title>
<link rel="icon" href="/favicon.ico" />
{metaTitle && <meta property="og:title" content={metaTitle} />}
{metaTitle && <meta property="twitter:title" content={metaTitle} />}
{metaDescription && (
<meta property="og:description" content={description} />
)}
{metaDescription && (
<meta property="twitter:description" content={description} />
)}
{image && <meta property="og:image" content={image} />}
{image && (
<meta property="twitter:card" content="summary_large_image" />
)}
{image && <meta property="twitter:image" content={image} />}
{loadTwitterWidget && (
<script
type="text/javascript"
async
src="https://platform.twitter.com/widgets.js"
></script>
)}
</Head>
<main>
<h1 className="title">{title}</h1>
<p className="description">{description}</p>
<div className="grid">{children}</div>
</main>
<footer>
<a href={MUX_HOME_PAGE_URL} target="_blank" rel="noopener noreferrer">
Powered by <img src="/mux.svg" alt="Mux Logo" className="logo" />
</a>
</footer>
<style jsx>{`
.container {
min-height: 100vh;
min-height: -webkit-fill-available;
padding: 0 0.5rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
main {
padding: 1rem 0 5rem 0;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
footer {
width: 100%;
height: 100px;
border-top: 1px solid #eaeaea;
display: flex;
justify-content: center;
align-items: center;
}
footer img {
margin-left: 0.5rem;
width: 71px;
}
footer a {
display: flex;
justify-content: center;
align-items: center;
}
a {
color: inherit;
text-decoration: none;
}
.title a {
color: #0070f3;
text-decoration: none;
}
.title a:hover,
.title a:focus,
.title a:active {
text-decoration: underline;
}
.title {
margin: 0;
line-height: 1.15;
font-size: 4rem;
}
.title,
.description {
text-align: center;
}
.description {
line-height: 1.5;
font-size: 1.5rem;
}
code {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
font-size: 1.1rem;
font-family: Menlo, Monaco, Lucida Console, Liberation Mono,
DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace;
}
.grid {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
max-width: 800px;
margin-top: 1rem;
}
.logo {
height: 1em;
}
@media (max-width: 600px) {
.grid {
width: 100%;
flex-direction: column;
}
.title {
font-size: 2.5rem;
}
footer {
height: 60px;
}
}
`}</style>
<style jsx global>{`
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue,
sans-serif;
}
a {
color: #ff2b61;
}
p {
line-height: 1.4rem;
}
* {
box-sizing: border-box;
}
`}</style>
</div>
)
}