-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mux-player-react, mux-uploader-react, mux-audio-react, mux-video…
…-react): add client component directive (#911) Add "use client" to all client-side entry points in - MuxPlayerReact - MuxUploaderReact - MuxAudioReact - MuxVideoReact Also update Next.js example: - Move nextjs-with-typescript example to Next 14 - Add [app router test page](https://elements-demo-nextjs-git-fork-decepulis-dc-rsc-mux.vercel.app/app-router) - move water.css to npm import to guarantee import order across pages and app routers - move the "browse elements" from pages to layout. Not really related to the PR 😅
- Loading branch information
Showing
35 changed files
with
1,452 additions
and
275 deletions.
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 |
---|---|---|
@@ -1,14 +1,7 @@ | ||
{ | ||
"root": true, | ||
"extends": ["plugin:@next/next/recommended"], | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2021, | ||
"sourceType": "module" | ||
"extends": "next/core-web-vitals", | ||
"rules": { | ||
"react/no-unescaped-entities": "off" | ||
} | ||
} | ||
} |
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,69 @@ | ||
import type { Metadata } from 'next'; | ||
import MuxUploader, { MuxUploaderDrop, MuxUploaderFileSelect, MuxUploaderProgress, MuxUploaderRetry, MuxUploaderStatus } from '@mux/mux-uploader-react'; | ||
import MuxAudio from '@mux/mux-audio-react'; | ||
import MuxVideo from "@mux/mux-video-react"; | ||
import MuxPlayer from "@mux/mux-player-react"; | ||
import MuxPlayerLazy from "@mux/mux-player-react/lazy"; | ||
import "@mux/mux-player-react/themes/classic"; | ||
import "@mux/mux-player-react/themes/microvideo"; | ||
import muxBlurUp from '@mux/blurup' | ||
|
||
export const metadata: Metadata = { | ||
title: 'App Directory test' | ||
} | ||
export default async function Page() { | ||
// because this is a server component, we can run async muxBlurUp | ||
const playbackId = "OG6Zq19uOjRkjO3bISLWasE2M01Cx8O3o" | ||
const { blurDataURL, aspectRatio } = await muxBlurUp(playbackId) | ||
return ( | ||
<main> | ||
<p>Mux Uploader React, Mux Audio React, Mux Video React, and Mux Player React all natively support client components.</p> | ||
<h2>Mux Uploader</h2> | ||
<MuxUploaderDrop muxUploader="uploader" overlay overlayText="You're doing great!"> | ||
<h2>Enter your upload GCS url:</h2> | ||
|
||
<input type="text" style={{ | ||
marginBottom: "20px", | ||
width: "min(100%, 400px)", | ||
boxSizing: "border-box" | ||
}} placeholder="https://storage.googleapis.com/..." /> | ||
|
||
<MuxUploader | ||
style={{ display: "none", height: "200px" }} | ||
className="foo" | ||
id="uploader" | ||
noDrop | ||
noProgress | ||
noStatus | ||
noRetry | ||
/> | ||
</MuxUploaderDrop> | ||
<MuxUploaderFileSelect muxUploader="uploader" ></MuxUploaderFileSelect> | ||
<MuxUploaderProgress muxUploader="uploader" >What should be here?</MuxUploaderProgress> | ||
<MuxUploaderRetry muxUploader="uploader" ></MuxUploaderRetry> | ||
<MuxUploaderStatus muxUploader="uploader" ></MuxUploaderStatus> | ||
<h2>Mux Audio</h2> | ||
<MuxAudio controls playbackId={playbackId} /> | ||
<h2>Mux Video</h2> | ||
<MuxVideo | ||
playbackId={playbackId} | ||
style={{ width: '100%' }} | ||
/> | ||
<h2>Mux Player</h2> | ||
<p>Standard import, with the classic theme</p> | ||
<MuxPlayer | ||
playbackId={playbackId} | ||
placeholder={blurDataURL} | ||
theme="classic" | ||
style={{ width: '100%', aspectRatio }} | ||
/> | ||
<p>Lazy import, with the microvideo theme</p> | ||
<MuxPlayerLazy | ||
playbackId={playbackId} | ||
placeholder={blurDataURL} | ||
theme="microvideo" | ||
style={{ width: '100%', aspectRatio }} | ||
/> | ||
</main> | ||
) | ||
} |
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,21 @@ | ||
import Link from 'next/link'; | ||
import DefaultHeader from '../components/default-header'; | ||
import '../styles.css' | ||
import { Metadata } from 'next'; | ||
|
||
export const metadata: Metadata = { | ||
title: "Mux Elements" | ||
} | ||
export default function RootLayout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html lang="en"> | ||
<head/ > | ||
<body> | ||
<DefaultHeader/> | ||
{children} | ||
<br/> | ||
<Link href="/">← Browse Elements</Link> | ||
</body> | ||
</html> | ||
) | ||
} |
30 changes: 30 additions & 0 deletions
30
examples/nextjs-with-typescript/components/default-header.tsx
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,30 @@ | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
|
||
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 legacyBehavior 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> | ||
</>); | ||
}; | ||
|
||
export default function DefaultHeader () { | ||
return ( | ||
<header> | ||
<MuxContent/> | ||
</header> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
/// <reference types="next/navigation-types/compat/navigation" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
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
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
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
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
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
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
Oops, something went wrong.