Skip to content

Commit

Permalink
fix: address typing issue on classes
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-altamimi committed Aug 11, 2022
1 parent 7fa7573 commit 68887e3
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,20 @@ export const App = ()=> {
let linkId = `${link.type}:${link.outgoing[0].name},${link.outgoing[1].name}`
let newNode = { id: linkId, type: "circle" ,data: { label: `${link.type}, Links: ${link.outgoing.length}`, atomType: link.type }, position: { x: 100, y: 100 }};
link.outgoing.forEach((linkNode, index:number )=> {
let newEdge = { id: `${index}${linkId}`, type: "colored", source: linkId, target: `${linkNode.name}`, style:TypesClasses["LinkList"].class };
newEdges.push(newEdge);

let typeClass: TypesClass | undefined = TypesClasses.get(link.type);

if(typeClass){

let newEdge = { id: `${index}${linkId}`, type: "colored", source: linkId, target: `${linkNode.name}`, style: typeClass.class };
newEdges.push(newEdge);

} else{

let newEdge = { id: `${index}${linkId}`, type: "colored", source: linkId, target: `${linkNode.name}`, style: DefaultClass.class };
newEdges.push(newEdge);

}
})
newNodes.push(newNode);
});
Expand Down Expand Up @@ -296,10 +308,25 @@ function FlowWithProvider() {

export default FlowWithProvider;

const TypesClasses = {
"LinkList": {
class: {
stroke:"blue",
},
}
}


interface TypesClass {
class: any
}
const DefaultClass = {
class: {}
}
const TypesClasses: Map<string, TypesClass> = new Map<string,TypesClass>(
[
["LinkList", {
class: {
stroke:"blue",
},
}],
["LinkList", {
class: {
stroke:"blue",
},
}]
]
);

0 comments on commit 68887e3

Please sign in to comment.