Skip to content

Commit

Permalink
feat: add loading state to iframes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Feb 6, 2024
1 parent 1da1fe1 commit 7efae63
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
31 changes: 22 additions & 9 deletions components/layout/modal/FeedbackPrompt.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { QuestionMarkCircleIcon } from '@heroicons/vue/24/outline'
import { watchOnce } from '@vueuse/core'
import { ArrowPathIcon } from '@heroicons/vue/24/solid'
const open = defineModel<boolean>()
Expand All @@ -11,6 +12,8 @@
promptFeedback.value = true
}
})
const isIframeLoaded = ref(false)
</script>

<template>
Expand Down Expand Up @@ -38,15 +41,25 @@
</div>

<!-- Body -->
<iframe
border="0"
cellspacing="0"
class="mt-5 h-screen max-h-[60vh] w-full rounded-md sm:mt-6"
loading="eager"
onload="this.style.visibility='visible';"
src="https://docs.google.com/forms/d/e/1FAIpQLSeJLEq12Z2T8nqOh9hqMAnKGKo0G3Zy-J6eBKVIlZAwS5kfSg/viewform?embedded=true"
style="visibility: hidden"
/>
<div class="relative">
<iframe
:class="{ invisible: !isIframeLoaded }"
border="0"
class="mt-5 h-screen max-h-[60vh] w-full rounded-md sm:mt-6"
loading="eager"
src="https://docs.google.com/forms/d/e/1FAIpQLSeJLEq12Z2T8nqOh9hqMAnKGKo0G3Zy-J6eBKVIlZAwS5kfSg/viewform?embedded=true"
title="Feedback form iframe"
@load="isIframeLoaded = true"
/>

<template v-if="!isIframeLoaded">
<div class="absolute inset-0 flex w-full animate-pulse flex-col items-center justify-center gap-4 text-lg">
<ArrowPathIcon class="h-12 w-12 animate-spin" />

<h3>Loading&hellip;</h3>
</div>
</template>
</div>

<!-- Actions -->
<div class="mt-5 sm:mt-6">
Expand Down
31 changes: 22 additions & 9 deletions components/layout/modal/PwaPrompt.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { HomeIcon } from '@heroicons/vue/24/outline'
import { watchOnce } from '@vueuse/core'
import { ArrowPathIcon } from '@heroicons/vue/24/solid'
const open = defineModel<boolean>()
Expand All @@ -11,6 +12,8 @@
promptInstallPwa.value = true
}
})
const isIframeLoaded = ref(false)
</script>

<template>
Expand Down Expand Up @@ -43,15 +46,25 @@
</div>

<!-- Body -->
<iframe
border="0"
cellspacing="0"
class="mt-5 h-screen max-h-[60vh] w-full rounded-md sm:mt-6"
loading="eager"
onload="this.style.visibility='visible';"
src="https://www.installpwa.com/from/r34.app/embed?theme=dark"
style="visibility: hidden"
/>
<div class="relative">
<iframe
:class="{ invisible: !isIframeLoaded }"
border="0"
class="mt-5 h-screen max-h-[60vh] w-full rounded-md sm:mt-6"
loading="eager"
src="https://www.installpwa.com/from/r34.app/embed?theme=dark"
title="Install PWA iframe"
@load="isIframeLoaded = true"
/>

<template v-if="!isIframeLoaded">
<div class="absolute inset-0 flex w-full animate-pulse flex-col items-center justify-center gap-4 text-lg">
<ArrowPathIcon class="h-12 w-12 animate-spin" />

<h3>Loading&hellip;</h3>
</div>
</template>
</div>

<!-- Actions -->
<div class="mt-5 sm:mt-6">
Expand Down

0 comments on commit 7efae63

Please sign in to comment.