-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIframe.vue
More file actions
138 lines (131 loc) · 3.77 KB
/
Iframe.vue
File metadata and controls
138 lines (131 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// eslint-disable-next-line vue/multi-word-component-names
<template>
<BlockWrapper
:block-background-color="backgroundColor"
:padding-top="96"
:no-padding-bottom="false"
:overlaps-next-section="true"
class="!pt-96"
>
<div class="iframe-wrapper aspect-[3/3.5] w-full sm:aspect-video">
<div
class="iframe-container size-full overflow-hidden bg-white shadow"
:class="{
'size-screen fixed left-0 top-0 z-[200]': fullscreen,
'relative rounded-6': !fullscreen
}"
>
<!-- <div v-if="!loaded" class="absolute left-0 top-0 flex size-full flex-col items-center justify-center rounded-6 border-2 border-gray/60 bg-white">
<h4 class="mb-4">
Looks like something went wrong
</h4>
<p class="mb-20">
Click here to see the map
</p>
<TheLink
:url="data.iframe"
:is-external="true"
variant="info"
text="View Map"
/>
</div> -->
<LoadingState v-if="!loaded" class="absolute-center scale-75" />
<iframe
v-if="data.iframe"
class="absolute left-0 top-0 z-50 size-full"
:class="{ 'rounded-6': !fullscreen }"
:src="data.iframe"
loading="lazy"
@load="triggerLoad"
/>
<Transition name="fade" mode="out-in">
<div
v-if="mapOverlayVisible"
class="group absolute left-0 top-0 z-[60] flex size-full cursor-pointer flex-col items-center justify-center bg-blue/90 text-white transition-colors hover:bg-blue/80"
@click="mapOverlayVisible = false"
>
<div class="size-fit transition-transform group-hover:scale-105">
<h3 class="text-white">
{{ $t('View locations in') }} <span class="capitalize">{{ useRoute().params.city }}</span>
</h3>
<TheLink variant="info" :text="$t('Open Map')" hide-arrow class="mx-auto mt-16" />
</div>
</div>
</Transition>
<transition name="fade" mode="out-in">
<button
v-if="loaded"
class="iframe-button grid-row-2 right-24 z-50 grid size-32 cursor-pointer grid-cols-2 rounded-full border-1 border-gray bg-white p-4 shadow-banner"
:class="{
'absolute top-24': !fullscreen,
'fixed !top-104 z-[999] md:!top-24': fullscreen
}"
@click="fullscreen = !fullscreen"
>
<ArrowExternal
class="col-start-2 m-1 w-6 self-end "
:class="{
'rotate-180': fullscreen
}"
/>
<ArrowExternal
class=" m-1 w-6 self-start justify-self-end"
:class="{
'rotate-180': !fullscreen
}"
/>
</button>
</transition>
</div>
</div>
</BlockWrapper>
</template>
<script lang="ts" setup>
import ArrowExternal from '~/static/icons/arrow-external.svg'
defineProps({
data: {
type: Object,
required: true
},
index: {
type: Number,
required: true
},
backgroundColor: {
type: String,
required: true,
default: 'white'
}
})
const loaded = ref(false)
const mapOverlayVisible = ref(true)
const triggerLoad = () => {
setTimeout(() => {
loaded.value = true
}, 1000)
}
const fullscreen = ref(false)
</script>
<style scoped>
@media (width < 640px) {
.iframe-wrapper {
@apply !px-16
}
}
.iframe-container {
container-type: inline-size;
}
@container (width < 768px) {
.iframe-button {
@apply !top-104
}
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.5s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
</style>