aboutsummaryrefslogtreecommitdiff
path: root/src/components/flash
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/flash')
-rw-r--r--src/components/flash/flash.js53
-rw-r--r--src/components/flash/flash.vue84
2 files changed, 137 insertions, 0 deletions
diff --git a/src/components/flash/flash.js b/src/components/flash/flash.js
new file mode 100644
index 00000000..87f940a7
--- /dev/null
+++ b/src/components/flash/flash.js
@@ -0,0 +1,53 @@
+import RuffleService from '../../services/ruffle_service/ruffle_service.js'
+import { library } from '@fortawesome/fontawesome-svg-core'
+import {
+ faStop,
+ faExclamationTriangle
+} from '@fortawesome/free-solid-svg-icons'
+
+library.add(
+ faStop,
+ faExclamationTriangle
+)
+
+const Flash = {
+ props: [ 'src' ],
+ data () {
+ return {
+ player: false, // can be true, "hidden", false. hidden = element exists
+ loaded: false,
+ ruffleInstance: null
+ }
+ },
+ methods: {
+ openPlayer () {
+ if (this.player) return // prevent double-loading, or re-loading on failure
+ this.player = 'hidden'
+ RuffleService.getRuffle().then((ruffle) => {
+ const player = ruffle.newest().createPlayer()
+ player.config = {
+ letterbox: 'on'
+ }
+ const container = this.$refs.container
+ container.appendChild(player)
+ player.style.width = '100%'
+ player.style.height = '100%'
+ player.load(this.src).then(() => {
+ this.player = true
+ }).catch((e) => {
+ console.error('Error loading ruffle', e)
+ this.player = 'error'
+ })
+ this.ruffleInstance = player
+ this.$emit('playerOpened')
+ })
+ },
+ closePlayer () {
+ this.ruffleInstance && this.ruffleInstance.remove()
+ this.player = false
+ this.$emit('playerClosed')
+ }
+ }
+}
+
+export default Flash
diff --git a/src/components/flash/flash.vue b/src/components/flash/flash.vue
new file mode 100644
index 00000000..95f71950
--- /dev/null
+++ b/src/components/flash/flash.vue
@@ -0,0 +1,84 @@
+<template>
+ <div class="Flash">
+ <div
+ v-if="player === true || player === 'hidden'"
+ ref="container"
+ class="player"
+ :class="{ hidden: player === 'hidden' }"
+ />
+ <button
+ v-if="player !== true"
+ class="button-unstyled placeholder"
+ @click="openPlayer"
+ >
+ <span
+ v-if="player === 'hidden'"
+ class="label"
+ >
+ {{ $t('general.loading') }}
+ </span>
+ <span
+ v-if="player === 'error'"
+ class="label"
+ >
+ {{ $t('general.flash_fail') }}
+ </span>
+ <span
+ v-else
+ class="label"
+ >
+ <p>
+ {{ $t('general.flash_content') }}
+ </p>
+ <p>
+ <FAIcon icon="exclamation-triangle" />
+ {{ $t('general.flash_security') }}
+ </p>
+ </span>
+ </button>
+ </div>
+</template>
+
+<script src="./flash.js"></script>
+
+<style lang="scss">
+@import '../../_variables.scss';
+.Flash {
+ display: inline-block;
+ width: 100%;
+ height: 100%;
+ position: relative;
+
+ .player {
+ height: 100%;
+ width: 100%;
+ }
+
+ .placeholder {
+ height: 100%;
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: var(--bg);
+ color: var(--link);
+ }
+
+ .hider {
+ top: 0;
+ }
+
+ .label {
+ text-align: center;
+ flex: 1 1 0;
+ line-height: 1.2;
+ white-space: normal;
+ word-wrap: normal;
+ }
+
+ .hidden {
+ display: none;
+ visibility: 'hidden';
+ }
+}
+</style>