From 464a04adc7d19b10675edcc6079647c7a8ead0ab Mon Sep 17 00:00:00 2001 From: vidhya-metacell Date: Tue, 9 Aug 2022 12:20:45 +0200 Subject: [PATCH] #26 Example application expanded node example integration --- .../widgets/CustomNodeExpandedWidget.tsx | 85 +++++++++++++++++++ .../components/widgets/CustomNodeWidget.tsx | 2 +- .../components/widgets/InputOutputNode.tsx | 21 +++++ example/theme.ts | 41 ++++++++- 4 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 example/components/widgets/CustomNodeExpandedWidget.tsx create mode 100644 example/components/widgets/InputOutputNode.tsx diff --git a/example/components/widgets/CustomNodeExpandedWidget.tsx b/example/components/widgets/CustomNodeExpandedWidget.tsx new file mode 100644 index 0000000..66b47a9 --- /dev/null +++ b/example/components/widgets/CustomNodeExpandedWidget.tsx @@ -0,0 +1,85 @@ +import * as React from "react"; +import { withStyles } from '@mui/styles'; +import {DiagramEngine} from "@projectstorm/react-diagrams"; +import {MetaNodeModel} from "../../../dist"; +import {Box, Typography} from "@mui/material"; +import NodeSelection from "./NodeSelection"; +import InputOutputNode from "./InputOutputNode"; + +export interface CustomNodeWidgetProps { + model: MetaNodeModel; + engine: DiagramEngine; + classes: any; +} + +const styles = () => ({ + textColor: { + color: '#4579EE', + }, + codeColor: { + color: '#ED745D' + } +}); + +export class CustomNodeWidget extends React.Component { + render() { + const { classes } = this.props; + const functionValues = (label: string, value: string) => ( + + {label} + {value} + + ) + return ( + + {this.props.model.getOptions()['selected'] && ( + + )} + + + + + + {this.props.model.getOptions()['name']} + + + + + + + + + + + + { + functionValues('Context', '12') + } + { + functionValues('Size', '8.90') + } + { + functionValues('Prefs', '44') + } + + Function + + + function + =pnl.Logistic(gain=1.0, bias=-4) + + + + + + + + + + + ); + } +} + +// @ts-ignore +export default withStyles(styles)(CustomNodeWidget); diff --git a/example/components/widgets/CustomNodeWidget.tsx b/example/components/widgets/CustomNodeWidget.tsx index d6b9e92..6f08f69 100644 --- a/example/components/widgets/CustomNodeWidget.tsx +++ b/example/components/widgets/CustomNodeWidget.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import {DiagramEngine} from "@projectstorm/react-diagrams"; -import {MetaNodeModel} from "../../../."; +import {MetaNodeModel} from "../../../dist"; import {Box, Typography} from "@mui/material"; import NodeSelection from "./NodeSelection"; diff --git a/example/components/widgets/InputOutputNode.tsx b/example/components/widgets/InputOutputNode.tsx new file mode 100644 index 0000000..150c5e4 --- /dev/null +++ b/example/components/widgets/InputOutputNode.tsx @@ -0,0 +1,21 @@ +import * as React from "react"; +import { Box, Typography } from "@mui/material"; +export interface InputOutputNodeProps { + text: string; + direction?: string +} + +class InputOutputNode extends React.Component { + render() { + const { text, direction } = this.props; + const nodeClass = direction === 'right' ? 'block reverse' : 'block'; + return ( + + + {text} + + ) + } +} + +export default InputOutputNode; \ No newline at end of file diff --git a/example/theme.ts b/example/theme.ts index 086d6df..8351387 100644 --- a/example/theme.ts +++ b/example/theme.ts @@ -89,7 +89,46 @@ const theme = { .primary-node.node-gray .node-button .icon { background: ${nodeGrayBackgroundColor}; - border-color: rgba(130, 130, 130, 0.2); + border-color: ${nodeGrayBorderColor}; + } + + .primary-node.node-red .block .disc { + background: ${nodeRedBackgroundColor}; + border-color: ${nodeRedTextColor}; + } + + .primary-node.node-red .block .disc:after { + background: ${nodeRedTextColor}; + } + + .primary-node.node-red .seprator { + background: ${nodeRedBorderColor}; + } + + .primary-node.node-blue .block .disc { + background: ${nodeBlueBackgroundColor}; + border-color: ${nodeBlueTextColor}; + } + + .primary-node.node-blue .block .disc:after { + background: ${nodeBlueTextColor}; + } + + .primary-node.node-blue .seprator { + background: ${nodeBlueBorderColor}; + } + + .primary-node.node-gray .block .disc { + background: ${nodeGrayBackgroundColor}; + border-color: ${nodeGrayTextColor}; + } + + .primary-node.node-gray .block .disc:after { + background: ${nodeGrayTextColor}; + } + + .primary-node.node-gray .seprator { + background: ${nodeGrayBorderColor}; } `, },