Skip to content

Commit

Permalink
feat(layouts): scale iframe-left and iframe-right (#783)
Browse files Browse the repository at this point in the history
fix #777
  • Loading branch information
AlexisRenchon committed Dec 12, 2022
1 parent bd45468 commit 1d4e2d1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
20 changes: 16 additions & 4 deletions packages/client/layouts/iframe-left.vue
@@ -1,14 +1,26 @@
<script setup lang="ts">
const props = defineProps<{ class?: string; url: string }>()
import { computed } from '@vue/reactivity'
const props = defineProps<{
url: string
scale?: number
}>()
const scaleInvertPercent = computed(() => `${(1 / (props.scale || 1)) * 100}%`)
</script>

<template>
<div class="grid grid-cols-2 w-full h-full">
<div class="h-full">
<iframe id="frame" class="w-full h-full" :src="url" />
</div>
<div relative :style="{ width: scaleInvertPercent, height: scaleInvertPercent }">
<iframe
id="frame" class="w-full h-full"
:src="url"
:style="scale ? { transform: `scale(${scale})`, transformOrigin: 'top left' } : {}"
/>
<div class="slidev-layout default" :class="props.class">
<slot />
</div>
</div>
</div>
</template>

18 changes: 15 additions & 3 deletions packages/client/layouts/iframe-right.vue
@@ -1,14 +1,26 @@
<script setup lang="ts">
const props = defineProps<{ class?: string; url: string }>()
import { computed } from '@vue/reactivity'
const props = defineProps<{
url: string
scale?: number
}>()
const scaleInvertPercent = computed(() => `${(1 / (props.scale || 1)) * 100}%`)
</script>

<template>
<div class="grid grid-cols-2 w-full h-full">
<div class="slidev-layout default" :class="props.class">
<slot />
</div>
<div class="h-full">
<iframe id="frame" class="w-full h-full" :src="url" />
<div relative :style="{ width: scaleInvertPercent, height: scaleInvertPercent }">
<iframe
id="frame" class="w-full h-full"
:src="url"
:style="scale ? { transform: `scale(${scale})`, transformOrigin: 'top left' } : {}"
/>
</div>
</div>
</template>

0 comments on commit 1d4e2d1

Please sign in to comment.