-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#26 Example application expanded node example integration
- Loading branch information
1 parent
59c9068
commit 464a04a
Showing
4 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CustomNodeWidgetProps> { | ||
render() { | ||
const { classes } = this.props; | ||
const functionValues = (label: string, value: string) => ( | ||
<Box className="block"> | ||
<Typography component="label">{label}</Typography> | ||
<Typography>{value}</Typography> | ||
</Box> | ||
) | ||
return ( | ||
<Box className={`primary-node rounded ${this.props.model.getOptions()['variant']}`}> | ||
{this.props.model.getOptions()['selected'] && ( | ||
<NodeSelection engine={this.props.engine} port={this.props.model} /> | ||
)} | ||
|
||
<Box className="primary-node_header"> | ||
<Box className="icon" /> | ||
|
||
<Typography component="p"> | ||
{this.props.model.getOptions()['name']} | ||
</Typography> | ||
</Box> | ||
|
||
<Box> | ||
<InputOutputNode text={"Input from Frame 1"} /> | ||
<InputOutputNode text={"Input from Frame 2"} /> | ||
</Box> | ||
|
||
<Box className="seprator" /> | ||
|
||
<Box className="block-wrapper"> | ||
{ | ||
functionValues('Context', '12') | ||
} | ||
{ | ||
functionValues('Size', '8.90') | ||
} | ||
{ | ||
functionValues('Prefs', '44') | ||
} | ||
<Box className="block"> | ||
<Typography component="label">Function</Typography> | ||
<Typography className="function"> | ||
<Typography component="strong" className={classes.textColor} > | ||
function | ||
</Typography>=pnl.<Typography className={classes.codeColor} component="strong">Logistic</Typography>(gain=1.0, bias=-4)</Typography> | ||
</Box> | ||
</Box> | ||
|
||
<Box className="seprator" /> | ||
|
||
<Box> | ||
<InputOutputNode direction="right" text={"Input from Frame 1"} /> | ||
<InputOutputNode direction="right" text={"Input from Frame 2"} /> | ||
</Box> | ||
</Box> | ||
); | ||
} | ||
} | ||
|
||
// @ts-ignore | ||
export default withStyles(styles)(CustomNodeWidget); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<InputOutputNodeProps> { | ||
render() { | ||
const { text, direction } = this.props; | ||
const nodeClass = direction === 'right' ? 'block reverse' : 'block'; | ||
return ( | ||
<Box className={nodeClass}> | ||
<Box className="disc" /> | ||
<Typography>{text}</Typography> | ||
</Box> | ||
) | ||
} | ||
} | ||
|
||
export default InputOutputNode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters