Skip to content

Commit

Permalink
Merge branch 'dev' into pdf-component
Browse files Browse the repository at this point in the history
  • Loading branch information
raaymax committed Feb 15, 2024
2 parents 9be40a0 + 1126aad commit 63bf10d
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 5 deletions.
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 @@ -20,6 +20,7 @@ import CoreTab from "../core_components/CoreTab.vue";
import CoreTabs from "../core_components/CoreTabs.vue";
import CoreImage from "../core_components/CoreImage.vue";
import CorePDF from "../core_components/CorePDF.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 @@ -66,6 +67,7 @@ const templateMap = {
separator: CoreSeparator,
image: CoreImage,
pdf: CorePDF,
iframe: CoreIFrame,
icon: CoreIcon,
timer: CoreTimer,
textinput: CoreTextInput,
Expand Down
96 changes: 96 additions & 0 deletions ui/src/core_components/CoreIFrame.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<template>
<div class="CoreIFrame" ref="rootEl">
<iframe
@load="handleLoad"
:src="fields.src.value"
draggable="false"
/>
<div class="mask" />
</div>
</template>

<script lang="ts">
import { FieldType } from "../streamsyncTypes";
import { cssClasses } from "../renderer/sharedStyleFields";
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, 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);
}
.CoreIFrame.beingEdited.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

0 comments on commit 63bf10d

Please sign in to comment.