forked from TamimEhsan/AlgorithmVisualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.jsx
More file actions
37 lines (36 loc) · 1.16 KB
/
Copy pathnode.jsx
File metadata and controls
37 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React, {Component} from 'react';
import './node.css'
class Node extends Component {
static = {
row: this.props.row,
col: this.props.col
}
render() {
const { row,col,isVisited, onMouseDown, onMouseEnter,onMouseUp } = this.props;
return (
<div
id = {`node-${this.props.row}-${this.props.col}`}
className={this.getClassName()}
onMouseDown={() => onMouseDown(row,col)}
onMouseEnter={() => onMouseEnter(row,col)}
onMouseUp={() => onMouseUp(row,col)}
/>
);
}
getClassName(){
if(this.props.node.isWall === true){
return "node node-wall";
} else if( this.props.node.isStartNode === true ){
return "node node-start";
} else if( this.props.node.isEndNode === true ){
return "node node-end";
} else if(this.props.node.ispathNode){
return 'node node-shortest-path';
}else if( this.props.node.isVisited === true ){
return "node node-visited";
} else{
return "node";
}
}
}
export default Node;