Skip to content

Commit

Permalink
Add output action
Browse files Browse the repository at this point in the history
  • Loading branch information
electrikmilk committed Nov 23, 2023
1 parent 46b1aac commit 7c2f918
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import AskForInput from "~/actions/ask-for-input";
import SplitText from "~/actions/split-text";
import GetFromList from "~/actions/get-from-list";
import SetName from "~/actions/set-name";
import Output from "~/actions/output";

interface ActionDefinitions {
[key: string]: ActionDefinition
Expand Down Expand Up @@ -67,6 +68,7 @@ export let actions: ActionDefinitions = {
'delay': Wait,
'exit': Stop,
'setitemname': SetName,
'output': Output,
};

export function actionText(value: string): HTMLElement {
Expand Down
39 changes: 39 additions & 0 deletions src/actions/output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {renderActionHeader} from "~/render";
import {actions} from "~/actions";
import {renderValue} from "~/value";

interface ShowAlertParameters {
WFOutput: string | object
WFNoOutputSurfaceBehavior: string
WFResponse: string | object
}

export default {
title: "Stop and output",
icon: "square_arrow_left",
background: "#007aff",
render: (container: HTMLElement, params: ShowAlertParameters) => {
container.classList.add('sp-output-action');
const action = renderActionHeader(actions['output'], renderValue(params['WFOutput'], 'Output'));

const outputSurfaceBehavior = document.createElement('div');
outputSurfaceBehavior.innerText = 'If there\'s nowhere to output:';
outputSurfaceBehavior.className = 'sp-output-surface-behavior';
action.appendChild(outputSurfaceBehavior);

const flexbox = document.createElement('div');
flexbox.style.display = 'flex';
flexbox.style.gap = '10px';
flexbox.style.alignItems = 'center';
flexbox.style.margin = '0 16px';
flexbox.style.height = '3rem';

flexbox.appendChild(renderValue(params['WFNoOutputSurfaceBehavior'] ?? 'Do Nothing', 'Behavior'));
if (params['WFResponse']) {
flexbox.appendChild(renderValue(params['WFResponse'] ?? null, 'Result'));
}
action.appendChild(flexbox);

return action;
}
}

0 comments on commit 7c2f918

Please sign in to comment.