Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added iframe component #237

Merged
merged 9 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/component-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ outline: [2, 2]
"Content": "Components that present content and are meaningful by themselves. For example, charts, images or text.",
"Input": "Components whose main objective is to allow the user to input data into the app.",
"Other": "These components occupy a special role and are amongst the most powerful in the framework.",
"Embed": "Components that integrate external functionalities seamlessly.",
"Root": "These components are the top-level containers."
};
</script>
Expand Down
Binary file added docs/docs/public/components/iframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"marked": "^7.0.2",
"monaco-editor": "^0.41.0",
"plotly.js-dist-min": "^2.22.0",
"remixicon": "latest",
"remixicon": "*",
"typescript": "^5.0.4",
"vega": "^5.22.1",
"vega-embed": "^6.22.1",
Expand Down
4 changes: 4 additions & 0 deletions ui/src/builder/BuilderSidebarToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ const categoriesData:Ref<Record<string, CategoryData>> = ref({
icon: "ri-flow-chart",
isCollapsed: false,
},
Embed: {
icon: "ri-code-s-slash-line",
isCollapsed: false,
},
});

function toggleCollapseCategory(categoryId: string) {
Expand Down
2 changes: 2 additions & 0 deletions ui/src/core/templateMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import CoreSeparator from "../core_components/CoreSeparator.vue";
import CoreTab from "../core_components/CoreTab.vue";
import CoreTabs from "../core_components/CoreTabs.vue";
import CoreImage from "../core_components/CoreImage.vue";
import CoreIFrame from "../core_components/CoreIFrame.vue";
import CoreTimer from "../core_components/CoreTimer.vue";
import CoreWebcamCapture from "../core_components/CoreWebcamCapture.vue";
import CoreVegaLiteChart from "../core_components/CoreVegaLiteChart.vue";
Expand Down Expand Up @@ -64,6 +65,7 @@ const templateMap = {
horizontalstack: CoreHorizontalStack,
separator: CoreSeparator,
image: CoreImage,
iframe: CoreIFrame,
icon: CoreIcon,
timer: CoreTimer,
textinput: CoreTextInput,
Expand Down
98 changes: 98 additions & 0 deletions ui/src/core_components/CoreIFrame.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<template>
<div class="CoreIFrame" ref="rootEl">
<iframe
@load="handleLoad"
:src="fields.src.value"
draggable="false"
/>
<div class="mask" />
raaymax marked this conversation as resolved.
Show resolved Hide resolved
</div>
</template>

<script lang="ts">
import { FieldCategory, FieldType } from "../streamsyncTypes";
import { cssClasses, secondaryTextColor } from "../renderer/sharedStyleFields";
import { getClick } from "../renderer/syntheticEvents";

const description = "A component to embed an external resource in an iframe.";

const loadHandlerStub = `
def load_handler(state):

# Sets status message when resource is loaded

state["status"] = "Page loaded"`;

export default {
streamsync: {
name: "IFrame",
description,
category: "Embed",
fields: {
src: {
name: "Source",
default: '',
desc: "A valid URL",
type: FieldType.Text,
},
cssClasses,
},
events: {
"ss-load": {
desc: "Fires when the resource has successfully loaded.",
stub: loadHandlerStub.trim(),
},
},
},
};
</script>

<script setup lang="ts">
import { Ref, computed, inject, ref } from "vue";
import injectionKeys from "../injectionKeys";

const rootEl:Ref<HTMLElement> = ref(null);
const fields = inject(injectionKeys.evaluatedFields);

function handleLoad(ev) {
const event = new CustomEvent("ss-load");
rootEl.value.dispatchEvent(event);
}
</script>

<style scoped>
@import "../renderer/sharedStyles.css";

.CoreIFrame {
position: relative;
width: 100%;
height: 80vh;
}

.CoreIFrame iframe {
width: 100%;
height: 100%;
display: block;
margin: auto;
border: 1px solid var(--separatorColor);
}

.CoreIFrame .mask {
pointer-events: none;
}

.CoreIFrame.beingEdited .mask {
pointer-events: all;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0);
border-radius: 12px;
raaymax marked this conversation as resolved.
Show resolved Hide resolved
}

.CoreIFrame.selected .mask {
pointer-events: none;
}
</style>
1 change: 1 addition & 0 deletions ui/src/renderer/ComponentProxy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export default {
childless: isChildless.value,
selected: isSelected.value,
disabled: isDisabled.value,
beingEdited: isBeingEdited.value,
...fieldBasedCssClasses.value
},
style: {
Expand Down
Loading