FIX: Improved the visuals of the visit card
This commit is contained in:
parent
5a2b3a303a
commit
4d467e9f86
1 changed files with 53 additions and 20 deletions
|
@ -1,39 +1,64 @@
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import { fly } from 'svelte/transition';
|
import { fly } from 'svelte/transition';
|
||||||
import {requestVisitCardsStore} from "../../Stores/GameStore";
|
import {requestVisitCardsStore} from "../../Stores/GameStore";
|
||||||
|
import {onMount} from "svelte";
|
||||||
|
|
||||||
export let visitCardUrl: string;
|
export let visitCardUrl: string;
|
||||||
|
let w = '500px';
|
||||||
|
let h = '250px';
|
||||||
|
let hidden = true;
|
||||||
|
let cvIframe;
|
||||||
|
|
||||||
function closeCard() {
|
function closeCard() {
|
||||||
requestVisitCardsStore.set(null);
|
requestVisitCardsStore.set(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleIframeMessage(message:any) {
|
||||||
|
if (message.data.type === 'cvIframeSize') {
|
||||||
|
w = (message.data.data.w) + 'px';
|
||||||
|
h = (message.data.data.h) + 'px';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
cvIframe.onload = () => hidden = false
|
||||||
|
cvIframe.onerror = () => hidden = false
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
||||||
|
.loader {
|
||||||
|
border: 16px solid #f3f3f3; /* Light grey */
|
||||||
|
border-top: 16px solid #3498db; /* Blue */
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 120px;
|
||||||
|
height: 120px;
|
||||||
|
margin:auto;
|
||||||
|
animation: spin 2s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
.visitCard {
|
.visitCard {
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
width: 530px;
|
|
||||||
margin-top: 200px;
|
margin-top: 200px;
|
||||||
max-width: 100vw;
|
max-width: 80vw;
|
||||||
|
|
||||||
.defaultCard {
|
|
||||||
border-radius: 5px;
|
|
||||||
border: 2px black solid;
|
|
||||||
background-color: whitesmoke;
|
|
||||||
width: 530px;
|
|
||||||
|
|
||||||
header {
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
border: 0;
|
border: 0;
|
||||||
width: 530px;
|
max-width: 80vw;
|
||||||
height: 270px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
visibility: hidden;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
@ -43,9 +68,17 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<section class="visitCard" transition:fly="{{ y: -200, duration: 1000 }}">
|
<section class="visitCard" transition:fly="{{ y: -200, duration: 1000 }}" style="width: {w}">
|
||||||
<iframe title="visitCardTitle" src={visitCardUrl}></iframe>
|
{#if hidden}
|
||||||
|
<div class="loader"></div>
|
||||||
|
{/if}
|
||||||
|
<iframe title="visitCard" src={visitCardUrl} allow="clipboard-read; clipboard-write self {visitCardUrl}" style="width: {w}; height: {h}" class:hidden={hidden} bind:this={cvIframe}></iframe>
|
||||||
|
{#if !hidden}
|
||||||
<div class="buttonContainer">
|
<div class="buttonContainer">
|
||||||
<button class="nes-btn is-popUpElement" on:click={closeCard}>Close</button>
|
<button class="nes-btn is-popUpElement" on:click={closeCard}>Close</button>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<svelte:window on:message={handleIframeMessage}/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue