Skip to content

Commit

Permalink
refactor: component base with built-in mask
Browse files Browse the repository at this point in the history
  • Loading branch information
raaymax committed Feb 23, 2024
1 parent 0db0d6f commit a3d53c6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
25 changes: 4 additions & 21 deletions ui/src/core_components/embed/CoreIFrame.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<template>
<div ref="rootEl" class="CoreIFrame">
<ComponentBase ref="rootEl" class="CoreIFrame">
<iframe :src="fields.src.value" draggable="false" @load="handleLoad" />
<div class="mask" />
</div>
</ComponentBase>
</template>

<script lang="ts">
Expand Down Expand Up @@ -46,6 +45,8 @@ export default {
import { Ref, inject, ref } from "vue";
import injectionKeys from "../../injectionKeys";
import ComponentBase from "../../renderer/ComponentBase.vue";
const rootEl: Ref<HTMLElement> = ref(null);
const fields = inject(injectionKeys.evaluatedFields);
Expand Down Expand Up @@ -75,22 +76,4 @@ function handleLoad() {
margin: auto;
border: 1px solid var(--separatorColor);
}
.CoreIFrame .mask {
pointer-events: none;
}
.CoreIFrame.beingEdited .mask {
pointer-events: auto;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0);
}
.CoreIFrame.beingEdited.selected .mask {
pointer-events: none;
}
</style>
25 changes: 25 additions & 0 deletions ui/src/renderer/ComponentBase.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<div class="ComponentBase">
<slot />
<div class="mask" />
</div>
</template>

<style scoped>
.ComponentBase .mask {
pointer-events: none;
}
.ComponentBase.beingEdited .mask {
pointer-events: auto;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.ComponentBase.beingEdited.selected .mask {
pointer-events: none;
}
</style>

0 comments on commit a3d53c6

Please sign in to comment.