forked from cybrespace/pinafore
80 lines
1.9 KiB
HTML
80 lines
1.9 KiB
HTML
|
<div class="video-dialog-wrapper">
|
||
|
<div class="close-video-button-wrapper">
|
||
|
<button class="close-video-button" aria-label="Close video" on:click="onCloseButtonClicked()">
|
||
|
<span aria-hidden="true">×</span>
|
||
|
</button>
|
||
|
</div>
|
||
|
<video poster="{{poster}}"
|
||
|
src="{{src}}"
|
||
|
width="{{width}}"
|
||
|
height="{{height}}"
|
||
|
controls
|
||
|
/>
|
||
|
</div>
|
||
|
<style>
|
||
|
:global(.video-dialog) {
|
||
|
position: fixed;
|
||
|
top: 50%;
|
||
|
transform: translate(0, -50%);
|
||
|
background: #000;
|
||
|
padding: 0;
|
||
|
}
|
||
|
:global(.video-dialog-wrapper) {
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
align-items: center;
|
||
|
justify-content: center;
|
||
|
max-width: calc(100vw - 40px);
|
||
|
}
|
||
|
:global(.video-dialog video) {
|
||
|
max-width: 100%;
|
||
|
}
|
||
|
.close-video-button-wrapper {
|
||
|
text-align: right;
|
||
|
width: 100%;
|
||
|
background: var(--nav-bg)
|
||
|
}
|
||
|
.close-video-button {
|
||
|
margin: 0 0 2px;
|
||
|
padding: 0;
|
||
|
background: none;
|
||
|
border: none;
|
||
|
}
|
||
|
.close-video-button span {
|
||
|
padding: 0 15px;
|
||
|
font-size: 48px;
|
||
|
color: var(--button-primary-text);
|
||
|
}
|
||
|
:global(dialog.video-dialog::backdrop) {
|
||
|
background: rgba(51, 51, 51, 0.8);
|
||
|
}
|
||
|
:global(dialog.video-dialog + .backdrop) {
|
||
|
background: rgba(51, 51, 51, 0.8);
|
||
|
}
|
||
|
</style>
|
||
|
<script>
|
||
|
|
||
|
import { importDialogPolyfill } from '../_utils/asyncModules'
|
||
|
|
||
|
export default {
|
||
|
oncreate() {
|
||
|
this.registration = this.register()
|
||
|
},
|
||
|
methods: {
|
||
|
async register() {
|
||
|
if (typeof HTMLDialogElement === 'undefined') {
|
||
|
let dialogPolyfill = await importDialogPolyfill()
|
||
|
dialogPolyfill.registerDialog(this.get('dialog'))
|
||
|
}
|
||
|
},
|
||
|
async showModal() {
|
||
|
await this.registration
|
||
|
this.get('dialog').showModal()
|
||
|
},
|
||
|
onCloseButtonClicked() {
|
||
|
this.get('dialog').close()
|
||
|
document.body.removeChild(this.get('dialog'))
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|