-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Mux uploader rsc for Next 13 #712
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
/node_modules | ||
/.next/ | ||
/out/ | ||
/build | ||
.DS_Store | ||
*.pem | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.env*.local | ||
.vercel | ||
*.tsbuildinfo | ||
next-env.d.ts |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import MuxUploader from '@mux/mux-uploader-react/rsc'; | ||
|
||
export default function Home() { | ||
return ( | ||
<main> | ||
<div> | ||
<MuxUploader /> | ||
</div> | ||
</main> | ||
) | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
:root { | ||
--links: rgb(223, 40, 104); | ||
} | ||
|
||
body { | ||
padding: 0 1rem; | ||
} | ||
|
||
header { | ||
padding: 2rem 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
|
||
.left-header, | ||
.right-header { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.mux-logo picture { | ||
display: inline-block; | ||
width: 81px; | ||
} | ||
|
||
.github-logo { | ||
display: inline-block; | ||
width: 26px; | ||
height: 26px; | ||
} | ||
|
||
header h1 { | ||
margin: 0; | ||
margin-left: .9em; | ||
margin-right: .9em; | ||
} | ||
|
||
h1 { | ||
text-transform: uppercase; | ||
font-weight: bold; | ||
letter-spacing: 0.2em; | ||
font-size: 18px; | ||
} | ||
|
||
h1 a { | ||
color: var(--text-main); | ||
} | ||
|
||
nav ul { | ||
list-style: none; | ||
padding: 0; | ||
display: grid; | ||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); | ||
grid-gap: 1.5rem; | ||
} | ||
|
||
nav li { | ||
position: relative; | ||
} | ||
|
||
nav li a { | ||
color: var(--text-main); | ||
font-family: monospace; | ||
font-size: 16px; | ||
padding: 2rem; | ||
height: calc(100% - 4rem); | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
li a.video { | ||
background: rgba(28, 160, 253, .1); | ||
} | ||
|
||
li a.audio { | ||
background: rgba(251, 80, 29, .08); | ||
} | ||
|
||
li a.player { | ||
background: rgba(31, 195, 168, .1); | ||
} | ||
|
||
li a.uploader { | ||
background: rgba(150, 32, 216, .1); | ||
} | ||
|
||
@media (prefers-color-scheme:dark) { | ||
body { | ||
background: var(--background-alt); | ||
} | ||
.github-logo { | ||
filter: invert(1) saturate(0); | ||
} | ||
} | ||
|
||
mux-player:not([audio]), | ||
mux-video:not([audio]), | ||
video { | ||
width: 100%; | ||
display: block; | ||
line-height: 0; | ||
margin-bottom: 1rem; | ||
background: #000; | ||
aspect-ratio: 16 / 9; | ||
} | ||
|
||
mux-player, | ||
mux-video, | ||
mux-audio, | ||
audio { | ||
width: 100%; | ||
display: block; | ||
line-height: 0; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.options { | ||
overflow: auto; | ||
max-height: calc(100vh - calc(var(--player-height, 450px) + 201px)); | ||
min-height: 400px; | ||
} | ||
|
||
.options > div { | ||
padding: 5px 10px; | ||
min-height: 25px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.options > div :is(input, select) { | ||
margin-left: 5px; | ||
} | ||
|
||
.options > div:nth-of-type(odd) { | ||
background-color: #e9e9f9; | ||
} | ||
|
||
input[type=text], | ||
input[type=url], | ||
select { | ||
flex-grow: 1; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
.options > div:nth-of-type(odd) { | ||
background-color: #3b3b3b; | ||
} | ||
} | ||
|
||
div.code-renderer { | ||
background-color: lightgrey; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
} | ||
|
||
.code-renderer pre { | ||
width: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
div.url-renderer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
} | ||
.url-renderer a { | ||
padding-block: 5px; | ||
width: 100%; | ||
overflow: scroll; | ||
max-height: 100px; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'water.css/out/water.css'; | ||
import './globals.css' | ||
import { Inter } from 'next/font/google' | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
|
||
const inter = Inter({ subsets: ['latin'] }) | ||
|
||
export const metadata = { | ||
title: 'Mux Elements', | ||
description: 'Generated by create next app', | ||
} | ||
|
||
const MuxContent = () => { | ||
return (<> | ||
<div className="left-header"> | ||
<a className="mux-logo" href="https://www.mux.com/player" target="_blank" rel="noreferrer"> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcSet="https://user-images.githubusercontent.com/360826/233653989-11cd8603-c20f-4008-8bf7-dc15b743c52b.svg" /> | ||
<source media="(prefers-color-scheme: light)" srcSet="https://user-images.githubusercontent.com/360826/233653583-50dda726-cbe7-4182-a113-059a91ae83e6.svg" /> | ||
<img alt="Mux Logo" src="https://user-images.githubusercontent.com/360826/233653583-50dda726-cbe7-4182-a113-059a91ae83e6.svg" /> | ||
</picture> | ||
</a> | ||
<h1><Link href="/">Elements</Link></h1> | ||
</div> | ||
<div className="right-header"> | ||
<a className="github-logo" href="https://github.com/muxinc/elements" target="_blank" rel="noreferrer"> | ||
<Image width="32" height="32" src="/images/github-logo.svg" alt="Github logo" /> | ||
</a> | ||
</div> | ||
</>); | ||
}; | ||
|
||
const DefaultHeader = () => { | ||
return ( | ||
<header> | ||
<MuxContent/> | ||
</header> | ||
); | ||
} | ||
|
||
export default function RootLayout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body className={inter.className}> | ||
<DefaultHeader/> | ||
{children} | ||
</body> | ||
</html> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Image from 'next/image' | ||
import styles from './page.module.css' | ||
import Link from "next/link"; | ||
|
||
export default function Home() { | ||
return ( | ||
<nav> | ||
<ul> | ||
<li><Link href="/MuxUploader" className="uploader"><MuxUploader></Link></li> | ||
</ul> | ||
</nav> | ||
) | ||
} |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
"@/*": ["./*"] | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "demo-mux-video-react-nextjs-13", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint" | ||
}, | ||
"dependencies": { | ||
"@mux/mux-uploader-react": ">=1.0.0-beta.0", | ||
"eslint": "8.43.0", | ||
"eslint-config-next": "13.4.7", | ||
"next": "13.4.7", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"water.css": "^2.1.1" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import Mux from '@mux/mux-node'; | ||
import MuxUploaderClient from './index'; | ||
|
||
const { Video } = new Mux(); | ||
|
||
export default async function MuxUploaderServer(props: any) { | ||
const upload = await Video.Uploads.create({ | ||
cors_origin: '*', | ||
new_asset_settings: { | ||
playback_policy: 'public', | ||
}, | ||
}); | ||
|
||
return <MuxUploaderClient endpoint={upload.url} {...props} />; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need an ability to pass in props to the
Uploads.Create
function, right?