Skip to content

Commit

Permalink
#16 chore: Add variant attribute to entities
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsobspinto committed Aug 1, 2022
1 parent 8348966 commit 988ca22
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 24 deletions.
19 changes: 14 additions & 5 deletions 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.

19 changes: 14 additions & 5 deletions 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.

2 changes: 1 addition & 1 deletion dist/models/MetaLink.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export declare class MetaLink implements ILink {
targetId: string;
targetPortId: string;
options: MetaOptions;
constructor(id: string, name: string, shape: string, sourceId: string, sourcePortId: string, targetId: string, targetPortId: string, options: Map<string, any>);
constructor(id: string, name: string, shape: string, sourceId: string, sourcePortId: string, targetId: string, targetPortId: string, variant: string, options: Map<string, any>);
getSourceId(): string;
getSourcePortId(): string;
getTargetId(): string;
Expand Down
2 changes: 1 addition & 1 deletion dist/models/MetaNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { Position } from './Position';
export declare class MetaNode {
children: MetaNode[];
options: MetaOptions;
constructor(id: string, name: string, shape: string, position: Position, options: Map<string, any>);
constructor(id: string, name: string, shape: string, position: Position, variant: string, options: Map<string, any>);
}
2 changes: 1 addition & 1 deletion dist/models/MetaOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IShape } from './IShape';
import { IId } from './IId';
export declare class MetaOptions implements IShape, IId {
options: Map<string, any>;
constructor(id: string, name: string, shape: string, options: Map<string, any>);
constructor(id: string, name: string, shape: string, variant: string, options: Map<string, any>);
getId(): string;
getShape(): string;
}
8 changes: 3 additions & 5 deletions example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ const useStyles = makeStyles(_ => ({
const App = () => {
const classes = useStyles();

const node1 = new MetaNode('1', 'Node 1', 'default', new Position(250, 100),
new Map(Object.entries({'variant': 'node-red'})))
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),
new Map(Object.entries({'variant': 'node-blue'})))
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',
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(
Expand Down
6 changes: 5 additions & 1 deletion src/models/MetaLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ export class MetaLink implements ILink {
sourcePortId: string,
targetId: string,
targetPortId: string,
variant: string,
options: Map<string, any>
) {
if (options == undefined){
options = new Map<string, any>()
}
this.sourceId = sourceId;
this.sourcePortId = sourcePortId;
this.targetId = targetId;
this.targetPortId = targetPortId;
this.options = new MetaOptions(id, name, shape, options);
this.options = new MetaOptions(id, name, shape, variant, options);
}

getSourceId(): string {
Expand Down
6 changes: 5 additions & 1 deletion src/models/MetaNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ export class MetaNode {
name: string,
shape: string,
position: Position,
variant: string,
options: Map<string, any>
) {
if (options == undefined){
options = new Map<string, any>()
}
this.children = [];
options.set('position', position);
this.options = new MetaOptions(id, name, shape, options);
this.options = new MetaOptions(id, name, shape, variant, options);
}
}
2 changes: 2 additions & 0 deletions src/models/MetaOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ export class MetaOptions implements IShape, IId {
id: string,
name: string,
shape: string,
variant: string,
options: Map<string, any>
) {
this.options = options;
this.options.set('id', id);
this.options.set('name', name);
this.options.set('shape', shape);
this.options.set('variant', variant);
}

getId(): string {
Expand Down

0 comments on commit 988ca22

Please sign in to comment.