Skip to content

Commit

Permalink
Merge pull request #267 from tokens-studio/fix-subgraph-output
Browse files Browse the repository at this point in the history
fix(1013): Subgraph output
  • Loading branch information
roppazvan authored Jun 12, 2024
2 parents 6d4613b + 1671ea6 commit 719b4ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/graph-editor/src/components/flow/wrapper/nodeV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useLocalGraph } from '@/context/graph.js';

const isHexColor = (str) => {
if (typeof str !== 'string') return false;
return /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(str);;
return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(str);;
};

export type UiNodeDefinition = {
Expand Down Expand Up @@ -156,7 +156,7 @@ const getColorPreview = (color: string, showValue = false) => {
return (
<Stack direction="row" gap={2}>
{colorSwatch}
{showValue ? <Text css={{ fontSize: '$small', color: '$gray12' }}>{color}</Text> : null}
{showValue ? <Text css={{ fontSize: '$small', color: '$gray12' }}>{color.toUpperCase()}</Text> : null}
</Stack>
);
}
Expand Down
8 changes: 6 additions & 2 deletions packages/graph-engine/src/nodes/generic/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export default class SubgraphNode extends Node {
this._innerGraph.addNode(input);
this._innerGraph.addNode(output);

this.addOutput("value", {
type: AnySchema,
visible: true,
});

autorun(() => {

//Get the existing inputs
Expand Down Expand Up @@ -94,11 +99,10 @@ export default class SubgraphNode extends Node {
return acc;
}, {});


const result = await this._innerGraph.execute({
inputs
});

this.setOutput("value", result.output?.value, result.output?.type);
this.setOutput("value", result.output?.value.value, result.output?.value.type);
}
}

0 comments on commit 719b4ba

Please sign in to comment.