Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/26 Expanded node move the styles to theme, allow changes from variant #27

Merged
merged 4 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.development.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.development.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.production.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.cjs.production.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/meta-diagram.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/meta-diagram.esm.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ import {Box, Typography} from "@mui/material";
import NodeSelection from "./NodeSelection";
import InputOutputNode from "./InputOutputNode";

export interface CustomNodeWidgetProps {
const styles = {
root: {
textColor: {
color: '#4579EE',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vidhya-metacell should go into the theme instead of "hardcoded" color in the object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zsinnema updated this one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zsinnema if nothing is pending, can this be merged?

},
codeColor: {
color: '#ED745D'
}
}
};

export interface ExpandedCustomNodeWidgetProps {
model: MetaNodeModel;
engine: DiagramEngine;
classes: any;
}

const styles = () => ({
textColor: {
color: '#4579EE',
},
codeColor: {
color: '#ED745D'
}
});

export class CustomNodeWidget extends React.Component<CustomNodeWidgetProps> {
export class ExpandedCustomNodeWidget extends React.Component<ExpandedCustomNodeWidgetProps> {
render() {
const { classes } = this.props;
const functionValues = (label: string, value: string) => (
Expand Down Expand Up @@ -64,9 +66,9 @@ export class CustomNodeWidget extends React.Component<CustomNodeWidgetProps> {
<Box className="block">
<Typography component="label">Function</Typography>
<Typography className="function">
<Typography component="strong" className={classes.textColor} >
<Typography component="strong" className={classes?.textColor} >
function
</Typography>=pnl.<Typography className={classes.codeColor} component="strong">Logistic</Typography>(gain=1.0, bias=-4)</Typography>
</Typography>=pnl.<Typography className={classes?.codeColor} component="strong">Logistic</Typography>(gain=1.0, bias=-4)</Typography>
</Box>
</Box>

Expand All @@ -82,4 +84,4 @@ export class CustomNodeWidget extends React.Component<CustomNodeWidgetProps> {
}

// @ts-ignore
export default withStyles(styles)(CustomNodeWidget);
export default withStyles(styles)(ExpandedCustomNodeWidget);
8 changes: 4 additions & 4 deletions example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'react-app-polyfill/ie11';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import MetaDiagram, {MetaNode, Position, ComponentsMap, MetaLink} from "./..";
import {CustomNodeWidget} from "./components/widgets/CustomNodeWidget";
import {ExpandedCustomNodeWidget} from "./components/widgets/ExpandedCustomNodeWidget";
import { makeStyles } from "@mui/styles";
import CustomLinkWidget from "./components/widgets/CustomLinkWidget";
import BG from "./components/assets/svg/bg-dotted.svg";
Expand All @@ -26,21 +26,21 @@ const App = () => {

const node1 = new MetaNode('1', 'Node 1', 'default', new Position(250, 100), 'node-red', undefined)

const node2 = new MetaNode('2', 'Node 2', 'default', new Position(500, 100), 'node-blue', undefined)
// const node2 = new MetaNode('2', 'Node 2', 'default', new Position(500, 100), 'node-blue', undefined)

const link3 = new MetaLink('3', 'link3', 'default', '1', 'out', '2', 'in', undefined,
new Map(Object.entries({color: 'rgb(255,192,0)'})))

const componentsMap = new ComponentsMap(
new Map(Object.entries({'default': CustomNodeWidget})),
new Map(Object.entries({'default': ExpandedCustomNodeWidget})),
new Map(Object.entries({'default': CustomLinkWidget}))
)

return (
<ThemeProvider theme={theme}>
<CssBaseline />
<div className={classes.main}>
<MetaDiagram metaNodes={[node1, node2]} metaLinks={[link3]} componentsMap={componentsMap}
<MetaDiagram metaNodes={[node1]} metaLinks={[link3]} componentsMap={componentsMap}
metaTheme={{
customThemeVariables: {},
canvasClassName: classes.canvasBG,
Expand Down
2 changes: 1 addition & 1 deletion src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const applicationTheme = (params: ThemeVars) => {
width: 1rem;
height: 1rem;
border: solid 0.0625rem ${nodeGreenTextColor};
background: ${nodeGreenBackgroundColor}
background: ${nodeGreenBackgroundColor};
border-radius: 50%;
display: flex;
align-items: center;
Expand Down