-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Prepare default theme from Mux Player for export (#668)
The goal of this PR is to package the existing default theme such that it can be exported as it's own module. This can then be easily swapped out in the future with a new theme. Theme source files now reside in `src/themes` (themes based in this repo and re-exported from media chrome). Build artefacts for themes are in `dist/themes`. --------- Co-authored-by: Gary Katsevman <[email protected]> Co-authored-by: Christian Pillsbury <[email protected]>
- Loading branch information
1 parent
2197108
commit c6a3434
Showing
13 changed files
with
141 additions
and
17 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
44 changes: 44 additions & 0 deletions
44
examples/svelte-kit/src/routes/mux-player-theme/+page.svelte
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,44 @@ | ||
<script context="module" lang="ts"> | ||
export const prerender = true; | ||
</script> | ||
|
||
<script lang="ts"> | ||
// this prevents the custom elements from being redefined when the REPL is updated and reloads, which throws an error | ||
// this means that any changes to the custom element won't be picked up without saving and refreshing the REPL | ||
// const oldRegister = customElements.define; | ||
// customElements.define = function(name, constructor, options) { | ||
// if (!customElements.get(name)) { | ||
// oldRegister(name, constructor, options); | ||
// } | ||
// } | ||
// import { page } from '$app/stores'; | ||
import { onMount } from 'svelte'; | ||
onMount(async () => { | ||
await import('@mux/mux-player'); | ||
await import("@mux/mux-player/themes/microvideo"); | ||
}); | ||
</script> | ||
|
||
<svelte:head> | ||
<style> | ||
mux-player { | ||
display: block; | ||
width: 100%; | ||
margin: 1rem 0 2rem; | ||
background-color: #000; | ||
line-height: 0; | ||
} | ||
mux-player:not([audio]) { | ||
aspect-ratio: 16 / 9; | ||
} | ||
</style> | ||
</svelte:head> | ||
|
||
<mux-player | ||
stream-type="on-demand" | ||
playback-id="23s11nz72DsoN657h4314PjKKjsF2JG33eBQQt6B95I" | ||
theme="microvideo" | ||
></mux-player> | ||
|
||
<a data-sveltekit-prefetch href="/">Browse Elements</a> |
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 @@ | ||
export * as MicroVideoTheme from "@mux/mux-player/themes/microvideo"; |
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,2 @@ | ||
themes/ | ||
!src/themes/ |
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,46 @@ | ||
#!/usr/bin/env node | ||
import { build } from 'esbuild'; | ||
|
||
const themes = ['classic', 'microvideo', 'minimal']; | ||
const devMode = process.argv.includes('--dev'); | ||
|
||
const shared = { | ||
bundle: true, | ||
target: 'es2019', | ||
loader: { | ||
'.html': 'text', | ||
'.css': 'text', | ||
'.svg': 'text', | ||
}, | ||
watch: devMode, | ||
}; | ||
|
||
// entryPoints doesn't support glob patterns so we iterate over known themes | ||
themes.forEach((theme) => { | ||
//@ts-ignore | ||
build({ | ||
...shared, | ||
entryPoints: [`./src/themes/${theme}/index.ts`], | ||
format: 'esm', | ||
outExtension: { '.js': '.mjs' }, | ||
outdir: `./dist/themes/${theme}`, | ||
}); | ||
|
||
//@ts-ignore | ||
build({ | ||
...shared, | ||
entryPoints: [`./src/themes/${theme}/index.ts`], | ||
format: 'cjs', | ||
outExtension: { '.js': '.cjs.js' }, | ||
outdir: `./dist/themes/${theme}`, | ||
}); | ||
|
||
//@ts-ignore | ||
build({ | ||
...shared, | ||
entryPoints: [`./src/themes/${theme}/index.ts`], | ||
format: 'iife', | ||
globalName: `mediaTheme${theme[0].toUpperCase() + theme.slice(1)}`, | ||
outdir: `./dist/themes/${theme}`, | ||
}); | ||
}); |
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
2 changes: 1 addition & 1 deletion
2
packages/mux-player/src/media-theme-mux.html → ...ux-player/src/themes/classic/classic.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
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,17 @@ | ||
// @ts-ignore | ||
import theme from './classic.html'; | ||
import { document, globalThis } from '../../polyfills'; | ||
import { MediaThemeElement } from 'media-chrome/dist/media-theme-element.js'; | ||
|
||
const template = document.createElement('template'); | ||
if ('innerHTML' in template) template.innerHTML = theme; | ||
|
||
class MediaThemeClassic extends MediaThemeElement { | ||
static template = template.content?.children?.[0]; | ||
} | ||
|
||
if (!globalThis.customElements.get('media-theme-classic')) { | ||
globalThis.customElements.define('media-theme-classic', MediaThemeClassic); | ||
} | ||
|
||
export default MediaThemeClassic; |
File renamed without changes.
File renamed without changes.
c6a3434
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.
Successfully deployed to the following URLs:
elements-demo-create-react-app – ./examples/create-react-app-with-typescript
elements-demo-create-react-app.vercel.app
elements-demo-create-react-app-mux.vercel.app
elements-demo-create-react-app-git-main-mux.vercel.app
c6a3434
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.
Successfully deployed to the following URLs:
elements-demo-svelte-kit – ./examples/svelte-kit
elements-demo-svelte-kit-git-main-mux.vercel.app
elements-demo-svelte-kit-mux.vercel.app
elements-demo-svelte-kit.vercel.app
c6a3434
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.
Successfully deployed to the following URLs:
elements-demo-vue – ./examples/vue-with-typescript
elements-demo-vue-git-main-mux.vercel.app
elements-demo-vue-mux.vercel.app
elements-demo-vue.vercel.app
c6a3434
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.
Successfully deployed to the following URLs:
elements-demo-nextjs – ./examples/nextjs-with-typescript
elements-demo-nextjs.vercel.app
elements-demo-nextjs-git-main-mux.vercel.app
elements-demo-nextjs-mux.vercel.app
c6a3434
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.
Successfully deployed to the following URLs:
elements-demo-vanilla – ./examples/vanilla-ts-esm
elements-demo-vanilla.vercel.app
elements-demo-vanilla-git-main-mux.vercel.app
elements-demo-vanilla-mux.vercel.app